Clojure 1.10 release(clojure.org) |
Clojure 1.10 release(clojure.org) |
The language has been designed by experienced and mature people and doesn't go through "let's throw everything out and start again" phases like so many other languages do.
Swift was designed by highly experienced and mature compiler devs and is notorious for making breaking changes. It's just a difference of opinion. I prefer to suffer the occasional upgrade pain in exchange for clean and consistent APIs. And I totally understand those who don't want to deal with that.
Although to be fair to them, Swift is much younger than Clojure and the number of breaking changes has steadily declined with each major release. In seven years maybe they will take the backwards compatible approach too.
"Compiler devs". I think that is exactly my point. I should have said "app developers" or "system designers". If you listen to a Rich Hickey talk, you'll see that he is all about Getting Things Done in the real world, and much less about theoretical concepts. Language design is subservient to app developer needs.
I've got a Clojure book with a spirited defense of why it's good that the simple symbol + just does what you'd expect instead of throwing exceptions based on an implementation detail, and it kind of falls flat now.
New macros can very well be prototyped and battle-hardened in external libraries before being added to core.
More complex things still present you with overly complex errors, but with some painless repl usage it's way easier to figure out things now.
Kudos.
Nice work everyone!
For me personally, I think Clojure (or any lisp) targeting Go would be awesome.
The JVM lacks a killer Go "feature" which is _native binaries/easy deployment. Common lisp and many other lisps lack community which is why I think Go+Lisp would make a great combo. Go, even though it is a new language, already outpaces (a much older) Common Lisp as far as libraries go due to the huge community Go has.
I know there is `zygomys` but it doesn't reach Clojure popularity/maturity.
Can Clojure target Go?
Edit:
Maybe it is infeasible but I think targeting JVM, Go, and JavaScript would give Clojure a ridiculous advantage over almost any current programming language.
The JVM /= Oracle JVM by the way. There is OpenJDK
EDIT: Also I think recent Java releases have gotten into making self contained binaries (which just means they package the JVM...it's in there, it might jump out and bite you!). But, as long as you are careful what you are shipping, packing up a JVM has always been an option
Kotlin has Kotlin/Native, so I was hoping there might be a similar initiative for Clojure. But, a few reasons:
* Startup time
* Ability to deploy/share a binary
* The JVM just seems so "heavy" to me. It's certainly the only language runtime I know of that runs a persistent helper app, or asks to install an Ask toolbar upon installation.
* Bias against Oracle and Java
> Also I think recent Java releases have gotten into making self contained binaries
TIL, thanks.
Edit: edited.
Most lisps allows such live repls for debugging like Scheme and Emacs lisp, while clojure only provides a stacktace on exception, and not a repl.
The emacs based tooling had too many components, and is very brittle, ie, a minor version bump in one of the component often renders the whole build/repl process unserviceable.
Usage of local jars is extremely difficult, you need to setup a local maven repository and then add dependencies through it, which is a very painful process, esp for hobby projects and prototyping. I should be working on my problem not wrangling with maven.
Clojure bundles tools.deps since 1.9, and it works great. cljs and figwheel already supports it, as do many others. I prefer it to leiningen, but YMMW.
I use emacs to develop clojure, never had any problems with it :/
> Usage of local jars is extremely difficult, you need to setup a local maven repository and then add dependencies through it, which is a very painful process, esp for hobby projects and prototyping. I should be working on my problem not wrangling with maven.
tools.deps makes this very easy.
Sadly tools.deps lack the support for reading credentials from a gpg/pgp-encrypted file: https://dev.clojure.org/jira/browse/TDEPS-9 This is a shame as I rely on this to keep repository credentials safe. I'm not a fan of the maven master password system.
It can turn a Clojure app into a single executable with excellent performance and memory characteristics.
All major commercial JDKs have such support, e.g. PTC, Aicas, IBM J9, IBM RealTime WebSphere, Imsys, Excelsior JET.
Additionally OpenJDK has been integrating such support since Java 9 via Graal and GraalVM.
It's a Clojure dialect written in Go. Currently, its mostly used as a linter but you can also do programming/scripting.
no, it typically doesn't. in certain edge cases the JVM does out perform Graal though.
That said, if you're looking to get into the Clojure ecosystem in general, almost certainly not the place to start. You miss out on the multitude of good OSS libraries that have Java deps.
Looks like last update 3 days ago.
The issue here is that, based on the way they (particularly Rich) talk, we can expect they will not do Bloody Stupid things like the old Python 2->3 changeover. Things like big, breaking changes that require architectural changes to keep current, or break all the available tutorials.
If the problem can be fixed with a macro or single function (like a change to plus behavior) it is an irritant, not a threat to productivity. That is not a concern.
Engineering is all about compromises.
There's breaking changes and there's writing a new language. It's a spectrum.
There is also Perl 6, and I've recently read about Go 2. Swift changes every couple of months in incompatible ways.
use v5.24;
use feature 'unicode_strings';
use feature 'fc';
use feature 'postderef';
…
Note that the `'postderef'` feature is now always enabled so that line is pointless if you use a new enough version of Perl5. The `'unicode_strings'` also isn't always necessary.That was over 7 years ago, so not particularly recent. And you can get the auto-promoting behavior with +' instead.
It is a breaking change, that sort of change could introduce bugs into existing codebases. If that matters, you can't upgrade your Clojure version without careful change management anyway.
It isn't like reduce is being depreciated or something. I don't need to change how I think about the language.
There is also a lein (clojure build tool) plugin for this at https://github.com/taylorwood/lein-native-image
It's always fascinating when I encounter people with opposite biases to my own. While I'm no fan of Oracle, I seek out technologies that are based on the JVM and try to avoid things based on many other technologies because I intrinsically trust certain behaviors and features of the JVM that other ecosystems lack.
- maturity of the infrastructure (monitoring, debugging, IDEs, build tooling). I love that I can fire up my debugger and remote attach to a process running on some other host and set a breakpoint for a specific condition to catch a bug. Or that I can do the same to profile memory etc., all with very mature tools.
- very good performance - smack bang inbetween C/C++ and higher level languages (acknowledging that startup time is a big hole in that - but not an important one for me)
- truly cross platform - none of this python style, cross platform except half your packages are really written in C and won't compile unless an entire ecosystem of dependencies is there to support them, and even then some of the flat out don't work on some platforms. This extends deeper than most other languages ie: you can get closer to low level OS features while maintaining 100% cross platform capability.
- strong / static typing under the hood which you can access optionally (eg: languages like Groovy / Kotlin let you write high level code without being burdened too much by the overhead of static typing), but all the Java APIs, ecosystem of libraries are all statically typed so you have good guarantees and excellent documentation.
- deployment behavior - I can run the JVM, give it specified memory footprint and know it's going to stay within that
Java is not as bad as you think. Clojure does takes a little longer though
> Ability to deploy/share a binary
there are jar files, but I know what you mean.
Interesting work happening in GraalVM land: https://www.innoq.com/en/blog/native-clojure-and-graalvm/
> Bias against Oracle and Java
yeah, well ... we're all biased. It helps us make decisions quickly ;)
For example, I have a Python script[1] that runs on each command prompt to print status about my current git repository. Just timed it, it runs in .08-.12 seconds within a repo and about .02s outside of a repo. I still want to rewrite it in C using libgit2 someday, but something like that would be unusable if it was written in Clojure.
[1] https://github.com/kbd/setup/blob/master/HOME/bin/repo.py
Wouldn't any replacement need just as much "weight"? The GraalVM example (linked elsewhere) turns a 300KB Java program into a 25MB standalone binary. The JVM provides a lot of features, and they don't come free. That's why he chose it.
There are issues with a Graal-compiled Clojure repl due to reflection (apparently), but I think it's only a matter of time before those geniuses come up with something.
Rich's writing, presentations, and example of overall conceptual discipline and maturity have helped me focus on the essentials in ways that I could not overstate. I'm glad (but not surprised) to see so much appreciation for him around here, even among non-Clojurists (like myself).
At the risk of fanboyism, I am constantly referencing his ideas* to my team, and I give them my blessing to watch any of his talks as soon as they come out.
* That is, the old but sometimes obscure ideas whose importance he's brought to his audience.
In static FP languages, the exotic features being added are almost always demanded by users in the industry. As a fun fact for Haskell, developers in academia are more likely to stick with the Haskell 98 language for stability and compatibility.
As an example Simon Peyton Jones in a recent chat with Martin Odersky at Scala eXchange was describing how he was approached by developers at GitHub, who are using Haskell for language analysis, saying that they can't wait for GHC 8.6 because they want "quantified constraints", a new and very exotic GHC extension.
The "real world" you're talking about wants expressive static type systems where they matter. And the problem with static typing is that the language acquires more features and thus becomes more prone to suffering from backwards incompatible changes. And note that more features doesn't mean more complexity, rather it can mean more tools to cope with complexity, otherwise we'd all be programming in RISC assembly.
When it comes to Clojure, sure it's stable and that's a good thing, however it has no static type system (therefore it's apples versus oranges) and by encouraging people to work with raw data (e.g. everything is a list, a vector or a map) in a sense it's actually a step backwards from classic OOP.
Rich Hickey was fond of saying that OOP complects data with the operations done on that data. However the need for OOP's encapsulation and polymorphism came from the experience people had with procedural languages like C, and that experience has been forgotten, but the fact remains that some of the biggest software projects around are built with static OOP languages.
Correlation doesn't imply causation of course, it might be that such projects are built in static OOP languages because these languages are popular (chicken and egg issue), but at the very least we have empirical evidence that they work, whereas the empirical evidence for what makes LISP great pretty much doesn't exist.
Basically as an application grows, so do the data structures, being inevitable and to be able to cope with that: (1) you need good encapsulation and (2) you need the ability to do refactoring cheaply. And I think standard Clojure, like other dynamic or LISP languages before it, fails hard at both.
My point being that ... it's really not impossible to keep compatibility in a language that doesn't care much about correctness.
And I also believe that the "real world programmer" meme is a symptom of anti-intellectualism.
Static typing isn't a bad idea, but it wasn't implemented because it had interesting logical implications. Languages like, eg, C, used static typing because it is critical to the entire design of C that you know how large an object is in memory, and that like is where I suspect most of its popularity comes from - I assume that to write high-performance code, you need fine-grained to control RAM. For the benefits of a static type system, Clojure is decoupling that implementation detail of size from the interesting logical implications of dynamic typing using the spec library (which has been present since 1.9.0, and is likely to be a pretty strict improvement on static typing for anything except raw performance). I doubt it is the first language to do that, but it is the first I've used.
As for encapsulation and refactoring it would be interesting to hear about where you think it falls down. I havn't used the language for anything large-scale, but for personal projects Clojure's approach to encapsulation with protocols is far more likely to capture what-I-actually-wanted than an inheritance system like the classic model in C++. Clojure makes it at least as easy to refactor as any other language.
Basically, Clojure cares a huge amount about correctness, that has been a focus for 1.9.0 and now 1.10.0. They just think that static types are a bad way of solving for correctness, because static typing puts a bunch more constraints on an object than are required.
I disagree. I would say it is actually easier to write performant code in lisps than in other languages. In languages with traditional syntax (ie. not homoiconic) it is usually tradeoff between performance and readability. As soon as you try to maximise performance, the program starts becoming unreadable.
In lisps, on the other hand, due to how you can have full control over every aspect of translation between notation and generated code it is much easier to write programs that don't hurt performance just because you want nice notation or DSL.
As an example, take printf. This function makes it easier to format strings and is available in many programming languages.
printf("%d", 7)
If no special compiler optimization is used (ie. compiler having hardcoded optimization just for printf) this results in code that will have to parse "%d" every time just to figure out, every time, it needs to take next argument and output it as integer.
On the other hand typical Common Lisp format macro looks very similarly:
(format t "~d" 7)
but you, as an author of a macro, have option to figure out that the format is an immutable string, so you can, at the compile time, replace call to format with an equivalent call to a simpler function that will take integer as an argument and immediately print it. This way you don't have to parse the format string every time and you don't have to pay for an extra stack frame as the expanded form of the macro takes place of the macro invocation.
For another example take a look at Peter Seibel's Practical Common Lisp chapter on parsing binary files (http://www.gigamonkeys.com/book/practical-parsing-binary-fil...)
This chapter shows a system of macros that take very high level of description of binary data structures and generates efficient code to parse, access parsed data and serialize it to the binary format.
In a typical language the requirement to have flexible description of the messages would likely result in a compromised performance. This is why so many "high performance" solution involve some variant of code generation but at the cost of additional complexity.
Standards must be low if that's now "deification" :)
Listen to some of his talks and you will see why people respect Rich.
Hi Trevor,
funny that you should say that - I've met Rich Hickey and had some great conversations with him - and what I always tell everybody is how normal, humble, human, down-to-Earth he is. (Which is probably deifying him even more, from your point of view).
But, although my current manager is excellent at supporting his team and would never think such a thing, let alone say it, the truth is that, unless you're a professional researcher, you really do have to do the hammock-driven thing on your own time, either by working it into your routine or by taking a long sabbatical (as Rich did). It's something I struggle with, even at a very good workplace.
"Nothing is more precious" than the chance to think through a problem over a long term, and as things stand, the best tool for thinking is still the mind, not the keyboard. I can see how that takes a leap of faith when your chief deliverable is code.
Anyway, maybe a better introduction for your typical manager is,
> The most expensive problems are problems of misconception.
That would be code as carpentry development model. Often encouraged by career managers.
There are plenty of those in the industry, people who have had rapid promotions before they could do non-trivial engineering work.