8 ms·
I have considered multiple times switching from Python to other alternatives. However, I instantly discard any language with a Lisp-like syntax. I just cannot w
by snrji 8y ago
I have considered multiple times switching from Python to other alternatives. However, I instantly discard any language with a Lisp-like syntax. I just cannot work with it. Being a Haskell hobbyist, I would like Python to be statically type and have better support for pure functional programming, but Python has the libraries that I need.
- omginternets 8y ago> I just cannot work with it. Can't or won't? I'm not being facetious, here. I just can't imagine any reason one _couldn't_ work with it, once the syntax is learnt. There's nothing about lisp-like syntax that's inherently hard to learn. Why is lisp special?
- blunte 8y agoNot only is it not inherently hard to learn, it's arguably one of the easiest syntaxes to learn. ( fn-name param1 param2 ... ) is the syntax. Once the brain grasps this, a whole layer of complexity just vanishes. Furthermore, not having to use punctuation between items is just heavenly. There's so much less noise compared to Python, and Python isn't even a particularly noisy language.
- istjohn 8y agoOnly if you don't consider a forest of parens to be noise. I do. I'm sure I could get used to it after a while, but at first glance, Python code is definitely cleaner than Lisp.
- F-0X 8y agoIt's not a "forest of parens" any more than any language with C style syntax is, they're just in different places (the correct places) and there's no need to distinguish with braces (which you shouldn't need to).
- holografix 8y agoThat’s not true. When you’re passing functions to functions inside functions that return functions... it’s a nested mess. I studied Lisp and Scheme at university and that’s where it had to remain for me: academically entertaining mind puzzles in data structures and algorithms. It’s just not productive or easily graspable from one coder to another.
- taeric 8y agoOnly if you insist on inlining all of the functions. Do yourself a favor and name a few of them. People that come after you will appreciate it, too.
- sooheon 8y agoTasteful macros can alleviate this, and Clojure's std lib has a few which are just delightful. The following does exactly what you'd expect, and there are even cooler ones like `some->` or `as->`. (->> some-nums (map square-root) (filter even?) set count) This is what lisp buys you, dead simple rules for syntax, with the option to add syntax with macros. If you made a mistake in syntax design, deprecate the lib and make a new macro, it need not be a feature of core language for all eternity.
- mschaef 8y agoAnd then you use a threading macro to assemble a middleware stack, only to find out that the middleware is applied in reverse order of what's listed as an inbound request comes in... (The outermost middleware being listed last in a threading form). There's a reason for it, for sure, but it's surely a part of the learning curve.
- sooheon 8y agoYep, it's always possible to have a mismatch in assumptions. That one definitely bit me as well. What's important is that the learning curve is not due to arbitrary rules, it's a faithful application of the logic of the macro. Remember that what is being passed through the threading macro is not the request, but the handler function itself. Each middleware takes the old handler, wraps itself over it to do things before and after the old handler. The threading macro is not a representation of the path your request will take, it is a way to build up a chained function that represents your final handler, which will then receive the request. Suddenly the ordering makes perfect sense :P
- nothrabannosir 8y agoYes, Python looks cleaner, Lisp thinks cleaner.
- michaelvmata 8y agoEditor tooling matters. Formatting, traversing, matching, and highlighting parenthesis made all the difference for me.
- freshm087 8y ago"Forest of parens" can be intimidating for sure, but if it's really a forest, then it usually means there's too much nesting. Which is a problem for any language/syntax. Overnested Python code is hard to grasp, and wide fields of whitespaces doesn't make it better than deep forests of parens/curlies, or mounting slabs of begin/end pairs.
- mschaef 8y agoMaybe. As someone with a Lisp background moving to Python (day job), all the semantics hidden behind whitespace makes me just a bit nervous. The parens, for me, make structural editing easier and also give a means of keeping the syntax around even when the whitespace gets damaged by whatever editing operations are happening. (But whitespace sensitivity has always struck me more as a way to enforce specific whitespace conventions than anything else, and even as far back as Pascal I've been religious about maintaining indention in code. It's easy to do with a decent editor (or not) and helps the readability immeasurably.)
- pletnes 8y agoPython can be statically typed with mypy and type annotations.
- dorkusmagnus 8y agoJust think of the parenthesis as loving warm homoiconic hugs.
- anon4242 8y agoHehe, when teaching my 8yr-old programming (in Python) I call (function call) parenthesis a hug to explain that a function "hugs" all arguments to it. She seems to get that :).
- rsyring 8y agoThis is a fantastic analogy, thank you for sharing! I found myself really struggling to communicate how a function's arguments got passed to it to my daughter and I'm going to try this the next time I need to explain it.
- VladimirGolovin 8y agoI'm teaching my 12-yr old daughter Python right now, and this looks like a neat analogy -- I'll try it in a few minutes.
- deleted 8y ago[deleted]
- moomin 8y agoI far prefer Haskell to Clojure myself but I will say: once you get half-decent at paredit, no syntax even comes close to Clojure’s. Indeed, if you really want fun, try Hackett: a Haskell variant implemented in and for Scheme.
- swlkr 8y agoYou could try parinfer, it effectively turns lisp (clojure) into a whitespace significant language like python. You still get the great “execute this block of code in the repl” with the parens too.
- smnplk 8y agoHey look it's the coast guy :)
- rhizome31 8y agoI haven't got much experience with Lisp, but I can imagine that, similarly to Python's significant indentation, it's a shallow weirdness that can be overcome easily after a little while. In both cases a little help from the editor will probably be needed.
- blunte 8y agoYou will shoot yourself in the foot less often with Lisp parens than you might with Python whitespace. Most modern editors handle the closing parens anyway. Plus, many editors without any plugins can jump between matching braces; so moving around the code is very quick compared to Python (unless you have a Python plugin that has block movement shortcuts).
- andybak 8y ago> You will shoot yourself in the foot less often with Lisp parens than you might with Python whitespace. I'm not letting that stand ;-) In my experience Python's whitespace generally removes sources of scope/block errors compared to parenthesis and curly-based languages > unless you have a Python plugin that has block movement shortcuts Not sure what this means. The only support I need in an editor is the ability to use tab and shift tab on blocks of text to change the indentation level. It's visually obvious when code is correctly indented.
- darkpuma 8y ago> "It's visually obvious when code is correctly indented. " Not when the beginning of the code block isn't on screen. And more to the earlier point, configuring your editor to jump to the beginning from the end or the end from the beginning of a particular block of code going to be trickier than the equivalent in even vim for lisp, which is simply % (And vim isn't even a particularly good editor for lisp, but out of the box unconfigured, it's better at lisp than it is at python.. % isn't even lisp specific functionality, lisp just happens to use balanced parenthesis which is something nearly every serious text editor happens to handle in a reasonably robust way, because balanced parens are generally useful in many languages, including python!)
- pmoriarty 8y ago"I instantly discard any language with a Lisp-like syntax. I just cannot work with it." I feel the opposite. I avoid any language without a Lisp-like syntax, since its absence is a serious handicap which unnecessarily complicates code and makes it less readable. I also much prefer the Lisp idiom of using meaningful function and variable names, vs the one-letter names and crypitic operators that are so common in Haskell, OCaml, and SML.
- endgame 8y agoBear in mind that often the reason Haskell code uses one-letter names (and this is possibly true for the other MLs) is that your types can be so generic that you can write useful functions without knowing what you're working on. In such situations, `x` is just as good as `thing`, as far as names are concerned. As for the operators: they are a visual language. We do not speak our punctuation aloud in English, and we use small marks to guide the reader's eye. Often, Haskell operators as similar, and there is a definite pattern. f $ x means "f applied to x" f <$> x means "map f over x" In general, the <> around an operator lifts it to work over a structure. Similarly: x & f means "f applied to x" x <&> f means "map f over x" For the applicative operators like <star>, star> and <star (where "star" should be an asterisk but I can never work out the formatting on this forum), the operators "point" at the values being retained. And so on.
- sooheon 8y agoIt's cool, and I wouldn't be sad to work with Haskell by any means, but I still think there's an elegance to lisp syntax that can't be beat. There are very few language level rules, everything is composable building blocks.
- tombert 8y agoI agree; once I beat the initial scariness of Lisp, I found it hard to go to any non-Lisp language. Macros, while easy to abuse, are kind of a game-changer; the ability to add new semantics to a language make it borderline impossible for me to go to any language that doesn't have a good macro system. I started with Clojure, which I still really enjoy, but due to how much I grew to love the `define-syntax` system in Chicken Scheme, that's become my latest weapon of choice.
- black-tea 8y agoTry, it's wonderful. The best. I write C and Python for a living.
- thom 8y agoI've programmed for 10 years in Clojure and have many regrets, but I've grown to just accept that Lisp syntax is correct. On day one you need to understand one thing. Years later, you need to understand one thing. And sure, in Clojure they happen to use three types of brackets for brevity but even that's optional. But other languages have dozens if not hundreds of little syntactical edge cases. I personally find that inconsistent mess repulsive.
- Scarbutt 8y agoWhat are those regrets? ;)
- thom 8y agoOh, so many things. The parallelism isn't actually that powerful, and in 2019 there's very little to set it apart. The building blocks are great, e.g. immutability everywhere, but few of the built-in primitives are actually usable (hidden unconfigurable thread pools etc). Stack traces still regularly horrible. Libraries are regularly abandoned. ClojureScript integrating with npm etc is more stress than you'd like. Core development is haphazard and proudly so. Types are nice, and spec is still up in the air, and slow, and not widely implemented, and will probably be rewritten several more times before being abandoned. Hiring is harder than a dozen other languages. All that said, there is still amazing stuff happening. I hold out some hope that Dragan's work might spark a bigger stats/ML community on top of Clojure, for example: https://dragan.rocks/ https://dragan.rocks/ Every day I can still write code and think "yay, that's cute", and be thankful for the dynamism and clarity it can enable. But I wouldn't recommend it to anybody, for anything really, and I feel sad realising that.
- fiddlerwoaroof 8y agoI had lots of pain dealing with CLJS but, since switching to http://shadow-cljs.org http://shadow-cljs.org as my compiler, I've generally found that things "just work": instead of complicated messing with externs, you just npm install the package and then add `["vega" :as vega]` to your namespace's list of requires. As far as the stack traces go, I have a hard time understanding why tooling like Cider's stacktrace filtering isn't wider spread: in Cider, when a stack trace pops up, it's one or two clicks to hide most of the things I don't care about and, yet, that information is still available for people working on the compiler or with Java interop.
- jhhh 8y agoEvery person that I've talked to that seemed to have a strong negative opinion about parens never used it. They just think they won't like it but wouldn't take the minimal amount of time to give it a try with something like paredit. I was also in this camp for a long time until I figured I would give it a serious try instead of disparaging something I had not used. You might consider that creating and editing code with balanced parenthesis doesn't actually require you to insert them manually when you have an editor that will always keep the code data-structure balanced and makes structural editing simple.
- Fice 8y agoFor me the ability to edit code structurally (rather than in terms of plain text) in a uniform way is a great advantage of Lisp syntax.
- Syzygies 8y agoI've been using Scheme as one of my languages for a decade. (Haskell, Python, Ruby, Bash are the main others.) I generally use a preprocessor for each language. The Haskell preprocessor treats indented as code, flush as comments, also supported by my syntax highlighting. Comment characters feel to me like a thousand Hitchcock birds shat on my car. They're so easy to avoid. It also introduces here docs; no language should be so full of itself that it can't embed multiple lines of another language verbatim. I've gone through several period of straight Lisp parens, and several periods of using a preprocessor. I believe in committing to muscle memory before deciding; I've oscillated back and forth between Querty and Dvorak, for example. I'm more committed to psychological experiments than anyone who claims the parentheses haters are newbies who haven't tried. Study counting in higher mammals: One finds that "one, two, three, many" is core to all of us, and higher systems are strapped on like the multiple layers of vision mechanisms. Humans can't deal with the tiger tails at the end of lisp expressions. But machines can? Yes, but machines can also handle inferred parentheses. The complainers about parentheses complainers want off-the-shelf support. Real programmers write their own support. Lisp looks best with indentation to help infer parentheses. Use a pipe "|" to open a parenthesis that auto-closes at the next ")" or the end of the line. Use a dollar "$" (borrowed from Haskell) to open a parenthesis that auto-closes when the indentation returns. Lisp written this way is stunningly beautiful poetry, cleaner than any of the dozens of languages I've programmed in. The remaining parentheses actually matter, so one pays attention to them. I've spent years each way, back and forth. Inferring parentheses is better, and one can write any tool to follow this syntax.
- coliveira 8y agoI have considered Python many times, but I cannot work with a language that considers whitespaces as required syntax. I just cannot work with it.
- lsh 8y agothe downvotes are funny because this was exactly the criticism Python got before it became popular. Probably still gets it.
- njharman 8y agoWhitespace is not any more significant in Python than most languages. Indentation is significant. Just replace '(' with space/tab and ')' with "deindent". Done.
- coliveira 8y agoHave you done indentation with anything else other than whitespace? I prefer to let this idea of required indentation to FORTRAN.
- endgame 8y agoThat's a shame. I use Haskell but wish it had paren syntax. I'd rather have strong types than sexps so I stick with Haskell.
- garyrob 8y agoLately I've been playing with Coconut [1], a functional language that is a strict superset of Python 3. It transpires to Python and can use all of Python's libraries. I've been playing with it lately and quite like it. [1] http://coconut-lang.org http://coconut-lang.org
- iLemming 8y agoYeah, there are people who simply can't read Lisp syntax. Where I see structure and beauty, they see "murder of parens" (or whatever demeaning collective noun they use to describe it). I call them dyslisplexics.
- bradcypert 8y agoBlog Post Author Here: It's really not that bad! Here are some insights into the parens! 1. I've converted Java code over to Clojure and found that it has less parens per file. 2. They're still there, they're just in a different place. `System.out.println("")` vs `(println "")` 3. There are some great tools to help with the Parens. If you're using Intellij, Pareninfer and Rainbow parens are two extremely helpful tools.