News for hackers. Stuff that matters.
Re:7 lines of code, 3 minutes: Implement a programming langu... by ramchip on Monday June 28, 2010 @01:01PM (#1468535)
For a fairly liberal definition of "from scratch", of course...
Re:7 lines of code, 3 minutes: Implement a programming langu... by Hoff on Monday June 28, 2010 @01:41PM (#1468708)
Obligatory Sagan quote: “If you want to make an apple pie from scratch, you must first create the universe.”
Re:7 lines of code, 3 minutes: Implement a programming langu... by Periodic on Monday June 28, 2010 @07:20PM (#1469789)
I'm often annoyed that between language theory and language implementation there is the trouble of lexing and parsing. Both are complex and take a lot of time and know-how (at least for me as they never work right the first time), and it's not until you have those done that you can actually work on language features.

Lisp is handy from it's data-is-code mentality it already has a general-purpose parser built in. It's something that is fairly easy to implement for functional languages which is much harder to implement for OOP languages.

Re:7 lines of code, 3 minutes: Implement a programming langu... by someone_here on Monday June 28, 2010 @01:19PM (#1468599)
Exactly. Once could say you can write all of perl in perl by using eval().
Re:7 lines of code, 3 minutes: Implement a programming langu... by fadmmatt on Monday June 28, 2010 @01:21PM (#1468609)
Sure, but the article doesn't use eval.
Re:7 lines of code, 3 minutes: Implement a programming langu... by alnayyir on Monday June 28, 2010 @06:49PM (#1469716)
You make your own eval for the lambda calculus, so that's not entirely accurate ;)

Edit: (Yes I know the difference, and I changed the he to 'you')

Re:7 lines of code, 3 minutes: Implement a programming langu... by johkra on Monday June 28, 2010 @05:03PM (#1469449)
Does (((λ f . (λ x . (f x))) (λ a . a)) (λ b . b))) reduce into the identity function?
Re:7 lines of code, 3 minutes: Implement a programming langu... by fadmmatt on Monday June 28, 2010 @07:02PM (#1469750)
Yes.
Re:7 lines of code, 3 minutes: Implement a programming langu... by inquisitor20 on Monday June 28, 2010 @12:01PM (#1468347)
this looks suspiciously similar to my analysis of programing languages class
Re:7 lines of code, 3 minutes: Implement a programming langu... by fadmmatt on Monday June 28, 2010 @01:59PM (#1468781)
It will look suspiciously similar to the Scripting Language Design and Implementation class that I'll be teaching.

This kind of stuff also showed up in my program analysis and advanced compiler classes, too.

One of the class projects was to implement first-class macros, and we used an interpreter that looked a lot like the one from this article:

http://matt.might.net/articles/metacircular-evaluation-and-f...

(/article author)

Re:7 lines of code, 3 minutes: Implement a programming langu... by dugmartin on Monday June 28, 2010 @02:00PM (#1468784)
Be glad you didn't go to school 20 years ago. I had to build a Lisp-1 REPL in Pascal on an IBM mainframe without a debugger for my programming languages class.

(I also had to walk to class barefoot in the snow uphill both ways)

Re:7 lines of code, 3 minutes: Implement a programming langu... by jorgeortiz85 on Monday June 28, 2010 @12:35PM (#1468452)
If you went to the University of Utah, he probably taught it (http://matt.might.net/#teaching).
Re:7 lines of code, 3 minutes: Implement a programming langu... by messel on Monday June 28, 2010 @01:41PM (#1468707)
epic sms (small world syndrome) if this was his teacher
Re:7 lines of code, 3 minutes: Implement a programming langu... by raghus on Monday June 28, 2010 @04:00PM (#1469250)
sws?
Re:7 lines of code, 3 minutes: Implement a programming langu... by petercooper on Tuesday June 29, 2010 @01:30AM (#1470505)
Unless you live in Australia.
Re:7 lines of code, 3 minutes: Implement a programming langu... by akkartik on Monday June 28, 2010 @12:01PM (#1468345)
I wonder: What's a minimal language in this vein with lisp-style macros?
Re:7 lines of code, 3 minutes: Implement a programming langu... by fadmmatt on Monday June 28, 2010 @12:47PM (#1468491)
That's a good question, actually.

Lisp macros need knowledge of the structure of the s-expression.

Certainly one can Church encode s-expressions and provide defmacro.

Gensym is trickier. Hygiene might be really challenging.

I might actually try that out.

(/article author)

Re:7 lines of code, 3 minutes: Implement a programming langu... by akkartik on Tuesday June 29, 2010 @10:49AM (#1471569)
"Lisp macros need knowledge of the structure of the s-expression."

I recently rediscovered this for myself: http://arclanguage.org/item?id=11880

Re:7 lines of code, 3 minutes: Implement a programming langu... by fogus on Monday June 28, 2010 @01:55PM (#1468761)
McCarthy's original could give you macros, although they would be extremely cumbersome. I've been wanting to implement some sort of macro system in my minimal Lisp impl. http://github.com/fogus/lithp
Re:7 lines of code, 3 minutes: Implement a programming langu... by mahmud on Monday June 28, 2010 @12:41PM (#1468465)
A lisp with T, NIL, if, and lambda, like "tiny-lisp" here:

http://tfeb.org/lisp/hax.html#CONDUITS

Literally, a package hack with zero implementation :-)

Import defmacro and friends and you have it.

Re:7 lines of code, 3 minutes: Implement a programming langu... by stcredzero on Monday June 28, 2010 @02:07PM (#1468813)
A challenge: get something comparable to macros out of Forth.
Re:7 lines of code, 3 minutes: Implement a programming langu... by celoyd on Monday June 28, 2010 @03:08PM (#1469036)
I could be wrong – it’s been a while now – but isn’t that what forth’s “immediate” is?
Re:7 lines of code, 3 minutes: Implement a programming langu... by silentbicycle on Monday June 28, 2010 @03:26PM (#1469104)
Yeah, immediate words are executed during compilation.
Re:7 lines of code, 3 minutes: Implement a programming langu... by brianobush on Tuesday June 29, 2010 @02:00AM (#1470558)
How about a C version? Always feel that using scheme/lisp/etc is cheating a bit :)