
Clojure: The JFDI language - michaelochurch
https://docs.google.com/presentation/d/15-7qFy6URdE7Owi2LitkQI_OHBu1AFWPUwHxgBc-O4E/edit?usp=sharing
======
davidp
I enjoyed the presentation very much, until

    
    
        "Engineers 3-10x more productive"
    

Citation needed.

If this were generally true (of any technology X) the dollars would be flowing
that way in an unstoppable torrent, and anyone using anything else would be
the subject of ridicule and/or pity. It would be like writing custom websites
in C.

Since that isn't happening, I have to take assertions like that with a sizable
chunk of salt. The alternative would mean that there's a gigantic arbitrage
opportunity that's being missed by a bunch of highly motivated people. So
yeah, citation(s) please.

~~~
danenania
The reason is simply that more powerful tools require more skill and
experience to use effectively. It's not just a question of switching from
imperative language X to clojure and seeing a huge productivity boost. You
must also understand why clojure is designed the way it is and how to use it
effectively. For awhile, you'll likely be less productive as you learn how to
approach problems functionally and wrap your head around the capabilities of
lisp, but you'll also be building stronger, more reliable systems, and at the
end of the learning process, you will indeed be significantly more productive.

Managing a transition like this is far from trivial for a company facing a
variety of immediate demands and constraints, even if it promises to pay
dividends in the long run.

~~~
craigching
> It's not just a question of switching from imperative language X to clojure
> and seeing a huge productivity boost.

It depends on who you are. I recently used Clojure on a skunkworks feature for
our product for which I had three days to complete. I am absolutely convinced
that it was at least 3x smaller (LOC) and took me at least 1/3 of the time it
would have taken in Java. I am an expert Java programmer and not a newbie to
Clojure, but I still have to look up a lot of things.

The killer productivity feature of Clojure (LISPS and other languages) is the
REPL. Trying things out, analyzing data structures, etc. is where I would have
spent a _ton_ of time in Java. Even if you're not an expert Clojure
programmer, just using the REPL can save you tons of time.

So not necessarily disagreeing with you, but I also think that a non-expert in
Clojure can still run circles around an expert Java programmer when
considering productivity.

~~~
rossjudson
I'm not disagreeing with you, but exactly what is it that you're doing in the
REPL that you're not able to do in, say, Eclipse's Display view while having
changes pushed into your program under debug (when it's able to)? Java
disallows pushing some changes into the VM, but many changes go right in
during debug.

~~~
yogthos
It's not about what's possible in principle, but whether the tools facilitate
a certain workflow. When you work in Clojure everything is interactive. You
can write a function evaluate it immediately, see the result, use it in the
next function and so on.

The workflow is very natural and you practically never have to restart
anything. You can build up state in the application, see how things interact,
reload functions add new functions, and so on. Using a debugger in Eclipse is
a very pale imitation of this.

~~~
craigching
Thanks Yogthos, that is pretty much exactly how I would have responded :)

------
danenania
Thanks for this. It's a great overview that manages to be both detailed and
easily accessible.

Your visual approach to explaining macros with arrows to demonstrate the
substitutions also really helped me to grok them in a way I haven't been able
to previously. They are actually quite simple aren't they? It's basically the
same idea as html templating, but outputs code instead of markup.

I'd love to see you get more in depth on some of the headier topics--
core.logic, monads, storm/hadoop interop, etc. You seem to have a gift for
making difficult concepts approachable.

