This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Programming

It's time to learn Scheme

By Daryl Lee on April 03, 2008 (9:00:00 AM)

Share    Print    Comments   

Have you ever peeked into one of those bazillion .el files in your Emacs installation's lisp folder and wondered what it meant? Or have you ever looked at a GIMP script .scm file and scratched your head over all the parentheses? Lisp is one of the oldest programming languages still in common use, and Scheme is a streamlined dialect of Lisp. Many universities use Scheme as the language to introduce students to the Computer Science curriculum, and some of their teaching methods are based on the assumption that Scheme is the one language they can count on their students knowing. Even so, many active programmers and system administrators are unfamiliar with Scheme. This article will get you on your way to adding this tool to your developer or sysadmin toolkit.

One of the first questions people have about Lisp-family languages such as Scheme is "What's up with all the parentheses?" Scheme programs are just sequences of lists, and lists are delimited by parentheses. After all, LISP itself is an acronym for LISt Processor. Whereas other programs use a variety of punctuation for syntax, Scheme's syntax is trivial -- everything is expressed as lists -- and this simplicity manifests itself in lists of lists of lists, all showing up as nested parentheses. In C you might see something like

if (x == y) { z = x; }

where you see syntax elements (), {}, and ;. A similar behavior in Scheme would be written as

(if (= x y) (set! z x))

The entire expression is a list with three components: the operator if and two more lists. The first of these two is a list with operator = and two variables; the second is the operator set! and two variables. There's no need to learn when to use braces or when the semicolon is required.

List manipulation

Where do lists come from and how are they taken apart for interpretation? There are three mystically named procedures, cons, car, and cdr. cons is an abbreviation for "construct" and constructs a pair from two elements. If the second of the two elements is a list, the resulting pair is a list. (There is also a non-list pair, but that is a topic for a longer article.) car returns the first element of a list, and cdr (pronounced could-er) returns the rest of the list, which might be empty, denoted (). The two operators car and cdr get their names from a couple of registers used on the very early computer that Lisp was first written for.

Normally, Scheme tries to evaluate any symbols it encounters in a list. For example, if presented with the list (a b c), Scheme will try to evaluate a, b, and c. To prevent this evaluation and tell Scheme to just use the list literally, a single quote mark precedes the symbol or a list, as '(a b c). The quote operator can also be used, as (quote (a b c)).

