Skip to content

Comment on Idiomatic Clojure with LightTable

Comments

I've been wanting to learn Clojure and recently bought the book Clojure Programming (not to be confused with Programming Clojure) and I'm curious to know if others believe it is a good idea for a Clojure novice such as myself (lisp and JVM novice too) to use kibit while learning. Any advice would be greatly appreciated. Thanks.

You're new to Lisp and JVM? (Perhaps new even to Emacs?) The activation energy required to get going in Clojure can be a bit daunting. Cool tool that it may be, I think that kibit should wait until you can drive around with some confidence. Premature optimization and all that, y'know.

Yup, new to Lisp and JVM. All of my experience, brief as it has been, is in Ruby. I've only taken a cursory glance at the book I purchased and frankly I think I'll be ok picking up Clojure. It just may require a lot of focus. Is Emacs the typical editor Clojuristas use? I use vim though I have recently switched to Sublime.

I use emacs for anything with S-expressions and vim for everything else, but you should be careful with information overload. It's very easy to get started with LightTable if you want to play with Clojure, so I'd recommend that approach to work through book examples.

If you're new to Lisp, I'd recommend working through Land of Lisp [1], and pg's On Lisp [2] in order. They're both Common Lisp books, but they will introduce you to and expand your mind on (respectively) what's possible with all the power Lisp gives you. Virtually everything you learn in those books will be very nice tools to have in your toolbox as a Clojure dev.

As for the best starting Clojure book, Clojure Programming [3] is excellent. It has great OOP -> FP examples, is fairly extensive and well-written.

[1] http://landoflisp.com [2] http://www.paulgraham.com/onlisptext.html [3] http://www.clojurebook.com

https://github.com/tpope/vim-fireplace is where it's at for vim/clojure tools.

I've heard good things about using emacs-live (https://github.com/overtone/emacs-live) to get you up and running quickly.

+1 for emacs live

Vim can work very well with Clojure (I use it). Look into ScreenSend, which lets you send code from the editor to a repl. You can use it with Python as well, and anything with interactive evaluation. You might also want to install paredit, which keeps your parentheses sorted out for you.

Correction, you must install paredit (and spend half a day familiarizing yourself with how it works). It'll make your learning experience 10x easier.

As for Emacs vs Vim, I also use Vim for Clojure development. There's definitely a bias toward Emacs in the community, but that doesn't mean that you have to go with Emacs. In fact, there are now useful plugins/packages to work with Clojure in Vim, Sublime, IntelliJ, Eclipse, as well as Emacs. There's even two editors written in Clojure itself: Clooj (https://github.com/arthuredelstein/clooj) and the afore-linked LightTable.

Correction, you must install paredit

Or the newer Smartparens: https://github.com/Fuco1/smartparens/wiki

(Confession: I am a novice to clojure/scheme/JVM myself.)

I admit that I have not tried kibit yet. However, LightTable/REPL is a great tool for this endeavour. If only clojure could have an error tracking report that would be comparable to the wonderful implementation that can be found with the python IDLE.. but I guess that is too much to ask?

Can you elaborate on what you mean by "error tracking report" in IDLE? Either I'm missing something cool about IDLE or I am totally misunderstanding. Thanks!

Sorry, what I meant was the TraceBack. It helped a great deal when learning programming and hunt those nasty bugs:

  Traceback (most recent call last):
    File "C:/Users/wuschel/Desktop/error-track.py", line 3,   in <module>
      newstrin = teststrin + 3
  TypeError: cannot concatenate 'str' and 'int' objects
In clojure, you get those error reports in java lingo - I don't know how fast you can get use to that kind of error messages when you do not know Java. Now, this one is obvious, but it just should serve as an example:
  clojure.lang.Compiler$CompilerException: 
  java.lang.RuntimeException: clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(null:4:1)

OK, this makes sense. I'm slightly disappointed though, I was hoping to learn a secret new python feature :)

Kibit looks neat, I haven't tried it. I think the generally applicable advice is to get comfortable with the core first, then add tools and libraries at the speed you're comfortable with, making sure that you understand what each component does.

Running `lein kibit` is super low effort once you've got lein set up, and even having used clojure for years it still reminds of features of clojure.core that I forgot pretty regularly. I think as a noob it would really help you in learning the core lib.

I cannot see any problem with using kibit.

Quite often my experience when learning a new language is "Am I doing this right? Or even close to right?"

If kibit can turn your code into idiomatic Clojure then you have a tool for exploring your solutions and how close they look to Clojure as it might be written by a native.

It can also prompt questions "Why do it this way rather than this way?" which could be a good learning opportunity.

I see no harm, only benefit.

Matt

I think it would only be good if its used as a learning tool and not a code-writing tool, compare:

write the best code you can -> run kibit -> spend an hour reading the docs and every blog post you can find about a feature you didn't know about -> repeat

write the best code you can -> run kibit -> show off your awesome code, you're a rockstar!

I agree with you although I think that's an unlikely scenario.

kibit, so far as I understand it, is a pattern matching solution that can replace one structure with another - more idiomatic - structure. It doesn't add anything and, hence, can't actually solve your problems for you.

Well, the problem comes up when it gives you proposals that are not equivalent, because it doesn't understand macros and/or local scope :)

You could try our product (www.crudzilla.com)

here's a short video demoing coding in clojure and other jvm languages:

http://www.youtube.com/watch?v=AqeOS2hqtMg

It's easy to get carried away with everything. My advice: start with an editor you know and use everything vanilla. You'll appreciate better tools more once you spend some time and get a feel for the pain points.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.