Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Clojure as a first progamming language?
10 points by Towelie on Dec 1, 2009 | hide | past | favorite | 19 comments
Hey everyone,

Thanks for taking the time to read. I’m interested in trying out Clojure for my first programming language--at least, the first programming language in which I intend to commit myself to becoming proficient. This might make more sense if I give a bit of background on my situation.

I have minimal experience (a couple college courses) with Java and C++, and I’ve tinkered with HTML, PHP, et al. on my own time. For a while, I’ve been intent on picking a language to learn for web application development, since got the startup itch. But being the person I am, I had to survey all the possible options first, since this is my first programming language we’re talking about. That wouldn’t matter to a lot of people, and maybe it shouldn’t to anyone, but I feel there’s a chance an experienced programmer has a certain connection with his/her "native" programming language, and if so, I want to choose a language worthy of that--none of this Java/C++ nonsense.

So after a few months of general web information gathering, I found and became intrigued by the ideas and concepts behind the Lisp family of languages. Being a math guy myself, I felt Lisp might be a more natural fit for my mind, that I might have a stronger natural connection with the language than I would with anything else. That said, of all the Lisps, I’m leaning toward Clojure at the moment due to its many features which make it far more ideal than most Lisps for say, web applications--which are what I intend to code once I’ve achieved the level of skill necessary.

With all that in mind, what do the readers of HN think about choosing Clojure for a first language? Are there any reasons I may want to consider going in a different direction? How necessary is it to be proficient with, for example, Common Lisp or Scheme, before picking up Clojure, for somebody whose mind hasn’t been molded to think in terms of C or Python or Java or whatever?

Thanks again for reading. I appreciate any and all responses.




I feel there’s a chance an experienced programmer has a certain connection with his/her "native" programming language

Sure, you will tend know more about the language that you have worked with the most, which in turn tends to be the one you prefer. But that need have nothing to do with the language you learn first.

A very large number of the programmers you will meet today learned programming via something like C64 or Applesoft BASIC, or (at best) Turbo Pascal. These languages were not exactly Lisp. In those days, BASIC only had global variables. Our growth was not stunted. The idea that learning BASIC stunts your growth was a load of crap at the time, and it remains a load of crap.

If you have the startup itch and want to teach yourself good habits, here's my advice: Don't dither, and don't pick up habits that encourage dithering. Like fretting too much about your language of choice. If you actually plan to build web software, take up Ruby, Python, or even PHP. You know, something normal. Something which features lots of libraries and blogs and books and colleagues and infrastructure.

And learn Lisp too. At the same time. Start with SICP, which involves starting with Scheme. Another useful Lisp to tinker with: emacs Lisp.

Eventually you will learn at least four languages, so don't worry too much about which comes first.


Ruby and Python and PHP all built their success because they were once the experimental non-normal choice. Argument holds no water.

And I'm sorry bad programming habits will stunt your growth (speaking from personal experience).

Learn the most expressive language you can that's still practical for your goal. Learn the language that you will find most fun and exciting - libraries be damned (Clojure has a ton of them anyway).


Ruby and Python and PHP all built their success because they were once the experimental non-normal choice.

Yes, and back when they were new, they weren't what beginners learned. When PHP was new, beginning programmers with an eye on the Web learned Perl, Java, or even C, because they had larger communities and better documentation, libraries, and books.

As a beginner it isn't your job to push the envelope of platform design. Unless your primary goal in learning programming is to tinker without necessarily shipping anything.

And, yes, bad programming habits are bad. Unfortunately, avoiding bad habits isn't as simple as choosing one language over another. You can write bad code in any language -- indeed, expressive languages let you explore the really complicated corners of the bad-code phase space -- and you will write bad code, until you've had practice. One good way to get that practice is to pick a language where there's a lot of well-written existing code and documentation and style guides and Stack Overflow comments to read over. See above.


Yes. I also started with C64 Basic. As far as I remember you could only have single-letter variables. Is this correct?

The language you feel most comfortable in does colour your thinking. (Or vice versa?) So just don't stop learning languages.


They gave you two letters, I'm pretty sure. But I've mostly forgotten.


I do remember that the syntax made spaces were unnecessary.


If you want to learn a language from the perspective of getting something done (in the startup webapp sphere), go for Python/Django or Ruby/Rails - they both have mature, well-established communities with plenty of documentation and available libraries.

Clojure seems quite cool, but it's a relatively new language and, especially when compared to the other two platforms mentioned above, it lacks the wealth of institutional knowledge about delivering good webapps that forms a significant portion of the value of Rails or Django.

Clojure is the exciting new thing you blog about. Rails or Django is what you used to write the blog itself.


Seeing as someone has already built a fast and scalable blog using Clojure I'm not sure your arguments holds any water. Having used both Python/Django, Python/CherryPy/Mako/CouchDB, and Clojure/Compojure/CouchDB I'd say that Clojure is a pretty damn capable web application programming language. And compared to my experiences with PHP+SQL, it is light years beyond.