If ll is the list (a b c), evaluating (cons 'd ll) produces the list (d a b c). Each of the elements could itself be a list. Now let's go the opposite direction and extract elements of the list. (car ll) returns the value a and (cdr ll) returns the list (b c). How would you get the value b? A good guess would be (car (cdr ll)). But this is such a common task that Scheme provides a suite of abbreviations. The one-step way to get b is (cadr ll).

We have been flirting with the question of how Scheme processes lists. A complete discussion takes quite a bit of space, but a beginner-level explanation is that Scheme looks at the first item in the list and evaluates it first, then decides what to do with the rest of the list. In a simple case like (+ 13 aa), Scheme sees that + is the addition operator, and then proceeds to evaluate 13 and aa. 13 just evaluates to the number 13, and if aa evaluates to a number, the two are added. If aa does not evaluate to a number, Scheme reports an error and aborts.

Some operators, called forms, do not always result in all of the following elements being evaluated. For instance, if the first item in the list is or, following elements are evaluated in sequence only until one evaluates to #t (Scheme's representation of true). For example, in

(or (number? x) (display "NaN"))

the display does not happen if x is a number.

Defining procedures

We need to take a deeper look at one special operator, define, Scheme's operator for defining new procedures. The easiest way to grasp this operator is with the aid of a simple example. Let's define a procedure to compute the cube of a number. We'd like to end up with a procedure that will return the cube of, say, 32 when we say (cube 32). Most Scheme programmers will define this procedure as:

(define (cube x) (* x x x))
Simply start with the operator define, write a pattern for how the procedure will be called, replacing a symbol for the parameter, and then an expression or a sequence of expressions for what the procedure does. The procedure's return value is just the value of the last expression evaluated. This example is trivial, but it contains the required elements.

Many procedures require local variables to be effective. Scheme offers two operators for initializing local variables, let and let*. The structure of both is similar:

(let ((var1 val1) (var2 val2) ...) (expr1) (expr2) ...)
where any number of variables can be set to any number of values, and any number of expressions can be evaluated. The values may themselves be expressions. The difference between let and let* is that in let expressions, all the value expressions must not contain any of the variables defined in the let, whereas in the let*, the values may be expressions that use variables defined above.

The method described above is syntactic sugar for a method that is both more flexible and, arguably, more expressive of what's happening under the covers. You can write this:

(define cube (lambda (x) (* x x x)))

The procedure lambda is an operator that produces an unnamed procedure. Procedural programming, which is well supported by Scheme and Lisp, makes heavy use of such procedures. The object returned by lambda is the procedure, and the define simply assigns a name to an otherwise anonymous procedure. If this seems a bit bizarre to you, don't get sidetracked by it; you can write a lot of effective Scheme code without ever typing l-a-m-b-d-a.

If you're an experienced Scheme programmer, you're probably sputtering something to the effect that there's a lot more to defining procedures than this. That's true, but the number of options and variations is beyond the scope of this introduction. For all the gory details, turn to the references in the sidebar.

Key differences between Scheme and Lisp

Comparing GIMP script-fu files and Emacs elisp files quickly raises a lot of questions about differences between the two. The first difference to get used to is the difference between define in Scheme and defun in Lisp. In the latter, the pattern is

(defun funcname (parm1 parm2) (...))

It's an easy enough difference to remember: Scheme uses a pattern that looks like how a Scheme procedure is called, and Lisp uses a pattern that looks like a lambda definition.

The other key thing to remember is that it is customary to define tests in Scheme with a question mark at the end, such as list?, whereas in Lisp it is common to put a "p (for "predicate") at the end, such as listp.

Beyond these two differences, it's mostly a matter of learning procedure names by that old tried-and-true method: start writing some code while you have a browser opened onto a good reference.

A simple practical example

Ready to see Scheme tackle some real work? I spend my workdays writing C++ code, and I got tired of always having to type in the same boilerplate information into the .cpp and .h files I create for every C++ class I create, so I called on Scheme to do that task for me. Now, by entering the shell command NewClass MyClass, I get two files, myclass.h and myclass.cpp, both set up with just the right minimum of C++ content so I can go right to work on coding. You should be able to follow along now.

#! /usr/bin/guile -s !# ;; Note the unusual shebang lines above. ;; ;; NewClass ;; Usage: NewClass ClassName ;; Produces classname.h, classname.cpp (all lowercase) ;; for C++ class ClassName (case preserved) ; Create header file containing class declaration (define (make-cpp-decl className) (let* ((fileName (format #f "~a.h" (string-downcase className))) (outf (open-file fileName "w")) (headerTag (format #f "~a_H" (string-upcase className)))) (display (format #f "#ifndef ~a\n" headerTag) outf) (display (format #f "#define ~a\n\n" headerTag) outf) (display (format #f "class ~a\n" className) outf) (display "{\n" outf) (display "public:\n\n" outf) (display "protected:\n\n" outf) (display "private:\n\n" outf) (display "};\n\n" outf) (display (format #f "#endif // ~a\n" headerTag) outf))) ; Create source file containing class definition (define (make-cpp-def className) (let* ((prefix (string-downcase className)) (srcName (format #f "~a.cpp" prefix)) (hdrName (format #f "~a.h" prefix)) (outf (open-file srcName "w"))) (display (format #f "#include \"~a\"\n" hdrName) outf))) ; Utility procedure for invoking both action procedures (define (make-cpp-class className) (begin (make-cpp-decl className) (make-cpp-def className))) ; Get second item on command line and invoke the utility procedure on it. (make-cpp-class (cadr (command-line)))

Summary

This should be enough to get you started. If you're a GIMP or Emacs user, play around with a few scripts. If you're not, spend a little time with guile and experiment. Pick a common task that you'd like to automate and see if you can implement it in Scheme. Before long, you'll want to hunker down with one of the resources given above to expand your knowledge. Have fun!

Dr. Lee has been writing software and managing programmers since 1979, using a wide variety of languages, from assembler to Java. He discovered Scheme a couple of years ago while browsing the MIT Open Courseware Project curriculum in Computer Science. One of his current tasks is evaluating the feasibility of a simplified Scheme interpreter in an embedded application.

Share    Print    Comments   

Comments

on It's time to learn Scheme

Note: Comments are owned by the poster. We are not responsible for their content.

It's time to move on from this old crap

Posted by: Anonymous [ip: 82.192.250.149] on April 03, 2008 10:19 AM
Why have people moved on from Lisp? Because it's hard to write and even harder to read. Computer science has made progress in the 50 years since Lisp was invented. Leave it in the trashcan of history, where it belongs.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 74.184.103.246] on April 03, 2008 11:50 AM
Nice first comment. The truth of the matter is that in these aforementioned 50 years, languages have adopted *MORE* things from LISP, not fewer. What's that tell you?

#

It's time to learn Scheme

Posted by: Anonymous [ip: 61.69.252.177] on April 03, 2008 12:17 PM
"The truth of the matter is that in these aforementioned 50 years, languages have adopted *MORE* things from LISP, not fewer. What's that tell you?"

That dinosaurs contributed to our DNA. Let LISP/Scheme die a dignified and long overdue death.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 142.166.59.245] on April 03, 2008 12:26 PM
To me, it tells me LISP is a great functional language which has a huge number of technical accomplishments. It just happens to present them in a complex way.

