The changes are pretty substantial when you need them. I wrote a clojure implementation of Base64 that's faster than apache's commons-codec. In 1.2 it was about 5x slower.
Couldn't you speed up loops without annotations by compiling two versions: one that uses longs and one that uses bignums. You start in the loop that uses longs and before an operation that can overflow you check whether it overflows and if so you jump to the loop that uses bignums. This way you only suffer a few extra checks which is a lot cheaper than boxed numbers.
Kawa guy. Kawa was written by a single person, Per Bother, in his spare time. Clojure has a massively larger mindshare and collection of coders behind it. Ask yourself: why has Clojure been so slow for so long?
> Clojure is faster in other stoff like interop witch is really importend on the JVM.
Actually in my experience this is where Clojure is very slow indeed. If Clojure has to convert everything to Refs, it gets extremely slow (in our tests on my simulation system, up to 1000x slower than Kawa. I am not making up that number.).
My point was not to translate the method name, it was to point out that (++) is anti-Clojure. I wanted to refactor the title to avoid mutability. I.e., "return the increment of clojure", not "change the value of clojure".
Well, I agree with you that isn't fantastic marketing. But neither is using a mutator function name to describe a talk on a functional language.
Rich Hickey loves to rail against nonsensical constructs/concepts like @date.day = 3, and I'm guessing he is very against the (++) method, as well. (How can you tell one number to become another number?)
I haven't done anything with Clojure, though I'm curious and wondering if would be worth my while. I'm already familiar with languages covering similar territory (Erlang, other Lisp dialects), but I haven't done much with the JVM. Also, the lack of tail-call optimization in Clojure is off-putting to me, but it looks several good design trade-offs elsewhere would probably make up for it.
That's not TCO, that's just an optimization for individual recursion. You might be able to use it for multiple forms under the same recur (like w/ "labels"), but it's very different when it applies to everything.
With TCO, you can use a set of mutually-recursive functions - you can set up a FSM via tail calls, use CPS for backtracking (and many other things), a re-entrant virtual machine where each opcode is a tail call (rather than a giant switch/case or lots of gotos), etc. Being able to use function calls like "gotos with arguments" (but with local scopes, etc.) can make some constructs much easier to read, reason about, etc.
I'm not that familiar with the implementation of the JVM, but AFAICT it's due to difficulties setting up tail calls efficiently in JVM bytecode.
As soon as the JVM supports it Clojure will support it. For me recur and trampoline are quite ok. I would want to miss on clojure because of TCO but I don't know what would be possible with TCO. I hope I can learn that in one of the books I have here :)
And yeah, I thought of mentioning trampolines, didn't know that it already had a readymade one. Sometimes they add too much overhead, but often it's still a good trade-off.
Do you mean the question if it was worth your while? If it was I would say yes because its a modern list that fixes old lisp problems, learn from the new languages and is pretty fast.
You can do optimized mutual-recursion in Clojure as well, using (trampoline). As with the optimized self-recursion using (recur), it's more work and not as nice as built-in TCO, but this is likely as good as it gets for now, given the current limitations of the JVM.
Bignums "contaminate" surrounding operations. Adding a long and a bignum yields a bignum. Seeding an equation with a single bignum (42N is a bignum representation of 42) will prevent overflow.
No one has come forward with a single real-world scenario where they're using bignums in Clojure. Choosing a default that is only theoretically useful rather than a 10x performance improvement seems a bit silly.
In any situation where the compiler cannot be sure you're using primitives everywhere, it will emit non-overflowing bytecode.
By my measure, there's nothing premature about this optimization. In Rich Hickey's words, Clojure is a replacement for Java, not Ruby. Giving up Java-like performance makes the language quantitatively less useful.
That Clojure's target is to replace slow old Ruby (actually that never happens, rather a successful language gains dominance in some niche and spreads from there) is only more evidence that it isn't worth breaking the abstraction called "numbers" to get merely an order of magnitude better performance. Seriously, I almost can't believe this is still an open issue in 2010. And Rich Hickey, who has designed such a great language otherwise, is on the wrong side of it? I'm boggled.
EDIT: If peregrine's comment is right, then we're arguing about something that isn't happening. I hope so.
Premature? No people have been complaining (or just getting very confused) about Clojure's numeric performance without oodles of invasive type-hinting for two years now.
More importantly with these changes it's now possible to reimplement Clojure's core datastructures in Clojure without sacrificing performance.
The majority of people who care about BigInts are solving Project Euler problems, not writing Clojure libraries or deploying apps into production.
The situations that deal with numbers that large are usually a bit nuanced. (i.e., "it's 1 in 2^63 of the time that I need bignums for day-to-day programming"). I agree that losing accuracy needlessly sucks (and I've been burned by floating-point), but 64 bit ints are usually good enough.
Correct, promotion will no longer be automatic because the semantics of primitive and auto-promoting arithmetic can't be unified (on the JVM with no fixnums, the return types are disjoint). However, missing from the blog post and discussion here is the fact that, should there be overflow, an exception will be thrown. We are not adopting the silent error strategy of C/Java etc.