Live data from Hacker News

Getting Started With Clojure

jrheard.tumblr.com

51–60 of 113 posts

Re: Getting Started With Clojure

#51
post #34

> The reason that you won’t find yourself running `clj` often is that the REPL built into bare Clojure is pretty much garbage.... This is what rlwrap is for. Call `rlwrap clj` instead of `clj`, and you get all that and more (C-r, for reverse incremental search, etc). Works with every other REPL that doesn't bother to re-implement read-line.

Using a raw repl at all is painful compared to just selectively evaluating expressions from a buffer (say, in Emacs, VimClojure, or the Eclipse and IntelliJ plugins).

I use this for clojure's python port with vim. I just sit inside vim and have macros that can evaluate the buffer or a selection thereof.

Re: Getting Started With Clojure

#52
post #38

Earlier quoted context omitted.

In Lisp terms, however, a keyword is a self-evaluating symbol , a constant. If it is a function, where it is defined and when? That's why I'm arguing that this form is confusing, and that transformation is more correct notion, at least if people are insisting to call it Lisp.)

It does evaluate to itself and it is constant. It is also a function though, and can be used in the function position of a function application just like any other function. Keywords and all their functionality are defined as a primitive in Clojure, i.e. in the Java source code for the language. It's typically one of the first things people learn when they pick up Clojure, and is used as an idiomatic way to access ma…

From the Lips's perspective it is a contradiction. Something is either a function or a constant.

The logic is that this object could be called as a function and at the same time always evaluated to itself?

That means whenever you call it you always getting it back - this is behavior of a constant. But if you could call it with an argument, you will get back some value, different from whatever it is?

As long as maps are immutable, it will behave as a function - return the same value for the same argument.

OK, but, please, don't tell me that this isn't confusing.)

Re: Getting Started With Clojure

#53
I have been thinking about getting into Clojure, but time is precious. It doesn't seem like there are that many jobs out there, but I could be wrong.

For those of you in the industry, why would I want to use Clojure? What would be a good project to try it on? A Web app? Why is it worth learning it?

Re: Getting Started With Clojure

#54
post #48

This is a great article. More articles in similar tone are needed to highlight how simple this language is. A big disservice to Clojure was probably done by a few early adopters of Clojure who hyped up the LISP heritage of the language to the extent it turned away C/java guys like myself: I recall reading somewhere that in order to learn Clojure , one had to master SICP and Scheme. That was a huge learning curve I di…

I had the same experience. When I first heard about Clojure, one of the first things I learned was that it was a Lisp. But having read in numerous comments, blog posts etc. that "only the top percentile of programmers use Lisp", and since I don't consider myself to be anywhere near the top percentile, I felt that my programming chops might not be adequate enough to learn it. So I put off learning Clojure for about a…

since I don't consider myself to be anywhere near the top percentile, I felt that my programming chops might not be adequate enough to learn it.

See? The magic was within you all along.

:)

I wonder if the causation is confused, here. That is, you do not need to be a top percentile programmer to understand or use Lisp. You are -- or become -- a top percentile programmer because you've learned Lisp.

I don't know if the relationship is as direct as all that. But I do think that if you learn and internalize some of the lessons of Lisp, it will expose you to new ways of thinking about programming as well a programming problems, and this is correlated with being a good programmer.

One particular example: the close relationship between code and data in Lisp pulls aside the curtain a bit on some concepts which are more obscured in languages like Java or C++.

Re: Getting Started With Clojure

#55
post #38

Earlier quoted context omitted.

It does evaluate to itself and it is constant. It is also a function though, and can be used in the function position of a function application just like any other function. Keywords and all their functionality are defined as a primitive in Clojure, i.e. in the Java source code for the language. It's typically one of the first things people learn when they pick up Clojure, and is used as an idiomatic way to access ma…

From the Lips's perspective it is a contradiction. Something is either a function or a constant. The logic is that this object could be called as a function and at the same time always evaluated to itself? That means whenever you call it you always getting it back - this is behavior of a constant. But if you could call it with an argument, you will get back some value, different from whatever it is? As long as maps a…

> That means whenever you call it you always getting it back - this is behavior of a constant.

No! You're confusing functions-as-callable-things and functions-as-values. The phrase "a constant" does not generally imply anything about a thing's behavior when called. It just means something whose value will never change. A self-evaluating constant is a constant that circularly evaluates to itself — nothing else can have that value without referring to the constant. But neither of these things have to do with calling anything; they're just about taking values.

A constant can certainly refer to a function that returns something other than that constant. For example, in Ruby: `Example = lambda { 1 }`. If you just evaluate "Example", you will get a Proc value, but if you call Example, you will get the Fixnum 1.