1st post is wrong to suggest it should be forgotten, 2nd is wrong to imply it should be *the* language. It simply is. Or was. As history shall tell. Still, a little education helps a lot; but an explanation of functional coding would prove quite useful to the budding Scheme / LISP / Haskell / CAML (my preferred language) programmer. Even more helpful when it points out where *not* to use them.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 72.158.234.34] on April 03, 2008 01:52 PM
I agree with the first comment. it's about time programs that are using lisp as their scripting language move on to a new one. with ruby, perl, python and the slew out there gaining popularity, there is no need to be stuck in the 1950's

#

Re: It's time to learn Scheme

Posted by: Anonymous [ip: 142.166.59.245] on April 03, 2008 02:42 PM
You may think Scheme is stuck in the 1950's but you're missing the big picture.

Regardless of your opinion, Scheme remains the best way to teach functional programming. Functional programming is a great tool for mathematical work since each function directly correlates to a mathematical equation.

It just happens to be poor at performing iterative tasks / object abstractions. Which is fine, since each paradigm has it's place. You must be of the "all programming is software development." If you want to find out whether that is correct, go talk to a physicist.

#

Counter point to the example

Posted by: Anonymous [ip: 168.182.39.249] on April 03, 2008 02:41 PM
The real problem with scheme isn't the construction of new programs but rather the legibility of new programs. The cpp boilerplate example above is the PERFECT example of why not to use scheme. If you consider a similar example in perl or python ( or ruby or php or JavaScript for that matter), it would be so much clearer to create the boilerplate as a single extended string (or here string) and then apply one or more regular expression substitutions to set the new class name as passed from the command line.

We end up with a program with an extended string for each document (header and source files), and a few lines each of which is a simple text substitution. Simple, intuitive and effective. In comparison, the scheme example above is far less clear and far more complicated.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 10.1.4.39] on April 03, 2008 02:45 PM
I just wonder what the ages of these commenters are. Because I really hate the "LISP is god because I learned it in HS in 1800!!!" commenters and I equally hate the "C/C++/etc are all outdated because I learned Java in school and it's the only language I know, I'm 12 by the way" commenters too.

"It's old" is *not* a valid argument. If you have some specific argument against LISP put it forth.

#

Re: It's time to learn Scheme

Posted by: Anonymous [ip: 142.166.59.245] on April 03, 2008 02:58 PM
" "It's old" is *not* a valid argument. If you have some specific argument against LISP put it forth."

