Sign in to follow this  

I'm a Scheme user

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[grin]

Good point. Well I just downloaded the Scheme interpreter and wanted to know where should I start as far as learning to program in Scheme? Should I try to emulate some program I made in C, C++, or Java? Should I start from scratch with a tutorial and "Hello World"? Or should I go a different route altogether?

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
[grin]

Good point. Well I just downloaded the Scheme interpreter and wanted to know where should I start as far as learning to program in Scheme? Should I try to emulate some program I made in C, C++, or Java? Should I start from scratch with a tutorial and "Hello World"? Or should I go a different route altogether?


Oh, so this isn't a drunk post (I actually thought it was), not because of spelling (which is good enough) it just sounded like you wanted to tell us you are a Scheme user for no apparent reason. Anyway you should try to do simple programs you have done before, stuff like calculating Fibonacci numbers (in a recursive/iterative way of course, don't use Binet's formula). When you start getting to the somewhat more advanced concepts you should try using them in a little larger project. Also if the resource you are learning from have any examples try them out.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
[grin]

Good point. Well I just downloaded the Scheme interpreter and wanted to know where should I start as far as learning to program in Scheme? Should I try to emulate some program I made in C, C++, or Java? Should I start from scratch with a tutorial and "Hello World"? Or should I go a different route altogether?


It would help to know the interpreter you got. The Scheme standard library is very small, so many interpreters have non-standard extensions.

But anyway. You might want to learn about the functional paradigm (as it applies to dynamically typed languages), it's pretty important in Scheme. The SICP (pronounced "sick-pea" in case you were wondering) book and Abelson and Sussman video lectures are classics which may help.

Share this post


Link to post
Share on other sites
the little schemer is a good book. There is also Structure and Interpretation of computer programs if you want a heavier read. http://mitpress.mit.edu/sicp/

If you want something more indepth start here:)
http://www.swiss.csail.mit.edu/projects/scheme/

I'm not sure if your sold on scheme or if you just want to learn functional programming. If its the latter, may I recommend lisp?? Google lisp-in-a-box. Peter Siebel has open sourced an excelled book called practical common lisp if your interested.

Cheers
Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by chollida1
the little schemer is a good book. There is also Structure and Interpretation of computer programs if you want a heavier read. http://mitpress.mit.edu/sicp/

If you want something more indepth start here:)
http://www.swiss.csail.mit.edu/projects/scheme/

I'm not sure if your sold on scheme or if you just want to learn functional programming. If its the latter, may I recommend lisp?? Google lisp-in-a-box. Peter Siebel has open sourced an excelled book called practical common lisp if your interedted.

Cheers
Chris


I will assume you mean Common Lisp by "lisp." In my opinion, Scheme encourages functional programming more than Common Lisp. It is also generally used more in Scheme. I recommend you learn both though. Common Lisp has more powerful metaprogramming features than the Scheme standard (however, non-standard extensions by some interpreters/compilers have made it just as powerful) while Scheme (as I said) is used more for functional programming. Both metalinguistic programming and functional programming are good to know about.

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
Quote:
Original post by chollida1
the little schemer is a good book. There is also Structure and Interpretation of computer programs if you want a heavier read. http://mitpress.mit.edu/sicp/

If you want something more indepth start here:)
http://www.swiss.csail.mit.edu/projects/scheme/

I'm not sure if your sold on scheme or if you just want to learn functional programming. If its the latter, may I recommend lisp?? Google lisp-in-a-box. Peter Siebel has open sourced an excelled book called practical common lisp if your interedted.

Cheers
Chris


I will assume you mean Common Lisp by "lisp." In my opinion, Scheme encourages functional programming more than Common Lisp. It is also generally used more in Scheme. I recommend you learn both though. Common Lisp has more powerful metaprogramming features than the Scheme standard (however, non-standard extensions by some interpreters/compilers have made it just as powerful) while Scheme (as I said) is used more for functional programming. Both metalinguistic programming and functional programming are good to know about.


I agree that scheme promotes a more functional programming approach. I just find lisp(common lisp) to be the more practical of the 2 languages due to the larger number of libraries available for it:)


Cheers
Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by chollida1
Quote:
Original post by Roboguy
Quote:
Original post by chollida1
the little schemer is a good book. There is also Structure and Interpretation of computer programs if you want a heavier read. http://mitpress.mit.edu/sicp/

If you want something more indepth start here:)
http://www.swiss.csail.mit.edu/projects/scheme/

