Live data from Hacker News

Why Clojure?

blog.cleancoder.com

71–80 of 202 posts

Re: Why Clojure?

#71
post #63
post #38

My team owns a Clojure app, amongst a lot of other apps - my understanding is the current DRI (who inherited this app once the original one left for another org) doesn't like working in it though, and that has been the experience of other developers who have been recruited to the project over the past two years. Most developers I work with on a day to day basis don't have any interest in learning Clojure, and would r…

Ive been doing various methods of js dev with tons of different framworks and traspilers for 20 years, nothing is more pleasant to work with than ClojureScript and re-frame once you learn it. It's the best of all the worlds, and the DOM is very abstracted away via React. State transition is a breeze with immutable data structs. Theres only 1 language to write, no JSX ugliness.

I have had a similar experience over the past 15 years. re-frame is absolutely wonderful.

Re: Why Clojure?

#72

Clojure is one of the better dynamic languages. The rub however is that GHC can check the consistency of my software faster than I or my colleagues will ever be able to, and programmer time is expensive. So that's why not Clojure.

I don’t think the only alternative to Haskell types is manually checking your program for consistency.

For one thing, Clojure has type analysis: spec. Also, as pointed out in the article, you can also write tests.

Re: Why Clojure?

#73

Earlier quoted context omitted.

Not original poster, but my take is: - Immutable data-structures with concise literals for lists, vectors, maps, and sets. Having pure functions and immutable data-structures makes code easier to reason about, easier to test, and thread-safe. (But clojure doesn't "force" you to be pure. The idea is that you write as much of your code in pure functions as you can, and push the IO and impure parts to the extremities. I…

> Macro system Macros are actually my least favourite part of Clojure. Sure, its great to have them and there are some libraries that use them to excellent effect (instaparse, Hugsql, etc), but most of the time, I prefer tools that don't use macros. You can see by comparing libraries that were made in the earlier days of Clojure versus more recent ones: the earlier ones love to use macros while the newer ones prefer…

I agree!

When I meet a girl, I ask her about macros and functions first.

I except to hear something like: macro < function < data.

Re: Why Clojure?

#74

Clojure is one of the better dynamic languages. The rub however is that GHC can check the consistency of my software faster than I or my colleagues will ever be able to, and programmer time is expensive. So that's why not Clojure.

I don’t think the only alternative to Haskell types is manually checking your program for consistency. For one thing, Clojure has type analysis: spec. Also, as pointed out in the article, you can also write tests.

Haskellers can and do write tests.

    +----------+-------+-------+
    | Language | Tests | Types |
    +----------+-------+-------+
    | Haskell  | Yes   | Yes   |
    | Clojure  | Yes   | No    |
    +----------+-------+-------+

Re: Why Clojure?

#75

Earlier quoted context omitted.

I think both are very production worthy as far as reliable code running in production. Check out the success stories on the Clojure site. One of the biggest ones to me is Walmart using it for Black Friday e-commerce. That is a good indicator to me. They've had good success stories with F# as well, but C# uses F# as a research language and the best bits are kind of bolted back onto C#. It keeps C# as less painful than…

You don't actually need to know anything about Java to be productive in Clojure. At least that was my own experience.

I've been told that before and respect your experience even if it is very different than mine.

Let's talk about writing code in Python. You write a script and either run it through your IDE or via the command line via Python pythonscript.py. With D, I write some code and feed it through the compiler like dmd scriptname.d.

With Clojure in addition to all the cruft I have to learn (Emacs, leinegen...etc), I still have to know something of Java. One of the big selling points is integration. If I know zero Java, how am I supposed to make use of the various classes? Even if I largely stick to just Clojure, how does one interpret the Java stack traces? What is the best method for running via the JVM? How do I performance tune the JVM? How do I use GUI frameworks that are largely all OO Java?

Re: Why Clojure?

#77
post #3

Clojure is by far the best programming language I've ever used. Rich Hickey's Sermons On The Mount changed the game of programming once and for all. With Clojure you could finally have your Lisp cake and eat it. Witness the sheer chutzpah of the guy when he basically told Ruby devs they were doing it wrong at Rails Conf in 2012 ( https://www.youtube.com/watch?v=rI8tNMsozo0 ).

Ever play with Erlang or Elixir? If yes, I am curious what your thoughts are on them.

I've been doing a lot of Elixir recently, and I have a fair amount of experience with Scheme and Clojure. The biggest "aha" moment for me with Elixir came when I realized that everything, just like in a LISP, was an expression.

Then, when I learned about Elixir's macro system, I thought, "wait a minute, this is LISP! This is just a LISP in Ruby's clothing in Erlang's pasture!"

That was a delight. :) My heart still belongs to the LISP family, but right now I'm working as an Elixir developer.

Re: Why Clojure?

#78
post #42

Earlier quoted context omitted.

I'm with you. Reading a text file (line by line) is the thing I do most and what I look for first. If you can't do that in a simple way, I move on. I also look at returning datasets from SQL databases, how you can make a GUI, and a host of other practical things. I think fibonnaci is a sort of one step up from "Hello World", so in a sense it gives a little taste of the language and syntax.

I think if all you are doing is reading files line by line, reading a database dataset etc, then your choice of language is probably irrelevant. Choose whatever you prefer typing. But here's CLojres read a file line by line and print it out: C:\\foo.txt "THis is line 1 This is line 2 This is line 3" (with-open [rdr (io/reader "C:\\foo.txt")] (doall (map println (line-seq rdr)))) =>THis is line 1 This is line 2 This i…

I don't think this is remotely true. Compare doing file parsing in Python, Perl, C#, Java, Common Lisp, OCaml, Ada, Fortran, C++...etc.

Doing it in Python is easy...it is a bigger pain in several of the other ones. Even your Clojure examples are definitely more work than in Python. You even defined a helper function (something I've never needed to do in Python) as the default is so easy. Mind you, the Clojure isn't too bad and definitely better than some of the others I've mentioned.

To your average developer...this is indeed probably irrelevant as IO might be a small part of your codebase. I do a lot of process automation though and do a lot of IO.

Re: Why Clojure?

#79
post #59
post #3

Clojure is by far the best programming language I've ever used. Rich Hickey's Sermons On The Mount changed the game of programming once and for all. With Clojure you could finally have your Lisp cake and eat it. Witness the sheer chutzpah of the guy when he basically told Ruby devs they were doing it wrong at Rails Conf in 2012 ( https://www.youtube.com/watch?v=rI8tNMsozo0 ).

It's a lot of fun but as projects got larger and larger for me (thousands of lines, or even tens of thousands), I found the dynamic typing taking up more and more of my time. I've since moved on to statically typed systems where the compiler takes a big load off the cognitive requirements of maintaining and debugging software.

This has been my experience as well. I have a couple of Clojure(Script) applications that are approximately 3-5K lines each and those have been a pleasure too work on. However, my latest project is now pushing past 20K lines and the mental load has jumped exponentially. There is a much greater need for spec, asserts, type hints, and comments just to keep everything straight.

Re: Why Clojure?

#80
post #48

This is all nice and exciting until you start to 1) Debug code, the high density of clojure code means that this is really painful. 2) Read code you wrote a while back. The high density of clojure code means that this is really painful.

looks like you don't know FP

pure functions are completely separate to every other parts of your software, they are very readable and easy to debug

* edit: don't write functions longer than a few lines

Post reply on HN