OK, I'm probably not the one that question is addressed to (although I learned Java in School, my project for fourth-year Prog.Lang. class was on functional languages design & development)...

But personally, I dislike that LISP is syntactically sugarred enough to *allow* the horrible code I've seen before. Sure, most of the other languages allow a mess of code too, but they're a little easier to clean up and understand. IMO, where an ounce of self-control is the rule with all language, two ounces is the rule for LISP.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 85.146.78.146] on April 03, 2008 08:47 PM
A good source of information could be the essays of Paul Graham (http://www.paulgraham.com/articles.html). It is quite interesting how he explains the notion of evolution of language (http://www.paulgraham.com/hundred.html) and explain how Lisp is able to redefine itself (http://lib.store.yahoo.net/lib/paulgraham/acl1.txt).

Lisp made the fundamentals ideas (http://www.paulgraham.com/diff.html) of computing programming. Paul Graham explains that language are medium of expression and why he prefers to express himself with Lisp (http://www.paulgraham.com/iflisp.html).

If you are lazy (do not insult anybody here lazyness is good sometimes) just read this one ( http://www.paulgraham.com/icad.html )I like how it shows that programmers go from java to perl to python cause each one is progressively closer to Lisp :)

#

It's time to learn Scheme

Posted by: Anonymous [ip: 71.131.181.172] on April 03, 2008 09:28 PM
The reality is that ALL programming languages are severely limited by 1) the inability of compilers to recognize anything resembling a natural language and 2) the lack of a representation that can represent the complexity of any non-trivial program and which can be both understood by humans and by compilers.

So we end up with truly broken languages like LISP which may be could for some things, but are nearly impossible to maintain. And since maintenance of programs consumes many more resources than development of programs, this raises the cost of software, introduces bugs and security problems, and makes the software industry the nightmare it is.

We need to start applying clear principles of software engineering and methods of AI (NOT using LISP) to the production of a software engineering platform which obsoletes conventional programming languages and which produces correct and efficient programs. While it is unlikely that we can produce such a platform which is perfect until we have true AI, we can certainly get closer than the primitive nonsense we have in the industry now, which regularly produces nightmares like Microsoft Vista or other buggy garbage.

With the poor software development methods we have now, it's amazing any of this stuff works at all, let along as badly as it does.

Learning LISP, however, is nothing to the purpose, except as a tool which can be added to the other - primitive - tools at our disposal at this time. It's good for certain things, but it's not significantly different than most other languages in its limitations.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 125.31.52.89] on April 04, 2008 04:23 AM
Those who dislike Scheme just do not understand the words by Einstein: Everything should be as simple as it is, but not simpler. That's what Scheme is. You can not judge a book by its cover!

#

It's time to learn Scheme

Posted by: Anonymous [ip: 129.215.149.96] on April 04, 2008 10:09 AM
I learned some Lisp and Java. It seems to me that they are equivalently complicated (or simple) if you ask me to judge it in terms of simplicity (or simply whether you can have clear and short coding). The Lisp and Java programs are not as concise as Ruby programs. Maybe Groovy is simplifying Java to become comparable with Ruby. I believe Groovy and Ruby can be further simplified. But simplicity is the only issue in computer programming. My personal preference is mine. I consider some features more important than others. How about you?

#

It's time to learn Scheme

Posted by: Anonymous [ip: 129.215.149.96] on April 04, 2008 10:12 AM
"But simplicity is the only issue in computer programming."

NOT the only issue.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 217.111.56.2] on April 04, 2008 12:30 PM
People have never 'moved on from Lisp'. But I would agree with the idea that someone to whom Lisp
is 'a primitive tool' could be greatly enhanced in his usefulness by at least bolting some artificial
intelligence onto him. I
,
It's about time that people who are not programmers stop complaining about
the fact that they aren't, demanding that because of this, it is really time that the stupid computer
starts to program itself. If the computer could program itself, it would prefer going to the cinema
to doing the payroll. That it cannot makes it usefully different from a human. And this same
people surprisingly never complain that because they cannot do a reasonably good haircut, it would be
about time to 'progress' to universal bald-headedness.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 62.173.103.210] on April 04, 2008 03:48 PM
I wouldn't categories myself as a Professional LISP or Java or any other language programmer but I would definitely would want to see programming evolving into something like working along with human brain. Where syntax errors can be corrected by AI and where "If i want to make a round box, it should make the round box and stop throwing exceptions at me". It frustrates me more and makes me feel that I am wasting my time and effort in correcting those bugs and errors all the time and half of my life has been spent in doing so.

