Make me good Clojure Buddy?


(Steve Pitchford) #1

Hi,

Over summer I’m hoping to learn a bit of Clojure. I did a bit of Lisp way back when back in uni, so the (do stuff stuff stuff) syntax seems familiar but a little foggy.

Wondered if anyone fancied having a comunal work through “Clojure for the Brave and True” ?

Steve


(Andy Wootton) #2

I started several months ago but haven’t got back into it since my holiday. What do you have in mind? I’ve made some notes that I was thinking I should put on Git, when I remember how.


(Steve Pitchford) #3

What I have in mind - I am open minded as to contact format - could be a thread here, or via email. Clojure strikes me as being interesting, but with individuals rather than a group in the west midlands, and a mix of interest in clojure.js and jvm clojure.

There seems to be a bit of a learning curve to move from (do, this, that, other) into full blown apps, and the handling of threads seems to be very interesting indeed.

I’ve downloaded clojure, and tried to opt for cursive ( https://cursive-ide.com/userguide/ ) as I’ve never been a massive fan of Emacs and tend to be a bit multi-platform.

However, even with this, I’m having difficulty taking my first Leiningen ( http://leiningen.org/ ) project and executing it in the IDE.

I’m pretty sure that the answer to this particular hiccup will be simple, but given the heavy unix/emacs bias in many tutorials, I’m wondering if anyone is interested in trying to try to pool experiences in an attempt to lowering the journey to moving from playing with the REPL loop to doing something meaningful - I have my own project in mind that I’m happy to work on in due course, or I’m happy just to share eurika moments and impediments in the hope that collective learning brings greater benefits to all involved.

I’ve done a fair bit of coding in the past, but don’t do as much as I would like presently, so am looking for someone(s) in a similar boat, or someone who can code a different paradigm and wants to experience something different.


(Andy Wootton) #4

I think you are probably already ahead of me so I may not be able to help much but I do tend to document what I learn because of my appalling memory, so I’m happy to share that.

The wall I’d hit before my holiday was that I’ve never coded in objects but I’ve been thinking in them for a few years. I haven’t quite got my head around how you start a Clojure project. What do you ‘think in’, if it isn’t objects? If it’s functions operating on data structures, I don’t know where to start. Do you see what I mean? I don’t know how to stop everything being a big spaghetti mess.


(Steve Jalim) #5

If you’re in the mood to sharpen up your low-level/syntax stuff, before full blown projects, you could try exercism.io (am enjoying it for Elm) - there are 46 Clojure exercises there http://exercism.io/languages/clojure


(Andy Wootton) #6

Thanks. I’m puzzled by Hickey saying this though:
“Good design is not about making grand plans, but about taking things apart.”


(Steve Jalim) #7

I take it as meaning that good design is about breaking things down into manageable, maintainable and malleable pieces.


(Andy Wootton) #8

Agreed, which sounds a lot like top-down design / functional decomposition. I haven’t understood the Clojure model for polymorphism yet, either.


(Steve Pitchford) #9

There’s an example of multimethods on the clojure site http://clojure.org/about/runtime_polymorphism - I found the code easier to read than the explanation. The “variable” definitions seem interesting though - when I first read the multimethod defs, I was assuming that the relationship between species and lion was similar to a dayofweek enumeration and “monday” - however, reading the variable defs beneath it looks almost like the variables just have a number of lables attached to them ( I assume the choice of variable names matching parameter lables is unfortunate coincidence ) …

I’ll try to read the link @stevejalim sent in a bit, perhaps after sorting out the issue I have with the IDE .


(Andy Wootton) #10

Values. Clojure doesn’t do variables. I’ve struggled with this too.

This helped https://youtu.be/-6BsiVyC1kM


(Steve Pitchford) #11

I blame XSLT for my sloppiness on that front.


(Andy Wootton) #12

@Steve_Pitchford Which IDE are you using?

I’ve just been trying to work out the relationship between Leiningen, nREPL, clojure, emacs and cider.

Am I right that you work inside a single emacs session and connect to REPL instances, presumably potentially on different processors/cores and each running clojure? I know Leiningen is a build system that can run a REPL so I guess you just give up on that. I read that cider is designed on the assumption that you never stop and start clojure systems, you hack them on the fly. I could imagine my old ‘change control board’ screaming. If you mess things up you must time-travel back to when everything was last OK :slight_smile:


(Steve Pitchford) #13

I’ve been a bit slow off the mark. I tried the intellij extrnsion for a bit, then seapped to emacs and a few extensions as per clojure for the brave. I need to invest a bit more time in it.


(Andy Wootton) #14

Me too. I think this was my first ever line of elisp
{:user {:plugins [[cider/cider-nrepl “0.8.1”]]}}

I have cider. It usually gives me a headache. :slight_smile:

If anyone else wants to play: http://www.braveclojure.com/basic-emacs/


(Andy Wootton) #15

I’m beginning to wish I’d invested more time in emacs a long time ago, so I might have been mildly competent by now. I think I was held back my belief in operating systems as a viable Lisp alternative. My tiny mind is blown by the idea that I can edit a running program and the editor I’m editing it with. I say “I can” with a currently unjustified level of optimism :smiley:


(Steve Pitchford) #17

It’s taking longer than I’d like to progress through CFTB - find myself managing 1/3 chapter snippets sporadically but feel like I need a little more frequency to make real gains.

The binding of keys to functions which perform the intended insertion of the key pressed marked a epoch of respect for emacs though - much as though I am slightly loath to admit it.


(Andy Wootton) #18

I felt exactly the same. I had a couple of goes at rote learning of key hieroglyphics without any understanding of the underlying structure. It’s really quite elegant. I also disliked emacs for not being in line with Unix philosophy but I now see that’s because it follows Lisp rules instead and there’s no real reason to ever leave emacs.


(Steve Pitchford) #19

Got a little ahead of myself and read through chapter 4 before finishing chapter 3. Most of it seemed to go in, but there are a few squiggles ( sigils? ) which I think I need to go back and cover before attempting the exercises at the end of chapter 4.

It seems to be taking a while to get to the stage where memory suggests I had got to on my first ADA lesson at uni, but I suspect that is down to two key factors: The unfamiliarity of the development environment, and the desire of the author(s) to promote coding based on understanding rather than panel beating.

Actually, so far, my learnings suggest that Clojure seems more resilient to panel beating than other platforms I could mention. I suspect terseness could be a factor in this.


(Andy Wootton) #20

I read Chapter 4 :-/

While I think I understood all the example it spelled out and put in front of my face, I feel it exposed a whole new world I don’t have much of a clue about. It’s an odd feeling. I’m getting that “before you can understand this, you have to understand everything else” panic that I got when I read ‘Zen and the Art’ for the first time.

…or, indeed, the last time I tried to learn a Lisp :slight_smile:
I think the problem is that I expect linear progression: Learn a bit, do something. There’s a gap between the trivial examples and being able to do anything meaningful. It could be because the power comes from using functions in combination.

Or like juggling is hardest to move from 2 to 3 balls (I’m told.)


(Steve Pitchford) #21

I haven’t done a great deal of late, I did go back to chapter 3 and can identify with a sentiment somewhere between anticipation and frustration with the speed of progress as I would traditionally measure it in terms of a developing piece of software.