I'm not sure if your sold on scheme or if you just want to learn functional programming. If its the latter, may I recommend lisp?? Google lisp-in-a-box. Peter Siebel has open sourced an excelled book called practical common lisp if your interedted.

Cheers
Chris


I will assume you mean Common Lisp by "lisp." In my opinion, Scheme encourages functional programming more than Common Lisp. It is also generally used more in Scheme. I recommend you learn both though. Common Lisp has more powerful metaprogramming features than the Scheme standard (however, non-standard extensions by some interpreters/compilers have made it just as powerful) while Scheme (as I said) is used more for functional programming. Both metalinguistic programming and functional programming are good to know about.


I agree that scheme promotes a more functional programming approach. I just find lisp(common lisp) to be the more practical of the 2 languages due to the larger number of libraries available for it:)


Cheers
Chris


PLT Scheme has a large extension to R5RS. That helps some.

Share this post


Link to post
Share on other sites
No, I'm not drunk [smile]

Ok! I'm already confused and haven't even coded yet. But for starters, I got the interpreter off the MIT website and bookmarked the SICP text site.

Now I thought Lisp and Scheme pretty much did the same thing. So now... lemme get this as straight as possible. Lisp does metaprogramming (templates) and Scheme does functional programming. But I thought they both were functional languages?

Anyone got a plain as day explanation?

Share this post


Link to post
Share on other sites
As far as I understand it, Scheme is basically LISP lite. They're really multiparadigm languages, though they have the look and feel of a functional language (and indeed were based on Lambda calculus originally).

Quote:
Lisp does metaprogramming (templates)

While I haven't been learning LISP for long, AFAIK it's metaprogramming facilities aren't really like C++'s templates, code in LISP is basically loads of lists, and thus metaprogramming involves creating lists which represent code using LISP code. This is done using the macro system.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
No, I'm not drunk [smile]

Ok! I'm already confused and haven't even coded yet. But for starters, I got the interpreter off the MIT website and bookmarked the SICP text site.

Now I thought Lisp and Scheme pretty much did the same thing. So now... lemme get this as straight as possible. Lisp does metaprogramming (templates) and Scheme does functional programming. But I thought they both were functional languages?

Anyone got a plain as day explanation?
Lisp isn't really a functional language. If you want to learn functional programming, Haskell or SML would be better choices than Common Lisp. Learn Lisp because it's Lisp.

Scheme is a dialect of Lisp which encourages a functional style. Features like assignment are available to the programmer, but their overuse is not encouraged. At its heart, Scheme is just a different dialect of Lisp, with a different outlook on things, different libraries, etc.

Scheme can do metaprogramming just like CL, but it sacrifices a little power in return for a hygienic macro system. This was a choice made by the designers, exchanging a little power for added safety.

I'd recommend learning scheme, as well as looking into common lisp, and then maybe learning a language like Haskell or ML.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Metaprogramming: Scheme style is to use hygienic macros, but most scheme implementations (like PLT mzscheme) have a lisp-style unhygienic defmacro implementation. So I wouldn't say lisp is more powerful metaprogramming language. Hygienic macros let you do many metaprogramming tasks without the risk of shooting yourself in the foot via variable capture, and defmacro is there if you need it (or prefer it).

Functional programming: They're both equally suited for functional programming in my opinion. Functions are first class. The difference is stylistic: lisp has separate namespaces for values and functions, while scheme has only 1 namespace for both. This means that when you want to pass a function to another function, you have to tell lisp you're passing the function and not the value in the. For example, say you want to apply the negation operator to a list of boolean values. You can do this using the map function, which takes a function of one element and a list it should be applied to:

scheme:

(map not '(#t #t #f #t))

lisp:

(mapcar (function not) '(t t nil t))

or #' is syntactic sugar for the function form:

(mapcar #'not '(t t nil t))

I find this makes functional code more cluttered and uglier, but that's just my personal opinion. You can do assignment in both languages, so they're not purely functional. Scheme style is to do express iteration with tail recursion, while cl has many iteration constructs to explicitly iterate.

Scheme is much smaller. Lisp has loads of predefined useful functions. Scheme has first-class continuations, I think lisp does not.

Why not try both out at once?

Share this post


Link to post
Share on other sites
Okay. First of all, to reduce confusion, let's refer to Common Lisp as Common Lisp, Scheme as Scheme and the Lisp family of languages (to which both Scheme and Common Lisp belong) as "Lisp." It can confuse things a lot when people use "Lisp" to refer specifically to Scheme, Common Lisp or some other language.

Quote:

Ok! I'm already confused and haven't even coded yet. But for starters, I got the interpreter off the MIT website and bookmarked the SICP text site.

Might want to bookmark the video site too.

Quote:

Now I thought Lisp and Scheme pretty much did the same thing. So now... lemme get this as straight as possible. Lisp does metaprogramming (templates) and Scheme does functional programming.


They are both functional languages. The both support metaprogramming, but Common Lisp has a more powerful metaprogramming system than the one defined in the Scheme standard (however, like I said, some Scheme interpreters/compilers have a system as powerful as Common Lisp's). Also, metaprogramming definitely does not mean templates. C++ supports metaprogramming through templates, but that is a very ugly and annoying way to do metaprogramming when compared to how you could do it in a Lisp language. Templates wouldn't make much sense in a dynamically typed language anyway.

Also, Scheme and Common Lisp are actually quite different, because of their standard libraries and a few other things such as a separate namespace for functions.

Quote:

But I thought they both were functional languages?


They are (by some definitions of the phrase, anyway). But Scheme encourages functional style more than Common Lisp. Neither, though, are purely functional (meaning they both have side effects and can be directly used for imperative programming (sequentialy execution of instructions)).

Share this post


Link to post
Share on other sites
When I was taking a class that used Scheme we had a number of large-ish projects that maybe you could work up to. The ones I remember are

Various variations on Scheme interpreters (in Scheme of course)
-First one had functions and variables all in the global environment
-Second made functions have a local environment
-Third allowed for macros (if I recall correctly)

An Enigma-style encoder/decoder

Some system which given a list of votes would perform an instant-runoff election

A Scheme source cross-referencer (which symbols are used in what functions, which symbols are in some function F, etc.)

With the possible exception of some of the evaluators I should have all the related source for this and more. If you're interested I could figure out what my homework assignments were. Just PM me or something.

Share this post


Link to post
Share on other sites
if you go to a langauge website, and see a lamda picture, its a (primarily or originally) functional programming langauge.

the original lisp is primarily a functional programming langauge (but many of the features you are used to in C++ / Java / Smalltalk originally came from LISP.

LISP can refer to any langauge / dialect that derives from the original LISP article, or almost any language which uses the same principles to define its core rules.

LISP has many many dialects, because different people want to do things with the language, and the article only specifies the semantic core requirements and minimum interface of the language - so people invent their own REAL lisp when the want to ... of which there have been DOZENS of dialects. Common Lisp was one attempt to standardize on a modern lisp in the last few decades - with features such as the Common Lisp object system (CLOS). Scheme was an attempt to make a very "pure" LISP dialect with almost nothing but pure functional features. There is also Haskell, and a few other psuedo-popular ones.

The different LISP dirivatives are almost as varied as the different C implemented scripting lanaguges (PERL, Python, ruby), but they also have as much in common.

Share this post


Link to post
Share on other sites
Quote:
Original post by Xai
Scheme was an attempt to make a very "pure" LISP dialect with almost nothing but pure functional features.


Scheme was an attempt to make a very small Lisp dialect, not necessarily a very pure one (by the definition of "pure" you're using). It is impure, but some elements of purely functional programming are commonly used in it.

Quote:

There is also Haskell, and a few other psuedo-popular ones.


Haskell is not a Lisp.

Quote:

The different LISP dirivatives are almost as varied as the different C implemented scripting lanaguges (PERL, Python, ruby), but they also have as much in common.


That seems contradictory, first of all. Secondly, Lisp languages can be extremely varied and two Lisp languages can have almost nothing in common, other than both being programming languages with the same basic syntax ideas (it is theoretically possible to have a statically typed, purely functional Lisp, for example).

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
Quote:
Original post by Xai
The different LISP dirivatives are almost as varied as the different C implemented scripting lanaguges (PERL, Python, ruby), but they also have as much in common.


That seems contradictory, first of all. Secondly, Lisp languages can be extremely varied and two Lisp languages can have almost nothing in common, other than both being programming languages with the same basic syntax ideas (it is theoretically possible to have a statically typed, purely functional Lisp, for example).


I was trying to say that, each lisp compared to each other may be as different as say Python compared to ruby ... and while those languages seem largely different, they really derive from nearly identical core assumptions. And the idea of Lisp is the very few core rules it derives from. It isn't strictly semantics, as many new ones can be defined. It isn't syntax, as S expressions, P expressions, M expressions, etc can be used. It is more of a starting point, or a 0th law of robotics, on which everything else is placed that makes it a lisp (so it seems to me).

Share this post


Link to post
Share on other sites
Sign in to follow this