I don't care if someone wants to use LISP or Java, to me it all comes to the preference. No language is better than other, but yes some are more complex than others which in a sense harder to understand and some are harder to implement.

Come on now just stop arguing on who is better than who. Are you better than your fellow member? No one is better than any other, yet they all are better in their fields.

I could go on and on but I have to attend a meeting so Caio for now!

#

It's time to learn Scheme

Posted by: Anonymous [ip: 163.192.21.43] on April 04, 2008 04:50 PM
People can write amazingly concise, well structured and logical code in scheme, lisp and other functional languages. Unfortunately, this requires an ability to think and dream in lambda calculus.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 58.69.84.67] on April 04, 2008 05:42 PM
It is scary. For somehow I have found a link between this and what I have recently discovered. And now i am here. Google pointed me here to be sure but on the same day? SICP and Linux. Looking for a tool for scheme, now I am here. Omg. The hackers of life sold their idea and a fellow buyer thought something of what they are saying then I went to mit and then here. Amazing. On the same day.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 58.69.84.67] on April 04, 2008 05:55 PM
For those who do not understand my ramblings. I am 58.69.84.67. Now I want to know how in the white blazes did I found out about this http://lifehacker.com/375789/best-first-programming-language-to-learn on the same day and became interested enough to read this http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html and then when consulting google happen across here.???? Does anybody understand????!

#

Re: It's time to learn Scheme

Posted by: Joe Barr on April 04, 2008 07:21 PM
Hinde malaking bagay!

#

It's time to learn Scheme

Posted by: Anonymous [ip: 217.111.56.2] on April 04, 2008 06:20 PM
> I wouldn't categories myself as a Professional LISP or Java or any other language programmer but
> I would definitely would want to see programming evolving into something like working along with
> human brain.
.
The solution is to hire a human to do the programming. But that comes with all
the drawbacks of having to coordinate what you want with someone who
wants something on his own, isn't willing to work for free and may even just
take your money, waste your time and do nothing at all.
.
What you would like to have is an intelligent slave combining all
the advantages of an intelligent being with all the advantages
of a machine which is not intelligent. This makes no sense
and that you would like it better otherwise doesn't change that.

#

The Author Speaks

Posted by: Anonymous [ip: 76.113.13.166] on April 04, 2008 07:54 PM
Wow. I guess that's called stirring the pot! I wrote this article not because I think Scheme is the greatest thing since sliced bread (although it might well be), but for exactly the reasons given: some very powerful apps, of which I mentioned only two, use Lisp/Scheme as a scripting language, and I felt underprivileged for always having to ask for help from someone less ignorant than I about programming in this class of language. It occurred to me that I might not be alone.

I will not engage in the "Scheme is better than Java" debate any more than I would take seriously any carpenter who spent his energy debating whether a hammer is better than a handsaw. And like a carpenter, I view my life as a programmer as one who collects tools, learns how and when to use them, and keeps them in proper working order. Now I can look down at my toolbelt and see Lisp/Scheme hanging there along with Java, C++, and Perl (not to mention the 20-30 others that I can dust off and use as needed).

Thanks to all of you for making my first Linux.com article so entertaining!

#

It's time to learn Scheme

Posted by: Anonymous [ip: 132.250.112.46] on April 04, 2008 09:32 PM
For those who don't/can't/won't understand LISP are doomed to reinvent it.

1. All compilers generate lisp - just look at the intermediate code tree fed to the opimizer, it is LISP in disguise.
2. Look at HTML... It too is LISP in disguise - the html tags themselves are lisp functions, with the corresponding end tags the close parenthises.
3. Look at SGML.... same thing.
4. Look at XML... same thing.

