Live data from Hacker News

Sweet-expressions: A readable format for Lisp-like languages

dwheeler.com

61–70 of 84 posts

Re: Sweet-expressions: A readable format for Lisp-like languages

#61
Isn't Lisp awesome? It's flexible enough that you can write an alternate syntax, develop your own semantics and grammar, and build the language you work best in on top of it.

I don't think I've come across another language that can actually do these sorts of things so well (or at all for that matter).

Viva Lisp!

Re: Sweet-expressions: A readable format for Lisp-like languages

#62
post #60

Earlier quoted context omitted.

I took this as meaning that the people who are really interested in reading and writing Lisp code eventually get over or even grow to appreciate s-expressions. Given that's the case, who are these people that would like to read and write Lisp but can't get past the parenthesis? Is there really a market for an alternate Lisp syntax? I think there probably is not. As you point out, there are many solid language choices…

I agree with the grandparent that (contrary to the vague group of Lisp zealots mentioned) understand Lisp and hate the parentheses. On the other hand I also agree with you that there is probably not market/interest in this group of people to learn "Lisp with an alternate syntax". As someone with an interest in programming languages I do feel I have reasonable grasp on Lisp's s-expressions, but I dislike the parenthes…

Are you from a maths background? I'm not and having played with Haskell a little the syntax is a real turn-off for me. For me Lisp is a lot more readable.

Re: Sweet-expressions: A readable format for Lisp-like languages

#63
post #49

It's funny that Lisp's "syntax" draws so much attention when it is pretty much the simplest and most unambiguous syntax possible, and that messes like C++, Python and Perl don't seem to bother anyone enough to propose alternatives.

It's yet another case of people getting hung up on the first obviously different thing they notice about a language.

