[erlang-questions] Tuples Vs Maps

Joe Armstrong erlang@REDACTED
Wed Sep 16 12:52:54 CEST 2015


On Wed, Sep 16, 2015 at 7:11 AM, Avinash Dhumane <nistrigunya@REDACTED>
wrote:

> I find it more expressive to use maps wherever I have been using tuples.
> Especially, when it comes to pattern matching.
>
> It is precise to put #{some_key := some_value} instead of {_, _, _,
> {some_key, some_value}, _, _} as a pattern.
>
> I only fear efficiency of maps over tuples, in particular the time-cost,
> not so much of space-cost.
>
>
You've set me off - I'm allergic to the word efficiency

Premature worrying about efficiency is not a good idea. You should

     1) Build and make correct
     2) Measure if you need to
     3) Optimise if necessary

Step one is the tricky bit - in 38 years of programming I can only
recall having to optimise a handful of programs.

In the last 20 years computers have become literally millions of times
faster. The Erlang of today is millions of times faster than that of 1986
(the first Erlang) - at a guess a factor 10-20 comes from better
implementation
techniques - the real speedup comes from hardware.

(So if you want a real speedup wait 10 years - you do *nothing* it just
gets faster ) in ten years time any design decisions you made about tuples
vs.
maps will be irrelevant - if you use any code you wrote ten years ago
you will value it being written as clearly and beautifully as possible.

I saw a quote on the notice board at bell labs years ago (not sure who said
it)
it was.

    " An incorrect program can be made arbitrarily fast "

The tricky bit is making programs that work - and that you can still
understand years after you wrote them.

/Joe




> How safe will I be if I resort to use only maps freely everywhere?
>
> Thanks
> Avinash
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150916/ea120467/attachment.htm>


More information about the erlang-questions mailing list