#

Improving Scheme readability

Posted by: Anonymous [ip: 129.246.254.112] on April 04, 2008 11:33 PM
A serious advantage of Scheme and other Lisps is that they are homoiconic - that is, when you type in code, you can see exactly what
underlying data structures it's going to be represented as, making macros and code-generating-code remarkably powerful.
But a serious problem with Scheme and other Lisps is that it's hideously hard to read (and I've used Lisps for more than 20 years).
I've been trying to fix that; see http://www.dwheeler.com/readable and its associated mailing list.

For example, here's the cube example above:

define cube(x) {x * x * x}

#

A simple practical example!

Posted by: ted61 on April 05, 2008 05:07 PM
I liked the simple example. "You should be able to follow along now." I am a mechanic who uses Linux as a toy. I think I will be able to follow along right after I learn one of those Persian alphabets.

Good article. I have spent about 6 of the last 18 hours reading up on programming from the MIT open books. I kind of like the way LISP is structured. I can understand the basics there. The Persian basics listed above are too complex for me.

I don't know anything about all of the arguments but I am having fun with LISP so far.

#

The power of scheme

Posted by: Anonymous [ip: 69.17.73.250] on April 06, 2008 05:07 AM
The advantage of scheme is that it lets you write your own language, a language tailored to your problem domain in which you can then solve your problem. And it lets you do so in small bits each of which is obviously correct. (For some value of obvious.)

A great way to learn scheme is to:
1) Copy the obtuse shebang program header presented in the article.
2) Use an editor that does parenthesis matching. Pretty printing wouldn't hurt either. Emacs works. I can't speak for anything else.
3) Read one of the books mentioned in the article sidebar ("The Structure and Interpretation of Computer Programs" at http://mitpress.mit.edu/sicp/ is the one I've worked with. I rely on the author's judgment regarding the other book.)

Karl O. Pinc <kop@meme.com>

#

It's time to learn Scheme

Posted by: Anonymous [ip: 91.153.32.197] on April 06, 2008 05:10 PM
Wow, so many expert opinions... and most of them from people who have obviously never used a Lisp-family language. People say it's hard to read, so is arabic (at least to me). How about learning it a bit? I'm not a Lisp expert, having used (Common) Lisp only for a year. However, I find reading well written Lisp code easy, badly written not so.

Impossible to maintain? Yeah sure, how many times did you try?

Yes there are newer languages (Ruby, Io etc).. some of them are decent, however newer != better. I happen to need some performance.. tell me when you find a dynamic language implementation which is faster than SBCL (a common lisp implementation).

#

Scheme is really quite cool

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 12:07 AM
I was introduced to LISP in the early 80's. I like to think of Scheme like this: it is the smallest complete computer language. The text of a LISP program is merely a dump of its structure, LISP the language has no syntax of its own. Perhaps you are not aware that Javascript is really LISP; it has all the same functional features, but it has a syntax that looks like Java or C.

The horribly difficult to read LISP code most of you refer to was written by LISP developers who do not understand the power of the LISP macro system's abilty to help developers create readable and maintainable code.

If your eyes are not used to looking at LISP notation, LISP programs can be easliy converted to a C-like syntax, and then they will look just like the C or Java or Perl programs that you are used to. Macros in LISP are similar to the preprocessor functioonality in C and C++, but they are much more powerful because they operate at a semantic level instead of a textual level.

What many people miss out on with LISP development is the power of the interpreted environment. It's really ideal for prototyping and GUI development because it well supports the iterative development style. Changes to code are implemented immediately with no recompiling or restarting. emacs has excellent LISP integration making development even more of a joy.

I have worked worked on a successful Scheme software system, it was a pleasure to work on. We used SWIG to generate glue for the various libraries we needed to call. Most applications spend over 90% of their CPU cycles in library calls so the efficiency of the interpreted environment is not really a factor.

Please do not criticize that about which you know little.

#

by the way...

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 12:17 AM
emacs LISP is not the same as Scheme or Common LISP, and you will have horrible troubles if you confuse them.

#

Scheme-LISP-Ruby

Posted by: ted61 on April 07, 2008 03:43 AM
I could not find any information on Scheme so I followed the above link to LISP. LISP may be easy, old and boring to you computer guys but the linked book is not very friendly for a mechanic to figure out. I went off to my local library and found a simple looking book to learn how to program Ruby. I don't know what Ruby is used for, but the instructions are so good I was declaring variables and watching the results in a few hours.

My ultimate goal is to learn what those css scripts do. The ruby book gives me nice instructions on how to install, find and use an interpreter. Hopefully, I will understand some of this persian when I am done. Maybe then, I will be able to write a script to have my photo pages load automatically.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 77.49.32.132] on April 07, 2008 07:14 AM
Even if lisp becomes obsolete it's an essential step in improving your skills and more essential in understanding programming.
For the braves there's a wikified version of "Write yourself a Scheme in 48 hours" on wikibooks.org, beware it's catching and in Haskell!

