
Clojure 1.8 - 147
http://blog.cognitect.com/blog/2016/1/19/clojure-18
======
jballanc
Be sure to follow the link to the full changelog
([https://github.com/clojure/clojure/blob/master/changes.md](https://github.com/clojure/clojure/blob/master/changes.md)).
In particular, a _huge_ feature that wasn't discussed in detail in this blog
post is the new socket server and REPL. In short, you can now get a REPL into
_any_ Clojure app by passing a flag on startup. Previously you would have had
to manually start a REPL server during app startup.

~~~
sdegutis
I'm really excited to see how this simplifies CIDER and the Clojure web app
tool chain, if at all.

~~~
dotemacs
This was already discussed by Bozhidar Batsov at last year's ClojureX talk:

[https://skillsmatter.com/skillscasts/7225-cider-the-
journey-...](https://skillsmatter.com/skillscasts/7225-cider-the-journey-so-
far-and-the-road-ahead#video)

I think that particular point is somewhere towards the end of the talk.

------
rev
Slightly off-topic: Packt Publishing offers Akhil Wali's book "Clojure for
Machine Learning" for free today ([https://www.packtpub.com/packt/offers/free-
learning](https://www.packtpub.com/packt/offers/free-learning)).

~~~
mej10
Thanks for that!

------
hcarvalhoalves
Solid. I would like to see better Clojure docs before 2.0 though. I can even
volunteer for a redesign.

~~~
rlander
Or just drop them completely in favour of Clojuredocs or Grimoire. New users
get very confused as to which resource is the official one (since the official
docs rank so low on G). Ie:

[http://clojure.github.io/clojure/clojure.core-
api.html#cloju...](http://clojure.github.io/clojure/clojure.core-
api.html#clojure.core/assoc)

[http://conj.io/store/v1/org.clojure/clojure/1.6.0/clj/clojur...](http://conj.io/store/v1/org.clojure/clojure/1.6.0/clj/clojure.core/assoc)

[https://clojuredocs.org/clojure.core/assoc](https://clojuredocs.org/clojure.core/assoc)

~~~
spinningarrow
This. As a new user, this still confuses me somewhat.

------
isnullorempty
I used Clojure for an small application last year and once I got up and
running (after watching many Rich's excellent videos and reading up) I got a
glimpse of how powerful bottom up functional programming could be, a
refreshing change from OOP. I wish Jetbrains would create a full featured IDE
for it.

~~~
edem
It looks like they just did: [https://cursive-ide.com/](https://cursive-
ide.com/)

~~~
AsyncAwait
It's not their IDE, but I agree that it is excellent.

------
jbeja
Congratulation, Clojure get better and better with each release.

------
georgewsinger
Has anybody tried the ahead of time compilation? Does it significantly reduce
script startup time?

~~~
mej10
Probably not enough to matter. Even if it halved the startup time it would
still be too slow for the tasks it is too slow for. Note: Clojure itself
performs fine, I am just talking about the startup time.

That being said, I use Clojure for scripting tasks frequently and it isn't so
bad. It just isn't as awesome as it could be.

POTENTIAL SOLUTION: I think for script startup time someone is going to have
to bite the bullet and write some kind of nREPL client in a language with no
startup time (Go, C, etc). Then you could just send code to be evaluated to
already running environments. You could use boot.pods to isolate the Clojure
runtimes. Seems straightforward-ish.

~~~
georgewsinger
You can also target nodejs with ClojureScript, which leads to blazing fast
scripts/startup time.

See as an example: [https://github.com/georgewsinger/yaml-
table](https://github.com/georgewsinger/yaml-table)

This script takes about 100 ms on my computer and about 2.25 seconds (!) to
run via pure clojure on the JVM.

------
votr
Congratulations! When is the 2015 State of Clojure coming out?

~~~
puredanger
Soon, just editing stuff before release.

------
Blackthorn
That change in linkage seems like it would have a serious effect on anything
that wanted to hook functions (like this library for doing it:
[https://github.com/technomancy/robert-
hooke/](https://github.com/technomancy/robert-hooke/)). Isn't the point of
rebinding that you don't necessarily know what you're going to want to rebind
ahead of time?

~~~
brandonbloom
There's a flag to disable the static linking if you need the dynamism.

~~~
Blackthorn
Does this work with jars you get via deps in your Lein project.clj file, like
clojure core?

~~~
puredanger
Direct linking is a compiler option so it affects any source you are compiling
with the flag on.

If the dependency jar has source files (.clj) and you transitively AOT compile
your app with direct linking, then yes.

If the jar has class files (.class) then you won't affect that dependency jars
calls within itself or out to other libs. But you can compile your own app to
directly link into a compiled dependency if it was compiled with Clojure 1.8
(and has the direct methods to call).

Clojure core itself is AOT compiled (that has always been true) with direct
linking on. So calls within clojure core itself are direct linked - how you
compile your own code to call into them is up to the choices you make when you
compile. Code compiled with direct linking actually retains both the direct
and dynamic call paths so this is always a compile-time decision.

------
edem
> Socket server and socket server REPL - adds the ability to allow remote
> Clojure REPL connections

Now _that 's_ something!

------
banku_brougham
I've been meaning to get my feet wet in Clojure, can anyone recommend a good:

A. Web tutorial intro B. Book

~~~
gantengx
Check out Clojure for the Brave and True -
[http://www.braveclojure.com/](http://www.braveclojure.com/)

~~~
brudgers
A reasonable recommendation. The book I'd recommend as an intro is
_Programming Clojure_. It can be found used for cheap.

~~~
edem
And after those you can try the "Joy of Clojure".

------
whalesalad
Good gravy we're still on 1.6 ... really need to put some time aside for the
upgrade.

~~~
mraison
Actually you may not need that much time, the 1.6 -> 1.8 upgrade is pretty
smooth!

------
segphault
Anybody know if this update addresses any of the issues with Java 8 interop?
It'd be really great if you could just pass a conventional Clojure function to
Java methods that expect to receive lambdas.

~~~
puredanger
No changes in that area.

------
TylerE
I like the idea of clojure a lot, but I just despise having to touch the Java
platform at all, everything is so over-engineered and bloated.

~~~
paulddraper
Care to add any specifics?

Looking at half of JS language features, I could say that's bloated too.

~~~
TylerE
Well, for a very first point JVM startup time STILL sucks, even with an SSD.

~~~
flippant
The JVM startup time is actually negligible. What you're seeing is the time it
takes to load the clojure jar.

~~~
TylerE
Does it matter? I don't experience this with nim or go or even python - but it
does show up with every jvm language, including clojure.

~~~
pjmlp
Don't blame the JVM for what it is a Clojure implementation problem.

[http://blog.ndk.io/jvm-slow-startup.html](http://blog.ndk.io/jvm-slow-
startup.html)

[http://martinsprogrammingblog.blogspot.de/2012/02/why-is-
clo...](http://martinsprogrammingblog.blogspot.de/2012/02/why-is-clojure-so-
slow.html)

If you program directly in Java it can be as fast as Nim or Go.

Granted, if you want AOT to native code, your only option is a commercial JVM.

~~~
merb
This post is really old. Even Scala has improved in startup time. I don't
think that numbers from 2012 are reasonable.

Especially when Java 1.8 will hit these languages. It reduces build times and
startup times since these lanaguages could share their bytecode when it comes
to lambda's and such things. With -Xexperimental on Scala 2.11 and changing
some things to lambda it will reduce the code size by 10-15% which is a lot in
such a big codebase. And I think closure will have such stuff, too. This also
means faster startup times. Also Java 9 and Java 10 will also help these
languages to improve.

~~~
pjmlp
So is Clojure 1.8 performance any better than those numbers?

For a long time I played with the idea of using it as common code between
Android and Windows Phone, but the performance on Android and outdated CLR
support demotivated me to pursue it, so it was back to C++11 (now C++14) for
common code.

~~~
merb
I'm not sure, I don't know how much Clojure 1.8 improved.

Currently this will bring a big one:
[https://github.com/clojure/clojure/blob/master/changes.md#11...](https://github.com/clojure/clojure/blob/master/changes.md#11-direct-
linking)

Also Clojure isn't tied to Java 8, it's compatible back to Java 5, so this
brings a lot of overhead.

~~~
puredanger
Clojure has required a minimum of Java 6 since Clojure 1.6.

~~~
merb
Still a lot of old code, and sorry for my misinformation. Java 6 to Java 8
will reduce code size by a order of magnitude. Even Scala will reduce code
size and Scala 2.12 is just amazing how good it fits to Java 8. I hope Clojure
will do the same.

We written a small ERP project and looking forward to have a calculation layer
in clojure.

