4 ms·
I’m mildly surprised by how well Clojure performs here. It isn’t statically typed yet fares much better than Haskell/Scala! From my experience Clojure is also a
by kccqzy 9y ago
I’m mildly surprised by how well Clojure performs here. It isn’t statically typed yet fares much better than Haskell/Scala! From my experience Clojure is also a joy to write, sometimes even more than Haskell.
- hellofunk 9y agoI have read elsewhere (in many places, in fact, such as the interesting read "Out of the Tar Pit") that the frequency of bugs in a project scales proportionally to the code size. And that this has a greater influence on bugs than features of any particular language. Clojure is an incredibly succinct language. It uses about half as many lines as Elm, 5% as many lines as C++. I love other languages, but nothing rivals Clojure in elegance. I believe this is the key reason why Clojure projects are so low on bugs -- they are much simpler to maintain, refactor, or rewrite entirely than in most other languages, so fixing problems is not the chore it can be elsewhere.
- jstimpfle 9y ago> 5% as many lines as C++ Dude, you need a reality check.
- hellofunk 9y agoWhy is that?
- pmarreck 9y agoOne only needs to look at RosettaCode for numerous examples http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#C.2B.2B http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_e...
- jstimpfle 9y agoOh come on. First, 20 vs 4 lines, which is 20%. Second, not exactly the most compact C++ version. You can easily make one in 10 lines even in a clean C style. Third, these code-golf comparisons are beyond silly.
- pmarreck 9y ago20% is still impressive and not atypical in my experience from coding in mutable/OO vs. functional languages I wonder what Rust would look like here
- eklavya 9y agoI was really surprised as well. Maybe Clojure people are really smart :P I would still take typed over untyped any day.
- hellofunk 9y agoIt really does just boil down (in my opinion) to code size. A small program is going to have fewer bugs than a large program. And Clojure programs can be quite small compared to the same programs written in other languages. While I too am attracted to the static typing in many ways, I have found in my own experience of working in C++ full time for a few years (with some non-trivial work in Swift as well, which has quite a strict type system), and then Clojure full time for a few years, that when you measure all the other features of a language, typing alone does not make a big difference. It's kind of like the argument some people make about how the cost of your rent or mortgage is the best indicator of your cost of living. There are so many other factors, and some of the lowest cost of living I've personally experienced has been in places with considerably higher rent than average, due to the offset of other factors.
- eklavya 9y agoI am finding it hard to believe that Clojure can beat Haskell/Scala in code size by a huge margin.
- hellofunk 9y agoWhy is that hard to believe? Static typing always add some code size, even in languages with inference. On top of that, the pervasive use of macros in lisp tend to lead to a kind of code-reuse that languages without macros lack. Not to say that Haskell can't be concise also, just not to the same degree. And I've seen very long lines in Scala that were due to pleasing the compiler's typing. Elm and Clojurescript offer a good contrast. Elm is written in Haskell and is not too unlike Haskell syntax and general language use. I've written in both Elm and Clojurescript and there is nearly a 2X difference in code size of Elm over Clojurescript for accomplishing similar non-trivial tasks. Code size isn't everything, but it is important. If you still find it that hard to believe, just try Clojure for awhile, and I think it will be clear. It's a tradeoff. When you don't have to satisfy a type checker for everything, you do write less code, that's just a matter of fact most of the time. The question is whether the increased code size of a statically-type language over a lisp makes up for the extra developer resources and potential for bloat-related bugs. But that is of course the core of the typing debate.