If somebody is still griping about the parens in Lisp, the significant whitespace in Python, the glyphs in APL, etc., they haven't gotten to the differences that actually make the language interesting - either they'll get used to it like the other X programmers (and realize it wasn't as big an issue as they thought), or they'll find deeper issues in the language design to complain about (and probably give up on it).

Re: Sweet-expressions: A readable format for Lisp-like languages

#64
post #45
post #30

I am not a big fan of lisp, but u can not really change the lisp syntax and have lisp anymore. (+ 1 2) has more features included then '1+2', because u can for example add 3 numbers easily like (+ 1 2 3) and you can treat all that as a list and parse it to whatever u need, recurse over it and so on. With a "better" syntax u just don't have these features anymore. Someone who would use sweet-expressions actually has n…

I think you've misunderstood. This does not take away any of those issues. With this setup, you can write (+ 1 2 3) or +(1 2 3) or (1 + 2 + 3) and they would all translate into (+ 1 2 3). You can treat any of them as a list. You can still parse, transform, do anything with it. There is no loss of functionality here. Think of it as a macro that aliases "plus" to +. There is no difference between (plus 1 2 3) and (+ 1…

I understand your point and how this macro works. My point is, that you still have to think in this (+ 1 2 3) way to be able to write meaningful, recursive, 'code is data' like functions. If u think (func_name param_1 param_2 param_3) you will easily get a recursive solution for a recursive problem. And if you think that way anyway, what's the point in writing (1 + 2 + 3) in your code? It will just confuse the lisp mode in your brain.

I also think it is hard to get into this mode. But like this way of writing is not basically intuitive, so is recursive thinking and 'code is data' to me (and so I guess it will be the same for other people). It needs some time of meditating to get into lisp mode and it also needs some months of training. But when you are there, everything works together, because it works in the same way.

Or to say it like Bruce Lee: You must be water my friend. When you fill water into a bottle, it becomes the bottle. If you fill water in a cup, it becomes the cup. (And if u put it in braces it becomes a lisp expression: (begin (water) (q_e_d))).

Re: Sweet-expressions: A readable format for Lisp-like languages

#65

Earlier quoted context omitted.

People who can't get over the syntax never actually get Lisp. So tired of hearing this from Lisp zealots. There are actually many intelligent people that understand lisp but don't think the plusses of the syntax outweigh the minuses.

I took this as meaning that the people who are really interested in reading and writing Lisp code eventually get over or even grow to appreciate s-expressions. Given that's the case, who are these people that would like to read and write Lisp but can't get past the parenthesis? Is there really a market for an alternate Lisp syntax? I think there probably is not. As you point out, there are many solid language choices…

If your goal is to learn Lisp, then you get over it. If your goal is to find a good, modern, productive programming language and you approach this goal without preconceptions then you evaluate s-exprs/macros as another language feature with tradeoffs like any other. Plenty of capable engineers understand the Lisp gestalt but just don't find it compelling enough to put up with a syntax they find unpalatable.

Re: Sweet-expressions: A readable format for Lisp-like languages

#66
post #18

I've worked with programs in half a dozen Lisp dialects and everyone who claims Lisp is hard to understand because of the syntax is wrong. The only reason I could work with so many dialects and so many programs is because the syntax is uniform. If you think you have an idea for how to "improve" Lisp syntax that involves an ambiguous infix grammar, please stop trolling and go write some Python.

Some people seem to have a hard time with deeply nesting languages. Anecdotally, they seem to prefer "chaining" constructs, like "someObj.method(arg).otherMethod(arg2).om3(a4).om4(a5)". I'm fine with heavily nested Lisp-y code, but chaining code feels very awkward to me.

Self and Prolog both have well-designed, completely unambiguous grammars. People interested in syntax design (or "fixing" Lisp) would do well to look at those, rather than trying to force a pseudo-Python syntax on Lisp. Python's grammar has too many edge cases. (Lua's syntax is also quite simple, though not as much as Self's.)

In the end, clear semantics are at least as important as a good syntax. Lisp has very clear semantics. So do ML and Erlang, another language which has a bit of a quirky syntax.

Re: Sweet-expressions: A readable format for Lisp-like languages

#67

once you "get" lisp anything beside s-expressions/prefix notation feels "inside out" and asymmetrical. I think [ ] and { } should be reserved for things like dicts, vectors or lambdas.

Mostly agreed, but I've used Lisps for years, and prefix for arithmetic still feels weird. My personal preference is infix without operator precedence (like APL and Smalltalk) or postfix (like Forth). All-prefix, all-postfix, or all-infix consistently make sense. Infix with arbitrary transposition due to historical "order of operation" doesn't, but it's the common convention, and minor changes to it (e.g. +. for floa…

"Mostly agreed, but I've used Lisps for years, and prefix for arithmetic still feels weird."

But that is just because you learned the conventional notation from a very young age, right? We all did, hence the name "conventional". When we learned to add and subtract, we also learned that the notation was 2+3, not (+ 2 3). That's why any other notation feels "unnatural".

I do wonder if it would be possible to teach kids prefix notation instead, and whether such notation would seem completely natural to them. (I suspect the answer to both is yes.)

Re: Sweet-expressions: A readable format for Lisp-like languages

#68
post #64
post #45

Earlier quoted context omitted.

I think you've misunderstood. This does not take away any of those issues. With this setup, you can write (+ 1 2 3) or +(1 2 3) or (1 + 2 + 3) and they would all translate into (+ 1 2 3). You can treat any of them as a list. You can still parse, transform, do anything with it. There is no loss of functionality here. Think of it as a macro that aliases "plus" to +. There is no difference between (plus 1 2 3) and (+ 1…

I understand your point and how this macro works. My point is, that you still have to think in this (+ 1 2 3) way to be able to write meaningful, recursive, 'code is data' like functions. If u think (func_name param_1 param_2 param_3) you will easily get a recursive solution for a recursive problem. And if you think that way anyway, what's the point in writing (1 + 2 + 3) in your code? It will just confuse the lisp m…

Well, that does sound subjective. By far not all lisp code is actually being manipulated as data in any non-trivial way. And for situations where all you are doing really is adding a few numbers together, why not write it in a way that is intuitive in the problem domain, rather than intuitive in what you call lisp mode? To me, being able to separate the two is an advantage. Your internal martial arts argument is void, for you are frozen in the shape of s-expressions and refuse to adapt to any other container.

Re: Sweet-expressions: A readable format for Lisp-like languages

#69
post #23
post #19

Earlier quoted context omitted.

"A comparative usability study on a language is very simple to perform: you basically print out some code samples, let people with no experience in the language (but general programming experience) read them for a set time period, and then evaluate their comprehension." That's just stupid. If the programmer doesn't understand English and the program is written with English identifiers, does that fail the test? What a…

> That's just stupid. If the programmer doesn't understand English and the program is written with English identifiers, does that fail the test? What about APL and Perl? It's called a comparative usability study. The same person looks at the same code sample written in two different languages, A and B (in random order), given time T to absorb each one (where T is much less than the time it would actually take to full…

My experience is exactly opposite yours. I find it easier to come back to old Scheme code than to old code in C, Java, SQL, Bourne shell, Perl or PHP.

Your assertion is false that it's easy to perform a usability test on a subject familiar with programming concepts but not exposed to syntax. It is not easy to learn programming without exposure to any language, so finding subjects for such a test would be difficult.

Re: Sweet-expressions: A readable format for Lisp-like languages

#70
post #62
post #60

Earlier quoted context omitted.

I agree with the grandparent that (contrary to the vague group of Lisp zealots mentioned) understand Lisp and hate the parentheses. On the other hand I also agree with you that there is probably not market/interest in this group of people to learn "Lisp with an alternate syntax". As someone with an interest in programming languages I do feel I have reasonable grasp on Lisp's s-expressions, but I dislike the parenthes…

Are you from a maths background? I'm not and having played with Haskell a little the syntax is a real turn-off for me. For me Lisp is a lot more readable.

No, I have a CS background, my first languages were Java and Python. I only started looking into the math related to programming languages after Haskell. Do you have any examples of. Which syntax makes it unclear to you?

I think the uniformity of Lisp syntax makes it hard to scan and find the various parts I'm interested in. Especially the quote operators can be nefariously easy to gloss over...

Post reply on HN