In most languages that have them, you cannot call a self-evaluating constant. It won't return itself — it's just not a callable thing. In Clojure, keywords are self-evaluating constants that have the behavior of looking themselves up as a key in the argument when called. They serve the purpose of self-evaluating constants exactly the same as in other languages, but they also have the handy property of doing map lookups.

Re: Getting Started With Clojure

#56
post #53

I have been thinking about getting into Clojure, but time is precious. It doesn't seem like there are that many jobs out there, but I could be wrong. For those of you in the industry, why would I want to use Clojure? What would be a good project to try it on? A Web app? Why is it worth learning it?

This post is specially relevant for me, since last weekend I've decided to take a quick look at Clojure, as one of my personal goals this year is to get acquainted with a Lisp dialect.

From my _very_ short experience (I've started coding a simple game), here are my two cents:

- If your application is heavily dependent on state, which changes continuously and must be maintained during most of the execution time - like a game - it may not be a good fit. You'll waste a lot of working around the fact that each modification results on new objects. - If your application comprises mainly of short requests that may create some state that will most certainly be discarded shortly after - like a web application - then I think it's a good fit and you'll probably enjoy it better.

Once again, I've just got started with it, so take this with a grain of salt :)

Re: Getting Started With Clojure

#57
post #22

I knew about clojars.org, but I hadn't known about http://www.clojure-toolbox.com/ . Very nice! I also recommend the Value of Values video presentation: http://www.infoq.com/presentations/Value-Values . It will help you internalize Clojure's approach to data. I really wish I could remember why I didn't experience nearly as much pain starting out as the author, but I'm glad that he took the trouble to put this togethe…

Off topic perhaps, but is Rich Hickey's wisdom only summarized in talks, or has he written some of this down? I see a number of glowing reviews of videos like this. While I don't want to miss out, I would personally much rather consume this info in writing. The one I did bite the bullet on and watch in full was his talk on “hammock-driven development”. I liked it, but couldn't help feeling it would have made a very n…

I can't speak to text, but you don't necessarily have to watch them. InfoQ offers MP3 downloads of talks, so you could listen to them on your commute, on a walk/bike ride/jog, etc. You'll still get 80% - 95% of the value.

I second fogus' comment about the Joy of Clojure, as well. I started with Simple Made Easy and the Value of Values before I even jumped into Clojure, and the Joy of Clojure dovetails quite nicely with all of the above.

Re: Getting Started With Clojure

#58

This is a great article. More articles in similar tone are needed to highlight how simple this language is. A big disservice to Clojure was probably done by a few early adopters of Clojure who hyped up the LISP heritage of the language to the extent it turned away C/java guys like myself: I recall reading somewhere that in order to learn Clojure , one had to master SICP and Scheme. That was a huge learning curve I di…

The reason for the hype may have been to leverage the rich literary tradition of LISP. Understanding LISPiness of Clojure probably depends upon that literature - there just aren't Clojure specific equivalents.

Re: Getting Started With Clojure

#59
post #53

I have been thinking about getting into Clojure, but time is precious. It doesn't seem like there are that many jobs out there, but I could be wrong. For those of you in the industry, why would I want to use Clojure? What would be a good project to try it on? A Web app? Why is it worth learning it?

I started learning Clojure because it seemed to be the logical next step for me. In the few years that I've been programming full-time, I've noticed some patterns: in general, imperative code with lots of side effects in it is difficult to reason about and hard to test, and pure functions are easy to reason about and trivial to test. The same rule seems to hold for code that uses mutability vs code that deals only with immutable things.

Over the past couple of years, I've learned Common Lisp by working through Conrad Barski's Land of Lisp[0] and dabbled in Haskell via Learn You A Haskell[1]. I had a great time learning both, but I found that Common Lisp had a decent number of warts (e.g. four different kinds of equality) that seemed to be primarily due to backwards-compatability concerns, and I had a really hard time getting up and running when trying to write a simple webapp in Haskell. In addition, I've gotten spoiled by how batteries-included Python (which I use at my day job) is; the library scene for both of those languages seemed lacking in comparison.

What I like about Clojure is that it gives me fast immutable data structures, has a really strong emphasis on functional programming, and has access to a really huge amount of useful libraries.

So - I've mainly been learning Clojure as a nice treat for myself; the amount of jobs that exist that employ programmers to code specifically in Clojure didn't even really occur to me as something worth thinking about. It's just really a lot of fun to program in. Also, with any luck, I'll be able to transfer any lessons I learn from Clojure to my daily work in Python.

(Haskell still has a very special place in my heart [I do frequently find myself wishing I had types], I'm not trying to dis Common Lisp nor Haskell, I'm just trying to honestly answer the question of why I thought it was worth learning Clojure).

[0] http://landoflisp.com [1] http://learnyouahaskell.com

Post reply on HN