#

It's time to learn Scheme

Posted by: Anonymous [ip: 77.49.32.132] on April 07, 2008 07:19 AM
Scheme is one of these eye-opening experiences one's got to have in order to mature as a programmer, even if one sticks to ruby afterall.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 209.6.171.130] on April 07, 2008 08:56 AM
To those who say Lisp like languages are old, outdated and useless. You are wrong. It's quite powerful and certain problems are quite suited to it.

To those who say Lisp and it's kind are the end-all-be-all of programming languages and everything else is sh*t. You are wrong as well, and egotistical.

A good deal of what a programming language does is help a human to express ideas/instructions to a machine. On that note, not everyone thinks in lambda, all things being equal, whatever language most readily conveys your thoughts to the machine is the right one.

Personally, that's why I use Perl. Some people will think this is insane, it is not. While the large degree of stylistic expression can allow people to write very obscure (or sh*tty) code, it also allows me to code in whatever manner best reflects me understanding of the problem. I can write code that is functional, recursive, or imperative. Lisp-like, or C-Like.

If and when perl6 ever hits the fan, I'll be ecstatic, Lisp-like macros for manipulating the language and adding to it, real support for functional programming, and still the freedom to write in the manner that best reflects my thought.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 07:47 PM
Scheme is already installed on most Linux systems, and you probably don't even know it. Type 'guile' at a prompt. The best way to learn Scheme is to pick up a copy of the excellent MIT textbook, "Structure And Interpretation Of Computer Programs" by Sussman and Abelson. I think the content and examples are available on-line. This book is brilliant beyond description, it will totally change the way you think about programming and software development.

Another excellent point is that learning and understanding LISP will make you a better programmer when you move on to other languages. To those who want to learn Java, I say, learn Scheme first, then Java.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 08:17 PM
Hey, perl6 guy, ever heard of Ada? I think it's the language you're looking for. It's everything you ever wanted in a computer language, plus lots more too! Perl is already a parsing nightmare and its syntactic complexity leads to ambiguity in execution. You end up with evil bugs where, for instance, a small typo results in a program that is syntactically correct but behaves in a slightly different way. Perl6 will be a nightmare of compiler bugs and excess baggage if it is as you say. Enjoy an extended beta-testing experience!

I write Perl scripts because there is no other interpreted language with all that library support. It is an unpleasant experience and leaves me wanting to wash my hands. As I learn more and more about shell scripting I find it far preferable to Perl.

This is the beauty of LISP. There is NO syntax, no confusing # with @ or % or $. One Perl book actually compares Perl code with modem noise. The irony is obvious but escapes perhaps even the author. With Perl you have to test and test and test because the compiler is so forgiving of bad syntax. Since the syntax is so bewildering and strange you are never really sure that your program is going to behave.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 209.6.171.130] on April 07, 2008 09:11 PM
Hey Ada guy,

Perl5 is certainly a tricky parse, but I disagree about your comments on typos. If you're using strict and warnings, anything of that nature will usually become readily apparent (mistyped hash keys are one exception due to autovivification).

Personally, I like sigils ($,@,%), they confer information at a glance (I hated them at first though). One of the things perl6 will be clearing up, is a lot of the ambiguity and making for a cleaner parse and syntax. For instance, sigils will not change based on context. You will always use @ for arrays, always % for hashes, whether you are accessing it in a scalar context or not. And even as far as Perl 5, there are certainly a lot of ways to express the same idiom, but if you are halfway knowledgeable, it's not hard at all to figure out how the program will "behave". If you're not golfing, it's quite easy to write easy-to- understand code.

Then again, perl6 been a long time coming, and still has a way to go. Not quite Duke Nukem, but it's been awhile.

#

Noone has yet mentioned

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 10:17 PM
The excellent arithmetic system in scheme. Numeric values are stored as rational values with numerator and denominator, so:

(* 3 (/ 1 3)) => 1 instead of 0.999999999

Also, if you can wrap your head around what is going on with (call-with-current-continuation ...) in Scheme, you will possess a very powerful programming technique that can be done only clumsily, if at all, in other languages.

#

problem with silly perl characters

Posted by: Anonymous [ip: 24.62.148.66] on April 07, 2008 10:33 PM
Suppose your code uses an array. You write a bunch of code that assumes you are using an array. The design takes a turn and now this same variable would do a much better job as a hash. This is the kind of refactoring problem that happens all the time. So now you have to pick over your code and change the array to a hash. If you miss something, it may even compile, but it sure won't work. In LISP this would not have been a problem because variables are typeless in the program text (they DO have types in the runtime), and besides, hashes and arrays are semantically identical. You put stuff in and get stuff out with a key. So what if the key is integer or float or string or what. This is the same as the equally stupid Hungarian Notation that Simonyi from Microsoft introduced with LPWORD and the like, creating code that needed extensive modification to compile on a 64-bit or big-endian platform.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 209.6.171.130] on April 08, 2008 05:07 AM
Certainly, they have many similarities and I yes, you could just say an array is a hash of sorts with numeric keys, but the types of operations you are bound to do on either data type, are different.

Arrays being for more queue like processing and hashes for keyed structures (not saying you don't know this). I don't find myself often changing from one to the other when refactoring. Usually the choice is clear from the get go. And again, outside of nested structures (which you'll get a runtime error), you'll get a compile time error when using strict.

And perhaps it's improved since I've last looked, but there are certainly performance benefits to take into account with having separate implementations.

But even so, most programs of any notable size are going to break off those things into modules and objects.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 24.248.89.66] on April 08, 2008 03:26 PM
I was once a Computer Science student who loved to program since the third grade, then I took a class where I needed to learn scheme. Well I dropped out of Computer Science, stopped programming and became a Communications major.

#

It's time to learn Scheme

Posted by: PyritePyro on April 08, 2008 09:35 PM
Communications guy: If you loved to program, why did finding one language you didn't pick up instantly deter you. Yes learning the functional programming paradigm is a little different from iterative programming, but it's not exactly invalidating what you've already learned. And sometimes it's good to streach yourself.

#

It's time to learn Scheme

Posted by: Anonymous [ip: 70.17.80.97] on April 11, 2008 04:28 AM
I program in many languages. I am proficient in z80 ASM, C, C++, JAVA, JPython CPython, Python, BASIC, and many many others. I knew Lisp a long time ago and I am just re-teaching myself and trying to learn Arc. Currently I am working on writing a semi-intelligent AI in Scheme. The difference between Lispy languages and languages for the masses is that Lisp is FUN to program. JAVA is a PITA.

This is the same rush I felt when I switched from C to Python. But Lisp is different. The programmer has complete control. I can go write something totally new. My thinking is not limited by the language. A language should be a tool to accomplish something and should never limit your understanding because of syntax or design. With Lisp, I can change it and do almost anything I want. I could write a totally new language if I wanted. I could even implement Lisp in Lisp or something equally convoluted.

I may know nothing about programming, but that is what I think. Plus, I love that Reverse Polish Notation. BTW, Reverse Polish Notation is (+ 1 2 3) instead of 1 + 2 + 3.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya