7 ms·
When I tried to introduce s-expressions to a DSL my co-workers nearly lynched me. The parenthesis were so violently hated I sunk into a deep hole and still have
by sirsuki 3y ago
When I tried to introduce s-expressions to a DSL my co-workers nearly lynched me. The parenthesis were so violently hated I sunk into a deep hole and still haven’t came back out of it.
- capableweb 3y agoIt is really fun (sad) to see this, I've seen it so many times myself too. You show how something would be with s-expressions, compared to something, and all they can focus on is how many parenthesis there are. But when you sit down and count, they're the same amount as the code was when it wasn't s-expressions, just in different locations. And when you remove the parenthesis, they can kind of understand the code, kind of.
- fwip 3y agoOne option that might be suitable for a DSL, is implicit parens based on whitespace. A newline opens a new paren, and the paren closes when it reaches another line with the same indentation e.g: (defun factorial (x) (if (zerop x) 1 (* x (factorial (- x 1))))) could be rewritten as defun factorial (x) if (zerop x) 1 * x (factorial (- x 1))
- alwaysbeconsing 3y agoWhitespace significance might be the choice even more controversial than Lisp parens. For myself, I appreciate both, but those that do not, really do not.
- capableweb 3y agoProbably there are more Python users out there than combined users of all lisp-like languages, which I guess would mean people are less scared of white-space significance than s-expressions :)
- nsajko 3y agoExisting SRFI: SRFI 49 "Indentation-sensitive syntax": https://srfi.schemers.org/srfi-49/srfi-49.html https://srfi.schemers.org/srfi-49/srfi-49.html
- fwip 3y agoThanks, I knew that there must be prior art out there. :)
- Syzygies 3y agoI doubt that SRFI 49, or any other proposal I've seen online, has been battle-tested. I've written thousands of lines of Scheme using my own preprocessor, and it's my favorite code to look at. I prefer Haskell, for incredible ease of parallelism and a deeper mathematical foundation. The two features I look for in a reduced parenthesis syntax (like looking for the bone marrow in a beef stew recipe) are: 1. Some constructions begin doubly parenthesized. One needs a symbol to represent the missing object one parenthesis in. I use $. 2. One can write more expressive lines with a flavor of open paren that autocloses at the end of the line. I use |.
- mtlmtlmtlmtl 3y agoIt really is kind of frustrating isn't it? Because anyone who's put any real effort into learning Lisp knows that the parentheses are not what's hard to understand, actually. You don't even have to read them, really. So when people complain loudly about parentheses in Lisp that just tells me they probably never made any real effort to learn it, and are actively opposed to trying. It's not a productive starting point for a discussion.
- alex_lav 3y agoCounterpoint: why are people under any obligation to try?
- mtlmtlmtlmtl 3y agoThey're not. But they're also not required to flaunt their own ignorance as though it's a well-formed opinion. Also, in a professional setting, I find it a bit unprofessional and rude to poo poo technical ideas over trivialities.
- alex_lav 3y ago> But they're also not required to flaunt their own ignorance as though it's a well-formed opinion. I don’t like the parenthesis. I’m not flaunting anything. Is it “flaunting” to calmly and respectfully share an opinion? To you it’s trivial, to me it’s not. It seems like you’re interested in creating conflict with people that don’t like a thing that you like. Which, I would cast this behavior as unprofessional, tbh.
- dang_flame 3y ago[dead]
- dun44 3y agoImagine someone who hates the exponentiation operator but wants to do mathematics nevertheless. For a living.
- deleted 3y ago[deleted]
- brundolf 3y agoI did it once in an internal UI because we needed to rapidly expose some functionality that could be composed/piped in complex ways and it would take a while to implement a normal UI Was met with skepticism, esp around the engineering/maintenance overhead, until I told them the parser took me a couple hours to write and was only a hundred lines of code or so
- e12e 3y agoMaybe: https://srfi.schemers.org/srfi-49/srfi-49.html https://srfi.schemers.org/srfi-49/srfi-49.html https://www.draketo.de/software/wisp https://www.draketo.de/software/wisp
- e12e 3y agoActually, there's a srfi for wisp: https://srfi.schemers.org/srfi-119/srfi-119.html https://srfi.schemers.org/srfi-119/srfi-119.html
- darthrupert 3y agoThe things I'm looking for in language syntax these days are 1. That it's unambiguous enough that my editor can format it correctly every time (provided the code is correct, obviously). Indentation-based languages like Python fail this. 2. That its elements and keywords are distinct enough that my editor can apply colours on it. I sometimes feel that S-expression languages fail at this because of their small number of distinct keywords, but that might not be true. Besides these two points, if the language is not a joke language, it's probably fine.
- xigoi 3y agoWhat is ambiguous about Python’s syntax?
- lostdog 3y agoif a: print("foo") if b: print("bar") Or wait, maybe the copy paste didn't work exactly right and "if b" was supposed to be inside "if a"
- xigoi 3y agoThat’s a problem with your editor, not with Python.
- darthrupert 3y agoBut it's what ambiguous about Python's syntax. And I can make it a bit worse: if a: print("foo") if b: print("bar") This is not a huge problem, but problems with syntax never are (in non-joke relatively modern languages). But it's still something I prefer that languages fix in their syntax if I get to have a choice.
- xigoi 3y agoThe example you just posted is a syntax error, as it should be. And I still don’t get what is ambiguous about the syntax, the specification clearly states how indentation corresponds to a syntax tree.