Live data from Hacker News

Data Structures in Clojure: Hash Tables

macromancy.com

1–10 of 13 posts

Re: Data Structures in Clojure: Hash Tables

#2
> On the machine this was implemented, insertion speed increased ~110x, compared with the non-hinted implementation.

That makes it sound like type hints are essentially mandatory for anything where performance matters.

Nice article! It would have been interesting to see how it fares against something like java.util.HashMap.

Re: Data Structures in Clojure: Hash Tables

#3

> On the machine this was implemented, insertion speed increased ~110x, compared with the non-hinted implementation. That makes it sound like type hints are essentially mandatory for anything where performance matters. Nice article! It would have been interesting to see how it fares against something like java.util.HashMap.

Yeah, the less runtime reflection you make it use, the better the speed gains (I'm glad type hints are optional though).

Re: Data Structures in Clojure: Hash Tables

#4
post #3

> On the machine this was implemented, insertion speed increased ~110x, compared with the non-hinted implementation. That makes it sound like type hints are essentially mandatory for anything where performance matters. Nice article! It would have been interesting to see how it fares against something like java.util.HashMap.

Yeah, the less runtime reflection you make it use, the better the speed gains (I'm glad type hints are optional though).

I only start type hinting if performance has proven to be a problem.

Re: Data Structures in Clojure: Hash Tables

#7

> On the machine this was implemented, insertion speed increased ~110x, compared with the non-hinted implementation. That makes it sound like type hints are essentially mandatory for anything where performance matters. Nice article! It would have been interesting to see how it fares against something like java.util.HashMap.

As the article suggests, rather than consider type hints mandatory, it's better just to check whether you need them with warn-on-reflection.

Re: Data Structures in Clojure: Hash Tables

#8

> On the machine this was implemented, insertion speed increased ~110x, compared with the non-hinted implementation. That makes it sound like type hints are essentially mandatory for anything where performance matters. Nice article! It would have been interesting to see how it fares against something like java.util.HashMap.

If performance matters _and_ you're doing interop with java.

Re: Data Structures in Clojure: Hash Tables

#10

Very nitpicky but I find the ligatures on all the "t" characters very distracting. Additionally, I don't know Closure, but are there any default hash-table implementations? If so, how does this implementation compare against the base one?

It's Clojure with a "j".

Clojure provides Persistent Hash Tries (look them up) as well as several other immutable map implementations. Mutable maps are provided by the Java base class libraries.

Post reply on HN