Live data from Hacker News

An Intuition for Lisp Syntax

stopa.io

41–50 of 201 posts

Re: An Intuition for Lisp Syntax

#41
post #37
post #16

So what does Lisp make harder to implement than today's programming languages? It seems like large-scale composition relies on a well-structured way to define and enforce APIs, and oh wow, typing facilities. Performance has historically been an issue for Lisp because its model is tightly tied to interpretation, but perhaps modern JIT-style compilation can address this. Others? What type of issues do large Lisp projec…

> a well-structured way to define and enforce APIs I don't see the issue here? What do you think is stopping you from doing this in, for example, Common Lisp? > and oh wow, typing facilities Common Lisp isn't typed, but there's no reason a Lisp dialect can't be. In fact, Typed Racket is just such a language.

Hell, to go even further you can implement your own type system on top of Racket's macro system; or better yet, use a macro DSL specifically created for type systems to implement your type system. [1]

[1] https://docs.racket-lang.org/turnstile/

Re: An Intuition for Lisp Syntax

#42
(shameless plug)

In Feb 2020, during the first Clojure meetup organized in Chennai, I gave a talk titled "I'm LisP, I'm inevitable" in which I spoke about the journey towards lisp/scheme in muvee's flagship automatic video editing product.

http://sriku.org/posts/inevitable-lisp/

It may be helpful to some to understand the recurrent pattern here so they can detect it early when it happens to them.

Re: An Intuition for Lisp Syntax

#43

This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . Unfortunately the standard js…

> This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing.

The classical one is "The Nature of Lisp"[0], which introduces data-as-code through XML and Java build tools. Same idea, just with examples more relevant at the time of writing. Still worth a read for non-webdev programmers.

Having learned Lisp, it's half funny, half disheartening to watch the industry repeatedly tries to rediscover "code as data", as people's configuration or data files in markup language du jour grow in complexity and eventually start directly encoding executable code... and then stop shy of embracing the code/data duality.

--

[0] - https://www.defmacro.org/ramblings/lisp.html

Re: An Intuition for Lisp Syntax

#44

This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . Unfortunately the standard js…

> I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D .

So many people start out thinking like this when they learn Clojure or some other Lisp and then after like 2-4 weeks of reading Lisp code, any C-like code starts to look comparatively irregular and Lisp feels much easier to read.

Re: An Intuition for Lisp Syntax

#45

This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . Unfortunately the standard js…

> This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. The classical one is "The Nature of Lisp"[0], which introduces data-as-code through XML and Java build tools. Same idea, just with examples more relevant at the time of writing. Still worth a read for non-webdev programmers. Having learned Lisp, it's half funny, half dishea…

Greenspun's tenth rule [0]:

"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."

Also:

> Hacker Robert Morris later declared a corollary, which clarifies the set of "sufficiently complicated" programs to which the rule applies "...including Common Lisp."

[0] - https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

Re: An Intuition for Lisp Syntax

#46
post #10

I've never really bothered to learn lisp, but this is incredible. I get it now. That being said, I wonder how data types would work as opposed to lists. What would a language based around maps look like?

It would look like Lua: https://www.lua.org

They call "maps" tables. Even arrays in Lua are tables, as are everything else.

Pretty cool concept... And there's even a low level, statically typed, system language that uses Lua as a composer language, Terra: http://terralang.org

In Terra, you manipulate your program using Lua at compile time. Really cool concept.

Re: An Intuition for Lisp Syntax

#47

This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . Unfortunately the standard js…

> This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. The classical one is "The Nature of Lisp"[0], which introduces data-as-code through XML and Java build tools. Same idea, just with examples more relevant at the time of writing. Still worth a read for non-webdev programmers. Having learned Lisp, it's half funny, half dishea…

If you take anything away from that: brackets are the most compact way to serialize a tree, for some reason they are called s-expressions. The parse tree for lisp is the syntax tree, you just rename each bracket node to whatever the first atom in the bracket happens to be.

One thing that XML could have done that s-expressions can't is a way to serialize a dag if proper nesting of tags wasn't required. I'm playing around with a language based on that, the mental load of having no clear way to delineate blocks visually makes it hard to reason about, unfortunately.

Re: An Intuition for Lisp Syntax

#48
post #10

I've never really bothered to learn lisp, but this is incredible. I get it now. That being said, I wonder how data types would work as opposed to lists. What would a language based around maps look like?

First of all, a map can be defined as a list where the even elts are labels and the odd ones are values. So it would be a lot like lisp but every elt in every list would have an extra before it, a short string name.

It's the other way around, actually. If you define a map as a list, it will have none of the properties of a map: you can't lookup a key in constant time.

But if you start with maps, then you can represent a list as a special case of a map in which the keys are integers that get incremented, starting at 0.

Re: An Intuition for Lisp Syntax

#49

This is maybe the best introductions to Lisp i have seen, especially for a js dev like me it could hardly get more approachable and convincing. I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . Unfortunately the standard js…

> I could not help but thinking at the end, this is really awesome but s-expressions are kind of hard to read and reason about for my brain, it would be cool if we could generate them from more readable syntax, maybe something like javascript :D . So many people start out thinking like this when they learn Clojure or some other Lisp and then after like 2-4 weeks of reading Lisp code, any C-like code starts to look co…

I heard that before but i wonder how much is survivorship bias :D it reads just so awkward to me as a programming language, even though i 100% dig the beauty and everything that it allows.

Re: An Intuition for Lisp Syntax

#50
post #20
post #8

Earlier quoted context omitted.

The formal Scheme syntax spec is, what?, a few pages. Far smaller than any other "real" language I'm aware.

I'm not too familiar with scheme, but syntax seems to be at least a few dozen pages here? www.r6rs.org/final/r6rs.pdf Also compare https://people.csail.mit.edu/jaffer/r5rs_9.html and e.g. https://docs.python.org/3/reference/grammar.html which I would consider a relatively syntactically rich language.

What I see is that the Scheme one is a lot more thorough and still shorter.
Post reply on HN