Live data from Hacker News

Why I am excited about Clojure

blog.txus.io

141–150 of 173 posts

Re: Why I am excited about Clojure

#141
post #113

Earlier quoted context omitted.

If macros are used properly, they should make the code easier to read, not harder. If you can't figure out what it does from it's signature and docstring (maybe with a reference to some documentation for more complex or abstract things,) there's a problem. You shouldn't have to read a macro's definition to be able to use it. Also, redefining a function should cause every function which directly references it to use t…

"If macros are used properly, they should make the code easier to read, not harder." Well, I think macros often play the role of jargon. They let you spell out a particular concept succinctly and precisely and make the whole much easier to follow once you are familiar with the jargon, but people unfamiliar won't fully understand. Much like jargon in spoken language in any field it can be picked such that those otherw…

I suppose. If you don't know what a for loop does you can't really be expected to use one. But you shouldn't have to understand how a for loop is implemented in order to use it correctly is really my point.

Macros can be used to implement some pretty novel abstractions so there can be some temptation to try to understand them by reading the implementation. However, if an abstraction is novel enough, it really should be documented somewhere very thoroughly.

So, to some degree your analogy makes sense. You can use macros (and functions too, really) to express concepts that are unclear unless you have a better familiarity with the topic or the program in question. But I feel that that's what docstrings are for.

Re: Why I am excited about Clojure

#142
post #138
post #134

> When I start using a language, there are usually some situations where I can't understand why my code isn't doing what I expect it to do. When that happens to me in a language like JavaScript, for example, finding out what the problem was is generally a very frustrating experience This is a very weird paragraph to me because I've experienced the exact opposite. You can see my frustration in this stack overflow ques…

I have been working in both clojure and javascript for a while. When I encounter bugs in javascript assuming it does not crash, it can become difficult to track down the source due to the lack of name-spacing, mutability of variables that allow for race conditions, and unintended changes upstream if you're not careful. Where as in clojure, the scope of name spaces is generally smaller, while the errors are more crypt…

Some JS frameworks lend to more difficult debugging.

Re: Why I am excited about Clojure

#143
> Plus, whenever some interface I've built feels awkward or there's some duplication, often times I find that, while thinking and trying to refactor it, the language tries to drive me to the cleanest solution

Yes, this is my exact feeling when I'm still learning it :)

Re: Why I am excited about Clojure

#144

Earlier quoted context omitted.

One thing I've noticed is that the JVM startup time is actually pretty small. What's slow is waiting for Clojure to bootstrap itself.

JVM Feature Request: The ability to preserve a complete JVM state (in this case with loaded Clojure stuff) and quickly start from there. Does anybody know if something like that is possible/already exists?

> Does anybody know if something like that is possible/already exists?

The majority of commercial JVMs that tend to be ignored on HN, provide JIT cache between runs and AOT compilation.

Re: Why I am excited about Clojure

#145
post #141

Earlier quoted context omitted.

"If macros are used properly, they should make the code easier to read, not harder." Well, I think macros often play the role of jargon. They let you spell out a particular concept succinctly and precisely and make the whole much easier to follow once you are familiar with the jargon, but people unfamiliar won't fully understand. Much like jargon in spoken language in any field it can be picked such that those otherw…

I suppose. If you don't know what a for loop does you can't really be expected to use one. But you shouldn't have to understand how a for loop is implemented in order to use it correctly is really my point. Macros can be used to implement some pretty novel abstractions so there can be some temptation to try to understand them by reading the implementation. However, if an abstraction is novel enough, it really should…

All certainly the case. Any sort of jargon should be well defined and well documented. Standardizing on jargon between groups eases transitions between groups, but may mean it fits individual problem domains slightly less well. &c, &c.

Re: Why I am excited about Clojure

#146
post #13

Earlier quoted context omitted.

At a fairly superficial level, the :keyword syntax seems reminiscent of Ruby. But I'm neither an expert Rubyist nor Clojurist (Clojurian?) so I would defer to those more familiar.

