3 ms·
Not very convincing when the very first example is apples vs. oranges: the java fib() code includes a main() driver with command line parsing and printing of t
by mpweiher 13y ago
Not very convincing when the very first example is apples vs. oranges: the java fib() code includes a main() driver with command line parsing and printing of the result to stdout, which I don't see in the clojure version.
- GhotiFish 13y agoalso. I have absolutely no idea how the first one even works. fib-seq is not a defined token. wtf is going on here?
- elwell 13y agoI don't know Clojure, but I assume it's supposed to be: (rest fibonacci) fibonacci) i don't know actually...
- zcam 13y agoIt's sloppy copy/paste work from http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci http://en.wikibooks.org/wiki/Clojure_Programming/Examples/La... This post is quite poor imho, and I am a clojure developer (I do use it at work as main language). Maybe it's also because I don't find Midje appealing at all, or find a bit odd the minimalism argument when talking about lighttable vs emacs. If you know what you're doing with cider-mode (previously nrepl) on emacs there's no reason at all to switch to lighttable, quite the opposite. LT is probably good for newcomers, but for power users it's just not there yet (if ever). Same goes for Marginalia, interesting and amusing, but I wouldn't use this for real documentation.
- delluminatus 13y agoIt looks like an error. The author probably based his code on an example from Wikibooks [1]: (def fib-seq (lazy-cat [0 1] (map + (rest fib-seq) fib-seq))) But, since he added an argument to the function, I don't think his code actually works, even if you ran :s/fib-seq/fibonacci [1]: https://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci https://en.wikibooks.org/wiki/Clojure_Programming/Examples/L...
- chongli 13y agoClojure, being a Lisp, uses the tradition of a REPL (Read-Eval-Print-Loop). The REPL handles all of the command line parsing and printing for you. All you do is load up your program and start calling functions with it. It makes for a great interactive development tool, as it can be used within most editors/IDEs which tend to have commands for automatically reloading all your code in the REPL.
- elwell 13y agoFair enough, but then the difference between the two languages is not linear across the development of the larger program. The largest difference in code size is displayed, but it focuses on boilerplate code being the inflating factor of Java.
- chongli 13y agoYeah, focusing on boilerplate is not all that interesting in the long term. For large applications (which both languages aspire to), it makes more sense to compare things such as static vs dynamic types, mutable vs immutable, etc. Though I guess there is some merit in having less boilerplate, as fewer lines written mean fewer lines to modify during a refactor/debug session.
- ytdtty 13y agoThat would be a good excuse for the apples to oranges comparison if people always ran production server code via the REPL.
- sehugg 13y agoNot to mention you could easily rewrite the Java version in one line with a conditional, if you wanted. Whitespace in your code isn't always a bad thing IMHO.
- deleted 13y ago[deleted]
- m0skit0 13y agoYou focus on one example to say "not very convincing"? Please elaborate more on why Clojure features are "not very convincing", I would like to hear your opinion.