How to structure a Clojure day for noobs?

319 views
Skip to first unread message

ulsa

unread,
Dec 15, 2012, 5:13:21 PM12/15/12
to clo...@googlegroups.com
In a couple of months, I'll have a whole day of teaching Clojure to ten of my colleagues. They are experienced Java programmers, but otherwise Clojure rookies. Any tips on how to structure such a workshop day?

Marko Topolnik

unread,
Dec 15, 2012, 5:57:48 PM12/15/12
to clo...@googlegroups.com
There is one advice I can give from my teaching experience: don't overwhelm them with data. A person can assimilate only so many concepts in a day, no matter whether the workshop lasts two or eight hours. 

Pick a few key concepts and spend much time on approaching each concept from many different angles. Have everyone involved with exercises. Make layered exercises: each of those ten people is going to progress at their own pace. Allow enough time for the slowest ones to get through the basic part of the exercise, but have a stash of extra stuff for the quicker ones, so they don't get bored and frustrated while waiting on others.

ulsa

unread,
Dec 16, 2012, 3:30:16 PM12/16/12
to clo...@googlegroups.com
Good points, thanks. 

It's so easy to overload them, because one wants to teach them every little piece of gold that's in there. I think it was in one of the old XP books, where there was this graph that showed which practices were supported by or enabled other practices. I would love to see something similar for the capabilities in Clojure. It would make it easier to see what can and can not be cut out from an introduction course.

My plan was to do something like this:

First half of the day

1. install Leiningen and learn the basics
2. get everyone an editing environment, with the option of using either Emacs, IntelliJ, or Eclipse
3. teach the basics and let everyone follow along in their own environment

Second half of the day

Either: solve a smaller problem, like Game of Life, Langton's ant, or something similar
or: just build a Compojure web app, and incrementally improve this, and have it deployed in CloudBees or Heroku

There are a few basic things that I think they need to see:
  • how do I get started
  • how is code modularized and packaged
  • how can it be deployed and executed
  • how does Java interop work
  • how do I handle the regular problems I have previously used for-loops to solve

Marko Topolnik

unread,
Dec 16, 2012, 3:44:33 PM12/16/12
to clo...@googlegroups.com

My plan was to do something like this:

First half of the day

1. install Leiningen and learn the basics
2. get everyone an editing environment, with the option of using either Emacs, IntelliJ, or Eclipse
3. teach the basics and let everyone follow along in their own environment

Second half of the day

Either: solve a smaller problem, like Game of Life, Langton's ant, or something similar
or: just build a Compojure web app, and incrementally improve this, and have it deployed in CloudBees or Heroku

Given this choice I'd go with the web app because it 
  • has greater impact (a publicly visible app) and 
  • doesn't involve the dullness of desktop GUI 
There are a few basic things that I think they need to see:
  • how do I get started
  • how is code modularized and packaged
  • how can it be deployed and executed
  • how does Java interop work
  • how do I handle the regular problems I have previously used for-loops to solve
Quite a good plan. Of course, don't forget the REPL :) 

Devin Walters

unread,
Dec 16, 2012, 4:58:56 PM12/16/12
to clo...@googlegroups.com, clo...@googlegroups.com
I think showing people how metadata works usually makes people start dreaming, and exposes them to docstrings and arglists which I think is crucial to self-directed learning.

So, I think I'd show them: (doc ...), and then show how that is metadata, and for quicker folks you could show how to add metadata, use ns-publics which means introducing var-quote, etc.

There's a lot in that exercise that's exciting IMHO. If you want help organizing something like that ping me privately.

Cheers,
'(Devin Walters)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ulsa

unread,
Dec 16, 2012, 5:55:02 PM12/16/12
to clo...@googlegroups.com
Thanks, I won't forget the REPL. 

I think, however, that there is a risk of a disconnect, where newcomers don't really grasp that there is a JVM running and that code is actually compiled and injected into it, and that it's for real. They are used to mickey mouse interactive tools that don't provide the real thing, and struggle to bridge the apparent gap between running code in the REPL and "properly compiling and running" files. There is no gap, but one needs to explain that, I think.

"When in doubt, lein repl."

ulsa

unread,
Dec 16, 2012, 6:01:08 PM12/16/12
to clo...@googlegroups.com
Interesting idea. Let me ponder that.

When one starts pulling on a thread like metadata for example, all kinds of interesting facets pop up. That's what I meant with my comment about the XP practices graph thing. Different Clojure capabilities support and enable other capabilities, and you need to be prepared to explain those other capabilities. They're all (well maybe not all) interconnected and I think it's hard to know which thread to start pulling on.

Marko Topolnik

unread,
Dec 17, 2012, 3:26:30 AM12/17/12
to clo...@googlegroups.com

