Live data from Hacker News

Lisp implementation in sed

github.com

41–50 of 64 posts

Re: Lisp implementation in sed

#41
post #38

Earlier quoted context omitted.

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?

That one's a cooler hack because it runs in old awk, from before they supported user-defined functions. The whole read-eval-print composition is a straight-line series of loops, with the recursions unrolled into explicit stack manipulation. If you want to see how to write fairly readable code within those restrictions, it's instructive. It even has a cooler name. (I said so when bringing it up in my documentation.)

On the other hand, awklisp has some value as a readable Lisp interpreter in a lower-level but still reasonable language, in between the usual Lisp-in-Lisp and Lisp-in-C tutorials.

Re: Lisp implementation in sed

#42

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

Yeah. As in, better done in awk. The opposite of awkward is sedward.

Re: Lisp implementation in sed

#44
post #27

Earlier quoted context omitted.

did I misinterpret or did you just call lisp "[nearly] unreadable"? all languages are unreadable for the uninitiated.

One theory that people often bring up vis-a-vis readability of lisp is that people seem to have a harder time parsing symbols than words (so all the parens makes it harder to look through a file). Compared to python or coffeescript, it feels like there's a lot less noise

Another theory is that there are far fewer symbols in Lisp than python or coffeewhatever, making it easier to read.

Re: Lisp implementation in sed

#45

Well, OK: I'm curious, can I use the sed to Perl utility, to then make a Lisp implementation in Perl?

Trying this myself, it returns an error:

    s2p: expression #1: extra characters after command (d)
Thankfully, I've never had the job of porting a sed script to Perl, so I'm not exactly sure what that's all about. The docs mention this error, but don't explain what it means,

http://perldoc.perl.org/s2p.html

Re: Lisp implementation in sed

#46

Well, OK: I'm curious, can I use the sed to Perl utility, to then make a Lisp implementation in Perl?

Aaaaand, obviously Perl has CPAN, so there's really no need (except to be evil):

https://metacpan.org/pod/CljPerl

(there's a few, actually, because TIMTOWTDI!)

Re: Lisp implementation in sed

#47

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?

With difficulty. I started playing with the idea of making a programming language out of sed at one point, but then I decided that, even if I succeeded, it would be a waste of time. I didn't take into account Hacker News.

Becoming famous by wasting time is something to consider...

Re: Lisp implementation in sed

#48
post #44
post #27

Earlier quoted context omitted.

One theory that people often bring up vis-a-vis readability of lisp is that people seem to have a harder time parsing symbols than words (so all the parens makes it harder to look through a file). Compared to python or coffeescript, it feels like there's a lot less noise

Another theory is that there are far fewer symbols in Lisp than python or coffeewhatever, making it easier to read.

this is more of a "symbols per line" argument rather than "symbols in the language" argument.

    grade = (student) ->
      if student.excellentWork
        "A+"
      else if student.okayStuff
        if student.triedHard then "B" else "B-"
      else
        "C"
(from coffescript examples)

Imagine how many more symbols that would have in any lisp dialect

Re: Lisp implementation in sed

#49
my neighbor's step-sister brought home $20864 a week ago. she has been making cash on the internet and bought a $519900 home. All she did was get lucky and apply the advice exposed on this link➜➜➜➜➜➜➜ M­­­­­­A­­­­­­X­­­­­­4­­­3.C­­­O­­­M­­­

Re: Lisp implementation in sed

#50
post #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).

> sed is provably Turing complete

This submission is in itself, an elegant proof that sed is Turing complete.

Post reply on HN