News for hackers. Stuff that matters.
Re:Why use Clojure? by mpweiher on Tuesday December 24, 2013 @11:02AM (#6959836)
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.
Re:Why use Clojure? by chongli on Tuesday December 24, 2013 @11:09AM (#6959866)
Clojure, 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.
Re:Why use Clojure? by elwell on Tuesday December 24, 2013 @11:15AM (#6959900)
Fair 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.
Re:Why use Clojure? by chongli on Tuesday December 24, 2013 @11:38AM (#6960017)
Yeah, 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.

Re:Why use Clojure? by ytdtty on Tuesday December 24, 2013 @11:20AM (#6959926)
That would be a good excuse for the apples to oranges comparison if people always ran production server code via the REPL.
Re:Why use Clojure? by chongli on Tuesday December 24, 2013 @11:23AM (#6959948)
It's actually possible to connect to your production server through a REPL and hot-swap code.
Re:Why use Clojure? by grogenaut on Tuesday December 24, 2013 @11:50AM (#6960078)
It's possible to connect to a production java server and hot swap code via eclipse. What's your point? Probbably not a good idea to do this for any real production system.
Re:Why use Clojure? by babs474 on Tuesday December 24, 2013 @01:14PM (#6960433)
One of the big features of erlang is intelligent hotswapping for building robust telecom systems that never go down, but can be bug fixed/upgraded on the fly. Just because something is not commonly done with current tools doesn't mean its a bad idea, just that it is a bad idea with current tools.

My understanding is that built in java hot swapping is very limited, and indeed would be a bad idea to try hotswapping in production.

If the clojure repl brings us closer to the erlang world isn't that a good thing?

Re:Why use Clojure? by grogenaut on Tuesday December 24, 2013 @02:00PM (#6960636)
The type of code swapping you are doing with the repl, eg coding on the fly in the prod systems, and the type you are doing with erlang are completely different.

Erlang does have a much better deployment story than jvms as far as code swapping.

But AFAIK Clojure is compiling to bytecode and is under the same constraints as the JVM that it is hosted in.

Re:Why use Clojure? by technomancy on Tuesday December 24, 2013 @05:43PM (#6961404)
> But AFAIK Clojure is compiling to bytecode and is under the same constraints as the JVM that it is hosted in.

This is true for certain features (protocols, records, and gen-class, which are easy to avoid for everything but high-performance bottlenecks and legacy interop), but vanilla Clojure functions are built around vars, which are specifically designed to support reloading.

edit: it's still primitive compared to Erlang, but it's miles beyond Java.

Re:Why use Clojure? by grogenaut on Tuesday December 24, 2013 @06:30PM (#6961554)
True good point. I still maintain that it's not a great idea in production and it really doesn't scale. I did stuff like this in single host servers in rails as well. Turns out to not be so repeatable and not a great idea in prod. Also isn't great if you bring down one node of prod or if you have a load that takes more than one box worth of processing.
Re:Why use Clojure? by technomancy on Tuesday December 24, 2013 @10:14PM (#6962040)
I agree, but I would qualify that claim: it's not a great idea in production because the tooling to support doing it well doesn't exist, not necessarily because of limitations in the language.
Re:Why use Clojure? by GhotiFish on Tuesday December 24, 2013 @11:06AM (#6959852)
also. I have absolutely no idea how the first one even works.

fib-seq is not a defined token. wtf is going on here?

Re:Why use Clojure? by zcam on Tuesday December 24, 2013 @11:16AM (#6959906)
It's sloppy copy/paste work from 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.

Re:Why use Clojure? by delluminatus on Tuesday December 24, 2013 @11:17AM (#6959914)
It 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/L...

Re:Why use Clojure? by elwell on Tuesday December 24, 2013 @11:09AM (#6959870)
I don't know Clojure, but I assume it's supposed to be:

  (rest fibonacci) fibonacci)
i don't know actually...
Re:Why use Clojure? by sehugg on Tuesday December 24, 2013 @11:47AM (#6960067)
Not 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.
Re:Why use Clojure? by m0skit0 on Tuesday December 24, 2013 @01:16PM (#6960442)
You 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.