News for hackers. Stuff that matters.
Re:Clojure Newbie Guide (2015) by didibus on Thursday June 22, 2017 @01:03PM (#14613634)
Clojure is good for everything you'd use Java for. So pretty much anything that's going to be long running, like services, or big apps meant to be open for a while. Yes, that fits the enterprise use case perfectly. A backend for any service oriented architecture, ETL jobs, data processing pipelines, backend for websites, rest/rpc/graphql services, client/server applications, big data analysis, machine learning, etc.

Clojure is not good for quick scripts, use bash, python, perl, hy, clojurescript, etc. for that.

Clojure is not good for low level code, like drivers, embedded systems, os, etc. Use rust, c, c++, D, etc. instead.

Clojure isn't good for squeezing every ounce of power out of hardware, such as games, use C++, assembly, etc. for that.

Clojure isn't good for mobile app development, use Java, swift, c#, objective-c, etc. for that.

Clojure isn't good as an embedded scripting language, use LUA, python, javascript, tcl, scheme, etc. instead for that.

Therefore Clojure competes mostly against Java, Scala, C#, F#, GO, NIM, Haskell, etc. Now as an astute reader, you've noticed how none of the competing languages I've listed are dynamic or of the lisp family. This makes Clojure unique in its space and the most controversial.

Re:Clojure Newbie Guide (2015) by heftyfive on Thursday June 22, 2017 @02:21PM (#14614200)
I agreed with most of your comment, but not the end.

I don't think Clojure competes with Go or Nim. And Clojure seems to be the antithesis of Haskell. Clojure competes with Java, Kotlin, Scala, and C# if you're on an MS platform.

I used Clojure for pet projects for a while (it's a gorgeous language) but eventually went back to Python because I wanted something with:

* easier interop with C/native libraries,

* faster startup (though for scripts, [inlein](http://inlein.org/) mitigates this issue)

* no requirement of the JVM

* better error messages / more help finding my bugs

* smaller memory and cpu footprint

Looked at some Schemes (Chicken), but couldn't stomach the car/cdr/dotted-pair stuff after having nice data structures like in Clojure, Python, et al. Not interested in ClojureScript, as I don't want JS underneath. Still prefer Clojure-the-language to Python-the-language, but here we are.

Re:Clojure Newbie Guide (2015) by didibus on Friday June 23, 2017 @05:56PM (#14623089)
Why wouldn't Clojure compete with go or nim?

Go and Nim are both mostly used for backend services, long running processes deployed inside docker instances, etc.

I agree it competes a little less then it does against Java, C#, et all. But it still does, in that there's overlap for what projects they'd be good candidate for.

Re:Clojure Newbie Guide (2015) by zurn on Thursday June 22, 2017 @01:58PM (#14614042)
I think Clojure fits well to quick scripts and exploraory programming, because of the rapid turnaround in interactive development. The finished tool, if compiled, will start fast enough (~1 second for hello world) even though it loses a bit to Python scripts.

Clojure also lets you drop down to the most basic JVM primitives, like unboxed types and atomics/volatile, so you can do lower level stuff than in other dynamic languages. You can even follow the asm code generated by the JIT. Combined with macros and other DSL building capabilities, I'd say doing low level or performance oriented work can be pretty productive with Clojure.

DSL building blocks and dynamic nature also make it a pretty good embedded scripting language.

Many embedded systems are plenty powerful enough to run Clojure (or Python or Java), so it works there too.

Re:Clojure Newbie Guide (2015) by didibus on Friday June 23, 2017 @06:01PM (#14623117)
What you say is true, yet false.

While you can use Clojure for script, or performance heavy tasks, or embedded systems, I think it's pretty obvious it's not the right tool for those, at least not yet.

If you want to mess around with scripts, performance heavy tasks or embedded systems, sure you can use Clojure, but if you are serious about any of them, it wouldn't make sense. You'd turn to languages that are better suited.

Re:Clojure Newbie Guide (2015) by zurn on Saturday June 24, 2017 @06:54PM (#14627819)
I don't think you addressed any of the arguments here, so quite far from obvious...?
Re:Clojure Newbie Guide (2015) by didibus on Saturday June 24, 2017 @07:32PM (#14627919)
Ok, well, for scripts:

- You mention sub second load times. Based on https://dev.clojure.org/display/design/Improving+Clojure+Sta..., the surveyed timings are around 2 to 5 seconds, going to 60 seconds for some. That's a bit too much for scripts, you can live with it, but users are going to be annoyed about it for sure.

- Another issue is the difficulty in starting them. You need to invoke java with a class path setup. So you can't have self executing scripts. You can use inlein, but that brings us to my third point.

- The bigget issue is that Java and Clojure are not standard on any machine. While python and bash tend to be. To use Clojure for scripts require each machine to be imaged with java, Clojure and inlein setup.

About performance and low level tasks. I'm not sure which of my use case you're specifically talking about. But an OS and drivers need to be compiled to specific hardware, so Clojure isn't an option for low level code like that. Now the JVM isn't performant enough for major games, you can't control memory yourself, or target specific CPU instructions.

Finally, only a minority of embeded chips support running a JVM instance, I'm not sure I need to explain any further, if you work in embedded systems, it just doesn't make sense to restrict yourself only to the more powerful chip that can run an embedded JVM.

P.S.: I love Clojure, I wish it was great at all these use cases, but it currently isn't, and I think we do the community a diservice to make people believe it is, because they'll try it, and have a subpar experience, leaving them feeling like Clojure isn't that great afterall. I'd rather people try it for what it's good at.

Re:Clojure Newbie Guide (2015) by zurn on Sunday June 25, 2017 @06:10AM (#14629385)
That survey is unrepresentative for scripting, since it's a survey of all Clojure applications. Scripting tends to be one-off, custom high level logic. I'm sure any Clojure user will tell you that short programs start fast enough for scripting - and for development, you are live-reloading in the REPL with 0 startup time.

About deployment and distribution, I think the JVM story is much better than the competition (Python, Node, etc) - you can just package everything in a single .jar and you need only this along with the JVM.

Embedded systems, like I wrote above, are hardly restricted to this kind of tiny chip. Embedded systems these days are frequently powerful enough to run Clojure. There's a big market for developing embedded solutions that value memory-safety, fast turnaround times and on-devices development ability along with access to JVM libs.

To summarize, I still disagree that all these broad sectors would be weak for Clojure (like you argued in your original post). There are be smaller niches inside these sectors that Clojure is not well suited to (like operating systems, or low-powered embedded, or frequently executed end-user scripts that need sub-second startup times, or code inside operating system kernels) but this hardly excludes Clojure for all your listed broad application areas.

Re:Clojure Newbie Guide (2015) by didibus on Monday June 26, 2017 @10:54PM (#14642241)
I haven't worked those sectors personally, so I'm not going to pretend I know fully their requirements and if Clojure would be a smart choice. But from what I've heard and read, embedded systems is dominated by C. Very little chips support embedded java from my googling about it. Serious work still needs compact binaries, and to maximise the chips output. The exceptions are critical use cases, where they might use java and have a TLS proof with it which I don't think would work if using Clojure, or they'll go with Haskell or Agda, because they need to guarantee there's no bugs. Now I say this only from searching online and people I know who work in embedded systems.

Is there a sector for scripting? I was thinking of IT mostly, sys admin, that kind of stuff. In those cases, configuring java and clojure and inlein feel pretty heavy to me. I've never seen it in practice. It always adopts a language that is bundled with the OS like sh, perl, python, powershell, batch, etc.

It seems to me like the niche in these sectors would be Clojure being the right language. But I don't have real stats, so you might be 100% right. Personally, I didn't feel it is, I can think of more examples of use cases where bash is a better choice for scripting, or more examples where C is a better choice for embedded.

If you work in those sectors you probably know better, but I didn't get the impression you did, so I guess neither of us really knows.