They both have same roots, the :keyword syntax comes from Common Lisp and others: From Matz (creator of Ruby): Ruby is a language designed in the following steps: * take a simple lisp language (like one prior to CL). * remove macros, s-expression. * add simple object system (much simpler than CLOS). * add blocks, inspired by higher order functions. * add methods found in Smalltalk. * add functionality found in Perl (…

Put another way, Ruby is a Lisp implemented by someone who doesn't understand what makes a Lisp worthwhile.

* Start with Emacs Lisp [1]: Well, if you like, but in exchange for the perceived simplicity as compared with e.g. ANSI Common Lisp, you're also giving up extremely useful things like lexical scope, and that's going to hurt your users down the road.

* Remove macros and s-exprs: Why? They're a powerful feature, and if you're building a Lisp, then operating on the AST shouldn't be hard. Except that removing s-expressions costs you homoiconicity, which means you need to translate from source to AST, which means the difficulty of writing a macro just jumped by several orders of magnitude, so, fair enough, if you're throwing out s-exprs then macros have to go as well. I can see an argument for this decision, in that it lowers the barrier to entry for non-Lispers who have yet to get over the parentheses allergy.

* Add simple object system: Is it really that much simpler to do single inheritance + mixins (Ruby) than to do multiple inheritance (CLOS)? This is an honest question; I've never implemented an object system, so I don't know which is easier from the developer's perspective. From the perspective of the language user, though, I don't know that I see a lot of difference.

* add blocks: This decision strikes me as totally indefensible.

If you already have lambdas, why do you need this separate abstraction which looks and smells mostly like a lambda, but doesn't act like one except in certain circumstances, and which is also the only place in your entire language with lexical scope rather than dynamic? You've just unforgivably complicated your language's syntax and implementation, and your users' lives; you've made it necessary for people both to write, and to understand, documents like [2]. Why would you ever do that?

And if you don't already have lambdas, in what crazy world of paisley skies and ice-cream seas does it make any kind of sense to put yourself and your users through all these unnecessary mental calisthenics, when you can just add lambdas, and solve all these problems with a single simple abstraction that everyone either already knows or should?

I can't imagine how anyone could possibly defend this reeking farrago, but I'd sure like to see someone try.

* add methods found in Smalltalk: I'll concede this one; it was a good idea, and a lot of Ruby's power comes from being able to hang magic off method_missing. Of course, a lot of Ruby's headaches come from that, too, and it is a persistent source of subtle bugs and unexpected behaviors, especially in frameworks like Rails which make heavy use of such magic hooks. For Smalltalk developers, this isn't so much of a problem, because Smalltalk is so heavily self-documenting; Ruby developers are not so fortunate.

* add Perl functionality: Well, this makes sense, if you're trying to come up with a Perl killer, in the same way that Perl was explicitly intended to be an awk and sed killer. It seems lately to be working, too; there's what looks to be an increasing trend for people to use Ruby for the sort of tooling which, a decade ago, they would've done in Perl. On the other hand, and I say this as someone who grew up with Perl and will always have a soft spot for it, Perl is a giant ball of hair laced with fish hooks, into which only a true expert may plunge his hands and pull them back out without severe lacerations. If you let your Perl emulation anywhere near the conceptual or implementation core of your language, you risk infecting it with the same disease -- indeed, I'm inclined to wonder if that's whence came the brain damage that led to Ruby's mess of mutant lambdas.

Don't mistake me: Ruby is a cute, useful little language, and it has some interesting ideas which I think are worthy of wider consideration, such as the method system. Unfortunately, Ruby also has some grave drawbacks, such as the lack of a self-documenting capability to make the method system sane to use at scale, which in my opinion rather severely reduce its appeal.

[1]: No, I've never seen Matsumoto admit outright that he started with Emacs Lisp, but I think it's a reasonable surmise. Consider: Emacs Lisp descends from MacLisp, which is both simpler and older than Common Lisp; in both Emacs Lisp and Ruby, lexical scope is an afterthought, inflicting at least occasional headaches on users of both languages; prior to inventing Ruby, Matsumoto was an Emacs Lisp developer of considerable Japanese repute.

[2]: http://awaxman11.github.io/blog/2013/08/05/what-is-the-diffe...

Re: Why I am excited about Clojure

#147
post #2

What is it about Clojure that Rubyists love? I am a Rubyist who is new to Clojure (I love it) and I cant explain it myself. Clojure was suggested to me by several other Rubyists. I find myself suggesting it to other Rubyists as well....

Rich Hickey (creator of Clojure) was/is a big Ruby user.

Re: Why I am excited about Clojure

#148
post #101

Earlier quoted context omitted.

While this is a reasonable approach, it quickly breaks down when you look at code written by others who do not follow this approach.

When approach X isn't followed, approach X breaks down? True for all approaches, no? Any language can be written poorly. I don't think any language will ever be able to force good coding style on programmers. Though Haskell comes closer to that impossible goal than many other languages, due to its type system, functional purity, and mandatory indentation.

The difference is that in lisp you cannot chose to not "follow the approach" because the approach is fundamental. So you will never look at anyone else's lisp code and see that they chose not to use parentheses uniformly.

Well, technically it's possible if someone used macros to embed a DSL that is paren free, but it just doesn't happen in the vast majority of cases. Whereas if you try to follow the approach of using parens everywhere in Haskell, the vast majority of other code you attempt to read will still be awkward for you.

Re: Why I am excited about Clojure

#149
post #42

I am a Ruby guy torn between diving into Haskell or Clojure. Help! Every time I get excited about one feature of one (ClojureScript) I learn the other has something equivalent or potentially better (Haste). One thing that has put me off on Clojure is 1) the ugly as hell JVM stacktraces, 2) hitting the wall of the number system results in nasty JVM errors if you are used to Ruby's trivial (to the developer at least) h…

2) Clojure has sensible math with auto promotion to bignums, you don't have to worry about overflows like in Java. 3) You don't pay the price for the JVM startup time when running unit tests. When developing Clojure you have a JVM active at all time for your REPL. The JVM startup time is really only a problem if you want to write scripts. Your first issue with Haskell is a plus! Everyone in #Haskell on freenode are i…

> Your first issue with Haskell is a plus! Everyone in #Haskell on freenode are incredibly helpful, and well, if they're all professors you likely to get some quality help, right?

Eh... The Haskell community is amazing and always willing to help. They get an A for effort, but they often have the curse of knowledge[0].

> The curse of knowledge is a cognitive bias that leads better-informed parties to find it extremely difficult to think about problems from the perspective of lesser-informed parties.

[0]: http://en.wikipedia.org/wiki/Curse_of_knowledge

Re: Why I am excited about Clojure

#150
post #87
post #76

Earlier quoted context omitted.

I agree, though one has to compare apples and apples. experienced programmer vs inexperienced programmer is not fair. Of course if one is unfamiliar with how to build a flexible type safe systems, (newbies), there could be these sorts of issues. But for experienced programmers, not really.

though one has to compare apples and apples. experienced programmer vs inexperienced programmer is not fair. Oh, definitely. I just feel that far too many people focus on programming languages that are good for beginners without really thinking about them from an experienced programmer's perspective. What may be good for a beginner can often be terrible for an expert. What may be hard to understand for a beginner can…

I'd guess that is because most developers ARE beginners, right up till they retire/career shift.

If we were even half experts, maybe that would change, but in a field where "anyone can be a developer" you will see a long tail of low skill.

Post reply on HN