4 ms·
This is what drove me away from lisp. If everyone says you have to use a plugin to auto-insert parentheses, that means computers know where they go. So why are
by Swizec 7y ago
This is what drove me away from lisp.
If everyone says you have to use a plugin to auto-insert parentheses, that means computers know where they go. So why are we writing them??
- azhenley 7y agoTry Forth :)
- wtetzner 7y agoThe computer only knows where they go because the rest of the code already has the parens. Having the parens has advantages, like everything being explicitly delimited, which makes it really unlikely that you'll insert some code that you thought was part of a block, but really wasn't (think one-armed if without braces in C-like languages). It also makes it easy to have your editor help you navigate your code. Being able to jump around expressions conveniently can really speed things up.
- Skunkleton 7y agoThe computer doesn’t know. It just knows that brackets need to go somewhere and makes it easier to edit them as a pair.
- mschaef 7y agoThey make the extent of syntactic expressions more obvious to both people and tools.
- capableweb 7y agoBecause they are not perfect and you need control of where they go. They don't always get it right and you might have to correct them. At least none of the solutions I've found been 100% perfect. So I much rather have the computer do as much as it can, then I correct if it gets it wrong. Collaboration with the machine is better in this case.
- tpfour 7y agoNot everyone uses plugins. I don't have autocomplete but my parens flash when they're paired. I like it. You write the parentheses because they have meaning. I can understand your frustration but I don't think you gave lisp a fair chance if you are asking "why parens". > '(this is a list) > this is a list These don't have the same meaning. The computer can't know what meaning you want to give to the code beforehand.
- lukifer 7y agoI've never spent any serious time with Clojure/Lisp, and the nested parens have been a pretty major impediment. I'm curious if anyone's ever experimented with dialects that replace brackets with significant whitespace (newline+tabs), similar Python? I could also see a drag-and-drop coding GUI being pretty powerful. I'm sure once one spends enough time with it, one starts to think in Lisp, and the desire to solve the "problem" disappears. :)
- vnorilo 7y agoIndeed. I came from C++, but I quite like homoiconic syntax by now. There have been alternative syntaxes [1] but their lack of popularity seems to align with your hypothesis. 1: https://dwheeler.com/readable/ https://dwheeler.com/readable/
- zdragnar 7y agoSignificant whitespace typically denotes blocks of statements or expressions. How do you use whitespace to represent a data structure? After all, the whole point is that literally everything, code included, is a list. (Edit: if all you want is homoiconicity, grab prolog, rebol or julia) There are plenty of non-paren functional and OO languages (f#, haskell, python, java) to replace functional and OO lisps depending on the itch you want to scratch. JavaScript has babel / babylon to generate a full AST to rewrite source code, though you need to either fork babylon or use sweet.js if you want your own macros.
- lvass 7y ago>How do you use whitespace to represent a data structure? SRFI-49[0] describes I-expressions, which can be mixed with S-expressions. I've tried it while learning Scheme, because parens didn't look good at first. My experience was that parens are an issue only until you get used to them, afterwards they're a boon. [0] https://srfi.schemers.org/srfi-49/srfi-49.html https://srfi.schemers.org/srfi-49/srfi-49.html
- tpfour 7y agoYou never spent much time with it and the parens are a major impediment? If you cannot overcome the "parens" (non) issue, I suppose the language is not for you. It really is not an issue, _at all_. I don't say this to be demeaning! I would say there are far more chances you really enjoy the language than not. Give it a try and stop worrying about the parenthesis and start thinking in terms of an AST. (let ((x 0)) (+ x 1)) If you want Python that's fine but there is definitely no problem with parens in Lisp/Scheme :)
- ken 7y agoLisp doesn't have more grouping characters than other languages. The primary difference is that it consistently uses prefix notation, so the cursor always immediately goes inside the parens, rather than needing to type one part of an expression (the function name) outside of it first. That's what modes like paredit help with. Programmers in languages like Ruby (optional parens for method calls) and Tcl (no parens for proc calls) might agree with you! Why does virtually every language require parens, when they're not needed? At least with Lisp, they serve a necessary purpose. Another one: almost every language uses commas to separate items in a list, including function arguments. In the vast majority of cases, the commas are useless. Lisp doesn't use commas to separate elements (though Clojure allows them if that's your druthers). Why can't I say f(x y) or [3 4 5] in, say, Python? There's nothing else it could possibly mean.