Live data from Hacker News

The Idea of Lisp

dev.to

111–120 of 348 posts

Re: The Idea of Lisp

#111
post #6

Does anybody have a few examples of DSLs people make in a lisp (ideally clojure because I have worked with it a tad)? I've seen plenty of cases where people make a pseudo-dsl via optional arguments, but not seen this so-oft mentioned "yeah we just wrote a dsl for it because lisp" sort of deal.

The TXR Lisp dialect provides an awk macro that implements a language closely resembling Awk in its structure and semantics.

For example, write the third field of every record (if the field exists) into `file.{recnum}`:

  (awk ([f 2] (-> `file.@nr` (prn [f 2]))))
The manual contains a translation of all of the Awk examples from the POSIX standard:

http://www.nongnu.org/txr/txr-manpage.html#N-03D16283

The (-> name form ...) syntax above is scoped to the surrounding awk macro. Like in Awk, the redirection is identified by string. If multiple such expressions appear with the same name, they denote the same stream (within the lexical scope of the awk macro instance to which they belong). These are implicitly kept in a hash table. When the macro terminates (normally or via non-local jump like an exception), these streams are all closed.

Re: The Idea of Lisp

#112
post #94
post #33

Earlier quoted context omitted.

Yes, I worked on a startup that did pretty much something like Ruby on Rails, but with TCL, inspired by AOLServer. The speed critical parts were written in C and loaded as TCL extensions. Back in the first .com wave. It also taught me to never again use a programming language without JIT/AOT compiler on their standard toolchain for heavy loads.

Hmm, was that the one headed by Phil Greenspun? Arsdigita or something like that...? Back in the day, aolserver w/ TCL + (open)acs + pgsql/oracle was teh awesomeness compared to LAMP that everyone else was doing. Oh well... :(

No, in Portugal.

We were eventually acquired by a company doing helpdesk and CRM software.

Re: The Idea of Lisp

#113
post #91
post #33

Earlier quoted context omitted.

Yes, I worked on a startup that did pretty much something like Ruby on Rails, but with TCL, inspired by AOLServer. The speed critical parts were written in C and loaded as TCL extensions. Back in the first .com wave. It also taught me to never again use a programming language without JIT/AOT compiler on their standard toolchain for heavy loads.

Interesting. There was this company called Vignette (in the same period). They too were doing .com projects for clients, and, IIRC, using AOLServer which I read was in Tcl. Tcl was used for the projects.

Yep, some of our guys went to work for them in projects across the Iberian Penisula.

Re: The Idea of Lisp

#114

I wonder why lisp isn't as popular as say python for AI, ML, and stuff. I see these fields as having a strong academic tone, and it feels like racket or clojure could be bigger when it comes to that.

Before compute resources became essentially free, Lisp took up rather more memory on the then-constrained commodity hardware than other languages. I remember being in awe of one of our developers who had a whopping 96MB on his machine - this was in the mid 1990s.

[deleted]

Re: The Idea of Lisp

#115
post #25

Earlier quoted context omitted.

If you like everything being an expression, check out tcl. A lot of ideas from lisp show up in tcl, especially the idea of everything as an expression. Tcl embodies this idea while also having the look of an algol-like language. Funny it can pull this off while having basically no syntax.

Correct me if I'm wrong but doesn't Ruby have everything (maybe just most?) things be an expression. I always liked x = if condition something else something_else end

Everything is an expression in Ruby, yes. Even `class` and `def` and `module`, for example. Though class, as a specific example, returns nil, so it's not terribly useful that it is one.

Re: The Idea of Lisp

#116
post #101
post #89

Earlier quoted context omitted.

>The other important one is that Tcl has no types. Is it that it has no types or that everything is a string? asking, not stating.

Yes, everything is a string. But you can pass data around anywhere you like without worrying about coercing. A command will receive its data in string representation and treat it however it likes. So when you go to do math with the 'expr' command, 'expr' will treat its arguments as numbers. set x 5 expr { $x + 3 } 'expr' receives x as the string 5 but knows to treat it as an int. I'm not sure that's a great explanati…

Thanks. Yes, I get it. I had read part of the Ousterhout book. And also Don Libes' Expect book uses Tcl, since Expect is written in it. Had read a lot of that too. Both very good ones. Didn't get to use Tcl in projects though. I'd read some years ago that Tcl was used heavily in the electronics / EDA industry.

Re: The Idea of Lisp

#117
post #92
post #57

Earlier quoted context omitted.

Common Lisp, Racket, and Clojure all have optional static typing.

They have gradual typing but I believe they're still enforced as runtime contracts, making them not static types.

Technically, the Common Lisp standard leaves it up to the implementation what to do with type declarations--in practice, I get compile time warnings for violating them (as well as for violating inferred types). Type declarations will not lead to runtime checks, you need to use CHECK-TYPE or similar for that.

Typed Racket is more extensive and gives errors at compile time. I don't know very much about how it works in Clojure.

Re: The Idea of Lisp

#118
post #20

Earlier quoted context omitted.

The "base rate" popularity of Python is much higher than all those others. This leads (via many mechanisms) to Python being more popular than these others. (The reason it's Python and not another popular language is another matter - I think for various reasons Python was a more popular language for scientific computing).

Could you explain what you mean by the "base rate" popularity?

I'm not the parent poster, but I'm pretty sure they're saying that because Python is more popular in general (the base rate) it's more popular in AI/ML/whatever circles because of better general support (more tutorials, more libraries, more people already know it before trying to use it for a specific problem).

Re: The Idea of Lisp

#119
It's interesting, I'm reading Black Swan at the moment by Nassim Taleb, and one of his big rants is about how we get blinded by idealized, platonic forms and ideas when the real world is messy and inherently unpredictable. E.g. trying to explain the forms of nature with platonic archetypal shapes like circles, rectangles and triangles. Lisp and the community around it kinda has that flavor - getting lost in a world of "pure forms" and grand ideas, but downplaying the important but messy practical reality of hardware, useful libraries, and getting cool stuff done with a minimum of fuss. I'm periodically fascinated by Lisp (I wrote an interpreter or two in C) but I wonder if its "Platonicity" is part of its downfall.

Re: The Idea of Lisp

#120
post #14

Earlier quoted context omitted.

In Rust, if-else is an expression, and there's no separate ternary operator.

My current project is over 90,000 lines of C and I have programmed in C since the 1970's (as well as many other languages). I have never used a ternary operator and I think it reads quite poorly. I just use a few lines of easily read code instead. I also never use a do/while construction with the condition at the bottom of the loop. When I need such a construct I just put in an "if" and "break" where ever needed inst…

I don't program in C but I use the ternary operator quite regularly. It's quite handy when you're populating large data structures. For limited use in that case I don't find the readability that diminished maybe even enhanced.
Post reply on HN