I think, however, that there is a risk of a disconnect, where newcomers don't really grasp that there is a JVM running and that code is actually compiled and injected into it, and that it's for real. They are used to mickey mouse interactive tools that don't provide the real thing, and struggle to bridge the apparent gap between running code in the REPL and "properly compiling and running" files. There is no gap, but one needs to explain that, I think.

I think this is a pivot point for everything in Clojure. The harder the mental switch, the more important to make it right away. Without understanding that, it will be very hard to maintain a clear picture of how everything fits together, especially when you start changing functions and reloading them. 

Peter Buckley

unread,
Dec 17, 2012, 10:31:32 PM12/17/12
to clo...@googlegroups.com
1. install Leiningen and learn the basics
2. get everyone an editing environment, with the option of using either Emacs, IntelliJ, or Eclipse

I would have people do this in advance, or provide a canned environment that has a better chance of "just working". There's decent odds that these two steps will eat up a bunch of your time and leave people feeling left out when their install/editor/integration is not quite right.

Personally I found the C-x-e of evaluating an s-exp in emacs to be the magic that makes clojure a bajillionty times better than any other programming language, so I'm partial to something like the emacs starter kit. But something like labrepl or eclipse+counterclockwise might be easier for people to start with.

On Mon, Dec 17, 2012 at 3:26 AM, Marko Topolnik <marko.t...@gmail.com> wrote:

I think, however, that there is a risk of a disconnect, where newcomers don't really grasp that there is a JVM running and that code is actually compiled and injected into it, and that it's for real. They are used to mickey mouse interactive tools that don't provide the real thing, and struggle to bridge the apparent gap between running code in the REPL and "properly compiling and running" files. There is no gap, but one needs to explain that, I think.

I think this is a pivot point for everything in Clojure. The harder the mental switch, the more important to make it right away. Without understanding that, it will be very hard to maintain a clear picture of how everything fits together, especially when you start changing functions and reloading them. 

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en



--
The king’s heart is like a stream of water directed by the Lord; He guides it wherever He pleases.

ulsa

unread,
Dec 18, 2012, 5:27:34 AM12/18/12
to clo...@googlegroups.com
Good point. 

I really would like themselves to be able to set up their own environment. I think it gives them a sense of control. However, as a fallback, it would be great with a virtual machine with everything working. I'll consider that.

I believe you can get a similar level of interactivity in both IntelliJ and Eclipse, but I agree that Emacs is still the master.

Nando

unread,
Dec 19, 2012, 2:38:05 PM12/19/12
to clo...@googlegroups.com
What about Clooj? http://dev.clojure.org/display/doc/getting+started+with+Clooj

Is it too buggy, or lacking in features, to start out with?
Nando Breiter

Aria Media
via Rompada 40
6987 Caslano
Switzerland


Thomas

unread,
Dec 20, 2012, 11:16:19 AM12/20/12
to clo...@googlegroups.com
If you need to touch on the why of Clojure I found the example in the beginning Stuart Halloways book quite a good one. the isBlank in Java and the one line blank? equivalent in Clojure. Show them the Java, talk it through with them and then highlight some of its downsides (multiple if statements, the loop, local variables, the fact that the two statements in the first if with can only be ordered in that way etc). and then show them the clojure code, talk them through that and show them what it better (even if functionally completely equivalent) about it.

just a thought,

Thomas

Seth Chandler

unread,
Dec 20, 2012, 9:55:46 PM12/20/12
to clo...@googlegroups.com
I would spend A LOT of time on working with the IDE be it Eclipse/Counterclockwise, IntelliJ or whatever.  In my limited experience the main impediment to Clojure is not Clojure itself, which is very sensible, but in dealing with file locations, dependency management, projects, Leiningen, all of which are -- with due respect -- very difficult, particularly for people not coming from an Eclipse or similar background.  Once you have the confidence that comes with understanding your IDE, you can learn Clojure by playing and by reading idiomatic code.  Until then, however, Clojure development can be VERY frustrating .  Maybe this will all go away once we have better IDEs (LightTable, Session) full developed, but until then don't just "assume" that people understand the IDE.

Brian Marick

unread,
Dec 20, 2012, 10:14:41 PM12/20/12
to clo...@googlegroups.com

On Dec 20, 2012, at 8:55 PM, Seth Chandler <chandl...@gmail.com> wrote:

> but in dealing with file locations, dependency management, projects, Leiningen, all of which are -- with due respect -- very difficult, particularly for people not coming from an Eclipse or similar background.

In my book, I decided to have everyone work at the repl, using only cutting-and-pasting or `load-file`. It's a 325-page book that never talks about namespaces or the `ns` macro.

The beginning instructions about how to do the exercises looks like this:

> You can copy and paste Clojure text into
> the repl. It handles multiple lines just fine.
>
> [… a note about possible glitches when copying from a PDF]
>
> If you want to
> use a Clojure command to load a file like (for example) `solutions/add-and-make.clj`,
> use this:
>
> {:lang="clojure"}
> ~~~~~~~~~~
> user> (load-file "solutions/add-and-make.clj")
> ~~~~~~~~~~
>
> *Warning*: I'm used to using `load` in other languages, so I
> often reflexively use it instead of `load-file`. That leads
> to this
> puzzling message:
>
> {:lang="clojure"}
> ~~~~~~~~~~
> user=> (load "sources/without-class-class.clj")
> FileNotFoundException Could not locate sources/without-class-class.
> clj__init.class or sources/without-class-class.clj.clj on classpath:
> clojure.lang.RT.load (RT.java:432)
> ~~~~~~~~~~
>
> The clue to my mistake is the ".clj.clj" on the next-to-last line.

These instructions seem to work well for my readers.

--------
Occasional consulting on programming technique
Contract programming in Ruby and Clojure
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo

ulsa

unread,
Dec 21, 2012, 2:27:24 PM12/21/12
to clo...@googlegroups.com
I used an early version of Clooj in a workshop some time ago, but got burned by some bug that rendered the REPL crazy and shredding people's code. That scared me away. Probably much better now, though.

ulsa

unread,
Dec 21, 2012, 2:30:23 PM12/21/12
to clo...@googlegroups.com
I have used the isBlank example in presentations. It's not a bad starting point. Might look at how it could be used in a workshop. Thanks.

ulsa

unread,
Dec 21, 2012, 2:54:49 PM12/21/12
to clo...@googlegroups.com
I also suspect that the IDE is important. These guys are experienced people, and I think that once they have an environment that works and they have some control over, they will have a foundation. I think they need and want to know how namespaces work, so that they can see how to modularize code. Then again, Brian's view that the REPL can be the basis for a whole book is also compelling. I must choose a path here.

My hope is that, given a whole day, I can spend some time on the environment issue and still hopefully have time for both some basics and also an end-to-end example, even if it's just a tiny little web app. The plan is to give them a sense of controlling the process from the IDE, setting up a project, incrementally building it using the IDE, and then deploying it in the cloud.

There are probably millions of good ways to structure such a workshop. What I'm trying to express in these posts is the lack of seeing a clear way through the features: what to start with, what to elaborate on so that they don't get too puzzled on the way to the next feature, and what to end with so that they get a sense of achievement. 

ulsa

unread,
Dec 21, 2012, 3:04:37 PM12/21/12
to clo...@googlegroups.com
This is good advice. I think you can cover a lot of ground using this approach, which I guess you need to do when writing a book. 

As I mentioned in another post, I believe I have to choose between covering a lot of ground and building them a foundation that they can experiment on further.

Lee Spector

unread,
Dec 21, 2012, 6:19:42 PM12/21/12
to clo...@googlegroups.com

On Dec 21, 2012, at 2:27 PM, ulsa wrote:
> I used an early version of Clooj in a workshop some time ago, but got burned by some bug that rendered the REPL crazy and shredding people's code. That scared me away. Probably much better now, though.

I've taught a couple of courses using clooj and I think it's nearly optimal for some categories of noobs and some non-noobs too (like me, much of the time). For me it has an essential combination of features that I can't find together elsewhere: one-click, idiot-proof installation, native and un-mysterious GUI that doesn't require special training, REPL, bracket matching, automatic code indenting, autocompletion, doc-string access, arglist-on-space, and leiningen compatibility (but it's not integrated). There are a few things that it doesn't have that I wish that it did -- especially stuff related to debugging -- but for me the tradeoffs are worth it.

However, it's true that it's not very actively maintained and that it currently has some problems. I don't think that the author has a lot of spare time for it these days. But I think that anyone can contribute and if anyone out there has the skill set and time to contribute to a project then I think this would be a worthy target...

-Lee

Denis Labaye

unread,
Dec 22, 2012, 1:41:29 PM12/22/12
to clo...@googlegroups.com
Only one link: http://www.4clojure.com/

That's what we did a few month ago when we did an introduction to Clojure for our fellow co-workers.

It worked well, to the point that it crashed www.4clojure.com :)

But on Clojure IRC, Anthony Grimes (IORayne) was kind to reboot the server, it demonstrated in an unattended way the friendlyness of the Clojure community.

On Sat, Dec 15, 2012 at 11:13 PM, ulsa <ulrik.s...@gmail.com> wrote:
In a couple of months, I'll have a whole day of teaching Clojure to ten of my colleagues. They are experienced Java programmers, but otherwise Clojure rookies. Any tips on how to structure such a workshop day?

--
Reply all
Reply to author
Forward
0 new messages