Monday, April 11, 2011

about JavaScript, Scheme and History

I've been doing a bit of JavaScript lately and I am shockingly enjoying it. I thought it was going to be a nightmare and a lot of copy+paste but after a good amount of reading and watching talks, I started to like the language. I've been collating bits an pieces of information in the ossdev-ireland wiki, mainly focusing it towards developers that only have to deal with the language in small doses.

Ossdev.org is a place to share experiences that overlap the different open source groups in Ireland. JavaScript and MongoDB are the two topics that seem to be gathering more interest so far, but it's been less that one week since the wiki was installed, so hopefully more topics will start being worked on soon.
The Irish Penguin is the one to blame for all this sharing craziness, and I hope more people get on board in the next couple of weeks.

As usual, following on links and references in talks and tutorials takes you to a thousand other talks and tutorials that you will never have the time to read and watch. I would recommend the fantastic series on Javascript by Douglas Crockford. I especially enjoyed Part I: the early years, cause although it does not contain any code, it is a great lecture in history of computing, and I totally agree that that is an area that we don't handle very well in the profession.

During that talk, Crockford recommends the little schemer as a book that will change the way you think about programming, so I had to get my hands on a copy of it. I have to say that it was a bit difficult to get started with it, because although it seems to be a book targeting children, there is no explanation whatsoever on how to start with the language itself. A bit more digging on the net and I finally downloaded DrScheme, and got it running. Although the site points to a newer version, namely Racket, DrScheme still exists as a package in Ubuntu systems, so that's what I'm using for now.
So this is my first scheme listing ever:

(define atom?
  (lambda (x)
    (and  (not (pair? x)) (not (null? x)))))
(define lat?
    (lambda (l)
      (cond
        ((null? l) #t)
        ((atom? (car l)) (lat? (cdr l)))
        (else #f))))

(lat? '(chunky bacon))
(lat? '(chunky (bacon)))

The first call to lat? returns true, and the second false. Let's see how long I can keep up with the parenthesis madness... the plan is to follow on to SICP, but I will have to finish this one first!

No comments:

Post a Comment