5 ms·
That's mostly because such lisps are overly verbose. The same code in Clojure: (let [hello (fn [] (println "Hello World"))] (hello
by _halgari 11y ago
That's mostly because such lisps are overly verbose. The same code in Clojure:
(let [hello (fn []
(println "Hello World"))]
(hello))
Or assuming hello is a global in your dart example:
(defn hello []
(println "Hello World"))
(hello)
Nothing too complicated about that. Clojure is way less verbose than some scheme variants.
- jcromartie 11y agoThe equivalent code in Racket is exactly as complex as your Clojure example.
- ahoge 11y ago> Or assuming hello is a global in your dart example The way it's written implies that it's somewhere inside some block, because "main()" is always the entry point. I wrote it like that because I couldn't be bothered to figure out how this stuff works in Scheme. With entry point: main() => print('Hello World'); Alternatively: main() { print('Hello World'); }
- 59nadir 11y ago> I wrote it like that because I couldn't be bothered to figure out how this stuff works in Scheme. I think that sums everything up, really. This is how shallow the complaints about parens are. No one who actually bothers will make a point about what delimits expressions in a language. To complain about parens is also doubly wrong, as they do bring something technical to the table. What Carmack talks about when he says S-expressions are nice for reading in terms of network communication, for example, is that the messages can be read exactly like other expressions over the wire. This is true for any I/O; you can read the data just as if it was code, because the code is data. The same mechanism that reads the code you are executing is available to you to read full expressions through any medium, and use that data/code as you see fit.
- ahoge 11y ago"This stuff" was referring to the entry point. I didn't complain about parenthesis. ASM's syntax is also extremely simple, but that doesn't make it easy to use, does it? If everything looks the same, it's hard to scan. C-like languages provide more visual hooks than Lisp dialects.
- brlewis 11y agoI'm currently using Java and Javascript for work. Previously I used Scheme. I do find that scanning is important in Java and JavaScript because often you don't need to read a whole section, just a piece. Back when I worked with Scheme, if I didn't need to read a whole section, generally the part I needed to know was right at the beginning. I think all Lisp dialects work this way. The worst example is immediate function application in JavaScript. You get to the end and all of a sudden the }(); tells you everything you've just read is a different context than you thought it was. In Scheme (and probably most Lisps) you'd recognize immediate function application at the beginning as soon as you saw ((. I don't know how people get really good at JavaScript without learning Scheme first.
- ahoge 11y ago> You get to the end and all of a sudden the }(); With most code conventions, you wrap immediately invoked function expressions (IIFEs) in parens: var foo = (function () { ... }()); The only purpose of those extra parens is to act as marker. Well, with block scope (`let` & `const`), IIFEs aren't really needed anymore.
- brlewis 11y agoAll Scheme variants are approximately as verbose as your second example, except you don't have to assume hello is global. Internal defines are part of the R4RS standard published in 1991.
- davexunit 11y ago>Clojure is way less verbose than some scheme variants. Bullshit.
- _halgari 11y agoEh, IMO (let [x (+ 1 2) y (+ x 3)] (* x y)) Is always less verbose than: (let ((x (+ 1 2)) (y (+ x 3))) (* x y)) I program in Clojure every day, and that latter example makes me say "aahhhh! The parens!"
- davexunit 11y agoAnd the Clojure example makes me say "aaah the ambiguity!" The key/value pairs makes much more sense to me when they are delimited as such. It's a minor point, anyhow. Clojure is just fine. I just don't think that it is significantly less verbose than Scheme. Let's just keep hacking with Lisps and be happy. :)
- technomancy 11y agoIt's dramatically less verbose when you are dealing with code that uses associative data structures, both because of having nicer literal syntax and because the data structures can be applied directly without needing to reach for things like hash-ref. (Which makes a boatload of sense, because immutable hash maps actually have more in common with mathematical functions than Scheme procedures do.) In addition, functional nested updates are very verbose in Scheme. However, both of these problems can be solved in Racket by third-party libraries.
- 59nadir 11y ago(let* ([x (+ 1 2)] [y (+ x 3)]) (* x y)) Less ambiguity, all of the clarity of what is what. I don't get why you use other delimiters for your Clojure code, but have this view that they can't be used in other Lisps/Schemes. (You will also have to use `let*` in (most?) schemes because the binding for y has absolutely nothing to do with the binding for x and so cannot be used in the binding of y.)