Live data from Hacker News

Getting Started With Clojure

jrheard.tumblr.com

31–40 of 113 posts

Re: Getting Started With Clojure

#31
post #21

Earlier quoted context omitted.

So, reader knows about keywords and does this implicit syntactic transformation? It seems to me that a function must be defined somewhere before one could call it.)

No, there is no syntactic transformation. The keyword is a function i.e. (in Java terms) it implements the IFn interface. The effect of that function is the same as calling the get function on a map using the keyword as the argument.

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.)

Re: Getting Started With Clojure

#32
post #25

Earlier quoted context omitted.

So, reader knows about keywords and does this implicit syntactic transformation? It seems to me that a function must be defined somewhere before one could call it.)

The keyword syntax is transformed into a keyword instance by the reader, and keyword instances implement IFn as objects on the JVM, hence can be used as functions under clojure's evaluation rules. As I understand it, the roles which things like lists and functions play in a traditional lisp are replaced in Clojure by abstract datatypes corresponding to Java interfaces. Which on one hand is kinda neat because the core…

I more than agree with your last paragraph.

Re: Getting Started With Clojure

#33
post #19

Earlier quoted context omitted.

This is something that clojure got right before any other language I'm familiar with did. You do not "install" clojure. You depend on clojure just like you might log4j or joda-time

You still need to install the JVM. Python/perl/ruby require installers because you need some platform-specific stuff for each. Running everything inside the JVM means you only need to ship what any arbitrary JVM library requires. In this case, its as simple as a .jar.

True clojure assumes the existence of the JVM. However no other jvm language has gone with the language as library system which is a shame.

Also, I don't think anything would preclude non jvm hosted languages from doing something similar. I think it is a better solution than say virtualenv from python.

Re: Getting Started With Clojure

#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).

Re: Getting Started With Clojure

#35
post #33

Earlier quoted context omitted.

You still need to install the JVM. Python/perl/ruby require installers because you need some platform-specific stuff for each. Running everything inside the JVM means you only need to ship what any arbitrary JVM library requires. In this case, its as simple as a .jar.

True clojure assumes the existence of the JVM. However no other jvm language has gone with the language as library system which is a shame. Also, I don't think anything would preclude non jvm hosted languages from doing something similar. I think it is a better solution than say virtualenv from python.

I believe that is what all of the other JVM languages do. How is what Clojure does any different that what Scala or Groovy does?

Re: Getting Started With Clojure

#37
post #19

Earlier quoted context omitted.

This is something that clojure got right before any other language I'm familiar with did. You do not "install" clojure. You depend on clojure just like you might log4j or joda-time

You still need to install the JVM. Python/perl/ruby require installers because you need some platform-specific stuff for each. Running everything inside the JVM means you only need to ship what any arbitrary JVM library requires. In this case, its as simple as a .jar.

So Clojure has over (say) Ruby the feature that you don't have to install it. Yet you do have to install a JVM... How is installing a JVM better than installing any other interpreter or runtime?

Re: Getting Started With Clojure

#38
post #21

Earlier quoted context omitted.

No, there is no syntactic transformation. The keyword is a function i.e. (in Java terms) it implements the IFn interface. The effect of that function is the same as calling the get function on a map using the keyword as the argument.

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 maps whose keys are keywords. I would argue that is is not confusing and that it is totally consistent - all you were missing is one fact: keywords are functions.

Re: Getting Started With Clojure

#40
post #33

Earlier quoted context omitted.

You still need to install the JVM. Python/perl/ruby require installers because you need some platform-specific stuff for each. Running everything inside the JVM means you only need to ship what any arbitrary JVM library requires. In this case, its as simple as a .jar.

True clojure assumes the existence of the JVM. However no other jvm language has gone with the language as library system which is a shame. Also, I don't think anything would preclude non jvm hosted languages from doing something similar. I think it is a better solution than say virtualenv from python.

matthavener wrote: "Running everything inside the JVM means you only need to ship what any arbitrary JVM library requires. In this case, its as simple as a .jar."

Considering a .jar is a zipped directory tree, and a virtualenv is a directory tree, would you be happy if we zipped up virtualenvs and called them .par or something?

I'm not sure what "language as library" will mean if you are not installing a VM or interpreter such as the JVM.

Post reply on HN