6 ms·
I'm still left with the question of "why all the parenthesis?" While it might sound silly and reductionist, it is ostensibly the single hurdle I could never ov
by graphememes 9y ago
I'm still left with the question of "why all the parenthesis?"
While it might sound silly and reductionist, it is ostensibly the single hurdle I could never overcome when it came to lisp languages. The majority resides with the fact that it could work without them, so I see it as an ancient artifact.
- bitwize 9y agoUse Emacs and optionally avail yourself of a structural editing mode like paredit. Then, at a minimum, the editor will help you match parens and you barely even have to think about them. Seriously, get over your Emacs hate (if you have any) because Emacs is to Lisp family languages what IntelliJ is to Java.
- graphememes 9y agoI don't hate emacs, I have however invested a lot more time and work into vim than emacs so that is why I do not use it.
- indigo0086 9y agoI use spacemacs. before I had to have a vim plugin in every ide. But seeing the incredible power of emacs and the ease of integrating vim with it (pretty much a "pick your style" at the beginning of spacemacs installation) I'll never go back.
- smnplk 9y agothe only reason i didn't like spacemacs was the 3 keystroke combos for everything that I do with 2 strokes in vim.
- throwaway7645 9y agoYea...I like the theory of emacs, but the reality of vim usage.
- flavio81 9y agoSLIME (for Emacs) is wonderful. I like Emacs, what i don't like is the key combinations, which are horrible. Fortunately, you can redefine them. Emacs can be customized at will, and using Lisp :)
- peterhadlaw 9y agoThe parentheses end up serving as a tool to speed up the development process with tool like paredit. You end up manipulating the "tree" of code vs the characters on a line. Check this out: https://www.youtube.com/watch?v=D6h5dFyyUX0 https://www.youtube.com/watch?v=D6h5dFyyUX0
- bryanlarsen 9y agoparedit doesn't require parentheses to do it's magic.
- bryanlarsen 9y agoThere seems to be a very nice solution to the parenthesis problem: https://sourceforge.net/p/readable/wiki/Home/ https://sourceforge.net/p/readable/wiki/Home/ I have no idea why it hasn't caught on. As far as I'm aware, there's no Clojure implementation. Lispers like their parentheses.
- protomyth 9y agoPerhaps because significant white space (e.g. Python) has quite a lot of detractors of its own.
- weaksauce 9y agoI absolutely cannot stand significant whitespace... it is a step back in almost every area of usability.
- throwaway7645 9y agoI love both Lisp & Python. I'm not sure about large projects, but to me, nothing is easier to read than Python and a lot of people agree. It is so strict and authoritarian that nearly everyone ends up writing similar code. Good for sharing scripts on my team. If I write Perl, only I can understand it...and even that is temporary lol (I joke, but you get the point).
- cutler 9y agoIf you love Lisp & Python try Hy (hylang.org).
- goatlover 9y agoIn your opinion. For you it's a step back. For some of us it's very easy to read and write.
- weaksauce 9y agoI don't really get this line of thought... are curly braces really that hard to read and get in the way of things to you?
- dangerbird2 9y agoParentheses exist because it is the easiest way to represent the raw AST in text form. S-Expressions were originally an intermediate form for a more algol-like syntax[0], but became the primary form of representing Lisp because allowing the programmer to manipulate the AST is extremely useful, arguably what makes Lisp Lisp. There are homoiconic languages like Prolog and Julia that have more familiar syntax styles, but S-Expression Lisps are unmatched in making homiconicity readily apparent. Another reason Lisp programmers tolerate parentheses hell is that Lisp development has often paralleled that of emacs and emacs-like editors that make manipulating s-expressions extremely intuitive. [0] https://en.wikipedia.org/wiki/M-expression https://en.wikipedia.org/wiki/M-expression
- dragandj 9y agoIt took me an afternoon to get used to the prefix notation (not to parentheses; those are used even in python), and after that afternoon I would refuse to program without it. Makes the code way more regular.
- coolmitch 9y agoI'll plug Parinfer as the best tool I've found for removing the pain of editing s-expressions. It's done wonders for my own workflow, and there's almost nothing to learn before you can use it effectively (compare to Paredit which requires you to know quite a few shortcuts before becoming productive) I almost never have to think about the parentheses while editing, any more than I would braces in a c-like language. It's really freeing. It's also fully integrated into Cursive so there isn't even a setup step if you're using that already. https://shaunlebron.github.io/parinfer/ https://shaunlebron.github.io/parinfer/
- ledgerdev 9y agoI feel most syntax themes are designed for syntax based languages and make the parenthesis far too dark/prominent and it's visually overwhelming. If you dial back the color of parenthesis and brackets to a lighter grey, the experience is almost like writing python with parinfer.
- flavio81 9y agoFor Lisp, parentheses are a big plus. They allow the following advantages: TL;DR: Once you start programming in Lisp for long enough, you end up loving and embracing the parentheses. 0. They allow for an extremely simple syntax, which in turn allows the source code to easily manipulate source code. No simple syntax, no really easy way to write macros. And macros are one of the most essential keys to Lisp's power. You can argue that, without extremely simple syntax, a Lisp language is not possible. 1. Syntax, being so simple, is extremely easy to learn. Yesterday i explained Lisp's syntax to a friend, in 3 minutes. 2. No need to care for special operator precedence rules. The precedence of operators is obvious by looking at the code. 3. IDEs, like SLIME, can easily traverse the code in many powerful ways. Due to this syntax, the IDEs can "understand" expressions and expressions within expressions. This means that the IDE can 'understand' any part of your code, not just big constructs like functions, methods or classes. 4. IDEs will also easily complete the parentheses for you, and will warn you of a missing parenthesis. 5. It is also dead simple to understand which parenthesis closes which one. It can be done with most source code editors -- Even a simple program like Notepad++ can do it, Visual Studio Code can do it, etc. 6. Parentheses also enable IDEs to automatically apply "pretty" format to the code rather easily. 7. As anything, you get used to it. Many people, for example, think that, in Python, whitespace as a block delimiter is a bad idea, however I never had any problem with that, it was just fine. Unless you are using Windows Notepad to edit code...
- graphememes 9y agoThis is more an emotional response to me than it is functional or logical one since you can apply all of these points to any other language.
- iLemming 9y agoIt's not emotional, no. After just a few months of using Lisps it feels like parentheses bring some structure and order. In non-lispy languages things feel "all over the places" - there you do have to deal with punctuation - not just parens but: semicolons, dots, commas, brackets, curlies, indentation. Programming in a Lisp is like writing a prose. Your brain is occupied with ideas, you just need to type them down. You don't need to think about structure (until later), it's a flow - you're looking for right words (functions), you can immediately try them out in the REPL, pretty much like a writer would review usage of a word in a thesaurus or a dictionary. But to be fair I met a few people who claimed that even after months of using a Lisp, they just couldn't get the parentheses. I dunno, guess some people's brains maybe just not suited. You can call it dyslisplexia or whatever.
- falcolas 9y agoContrast, for a moment: var x = fib(a, b); with (let x (fib a b)) And count the delimiting symbols. I count 5 in the first example. In the second, I see 4. Let's try something a bit harder. function(a, b) { return a * b; }(6, 4); vs. ((fn (a b) (* a b) ) 6 4) 10 first, 8 second. Yes, "why all the [symbols]" indeed.
- deleted 9y ago[deleted]
- bshimmin 9y agoFor your second example, your JavaScript is wrong. Let's compare the ES2015 JavaScript: ((a, b) => a * b)(6, 4); ...against the Clojure: ((fn [a b] (* a b)) 6 4) Not a lot in it, really, is there?
- lilactown 9y agoIf we're golfing... (#(* %1 %2) 6 4)
- smnplk 9y agoAnd a bit shorter version... 24 ;)
- mrkgnao 9y agoI wonder, does #(* %1) do anything sensible?
- kbp 9y ago> I wonder, does #(* %1) do anything sensible? It's a 1-argument function, so applying it to 2 arguments would give an error. Minus the arity error, 1-argument * is an identity.
- latte 9y agoClojure's * can accept any number of arguments, including zero (returns 1 in this case), one (acts as identity function on numbers) or more than two (returns the product of all arguments). This helps to simplify arithmetic expressions in some cases (e. g. polynominals) and allows to calculate a sum or product of any sequence, including empty one, using (reduce * xs)