Clojure also has an extremely rich _core_ library of functionality - a lot of things that would simply be more work in Python or even Ruby can be expressed more succinctly in Clojure (yes I know Haskellers won't be impressed ;)

As far as communities I've found #clojure IRC orders of magnitudes more helpful than #django or #python (and both those channels aren't bad).


Your last thought is quite opinionated. The other approach is to write the actual code (in whatever you want) instead of blogging ;P


There's something to be said for starting with a language that has great library support. While one approach to learning is to write from scratch, another is to read existing code and be able to build what you want to build using parts that are already there (less likelihood of losing your enthusiasm out of frustration too). Clojure does have Java library support, but it's native library support doesn't match that of Python or Ruby or Java.


Yeah of course decent amount of good quality libs is crucial for learning, because you can see how idiomatic code is written.

For me, Clojure has enough. YMMV.


This is a good idea I think. I would consider learning Java, the basics, with Clojure. At the same time because you will have to regularly make use of the huge Java library. So it's a good idea to know about classes, objects, basic syntax and primitive types. Of course you will put the focus on Clojure. I also recommend SICP and Scheme. Scheme, in its R5RS form, is a really good pedagogical programming language. I learned it at school and it was a really good experience. One that forever changes the way you think about programming. But I didn't get that at the time, only later :) You can do the SICP exercises with Clojure instead of Scheme. I would avoid digging into C++ or Common Lisp now. Those are quite complex. Keep CL for later, and forget about C++ :) Next get deeper into Java and start to learn a "scripting" language like Ruby, Python or Perl. All in all, I think it is really important to grasp different programming paradigms: functional (Lisp, Haskell, ML, Erlang, ...), logic with Prolog, procedural/OO with Java (can get you a job :-), distributed (Erlang) ... There are a lot of other interesting languages out there but it is a good start: Clojure + Java.


I'd say something a bit different that most responses, well I guess it's worth taking your time.

Choose language which seems most natural to think in. It's really important.

For example, many people just don't have that wires in brain which cause them to see everything as objects, so all that OO & design patterns stuff seems missing the point. But others love it and use this approach naturally!

You just want to avoid the situation when after a first-time crush on some programming paradigm "wow how is it powerful" there comes realization that writing anything in it is a boring and misplaced experience. Just switch to another paradigm instead.

And don't be lured by the current popularity of some web frameworks, tools or whatever. They come and go. Your language of choice -- given that it's actively developed and not only an academic experiment -- will have them sooner or later. In the meantime you will expand your mind with the language you really like. It's worth.


Clojure has a simple functional language foundation that should be good for learning as a first language. The biggest impediment may be the lack of a tutorial from a beginner's perspective, that focuses on that foundation. Using most material for Clojure a beginner will soon be exposed to features probably beyond their understanding.


I think Clojure is not a simple language. The reason is, that you have to learn about 1) Lisp, 2) Clojure's approach to concurrency (immutable data structures + reference types) and 3) the JVM. These are all fairly complex systems on their own. The combination of them is what makes Clojure interesting, and, in my opinion, you can't leave one out and still have a great language.

Depending on your knowledge, this may make it a bad choice as a first language because it's so much to learn at once. You could be better off, to start by learning something more similar to what you already know (possibly Python/Django or Ruby/Rails for web programming).

That said, Clojure is learnable, of course. It may just take more time. If it feels right to you, then go for it. Enthusiasm about the tools will help your learning. And either way, it's not like you are making a mistake.


Clojure's beauty is in that it _is_ simple. It's also a language where it's completely unnecessary to have to understand all the parts at once. I coded in it for 6 months and never used a single concurrency primitive.

That said, JVM stuff does present a challenge but not more than the various non-sensical annoyances I've experience with every programming language. Two other real difficulties is lazy-sequences and less than ideal error-reporting.

lazy-sequences is like learning pointers- tough and then you get it. error-reporting is a symptom of early days. This issue is offset somewhat by Clojure's FP sensibilities.


Lazy-sequences may also help to prepare you for a completely lazy language.


Thanks for your response. :)

Quick question: regarding learning about the JVM, are you aware of any good resources, especially any which look at it from a Clojure perspective?


1) Lisp isn't exactly a complicated pattern to match (syntax is much more simple/readable than say, Java/Ruby). If you do a lot of macros there are difficult things involved, but then again, macros are an entire level of power greater than Ruby/Python.

2) You don't have to use the concurrency stuff if you are just learning programming. The whole point of STM is that it takes care of the concurrency and transactions for the programmer. This is like saying garbage collection is more difficult than hand allocating memory because the system that implements it is more complicated.

3) Huh? I mean, if you want to use Java libraries you have to learn a bit of the java idiom (.... camelCase), as well as the library that you want to use, but there is no demand that you become intimately acquainted with the JVM any more that you become intimately acquainted with the specific implementation details of python or ruby.

I'm not sure if your post is FUD or genuine ignorance of Clojure (or both).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: