Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize groupBy using sofs #12

Closed
wants to merge 1 commit into from
Closed

Optimize groupBy using sofs #12

wants to merge 1 commit into from

Conversation

bjorng
Copy link

@bjorng bjorng commented Feb 24, 2015

On my computer, this optimization made it run 10 times faster.

On my computer, this optimization made it run 10 times faster.
@andreaferretti
Copy link
Owner

Just to be sure - I received the Erlang example, so I am not able to judge. The examples in other languages all use a groupBy operation, which in turn is usually implemented with a hashmap. Is this approach in Erlang equivalent?

@bjorng
Copy link
Author

bjorng commented Feb 24, 2015

sofs does not use a hash map. It works by sorting the
list and then goes through the sorted list and groups
the values.

The rules says "idiomatic code", so I wrote idiomatic
code.

On Tue, Feb 24, 2015 at 10:55 AM, andreaferretti notifications@github.com
wrote:

Just to be sure - I received the Erlang example, so I am not able to
judge. The examples in other languages all use a groupBy operation, which
in turn is usually implemented with a hashmap. Is this approach in Erlang
equivalent?


Reply to this email directly or view it on GitHub
#12 (comment).

Björn Gustavsson, Erlang/OTP, Ericsson AB

@andreaferretti
Copy link
Owner

Unfortunately, this makes hard to compare the results with other languages. Would it be possible to provide a hashmap-based implementation?

@jlouis
Copy link

jlouis commented Feb 24, 2015

In general, no. Hashmaps in the traditional sense can't be implemented in a functional language because of data persistence. You can fake hashmaps pretty well through HAMT structures, but you won't get the same speed as a system which is able to do destructive updates. Once you begin looking at idiomatic Haskell or OCaml, chances are this will bite you as well.

@andreaferretti
Copy link
Owner

Well, HashMaps certainly do no need to be mutable. Scala has immutable, persistent hashmaps, and I think both OCaml and Haskell have them (but I am not sure).

@jlouis
Copy link

jlouis commented Feb 24, 2015

Both OCaml and Haskell have hashmap implementations, but you run into the trouble of what idiomatic means.

@andreaferretti
Copy link
Owner

I settled accepting the other pull request which follows more closely what is done in other languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants