12 ms·
Clojure 1.9 is now available
- Y_Y 9y agoCan anyone sell me on why I should use clojure over say, any of the other nice Lisp-1s, given that I don't care about java.
- YuriNiyazov 9y agoDo you develop in JavaScript either front or back?
- Y_Y 9y agoNot when I can avoid it ;) My real work is HPC, but I'm looking at this from a hobby perspective.
- YuriNiyazov 9y agoI actually don't think Clojure is a good hobby language; it has specific opinions that are there to help you make good design decisions in large scale systems, but in small projects they just get in the way.
- noncoml 9y agoLibraries/Ecosystem
- koolba 9y agoRunning on a JVM opens up access to a huge ecosystem of drivers, platforms, and integrations. Any new libraries written for Java can be trivially accessed from Clojure.
- giblet 9y agohttps://clojure.org/about/rationale https://clojure.org/about/rationale https://clojurescript.org/about/rationale https://clojurescript.org/about/rationale
- aeorgnoieang 9y agoIf you're indifferent to Java then you can use a Lisp that just so happens to let you interop with Java libraries which is very very handy. It's also a nice Lisp, tho not as pure or quite as powerful as others. But I'm not very much up-to-date on anything new in the past few years, and I was never a guru anyways, so maybe there are better pitches.
- m1n1 9y agoDo you have a favorite accessible guide to comparisons of lisps with respect to purity and power?
- simongray 9y agoThe main "unpure" parts of Clojure is that * it doesn't do tail call optimisation unless you explicitly mark the self-call using by using recur (the lack of implicit TCO is a JVM limitation) * it doesn't use macros as much, although they are they're there and still used pretty often * it has language literals for the built-in data structures that look odd to other LISP'ers, e.g. {...} #{...} [...] * it's error messages are ecosystem dependent, e.g. Java stack traces for Clojure or and JS ones for ClojureScript
- tensor 9y agoIt has a strong focus on immutable data structures and good concurrency primitives. True that you can get these in libraries for other lisps, but having the entire eco-system based on them is a big selling point.
- unit91 9y agoI wouldn't try to sell you on it. Languages are tools, so your question is like asking "can anyone sell me on why I should use a flashlight instead of a cheese grater?" I don't know, because I don't know what you're trying to do. Perhaps neither Clojure nor Lisp is appropriate. Basic sales pitch: use the right tool for the job. For many of us, Clojure(Script) is the right tool: a balance of performance, ecosystem interoperability, expressiveness, etc. on the platform we're targeting.
- nikki93 9y agoYou've well captured a sentiment I feel when questions are phrased this way -- "can you sell me on X." Thanks for posting and showing me this. :)
- escherize 9y agoImmutable by default Lots of support Great interactive workflow (with Emacs, Intellij, or Atom) Data oriented (Most of your code are pure functions making simple operations on datastructures)
- barkingcat 9y agoWhy would anyone want to sell you on something? Do you want to be sold on it? Is that what you want your interactions on this site to be?
- Y_Y 9y agoSome people probably like it. They've had a good experience with it, that they'd like to pass along. I feel this way about several thing and will happily evangelise to someone who seems willing. I was inviting others to do that . Several of them have responded as I expected and provided lots of interesting information. Since I achieved my aim and stimulated some useful and on-topic discussion, yes, this is what I want my interactions on this site to be. Thanks for asking.
- neutronicus 9y agoAssociative data structures (maps / dicts) are super first-class in Clojure, in a way that they aren't in other Lisp-1's (at least from what I remember of dabbling in Racket). There's a literal syntax for them. Keywords are functions that you can call with a map as an argument. You can destructure them in `let` bindings. And so on. In my opinion, this turns out to be a pretty major win. Code is still data, it's just that this data is a mix of lists, vectors, and maps, and now you can type associative data structures into your code as easily as you can lists. Hash tables in vanilla Common Lisp are a nightmare (there is a nice library that at least gives a Clojure-y initialization option via Reader macro), and a glance at the Racket documentation suggests the story there is probably not much better. Clojure code in the wild uses the destructuring on maps a lot like, e.g. Haskell code uses pattern matching, and Spec is an interesting core library aimed at allowing libraries to insist that keys be present in maps and so on. Anyway, I had occasion to interact with some Common Lisp code I'd written several years ago, and I was struck by how annoyed I was at it for not being Clojure. Part of that is the Lisp-2 issue, but I also really missed how lightweight and easy Clojure maps are, and how easy they are to use for control flow. (I will say that Clojure's clunky recursion annoys me, but much less than trying to deal with Hash Tables in CL) Also, and I know you say you don't care about Java, but ... sometimes you have to interact with some annoying outside system (like, a database or a web browser), and there is a high-quality Java(Script) library that makes this task trivial and lets you work on what you want!
- joncampbelldev 9y agoAlso on the subject of clojure's data structures, they are all immutable by default (with structural sharing so changes are efficient, not just defensive copys). This greatly assists in writing functional, multi-threaded code. For original asker, see here for more details: https://clojure.org/reference/data_structures https://clojure.org/reference/data_structures
- flavio81 9y ago>Hash tables in vanilla Common Lisp are a nightmare I seriously disagree with such a statement. Also, i feel confused that a lisp being a Lisp-2 could be an "issue". Separate namespaces for functions, symbols, classes, labels and so on is great, because they dramatically simplify naming things, which is one very important task for writing clean, readable, maintenable code.
- adrianm 9y agoI am a big fan of all Lisps (you will pry my Common Lisp REPL out of my cold, dead hands!), but there is only one that which has elevated both my hobby and professional work into a realm I can honestly describe as fun and intellectually stimulating even years after the honeymoon period has waned. That Lisp is Clojure.
- geofft 9y agoI am planning on learning Clojure for essentially two reasons: the community / ecosystem seems very active (which is really my primary reason for picking a programming language; I have no interest in writing something if a library exists), and I've heard good things about a couple of things that distinguish it from other Lisps, like maps and spec. I'm somewhere between indifferent to unhappy that it runs on the JVM, but it's not a blocker for me. And as someone else mentions, it means there's pretty good access to the Java library ecosystem.
- simongray 9y agoThe good thing about Clojure is not that it's not married to the JVM. I think the JS implementation has been carrying the torch for the past year because of the many excellent front-end frameworks based on React, which are oddly faster than just using React in JS due to the code-optimisations performed by the ClojureScript compiler and Google Closure. It also has one of the best front-end dev experience in the shape of figwheel, which has become the default for all front-end dev in the language.
- oneweekwonder 9y agoSomething I like about it is that it runs on different vm's: java, .net and js. Not sure how usable the .net part is.
- puredanger 9y agoThe .net part hasn't released a version on parity with Clojure 1.9 yet, but it is up to date with 1.8. Not many people use it, but it is quite usable. The core was developed by Rich in tandem with the JVM version until Clojure 1.0.
- flavio81 9y ago>Can anyone sell me on why I should use clojure over say, any of the other nice Lisp-1s, given that I don't care about java. It's the same question I make myself, since after learning Clojure here I am, still using Common Lisp happily ever after. Well, if you think that data should be immutable by default, if you really need readymade syntax sugar for hash table and the likes, if you don't have any need for object oriented programming, not even once a year, and if you particularly don't feel any appeal for what is by far the most advanced OOP system out there (CLOS), if you love the Java ecosystem and need to be reminded of the J2SE libraries by using them directly all the time to do things other languages have built inside their own stdlib (but Clojure does not), if you don't feel wrong knowing that your code won't be compatible with the .NET CLR (or other platforms) without rewriting substantial parts, despite the language still being called "Clojure", if you don't know that basically all you can do with Clojure, including talking to Java (and also C) libs, and all sorts of concurrency things, you can also do with good old, high performance Common Lisp... ... then welcome to Clojure! Clojure is easy to learn, fashionable, well supported, and popular. I guess that if you are into developing single page applications, Clojure can be a neat choice.
- DigitalJack 9y agoWell that was condescending.
- flavio81 9y agoMore disillusionment than condescending. I jumped on learning Clojure waiting for big, nice surprises, new stuff, or an enlightening moment, but there wasn't any. I do, however, find it easy to learn and that's a good thing. On the other hand i am not really knocking down Clojure. If somebody wants me to do a project that requires interacting with lots of Java classes, I'm really glad Clojure exists, since it liberates us from plain Java. I am also glad that it's a good "gateway drug" to Lisps in general. I'm also glad that ClojureScript exists, perhaps this is the best part of Clojure. But Clojure is not really my cup of tea. I want wide options for mutable data (for performance reasons). I want multiple paradigms, including a powerful OOP system. I want easy recursion with tail call optimization. I want explicit, detailed error messages, etc.
- systems 9y agoIf you need to force yourself, or if you need extra special motivation to use Clojure .. most likely you will never use it You might spend sometime learning it out of curiosity, but you will never use it The languages I used, are ones I had to use, either because they were the only option, or clearly the best option for my solution (C#, VB.Net, Powershell, SQL) Clojure will never be your only option, and .. it being the best option is highly subjective I tried to like Clojure, because of all the blogs and talks, and the reputation of it being a smart language for smart people (I obviously, wanted to belong to this group, and still do) .. but for my work, and use cases (Business Intelligence), it will never be the best option, or the only option The same list that include Clojure, for me also include F#, D, Dart, Ada 2012, Idris, Julia, Rust .. I am sure since you asked this question, you have your own list too .. and you know, nothing will really work to motivate you
- jcadam 9y agoClojure is the best option for me, on my own projects, because I like it and I'm more productive in it (this applies to Lisp in general, I suppose) than any other language I've tried. And when I'm working alone, that's all that matters :D Now, when I'm working on a team... I must tell you I live in Florida and if I've ever met another Clojure/Lisp programmer in meatspace I'm not aware of it (and I'd be surprised). In fact, most of the Java developers I work with only really know Java (and some are helpless without Eclipse). So recommending anything that isn't Java probably wouldn't be wise. So, yea.
- 9y ago
- indigo0086 9y agoI think the age of convincing other people to use a language is over, you have to find that out for yourself, like I imagine many of use who love clojure have done.
- raspasov 9y ago+ exceptionally well designed "immutability by default": reduces accidental complexity to a minimum and lets you focus on the problem at hand + ClojureScript: allows you to write Clojure for any JavaScript platform (web, ReactNative iOS/Android, node.js) while writing 97% the same language excluding any platform-specific differences between the JVM and the JavaScript runtimes (V8, JavaScriptCore, etc) + piggyback on the entire mature+stable+performant JVM ecosystem of ... + tools (Maven >> npm, cocoapods, et al) ... + libraries (Netty, JodaTime, etc)
- _sdegutis 9y agoHaving spent 10,000 hours writing Clojure code professionally, I feel confident in saying that the main selling point for Clojure is that it's a simple dynamic JVM language with very little magic. If you don't need to use any Java libraries or have any hard requirements on deploying JAR files, then Clojure probably isn't what you need. Personally if using a Lisp-1 was a hard requirement, I'd be looking into Racket.
- titanix88 9y agoOne very important aspect of Clojure is lock-less, STM(software transactional memory) based concurrency that just works. In clojure, shared memory is readily available and with a few lines of code, you can get rid of entire third party projects typically used for in-memory caching, message-passing and background job processing. This is a huge win if you are writing long running server applications.
- flavio81 9y ago>readily available and with a few lines of code 1. Declare the classes you want to work under transactional memory as transactional... by wrapping them in such a way: (transactional (defclass ...)) 2. Whenever you need to do a STM transaction, just wrap the critical code within (atomic): (atomic (do-stuff ... )) Is it hard? Nope. The above example is one easy way to do it in Common Lisp, using the STMX library, which of course you can download, compile and load with one line of code: (ql:quickload "stmx") So yes, it is easy under Clojure, but not only in Clojure.
- thom 9y agoMight help to hear the man himself explain the motivations: https://www.youtube.com/watch?v=2V1FtfBDsLU https://www.youtube.com/watch?v=2V1FtfBDsLU
- cup-of-tea 9y agoYou should watch Rich Hickey's talk "Clojure for Lisp Programmers" https://www.youtube.com/watch?v=cPNkH-7PRTk https://www.youtube.com/watch?v=cPNkH-7PRTk https://www.youtube.com/watch?v=7mbcYxHO0nM https://www.youtube.com/watch?v=7mbcYxHO0nM
- escherize 9y agoYes! With this release clojure.spec is ready to go (tm). It adds a ton to Clojure(script), including better error messages (yes!), data-structure shape declarations, generation of data, writing quickcheck (generative) tests for a function by just describing the args and return values of functions, and more.
- karma_fountain 9y agoYes, but I'm confused. The website still says specs still in alpha so whats the deal? Is the spec api now stable?
- tensor 9y agoSpec is still alpha as far as I'm aware. They decided to break spec off into it's own library because it was holding up the release of 1.9.
- puredanger 9y agoThe API is still subject to change (alpha) but those changes are not expected to be dramatic at this point.
- roenxi 9y agoI'm looking forward to hearing a long-form rational of the :args :ret :fn function instrumenting decisions, and seeing if the devs see it as an easy choice or up for debate. It feels really uncomfortable declaring a full spec for a function & instrumenting it, then getting feedback if the args don't conform to spec but Clojure being A-OK if the return value doesn't. I understand well that in theory the functioning of a function can be fully checked in a proactive test framework, but the process for testing return values is way clunkier and less fun than testing argument values. It just seems weird that the function has a spec, the function doesn't conform and Clojure doesn't seem to be bothered. I can see it will only be a matter of days until I have Orchestra installed for all my projects.
- _sdegutis 9y agoWhy focus on command line tools? There's already Leiningen which does an amazing job, and Boot for the few use-cases Leiningen doesn't take care of. Creating another CLI seems very strange.
- _halgari 9y agoWell, for the first time since the langauge was created you can now do `brew install clojure`, and then `clj` on the commandline and get a repl. I would have loved something that painless when I was learning Clojure.
- bpicolo 9y agobrew install leiningen -> lein repl does exactly that
- _sdegutis 9y agoLeiningen has been incredibly painless: $ brew install leiningen $ lein repl That's literally all it took.
- systems 9y agoI agree, but it does take a while to figure out that leiningen exist And then you learn that not everyone use leiningen ... and things become a bit more confusing than necessary for some people, especially beginners
- _sdegutis 9y agoSorry but this whole conversation is a stretch. Anyone who looks into Clojure finds out about Leiningen. The official clojure.org even mentions it. No it's more than a stretch, it's rationalizing.
- puredanger 9y agoAs I mentioned at length in my prior answer, this was not the primary driver.
- disease 9y agoIs clojure.spec a replacement for static typing? I ask because I've taken a look at clojure in the past and generally like what I see, but after moving from JavaScript to TypeScript at work I don't think I can ever return to a dynamically typed language again. Types are just priceless when refactoring, integrating someone else's code with your own or just exploring new libraries or APIs.
- tensor 9y agoIt addresses similar problems as static typing, yes, but it's not a compile time check. Instead, it's an optional runtime check. The idea is to use it during testing and development, and have it be disabled during production.
- jeremiep 9y agoIts also great at validating data! We're running some of our specs in production to enforce guarantees on data coming in and out of the app :)
- misterbowfinger 9y agoYup, specs can be used at runtime as well. Very helpful to validate data, or perhaps a set of business rules. Insures the spec you use to test is the same logic you use at runtime.
- always_good 9y ago>specs can be used at runtime as well. What do you mean "as well"? I thought it was only a runtime check at all.
- simongray 9y agoOne of the stated goals of spec is generative testing. While technically runtime, it's is not runtime from the user's point of view.
- billfruit 9y agoHow is debugging support nowadays? Does it allow to spawn a repl at point of exception and examine locals? Is the Emacs based tooling become more refined?
- billburcham 9y agoclojure.core.server/start-server Will start a socket REPL at any point in your Clojure program. Unravel is a terminal-based REPL client you can use to connect to that REPL: https://github.com/Unrepl/unravel https://github.com/Unrepl/unravel Alternately, for a smooth interactive development experience, including the ability to set breakpoints on lines, there is Cursive: https://github.com/cursive-ide/cursive https://github.com/cursive-ide/cursive Cursive is a plugin for IntelliJ. There's a free community edition of IntelliJ that works great.
- thom 9y agoI'm disappointed that spec didn't get beyond alpha for this release. This worries me a little just because in the past a lot of stuff in Clojure releases has felt abandoned after a while - transducers were new in 1.8, but couldn't use the parallelism of 1.7's reducers (do we use them still?!) because of the way stateful transducers worked. I don't see this having been worked upon for this release. As it is, spec is pretty slow, and the implementation is a massive black box, with a ton of `(case op...)` on the inside making it almost impossible to extend in any sensible way for the moment. Beyond that I'm still really not clear on what the workflow with spec is supposed to be. I just don't verify code in the repl and then move on with my life, and there's no clear guidance on what a productive developer workflow for this stuff is. It doesn't help when every example of generative testing I see online omits the bit where you actually check a function does what it's supposed to. Anyway, love Clojure still, but in a way it feels like an ongoing dialogue that's over my head, rather than a programming language.
- billburcham 9y ago> do we use (reducers) still?! Yes, for the reason you cite: parallelism. See Alex Miller's recent comment here: https://clojureverse.org/t/reducers-what-are-they-for/1054/3 https://clojureverse.org/t/reducers-what-are-they-for/1054/3 > it feels like an ongoing dialogue that's over my head There's always Haskell: https://www.youtube.com/watch?v=6GNDzrgFhGM&t=23m34s https://www.youtube.com/watch?v=6GNDzrgFhGM&t=23m34s
- puredanger 9y agoThere have been things that were alpha parts of Clojure for years in the past. They were eventually finalized or in a few cases deprecated. Given that few people try alpha software, it's better to release and let people use it while the work is finished. I have no doubts that spec will finish and leave alpha. spec is one of the fastest libraries available for validation (http://muhuk.github.io/validation-benchmark/ http://muhuk.github.io/validation-benchmark/). spec is not designed for extension by making new kinds of spec. It's designed to utilize any predicate function on the bottom and by combination from the pieces available. By analogy, is LEGO bad because it's hard to make your own bricks? That's just not how you use it. There are some known problems that make generation slow (mostly having things that grow too quickly in combination). One known problem was fixed in the late stages before release and we will continue to work on the sizing issues. There is more to the generative testing story that has not yet surfaced. We've got another whole project related to this that is still a work in progress. Even without that, I think there is a lot of value to be had in spec right now.