8 ms·
Clojure Newbie Guide (2015)
- georgewsinger 9y agoHere are the reasons I stopped using clojure (a phenomenal language) a year ago, in order of importance: 1. No C/C++ FFI. 2. Lack of a strong type system (clojure.spec almost solves this problem now, but when I quit this didn't exist yet). 3. Horrific startup times: although clojure itself is fast, its startup time isn't. This makes scripting in clojure unsatisfying. And you don't feel like a ninja when it takes 30 seconds to start a REPL. You can use clojurescript to target node to get around this, but then you cut yourself off to most of the powerhouse clojure libraries. I now use Haskell (with C/C++ FFI). I do miss the homoiconicity (and slightly more concise syntax) of clojure. In my opinion Haskell and clojure are the two sexiest mainstream languages that you can get stuff done in.
- Jach 9y agoI guess for #2 you didn't get a chance to try out Schema? (Now at https://github.com/plumatic/schema https://github.com/plumatic/schema) Or if so, I wonder what you found lacking in it? http://www.lispcast.com/clojure.spec-vs-schema http://www.lispcast.com/clojure.spec-vs-schema does a good job highlighting some differences..
- fbonetti 9y agoRuntime type checking is useless. If a given function can't accept the data I plan to send into it, I want the compiler to tell me immediately.
- tmountain 9y agoI think useless might be a stretch. While I certainly prefer compile time checks as well, spec is a huge step forward for folks that are committed to Clojure. If there was no merit to runtime checking, Haskell wouldn't have QuickCheck and would exclusively rely on compile time checking.
- Jach 9y agoThat way lies SOAP, and it's not the compiler that tells the client it can't call an API some way but a broader build tool. And you still need some runtime verification somewhere on the server anyway since without it nothing stops any arbitrary stream of bytes. My own related exaggeration is that type declarations without performance gains are useless. Get them out of my dynamic langs unless you can deliver the performance goods. (Like Common Lisp can. It can also tell you you're stupid locally trying to make an invalid call, at compile time, since COMPILE is built-in.)
- regularfry 9y agoHas anyone looked at grabbing the jnr-ffi libs from jruby for #1? This is an example of what the Java bits end up looking like: https://github.com/jnr/jnr-ffi-examples/blob/master/getpid/src/main/java/getpid/Getpid.java https://github.com/jnr/jnr-ffi-examples/blob/master/getpid/s... Can't imagine that would be too hard to wrap.
- pjmlp 9y agoWhy not use a proper Common Lisp instead, then?
- zintinio5 9y agoI've wrapped C and C++ code via the JNI and called it from Clojure. There are a good number of projects wrapping C code in Clojure. It's a little awkward (Clojure -> Java -> JNI -> C), but works well enough. We get around the startup time by keeping our work either in the REPL, or just having large enough tasks that the loading is dwarfed by the time it takes to get started. Webdev might be a little crappy if you're used to the turn-around cycle of either node or PHP.
- zurn 9y agoIn web development you live-reload code in the running Clojure app, so turn-around time is excellent. (ClojureScript has very good live reload support as well)
- zintinio5 9y agoThere can be problems with state management, which I've only seen with our web application. Sometimes a hard stop / start is what you need unless you designed the application for reload-ability. We're working towards that for our web application. Frameworks especially seem to exacerbate this problem, since you have limited control over the execution of your program.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- flavio81 9y agoIf in any case you still feel the same about Clojure, you should try Common Lisp, it has the three things you want: 1. Easy calls to C with CFFI. No Clojure->Java->JNI->C, just straght CL->C. 2. Useful, optional, type system (which can also catch mistakes at compile time with SBCL and other compilers) 3. Very fast startup times. and many more features like for example an object system that is massively above what Clojure and Java bring to the table, better exception handling, very explícit errors and nice stack traces, it can also compile to JVM if you want, etc. If you like Lisp, try it. You already learned a Lisp so the jump is easy.
- peatmoss 9y agoChiming in to give Racket a shout out. Good FFI, good libraries, good tooling, good community, good (soon to get even better) performance, subjectively more modern feel than CL, great type story via Typed Racket.
- flavio81 9y agoThanks, i use CL and will take a deeper look at Racket as well, i have this pending for a long time...
- dTal 9y ago>(soon to get even better) performance Why? Are the rumours of porting the language to Chez Scheme true?
- peatmoss 9y agoI hope it's not just a rumor! https://news.ycombinator.com/item?id=13656397 https://news.ycombinator.com/item?id=13656397
- jakebasile 9y ago1. There is JNI. I made an example project[1] a while ago. I'll admit it's a little involved but it does exist. 2. Spec does solve the problem for me, but I don't really like static typing anyways. 3. I keep Clojure REPLs open for days. I restart if I need a new dependency and for other minor reasons, but startup time is almost a non issue for development. For scripting, you can try Planck, although yeah you lose the Java interop. I love Clojure, but I just don't use it for scripting. Not trying to tell you you're wrong, just offering some insight into how Clojure could address (or not address) your points. [1]: https://github.com/jakebasile/clojure-jni-example https://github.com/jakebasile/clojure-jni-example
- escherize 9y agoWith cider and clojure-refactor mode, you can hotload a dependency without restarting the repl. It is kind of brittle but when it's working hot damn is it good.
- justinhj 9y agoI gave up on Clojure despite spending a lot of hobby time on it and moved to Scala because it's simply a much easier language to sell to other engineers and management. For me the C/C++ was a minor issue since if you're going to the trouble to do it on the JVM you may as well build that part in Java.
- Jach 9y agoAny tips for how you sold Scala? I don't even like it but I picture the sell to be at least as hard as Clojure, at least if you're selling Scala honestly... Clojure can't hide its alienness anywhere but a Scala intro can. I'd like to find a way to push for Kotlin at the moment, which would be nicer day-to-day than plain Java plus open the door later for other JVM languages.
- justinhj 9y agoThe major things are: Show examples of large companies using Scala in production (Twitter, LinkedIn, Walmart etc) Gradual low risk introduction of Scala using Gatling load test and ScalaCheck Production ready frameworks like Play and Akka Demonstrate that Scala can be introduced at various levels from "Java without semi colons" to "You need to learn category theory to understand this" and what we would do to make sure everyone on the team would be up to speed. Build a prototype What counted against Clojure and Common Lisp was the immediate reaction of people with no exposure to lisp languages was "those brackets" and the lack of a large stable framework one can pick up and use as a gateway to using the language. Simply put there can be a gradual adoption of Scala in a company that's really not possible with Clojure.
- didibus 9y agoWhat kind of programs do you normally write?
- manishsharan 9y agoI have been a Clojure newbie for over 3 years now and here is why I am still using it: 1. Clojure code makes sense to me : I could go back to Clojure code someone wrote three years ago and I would have no problem in figuring out what the code was doing. With Java or Javascript, unless the code is documented with extreme diligence, the nuance are hard to decipher. 2. REPL based coding makes it easy to get code right before making it part of my namespace 3. lack of strong typing has not been a stopper for me yet. Spec is good enough for my needs 4. State and concurrency : Its hard to screw up concurrency and state mutation with Clojure edit: formatting
- wry_discontent 9y agoWhat're you using it for? I really like the language, but it seems geared to replace Java for heavy enterprise enterprise applications. A lot of the benefits I hear people talk about sound like they require a large project to be properly noticed. I've used Clojurescript for a couple toy projects, but it seems awkward to me.
- manishsharan 9y agoI am using it to implement REST services using the Luminus library.
- swlkr 9y agoClojure is great for any size web app, but I will agree here, I found clojurescript awkward as well.
- TheSmoke 9y agoif you could elaborate on awkward part, i'd love to give you a hand. i have 1 react native app built with cljs and 1 chrome extension. using cljs is the best technical decision i've ever made.
- wry_discontent 9y agoI'm still a n00b, but I found the errors to be obscure. Often times, I couldn't even get an error to display when I _knew_ something was wrong. After I fixed that error, the app would show up again. For the most part, everything was incredible while it worked, but every so often very technical errors would come up and that makes me hesitate to advocate for its use at my job.
- flavio81 9y agoHappy to see there are good learning resources for Clojure. The more Clojure users out there, the better, since it is a Lisp language, and as more people learn and use Lisp, it will be more easy for them to also able to also use Scheme, Racket, Common Lisp, LFE and the other friends in the illustrious Lisp family. This, in the same way people can easily learn C, Java, C++, Rust, by knowing just one of those four languages. Once you understand the syntax, it gets really easy.
- amk_ 9y agoDoes anyone use Clojurescript as a webapp backend instead of Clojure?
- iammiles 9y agoNot sure if anyone is using it, but there is this: https://macchiato-framework.github.io/ https://macchiato-framework.github.io/