erlang

Relation between language and scalability

I came across the following statement in Trapexit, an Erlang community website: Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Also I recall reading somewhere that Twitter switched from Ruby to Scala to address scalability problem. Hence, I won...

Erlang : Which is more efficient in this scenario - using try catch or case statements?

Say I have some function fn1() in Erlang which returns {ok, Result} if the function was executed successfully and {error, "ErrorReason"} if there was an error. Now in another function fn2() I call fn1() and I need to check the result of fn1 and proceed only if it is {ok, Result}. I figured, I can do this using either case or try catch...

Erlang: how to embed inets:httpd ?

What is the proper way to embed the inets:httpd module inside an existing application? I would like an example / guidelines to achieving this, please. Updated: I want to be able to start an inets:httpd service dynamically from within an existing application. I do not want a solution which leverages a boot script as using this method do...

Erlang: cascaded supervisors?

Is it possible to cascade supervisors inside an application? E.g. supervisor sup1 spawning a child process which creates a supervisor sup2 ? ...

Is erlang considered managed or do you have to handle memory/pointers?

Is erlang considered managed or do you have to handle memory/pointers? ...

erlang and scala, do they run on apache?

erlang and scala, do they run on apache? ...

Where is $ERL_TOP on a macports installation of Erlang

I've installed Erlang through macports on my macbook and I'm trying to use the Erlang Eclipse plugin, but it needs me to point it to the $ERL_TOP directory. Where does that exist? I know my erl binary shell is located at: which erl /opt/local/bin/erl ...

Erlang: gen_server or my own custom server?

I need to write a server that will receive instructions from other modules and take actions depending on the instructions received. Efficiency is my main concern. So do I use gen_server or do I write my own server. By "my own server" I mean something like: -module(myserver). -export([start/0, loop/0]). start() -> spawn(myserver...

Erlang: when to perform `inets:start()` ?

What is the appropriate place for performing inets:start() ? in `applicationname_app' module? in applicationname_sup supervisor module? in a child process hanging from the supervisor?\ someplace else? (I am still struggling with inets:httpd) Note: the answer cannot be to the tune " use a boot file " , please. ...

Achieving code swapping in Erlang's gen_server

I am looking to make use of Erlang's hot code swapping feature on a gen_server, so that I don't have to restart it. How should I do that? When I searched, all I could find was one article which mentioned that I need to make use of gen_server:code_change callback. However, I could not really find any documentation/examples on how to use...

Erlang: multiple behaviors defined in the same module?

Q: I'd like to have an idea of the pros and cons of defining multiple behaviors in the same module file. E.g. -module(someapp_sup). -behavior(supervisor). -behavior(application). Using this sort of layout, I can save a module file whilst not loosing much on the maintainability side (the whole application is started through someapp...

Erlang: specifying a working directory for mnesia?

How do I specify a working directory for mnesia without resorting to passing the "dir" parameter on the command-line? In other words, can I specify a "working directory" for mnesia just before calling `mnesia:start()' ? ...

Erlang: side effect(s) to calling mnesia:create_schema more than once?

Is there a side effect to calling mnesia:create_schema() on each application start? From what I keep reading, this function should only be called once per database instance. Is it a big issue to call it more than once on an existing database? ...

Erlang Front-End Admin Panel

We're looking for a framework in which we can assign multiple roles to different users and allow those users to in turn manipulate certain data (based on their role). We have an ejabberd backend and a Mochiweb (BeepBeep framework) front end, and the nodes are connected so Mochiweb can manipulate ejabberd's mnesia tables. Does a direc...

Mochiweb : Reading a file as it is uploaded

I want to be able to read a file just as it is being uploaded by the user, i.e. I want to read the incoming stream of bytes from the user's browser.. Is that possible with Mochiweb? If not, where do I need to look/modify? If something else easier exists on Yaws, that will also be great. Thanks. ...

Eunit timeout doesn't work

Hi, I am trying to run all unit tests using eunit inside a folder but it seems like timeout always reset to 5 seconds. e.g. Module: -module(example). -include_lib("eunit/include/eunit.hrl"). main_test() -> % sleep for 10 seconds ?assertEqual(true, begin timer:sleep(10000), true end). Command line: Eshell V5.7.3 (abort wit...

Erlang: what is the difference between "include_lib" and "include" ?

What is the difference between "include_lib" and "include" ? E.g. -include_lib("eunit/include/eunit.hrl") ...

Backtracking in Erlang

First of all sorry for my English. I would like to use a backtracking algorithm in Erlang. It would serve as a guessing to solve partially filled sudokus. A 9x9 sudoku is stored as a list of 81 elements, where every element stores the possible number which can go into that cell. For a 4x4 sudoku my initial solution looks like this: [[1...

Profiling Mnesia Queries

Our Mnesia DB is running slowly and we think it should be somewhat faster. So we need to profile it and work out what is happening. There are a number of options that suggest themselves: run fprof and see where the time is going run cprof and see which functions are called a lot However these are both fairly standard performance ...

'zip' in Erlang

I'm just wondering if there is a ready implementation of zip-function in the standart erlang library. Something like that: zip([H1|T1], [H2|T2], Acc)-> zip(T1, T2, Acc ++ [{H1, H2}]); zip([], [], Acc) -> Acc. ...