~~~
brandonbloom
To be clear, that ` character is called "syntax-quote" (in Clojure; "quasi-
quote" elsewhere) and it's the "templating" part. It's both possible and
common to use macros without syntax-quote and vice versa.

In fact, common practice in Clojure is to define a your macros in terms of a
backing function:

    
    
        (defn foo-fn [body]
          (fancy stuff here that probably uses syntax-quote somewhere))
    
        (defmacro foo [& body]
          (foo-fn body))
    

Clojure's style of macro system is known as a "procedural" macro system
because the macros can be any arbitrary procedures which returns code as data.
There are other types of macro systems, like Scheme's syntax-rules, which are
more directly embrace the fact that most macros are tree rewrites.

~~~
chc
Syntax-quote is a little bit different from quasiquote. Clojure's macros
_look_ a lot like Common Lisp's unhygienic macros, but Clojure's syntax-quote
offers a sort of "hygiene by default" by forcing namespaces on variables and
making it hard to introduce non-gensym symbols accidentally.

~~~
brandonbloom
Hence this project:
[https://github.com/brandonbloom/backtick](https://github.com/brandonbloom/backtick)

------
sandGorgon
Question - there was a recent post about how the dailymail group moved 140k
lines of java code to 4k lines in clojure.

Since I have never programmed much in Java (I went from c++ to ruby!), could
someone tell me where the gains are coming from ?

I know that eliminating the setters and getters (and the private/protected/etc
system) would eliminate a lot of code, but I dont understand if it would be
_that much_.

Possibly, I'm also trying to understand if they would have gotten similar
improvements in kloc if they had switched to.. ruby/python for instance.

~~~
cliftonc
Hi, I'm the CTO at the MailOnline so can comment. The biggest reduction in loc
was due to the move from a relational DB to elastic search containing flatter
representations of our content. This basically meant that we could delete
thousands of lines of boilerplate and create a very simple processing pipeline
to render content, and for this clojure really shines of course.

The REPL made the first week of exploring the problem and solution space
really effective, and even as a node guy I was impressed with what could be
done.

I can say that there is definitely a big productivity boost, but as others
have said it isn't purely the language, but rather thinking about the problem
in a completely new way that really did it. I do credit clojure though with
giving our engineers the ability to think differently, as that is often the
hardest part.

There was a comment I made in a speech recently about functional programming
being frictionless for content management system design, this is what I was
alluding to.

I don't want to start a flame war, but we built an earlier version in ruby
(with one of the best OO guys I know leading it), and it was much more complex
through attempting to model our home page as a set of inter related objects,
using visitor patterns to traverse etc., than the clojure version.

~~~
sandGorgon
very interesting. I had a similar experience with elasticsearch in modelling a
ecommerce catalog - however that was with jruby. In fact, it took me quite
some convincing to not go with something like mongodb - elasticsearch served
us quite well.

Could you comment a bit more on the interaction of functional programming to
content management ? Intuitively, it feels to me that a lot of it has to do
with the NOSQL-like data model of elasticsearch. Being a lisp beginner, I feel
that a visitor pattern is very analogous to "map" in functional programming -
again, without all the OO getter/setter functions (e.g. "accept", "visit").

~~~
cliftonc
A lot of the simplification was definitely down to flattening the structure
that was represented in 20-30 tables down into a smaller set of documents in
ES. But the functional approach to then rendering these documents simplified
it further.

A functional map is definitely analogous to a visitor pattern, but don't
underestimate how much of a productivity boost arrives by being able to see
all of the code in a small set of terse statements in one place, vs having a
set of fairly abstract classes with accept/visit scattered all over the place.

We just found that the OO solution resulted in more code and it was more
difficult to hold the resulting model in your head as the number of things
that could be visited grew - we run a very big site.

The other big enabler vs a traditional CMS approach is that we have a very
clear separation between the part of our stack that allows editors to create
content, and the part that renders it (connected via messaging) - so we aren't
mixing r/w domains and our rendering pipeline isn't burdened with the
additional complexity of having to understand how content changes, it just
renders what it is given as fast as it can.

------
johnwalker
The misconception list basically summarizes the interactions I have with
people who know I use Clojure. It's really interesting that these are still
around, especially considering that lisp hasn't been new for a long time.

As an aside, I loved the chrono trigger reference! I was actually listening to
some of its music as I viewed the slides.

I know this is old hat for the FP community, but it's worth mentioning that
the dot product would be normally be written as (reduce + (map * xs ys)) (or
something similar) for the sake of readers scared by the loop acc pattern.

~~~
michaelochurch
_It 's really interesting that these are still around, especially considering
that lisp hasn't been new for a long time._

People want to believe the world is simple, and that learning one PL is
enough. Once you know Java, why learn another one? Either they're all the
same, or they're so radically different they must be weak in some critical
way.

When you grok Lisp, and realize that it _is_ actually practical, you realize
that you've only scratched the surface of the PL problem... and that's scary
for a lot of people, especially as there's a tendency to overestimate the
barriers between languages. (The Internet runs on components written on all
sorts of different languages.)

 _it 's worth mentioning that the dot product would be normally be written as
(reduce + (map _ xs ys))*

Yes, I had that thought, too.

In fact, that formulation is too slow for, say, large-scale ML. I've been
getting a lot of mileage out of Prismatic's hiphip library... and I really
look forward to, about 5 years from now, when Clojure is as mature for numeric
programming and ML as Python is with Numpy, Scipy, Numba et al.

------
wuschel
(Disclaimer: I am a python that found a new home in the scheme world)

Clojure is a Lisp. Lisp based languages are great.

However:

One of the problems with clojure - or rather with its home or ecosystem - is
the fact that it requires a very high activation energy to get going. Grasp
the concept of functionial programming, cc/call, macros, totally different
syntax than your previous imperative language of choice, and last but not the
giant blob that is called Java platform with all the traps regarding project
management, IDEs, building, compiling, deploying etc. I know that there are
great tools such an Leiningen or LightTable, but they only make the whole
process of transition more manageable.

Now, I know that Java is a huge benefit for all that want to make use of its
gazillion tools. But if You are not into Java, then Clojure might give you
some hickups.

In comparison to Clojure, Python also allows for some functional programming,
gives the eager disciple an easy going start. Most of libraries are written in
Python (or exist in a fast, a C-esque implementation) and are very easy to
grasp. I can not say that for the Java enviroment Clojure has been born into.

I frown at java lingo error tracebacks in the REPL, and to bring a external
Java library into play is even more problematic. Any thoughts on this how to
remedy this problem without getting involved into Java?

I wish there would be some kind of Index of how to use certain Java libraries
from Clojure, or an index of Clojure wrapping packages. It might make life a
bit easier.

Finally, I claim that for now, I am quite happy with my choice to migrate from
Clojure to Chicken Scheme/picolisp. You can get quite a bunch of Clojure data
types from the good package repository. It compiles without setting your hair
on fire. And it is really simple, as the language basics are small.

I will keep an eye on Clojure. but I must say that Julia is as appealing to me
when it comes to the choice of future language.

~~~
john2x
Agree on the Java ecosystem. I deployed a toy app using Tomcat a couple of
months ago, and now I have no idea how to update it. I lost the "tutorial" I
found and can't remember what it was (stupid mistake), but still, the fact
that I had to resort to a pretty unknown tutorial to deploy something shows
how desperate I was.

I'm looking for another language with similar philosophy to Clojure's, but
with a better ecosystem.

~~~
chc
FYI, you could have just used http-kit. If you don't want an enterprisey
ecosystem, don't use the enterprisey stuff. That's how I use it.

~~~
john2x
Hmm not really clear what it's for. Is it a replacement for Jetty/Tomcat?

~~~
chc
http-kit lets you run your own app server like Node.js does instead of
sticking it in a servlet container. You just call run-server and you've got a
working web app. So yeah, basically a Jetty replacement, but it's less tied
into the Java ecosystem and more into Clojure.

~~~
john2x
Oh ok. Not familiar with Node.js but if it means getting out of Java then
definitely worth a deeper look. Thanks. Have any links to quickstart type
tutorials? Something that allows someone to deploy a (toy) webapp?

~~~
danneu
Clojure has a simple scratch->toyapp->deploy workflow. It's just that to find
it as a newcomer, you either:

A. Luck out and find it immediately.

B. Get directed to it by someone more experienced.

C. Chase a suboptimal solution because you don't know better. You simply don't
know there's an easier workflow. You don't know you can eval code within an
editor. You don't know there are tools like paredit or how they'd help you.

For toy webapps, it's good to know these incantations:

    
    
        lein new compojure myapp (creates webapp skeleton)
        lein ring server (starts embedded server for dev)
    

Here's the live demo of a dumb app I threw together to take an IRC joke too
far: [http://www.danneu.com/spinners/](http://www.danneu.com/spinners/)

And here's the Clojure code: [https://github.com/danneu/spinners-as-a-
service/blob/master/...](https://github.com/danneu/spinners-as-a-
service/blob/master/src/spinners_as_a_service/handler.clj)

To deploy it, I rsync the repo to a remote server, run `lein uberjar`
remotely, and launch the uberjar.

That repo shows how to use Compojure for routing, Hiccup for html,
Clojurescript, and a few incantations (like `:genclass`) to get it working.

------
eklavya
I don't get it. Scala has all the features, it's fast AND it's easier to read
(no matter how much the presentation tries to play down the () issue, it's
there.)

Why not use Scala insead?

~~~
krat0sprakhar
Can't agree with this more. All the plus pointed touts for FP are available in
Scala without the necessary mental context-switch that is required to grok the
parenthesis extravaganza. Why Clojure instead of Scala?

~~~
dm3
The 'easier to read' part is valid maybe for the first week of working with a
Lisp (commenting as a part of a team which switched from mostly-Java to only-
Clojure several months ago).

Pros for Clojure:

* Faster code -> result cycle. No need for compilation (except for AOT-compiling releases).

* Absence of static typing helps in some of the domains, e.g. web applications. We have successfully used Prismatic's Schema[1] in places where a stable data interchange format was needed.

* Binary compatibility. No need to recompile libraries for different Clojure versions.

* Community oriented towards simplification. People mostly try to mimic Rich Hickey and Clojure.core development approach.

* Orientation towards small libraries. I haven't yet had a need to use a framework written in Clojure (although Pedestal[2] seems interesting).

[1] [https://github.com/Prismatic/schema](https://github.com/Prismatic/schema)
[2] [http://pedestal.io/](http://pedestal.io/)

~~~
lmm
How complete is core.typed? Does it have a good story for scala type features
I've come to depend on (covariance, some kind of typeclass-like functionality,
higher kinds)?

~~~
dm3
Core.typed appears to have some higher kind and variance support (as seen in
the user guide - [https://github.com/clojure/core.typed/wiki/User-
Guide](https://github.com/clojure/core.typed/wiki/User-Guide)).

Type classes can be mimicked via multimethods or protocols.

------
coolsunglasses
It's not really accurate to think of core.async as mutable state at all,
because by default channels are only queues in the sense of implicit waiting
go blocks forming a queue.

Unless you use a buffer implementation, channels have no "placeness", you're
not mutating/adding to a queue by parking a go block.

I liked everything else.

~~~
michaelochurch
Yeah, a couple of other people pointed that out.

core.async has state (when buffers are used, in particular) but state is not
exactly the same thing as mutability. Producers and consumers don't have
unconstrained access to channels, in the way that users of a mutable cell (a
Clojure atom, a ref cell, or just a variable in many languages) can clobber it
at will.

Likewise (although I didn't get into this) state doesn't necessarily violate
referential transparency. Memoization uses state as an optimization, but
doesn't interfere with RT.

~~~
coolsunglasses
>Likewise (although I didn't get into this) state doesn't necessarily violate
referential transparency.

Boy do Haskell users ride that one hard.

------
ninetax
Are there really more Clojure jobs than programmers? As a clojure programmer
looking for a job I haven't seen many...

Wish there were more though!

~~~
michaelochurch
I said the opposite: more programmers than jobs.

That might change. Clojure's been making some pretty impressive in-roads into
the enterprise.

At this year's Conj, there were a fair number of companies hiring. Staples
Innovation Labs is apparently hiring a lot of Clojure people.

What part of the world are you in?

~~~
ninetax
edit: well after actually reading your comment, I see now what you said :).
Yes that seems like a good reason for companies to adopt Clojure, I hope they
do.

Ah, yeah, I really wanted to go to Conj, but only found out about it last
minute. I'm in San Francisco.

It's not that there are no companies using Clojure, it's more that the
companies where I do want to work, don't want to use it.

When I mention it in an interview or something they kind of give me a funny
look like they hope I am not one of those LISP people. I mean I can see where
they're coming from. It's a big risk to let someone write in a language you
don't know much about, and that you don't know if you'll be able to hire for
in the future.

And at the places where they _are_ feeling a bit adventurous, everyone seems
to be leaning towards Go :(

Oh well, I can still use it for all my side projects until it gains more
popularity I suppose. It really is such fun to use. I only started 2 months
ago and I have been having the best time of it.

~~~
puredanger
We are planning Clojure/West to take place in San Francisco in the spring
(April-ish timeframe).

------
vorg
> Functional programming has two simple, elegant design pattern that don't
> suck: noun and verb.

I'd add adjectives (including adverbs), which is the metadata on the nouns and
verbs.

~~~
dscrd
Interesting point. I wonder if it would have an effect on how non-programmers
view coding if programming language constructs were renamed like that.

~~~
lhnz
I could teach a student with good language theory to program faster this way,
but other students probably not...

------
yresnob
Great overview..

from direct work experience in building complex systems in clojure....I agree
with all the statements made in this document...

I am a better developer because of it and will look at things differently if I
need to pick up java or scala again..

and I will also make sure to always "get in the hammock" before writing a line
of code..

------
saosebastiao
Interesting to see you mention Supply Chain Optimization. Other than myself, I
know of only one other person that actively uses it for the task. Is there
some hidden community that I'm not aware of?

~~~
dm3
Curiosity took the best of me. Could you elaborate, please? Where are you
actively using SCO?

~~~
saosebastiao
I use Clojure for a lot of analysis, modeling, protoyping and optimization for
supply chains (I work in Amazon's Supply Chain). The presentation mentioned
that Clojure was used for SCO, and I was curious jf there was some community
of supply chain users of Clojure somewhere because AFAIK I'm one of two people
that use it for SCO.

~~~
speek
We use it at my company, Weft -- we're building Waze for Cargo. Shoot me an
email (marc@weft.io) and we'll try to get a Clojure for SCO group going! There
are at least a few of us hacking away on that kind of stuff.

------
swah
Related to this is the Erann Gat "How I lost my faith in Lisp" story[1]. He
was also a googler but going the other way. Of course, this is quite old
(before Clojure). But the points remains...

[1]
[https://groups.google.com/forum/#!msg/comp.lang.lisp/L5dZ-j6...](https://groups.google.com/forum/#!msg/comp.lang.lisp/L5dZ-j6Id-s/9tOJorXPdW8J)

------
joelgrus
This is a really nice overview of Clojure, thanks.

------
EdwardDiego
Cheers for a great synopsis that I intend to inflict upon my coworkers at the
first available opportunity. :D

------
turar
Is there a web framework for Clojure similar to Play for Scala?

~~~
yogthos
Closer to Sinatra or Flask, but you can always check out
[http://www.luminusweb.net/](http://www.luminusweb.net/)

~~~
turar
Thanks! I found an interesting discussion on the topic here as well:
[http://grokbase.com/t/gg/clojure/131bp962q1/full-stack-
cloju...](http://grokbase.com/t/gg/clojure/131bp962q1/full-stack-clojure-web-
rest-framework-is-there-any-mileage-in-it)

