3 ms·
I always thought the main reason lisp did not become the world's dominant language (or, at least, dominant language with garbage collection) is that writing (/
by casualrandomcom 4y ago
I always thought the main reason lisp did not become the world's dominant language (or, at least, dominant language with garbage collection) is that writing
(/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c)))) (* 2 a))
is a pain in the neck, and even more so when you have to read it, while
(-b + sqrt(b*b - 4*a*c))/(2*a),
can be checked on the fly.
I am kind of amazed this hasn't finally sunk into programmers' hearts.
- vindarel 4y agoPeople who write that much math can use a reader macro for infix notation: https://github.com/rigetti/cmu-infix https://github.com/rigetti/cmu-infix
- Kodiologist 4y agoIn Hy, you can include Python with `py`, as in (py "(-b + sqrt(b*b - 4*a*c))/(2*a)")
- m45t3r 4y ago> I always thought the main reason lisp did not become the world's dominant language (or, at least, dominant language with garbage collection) is that writing I can write ugly code in any language. But if I was writing this code in Clojure, I would probably do something like this: (let [r1 (- (* b b) (* 4 a c)) r2 (+ (- b) (sqrt r1))) r3 (* 2 a)] (/ r2 r3)) That is perfectly readable to me. Yeah, you may say that I needed to introduce other variables to make this work and the code got bigger as a result, but on the other side how many people are actually writing this kinda of code on daily basis that are not Computer Scientists?
- gilch 4y agoEven indenting properly goes a long way: (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c)))) (* 2 a)) The trick is that a trail of any number of `)`'s should also end the line. Like any language, it takes some getting used to, but I find this tree structure perfectly readable now. Sure for the four-function calculator operations, operator precedence levels are a reasonable notation, but when you can define your own functions, and your programming language now needs a dozen precedence levels, it becomes hard to read. Lisp is completely unambiguous.
- gilch 4y agoPython expressions are accessible in [Hissp][1]. In [readerless mode][2], you're writing in Python anyway, so it's trivial. In [Lissp][3], you can inject Python code strings with `.#`. In [Hebigo][4], you just put parentheses around the whole thing. [1]: https://github.com/gilch/hissp https://github.com/gilch/hissp [2]: https://hissp.readthedocs.io/en/v0.3.0/tutorial.html#hello-world https://hissp.readthedocs.io/en/v0.3.0/tutorial.html#hello-w... [3]: https://hissp.readthedocs.io/en/v0.3.0/tutorial.html https://hissp.readthedocs.io/en/v0.3.0/tutorial.html [4]: https://github.com/gilch/hebigo#bracketed-expressions https://github.com/gilch/hebigo#bracketed-expressions