Live data from Hacker News

Lisp implementation in sed

github.com

31–40 of 64 posts

Re: Lisp implementation in sed

#31
post #5
post #3

This is amazing. Just reading the code makes my head hurt, but you implemented a language with it.

Here, for example, is the implementation of `atom` (I think): /(atom /{ /\[\S\+\]/{ s/.*/[]/ bpop_context } s/.*/t/ bpop_context }

The author has won an IOCCC contest. This would have just pricked him a bit.

Re: Lisp implementation in sed

#32
post #17

Earlier quoted context omitted.

Oh come on. They took an unreadable language and implemented a slightly less unreadable language in it. That's at least two problems and one solution. To what, I don't know.

Having a Lisp will make it a little easier to write the Javascript interpreter. Baby steps.

Oh, excellent. Once I have JS I'll be able to run Clojure code on it.

Re: Lisp implementation in sed

#33
post #20

Earlier quoted context omitted.

You didn't misinterpret.

i am not particularly gifted at computer science and especially not programming languages. by necessity, the only languages i know are JavaScript and lisp. so I am always surprised to hear lisp is "unreadable" as opposed to "unfamiliar".

I appreciate the fact that one reply to your comment it "yes, not enough macros", and the other is "indeed, too many macros".

Re: Lisp implementation in sed

#34

Earlier quoted context omitted.

i am not particularly gifted at computer science and especially not programming languages. by necessity, the only languages i know are JavaScript and lisp. so I am always surprised to hear lisp is "unreadable" as opposed to "unfamiliar".

I appreciate the fact that one reply to your comment it "yes, not enough macros", and the other is "indeed, too many macros".

Say what? Both replies are saying that macros can make it tough to read. (Though, personally, I don't have a problem with most macros -- just reader macros.)

Re: Lisp implementation in sed

#35

Would someone mind giving a quick explanation of how this works? I have only used sed to replace text in files and directories. How do people write interpreters and game loops with this unix utility?

sed is provably Turing complete: http://www.catonmat.net/blog/proof-that-sed-is-turing-comple... which means that it's effectively able to simulate any other Turing-complete language (provided enough processing power and memory).

Re: Lisp implementation in sed

#36
post #28

Earlier quoted context omitted.

i am not particularly gifted at computer science and especially not programming languages. by necessity, the only languages i know are JavaScript and lisp. so I am always surprised to hear lisp is "unreadable" as opposed to "unfamiliar".

I think that Lisp got a reputation for being unreadable because some Lisp programmers have the tendency to get too far into macros to extend the language, resulting in a language that other developers have not seen before.

My theory is that it has to do with not having any operators, except parentheses, and using exclusively prefix notation, where other languages allow infix for doing arithmetic. Also, in Scheme loops are usually recursion, which means they have no standard form and they are upside-down from usual (the loop condition and increment are near the bottom, where the recursive call is).

Re: Lisp implementation in sed

#37

Earlier quoted context omitted.

Yep, that's pretty much how you have to do it. (If all you need is increment/decrement, though, you can actually do it pretty concisely with decimal-digit strings. Skipping the binary-to-decimal conversion greatly simplifies displaying numerical values.)

The GNU sed manual has examples like that at the end. It always seemed odd to show examples of things that are so awkward and inefficient. If they meant for sed to do those things, presumably they would have made commands for them.

> to show examples of things that are so awkward and inefficient

Re: Lisp implementation in sed

#38
post #2

Ahahah. Awesome. There is even an 'awk' version: https://github.com/darius/awklisp

I wrote that, and I gotta say sed is a much crazier target. More sed fun: http://aurelio.net/projects/sedsokoban/

Kudos, there was also this one: http://www.cs.cmu.edu/afs/cs/Web/Groups/AI/lang/lisp/impl/aw... Possibly based on the same newsgroup post?

Re: Lisp implementation in sed

#39
post #28

Earlier quoted context omitted.

i am not particularly gifted at computer science and especially not programming languages. by necessity, the only languages i know are JavaScript and lisp. so I am always surprised to hear lisp is "unreadable" as opposed to "unfamiliar".

I think that Lisp got a reputation for being unreadable because some Lisp programmers have the tendency to get too far into macros to extend the language, resulting in a language that other developers have not seen before.

I like scheme to be honest, especially the racket style of preferring define over let. Combined with well chosen variable names, list comprehensions, pattern matching and optional square brackets, all but the trailing ))))) becomes not a problem.

Re: Lisp implementation in sed

#40

Earlier quoted context omitted.

The GNU sed manual has examples like that at the end. It always seemed odd to show examples of things that are so awkward and inefficient. If they meant for sed to do those things, presumably they would have made commands for them.

> to show examples of things that are so awk ward and inefficient

[deleted]
Post reply on HN