1. 7 months ago

    Build Erlang R14Bx on Mac OS X Lion

    Usually to build software from source on Linux or Mac OS X, you follow the pattern:

    ./configure
    make
    sudo make install
    

    When trying this on Mac OS X Lion you’ll find that make is no longer part of the OS like it was with Snow Leopard and before. Instead, it is part of Xcode 4.1 or greater. So you need to head to the Mac App Store app and get your free copy of Xcode 4.1 (or greater) so that you’ll have make installed.

    Another wrinkle, specifically for getting Erlang from source, is that there are some obscure flags you need to use with configure to get Erlang to build cleanly. This sequence works (tested on Erlang R14B03 and Lion 10.7 (11A511):

    CFLAGS=-O0 ./configure --enable-darwin-64bit
    make
    sudo make install
    

    Thanks to the community on the Erlang questions mailing list for collaborating on this solution. I’m just passing it along.

    Erlang

    mac os x

    Lion

  2. 10 months ago

    Link > Erlang's Treatment of Memory and Threads

    This is a good, short post on Erlang’s unusual treatment of memory and threads. Substitute “Ruby” or “Python” for “Java” if it makes it easier for you to understand and none of the comparisons will be much different. It serves to explain why you overlook Erlang’s quirky syntax (which I happen to mostly like) when you need extreme concurrency.

    Erlang

  3. 1 year ago

      Erlang native compilation, why not?

      1. belucid: what are the downsides of compiling Erlang native? (HiPE) Any reason not to use it all the time?

      2. MononcQc: the native modules aren't garbage collected when loading a new version

      3. MononcQc: also they are not portable like .beam files

      4. MononcQc: they're slower to compile and are not necessarily faster

      5. MononcQc: but they are entirely worth it for numerical stuff

      6. belucid: ok

      7. belucid: so I should run some perf tests with both

      8. belucid: and see if it makes a diff for my application

      9. MononcQc: ideally, yeah

      10. MononcQc: always measure

      11. belucid: yep

      12. belucid: and then... if they do make a meaningful diff, the impact is that I really shouldn't plan to load new versions

      13. belucid: and of course, need to compile for the target machine

      14. MononcQc: oh, load new versions all you like

      15. MononcQc: it's not a big overhead

      16. MononcQc: just something to consider

      17. belucid: ok

      18. belucid: just shouldn't plan on loading new versions forever and ever then

      19. belucid: at some point it would add up

      20. MononcQc: yeah, but then you'll need to tear the node down to upgrade the VM

      21. MononcQc: so I'm not sure it's actually that problematic in practice

      22. belucid: gotcha

      23. belucid: on days like today, Erlang R14B release day

      24. belucid: you'll bring the app down anyway

      25. belucid: thanks as always MononcQc!

      26. MononcQc: no problem

      Erlang

  4. 1 year ago

    The Erlang Shell

    One option to running the Erlang shell when your code is in ./src, including files in ./include, and building to ./ebin is to run erl from ./src as such.

    erl -pa ../ebin

    All your modules are then local and can be accessed. You can include records with rr(module).

    Thanks MononcQc on #erlang.

    Erlang

  5. 1 year ago

    Zipper

    A zipper is a data structure that provides constant time access for some important class of operations, namely access to the current, next, and previous elements, and insert and delete at the current element.

    For those not familiar, the difference between a data structure that provides O(log n) or O(n) for an operation, and one that provides constant time, is that the former take longer and longer as the number of elements in the data structure grow, while the latter takes a fixed amount of time, even as the data in the data structure grows.

    A zipper uses two lists:

    { [ previous | list of previous items in backwards order ], [ current | list of next items in forward order ] }

    So a zipper of the alphabet, that is currently at the letter L looks like:

    { [ K | J,I,H,G,F,E,D,C,B,A ], [ L | M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ] }

    To traverse to the next letter, M, we simply take the head (L) off the second list and append it to the first. That happens in constant time of course.

    { [ L | K,J,I,H,G,F,E,D,C,B,A ], [ M | N,O,P,Q,R,S,T,U,V,W,X,Y,Z ] }

    To traverse to the previous letter, we simply take the head (L) off the first list and append it to the second. It’s the same operation, so of course it happens in constant time too.

    { [ K | J,I,H,G,F,E,D,C,B,A ], [ L | M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ] }

    Now let us suppose the IAA (International Alphabet Association) decreed that there should be a new letter ∀ (pronounced vlork) that comes between K and L. We simply insert vlork as the head of the 2nd list. A constant time operation.

    { [ K | J,I,H,G,F,E,D,C,B,A ], [ ∀ | L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ] }

    And when the IAA comes to their senses after the inevitable public outcry, we delete vlork by removing it from the head of the 2nd list. You guessed it, still in constant time.

    { [ K | J,I,H,G,F,E,D,C,B,A ], [ L | M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ] }

    Our example alphabet list has just 26 items. But it could have 26 million items and the time it takes to get the current item, traverse to the next item, traverse to the previous item, insert at the current place, or delete at the current place is constant.

    A zipper may not seem like much for languages with pointers or dynamic object references, since it has the same access time characteristics as a doubly-linked list. But for functional languages like Erlang or Haskell, with single assignment and no pointers (very important characteristics for robust concurrency), the zipper is an important data structure.

    Thus far, I’ve only talked about zippers and lists. More later on zippers and trees.

    References:

    Yet Another Article on Zippers, in Erlang

    You could have invented zippers

    programming

    data structures

    Erlang