News for hackers. Stuff that matters.
Re:Lisphp is a Lisp dialect written in PHP. by mahmud on Monday July 05, 2010 @12:13PM (#1488519)
Well done jacquesm! It's only been what since you first looked at Lisp? 2 months? Already you know your way around typical primitive implementations.

Respect!

Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @12:18PM (#1488530)
I've been studying it so I can go and write a little lisp interpreter in C just to make sure I really 'got' it.

For me that's the 'benchmark' of understanding a language, to be able to re-implement it.

edit: by the way, it's been more than two months, but there have been a lot of things done in that time that have nothing to do with programming.

Re:Lisphp is a Lisp dialect written in PHP. by mahmud on Monday July 05, 2010 @01:13PM (#1488637)
I wrote a few long-winded posts on HN listing Lisp implementation bibliographies. There are a few essential papers that you need to read to get the full picture; Here they are collected in an archive. Nearly all of them assume nothing more than rudimentary familiarity with Lisp, some functional programming (Scheme and tiny bit of ML) and they're geared towards someone with some C, machine-org and assembly knowledge.

http://dl.dropbox.com/u/2083231/essential_lisp_implementatio...

I would recommend these to someone who wants to implement a functional or a Lisp language, going with nothing but basic systems programming knowledge.

Recommend prerequisites are the first 2-3 chapters of SICP, some familiarity with classic compiler construction (dragon book would do, skip the lexical analysis and parsing parts though; you wont need much of that for Lisp if you retool and existing lexer. But focus on function calling and stack discipline, lexical scope and variable visibility, and maybe learn how an Algol dialect implements runtime heap-allocation) some exposure to C and assembly, and healthy curiosity.

A suggested order might be: Ghuloum, Wilson, Dybvig, the uncredited "lisp-implementation.pdf" paper, Gudeman, Kelsey, then Shao (Shao might make a whole lot more sense if you read one of Andrew Appel's compiler books and dip a tiny bit into ML.)

Re:Lisphp is a Lisp dialect written in PHP. by eru on Monday July 05, 2010 @04:59PM (#1489086)
For the brave, I can also recommend "Write Yourself a Scheme in 48 Hours" (http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...).

I write `brave', because it implements Scheme using Haskell. And if you aren't familiar with either, the learning curve will be steep.

Re:Lisphp is a Lisp dialect written in PHP. by eru on Monday July 05, 2010 @01:11PM (#1488632)
For a challenge: Try a lazy language next.

See http://research.microsoft.com/en-us/um/people/simonpj/papers... for some hints on writing a compiler for those (or just general amusement).

Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @01:15PM (#1488640)
Lisp is enough of a challenge for me at the moment.

For instance, it seems to be like travelling back to the 80's just to have to live with the 'third element in the list containing the data about a person' instead of simply using person->name , I've gotten used to thinking in terms of symbols so much that I find it hard to go back to the kind of trickery that was 'normal' in say microsoft basic in the 80's because it lacked named elements in something akin to a struct.

There is a certain kind of elegance in something so minimal but it also comes with considerable mental overhead and opportunity for mistakes.

Re:Lisphp is a Lisp dialect written in PHP. by gruseom on Monday July 05, 2010 @01:40PM (#1488686)
third element in the list containing the data about a person

Most people don't do that, except in throwaway code. In CL you can use an alist, a plist, a struct, or CLOS.

I've gotten used to thinking in terms of symbols so much that I find it hard to go back

Given that Lisp's history with symbolic computing goes back to the beginning, something about that doesn't sound right.

Your person->name comment reminds me of something, by the way. Portions of our app run in both CL and JS (via the Parenscript library). This is relatively easy, although there are a few disagreements between the two that you have to watch out for (such as how they handle null). Anyway, there are lots of CL features we've "ported" to JS via macros, but there is also one JS feature I found myself envying so much that I finally wrote a partial implementation of it in CL. That is JS's willingness to allow you to stick any property on any object just by setting it. It's a rather Lispy feature since it's maximally dynamic and maximally flexible. I find it handy for incremental development. When you have some data about a thing that you want to associate with it, but only some of the time, it's a real pain to have to make a separate data structure to hold it and then make sure it gets passed alongside the original thing to all the appropriate places. Our CL implementation of this is pretty crude but it allows the important thing, which is that you can write (@ something :some-data) and (setf (@ something :some-data) "blah") pretty much wherever you want. So we can be said to have Greenspunned a bit of JS in Lisp!

Re:Lisphp is a Lisp dialect written in PHP. by mahmud on Monday July 05, 2010 @01:30PM (#1488671)
You're still in the pedagogy sandbox; every real Lisp worth using has structures and objects:

  (defstruct person
    name age occupation)  => PERSON

  (make-person :name "Kris Kringle" 
               :age 71 
               :occupation "Santa") => #S(PERSON-1)

  (person-name *) ==> "Kris Kringle"
Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @02:11PM (#1488736)
> You're still in the pedagogy sandbox;

Don't worry, I realize that :)

> very real Lisp worth using has structures and objects:

That's a tricky and somewhat circular definition.

If it is worth using it is probably real and vv, but most lisp tutorials that teach 'pure' lisp do not have structures and / or objects, they rely on lists alone as their major data structure.

That also defines all lisps that do not have these items as somehow not real and there seem to be a lot of lisp people that somehow consider this 'impure'. Or is my reading material that dated ?

Re:Lisphp is a Lisp dialect written in PHP. by jules on Monday July 05, 2010 @02:28PM (#1488765)
If your reading material Lisp doesn't have some form of defstruct then it certainly is dated, or they are avoiding it on purpose. Every non-toy Lisp has it.
Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @02:42PM (#1488800)
Ok, thanks. That helps. I started 'from the ground up', I figured that the best way to study a language is by looking at the way it was in the beginning since that's the most pure form of it. If 'lists' are as great as they are said to be you'd expect that things like structs and classes are optimizations, not essentials.
Re:Lisphp is a Lisp dialect written in PHP. by eru on Monday July 05, 2010 @04:46PM (#1489058)
Don't do that for Lisp. You will be stuck with the dynamic scoping that Lisp used to be plagued with in the beginning.

Go far a modern Lisp like Scheme. (You can ignore the syntax you don't want to deal with, yet.)

Re:Lisphp is a Lisp dialect written in PHP. by jules on Monday July 05, 2010 @04:27PM (#1489024)
Yeah, you can view it as an optimization: you can build defstruct & co on top of lists with macros. However, using ca(d)*r by hand is not advisable in any case...

Usually it goes the other way around: you implement lists on top of defstruct.

Re:Lisphp is a Lisp dialect written in PHP. by mahmud on Monday July 05, 2010 @03:44PM (#1488930)
Restricting yourself to Pure Lisp is like insisting on only dating virgins.
Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @03:48PM (#1488939)
I have a very snappy comeback to that one but I highly doubt it will pass the censor ;)
Re:Lisphp is a Lisp dialect written in PHP. by eru on Tuesday July 06, 2010 @09:22AM (#1490867)
How about: "If she wasn't good enough for the other people, she won't be good enough for me."
Re:Lisphp is a Lisp dialect written in PHP. by KirinDave on Monday July 05, 2010 @01:53PM (#1488703)
Instead we all just use associative arrays.

But there is a danger in overusing structs and classes, too. You end up with these hugely complex ontologies for every little program, and frequently when you try to reuse code you end up with conflicts.