From 0x6e6562@REDACTED Wed Aug 1 00:38:41 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 31 Jul 2007 23:38:41 +0100 Subject: [erlang-questions] Sending message to process already listening on a socket In-Reply-To: References: <269388e30707301529u74ec7f98l4621674419948055@mail.gmail.com> Message-ID: <269388e30707311538l1661e018we6718428db5ab2ce@mail.gmail.com> > If you use the socket option {active, once} you will > get the TCP data in the process mailbox. See the > man pages for inet and gen_tcp. Great! Can I assume that this works irrespective of which peer initiated the tcp connection, i.e. if I have a client side loop (the peer that connected to the server socket) that is receiving frames from the server? Thanks, Ben From chandrashekhar.mullaparthi@REDACTED Wed Aug 1 01:12:40 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 1 Aug 2007 00:12:40 +0100 Subject: [erlang-questions] Sending message to process already listening on a socket In-Reply-To: <269388e30707311538l1661e018we6718428db5ab2ce@mail.gmail.com> References: <269388e30707301529u74ec7f98l4621674419948055@mail.gmail.com> <269388e30707311538l1661e018we6718428db5ab2ce@mail.gmail.com> Message-ID: On 31/07/07, Ben Hood <0x6e6562@REDACTED> wrote: > > If you use the socket option {active, once} you will > > get the TCP data in the process mailbox. See the > > man pages for inet and gen_tcp. > > Great! Can I assume that this works irrespective of which peer > initiated the tcp connection, i.e. if I have a client side loop (the > peer that connected to the server socket) that is receiving frames > from the server? > Yes. Chandru From jla415@REDACTED Wed Aug 1 01:14:19 2007 From: jla415@REDACTED (jla415) Date: Tue, 31 Jul 2007 16:14:19 -0700 (PDT) Subject: [erlang-questions] example of race conditions ? In-Reply-To: <89C58813-7413-4BC3-95F9-1C0D60A8FFB5@ketralnis.com> References: <1085.81.149.81.161.1185898704.squirrel@webmail.erlangsystems.com> <89C58813-7413-4BC3-95F9-1C0D60A8FFB5@ketralnis.com> Message-ID: <11936940.post@talk.nabble.com> David King-6 wrote: > >> The problem is that only one process can have a certain name and what >> happens if more then one process want a certain name? > > This example is basically identical to mine (and sent a few minutes > before mine), so I'm glad to see that my concern about it is warranted. > > What is considered "the" solution to this? To create these processes > before calling functions that may use them? What if you're writing a > module that others may use, and don't have control over their startup > process? Or what if a given daemon process is rarely used? It seems a > waste of resources to spawn it if it may never be used. Can the > process-table be locked? That doesn't seem very Erlang-ish either. > First off let me say processes are extremely cheap and that you shouldn't be concerned with keeping a daemon process around that may not be used. if you have something that needs to stay running with a registered name you should probably be running something like a gen_server in a supervision tree which would prevent worrying about all this stuff in the first place. Having said all that, the way to start a process and ensure only one process is running and registered is to first spawn the new process, then register it inside the new process. spawn(fun() -> register(?NAME, self()), server_loop() end). on subsequent attempts to start the process the newly spawned process will die with badarg during the register() call which ensures only 1 process is running at a time. if you had done it by first spawning the process then registering it from the parent there is a possibility of multiple processes running. eg: Pid = spawn(fun server_loop/0), register(?NAME, Pid). in the above example if ?NAME was already registered the newly created process would continue to run in this example and the parent process would die with badarg from the register call. Probably not what you had in mind... if you need to do something more complicated like return the registered pid every time you try to call a function things get a little more complicated and you'd need to do something along the lines of the following to get around all the little race conditions that can occur. ensure_running() -> case whereis(server) of undefined -> Parent = self(), spawn(fun() -> register(server, self()), Parent ! {registered, self()}, server_loop() end), receive {registered, P} -> P after 5000 -> whereis(server) end; P -> P end. this version will ensure there is only 1 spawned process running and the registered pid returned even in the case that 2 different processes try at the same time and the initial whereis() returns undefined. In this case the second process to try to register itself would die and the parent would time out and fall back to whereis to try to grab the pid from the first successful registration. You could also use something like a monitor to catch the exit instead of using the timeout. So yes, while not exactly pretty it is possible to do what you are trying to do and still remain lock free -Jason -- View this message in context: http://www.nabble.com/example-of-race-conditions---tf4194003.html#a11936940 Sent from the Erlang Questions mailing list archive at Nabble.com. From chandrashekhar.mullaparthi@REDACTED Wed Aug 1 01:11:37 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 1 Aug 2007 00:11:37 +0100 Subject: [erlang-questions] sending packets using gen_udp In-Reply-To: <46AE3475.9040706@free.fr> References: <46AE3475.9040706@free.fr> Message-ID: On 30/07/07, igwan wrote: > Hi, > > I have a process that sends a number of UDP packets at a time using > gen_udp:send/2 . > I open the socket with : > > {ok, Socket} = gen_udp:open(Local_port, [binary, {sndbuf, 16#100000}]) > > then I send my 100 binary packets in a loop (1472 * 100 = 147200 bytes > so this shouldn't fill my send buffer). gen_udp:send/2 returns 'ok' each > time, but only 9 packets reach my network interface. Only when I send > 200 or more packets at a time I get {error, eagain} but still only 9 > packets reach the interface. > > Why do packets get lost before being sent and without an error ? Where are you sending the packets? When you say you see only 9 packets on your network interface, which n/w interface are you talking about? The source or the destination? If it is the destination, probably your receiving end has a small receive buffer? From dmercer@REDACTED Wed Aug 1 01:12:12 2007 From: dmercer@REDACTED (David Mercer) Date: Tue, 31 Jul 2007 18:12:12 -0500 Subject: [erlang-questions] Abstract Data Type: tape Message-ID: <006101c7d3c8$3ac44650$891ea8c0@SSI.CORP> I am writing my first Erlang program, and found myself requiring a data type that simulates a finite tape (i.e., a finite version of a Turing machine's tape). I am attaching here the documentation (produced by edoc) and the module source code in case anyone is interested. On the off-chance that someone is interested, I wonder if you could help me: 1. Did I take the correct overall approach? No knowledge of the internal storage of a tape is required in order to use the ADT, so I think I did it about right. 2. Is the module name "tape" appropriate, or should I either rename it to "finite_tape" or add support for infinite tapes in order to name it "tape"? While I am sure you're thinking that's up to me, ideally, if this is useful to others, I would submit it to some repository for use by others. 3. Do I handle errors correctly? I was kind of schizophrenic in that I do not handle a move beyond the edge of the tape (causing an error), but in other cases, such as reading or writing a tape cell, I return the {ok, .} tuple or an atom indicating an error. (I suppose I should have returned {error, null_tape} instead of plain old null_tape in this case, right?) The cause of my schizophrenia was that I started out thinking that The Erlang Way is to not do any error checking and let errors fall where they may, but then I thought of other Erlang code which prefers to signal exceptions with the return tuple, so I switched my style half way through. Naturally, I would fix this before publishing, but I just don't know which way to fix it. Advice? 4. Did I document it using edoc correctly? Mainly I just used @spec's and @doc's, and the result is attached. 5. Does anyone else think this is useful, or is this functionality already available in a library somewhere that I overlooked? 6. Is it normal in Erlang, when creating functions that act on an ADT, for the abstract data value to be passed as the last argument (as I did) or to pass it as the first argument? E.g., should I have defined move/2 as move(N::integer() | first | last, Tape::tape()) -> tape() or move(Tape::tape(), N::integer() | first | last) -> tape() ? Any advice appreciated. Else, I'll continue along my happy way. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: tape.erl Type: application/octet-stream Size: 6348 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Wed Aug 1 01:14:39 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 1 Aug 2007 00:14:39 +0100 Subject: [erlang-questions] Efficiency of passing data through port owner In-Reply-To: <862881.42609.qm@web52006.mail.re2.yahoo.com> References: <862881.42609.qm@web52006.mail.re2.yahoo.com> Message-ID: On 31/07/07, Richard Andrews wrote: > I have a set of processes in mind: > > Receiver process assembles out-of-sequence parts of a large message sent by > other processes so the whole message can go out a port as a binary when > assembled. > > PortIO process handles data coming back from the port ExternalPort and as such > is the port owner. > > I'm inexperienced with using ports and I'm looking for hints on how to > efficiently get the data accumulated in Receiver out through ExternalPort. The > obvious approach is to send the full message to PortIO which then sends it to > ExternalPort, but I am concerned that this introduces inefficiency due to the > size of the message. > > Would the above strategy result in a copy of the message binary being made from > Receiver to PortIO prior to being pushed out the port? Depends on the size of the message. Binaries smaller than 64 bytes (I think) are copied whereas bigger binaries are passed by reference. See http://www.erlang.org//doc/efficiency_guide/processes.html#5.2 > > Is is possible to send directly from Receiver to ExternalPort (eg. registered > port), but have data come back from ExternalPort into PortIO? Yes. > If possible, is it a recommended approach? There is no reason not to do it this way. I would recommend this approach so that the PortIO process does not become a bottleneck. > Is it possible for PortIO to also reliably send messages and admin commands to > ExternalPort in this situation? Yes. > Is there a potential for messages to get > corrupted by interleaving if sent to the port from different processes at the > same time? No. > Would TCP be better than a pipe-based port? Ports are really meant as an access mechanism to existing programs on the same host as the erlang node. If you want the flexibility to host the two processes on different pieces of hardware then ports are not suitable. On a UNIX box, Erlang ports use pipes as the IPC mechanism. Not sure about Windows. Chandru From chandrashekhar.mullaparthi@REDACTED Wed Aug 1 00:54:45 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Tue, 31 Jul 2007 23:54:45 +0100 Subject: [erlang-questions] Maximum number of Mnesia nodes In-Reply-To: References: <001801c7d060$f18e6f70$b029030a@mtl.ubisoft.org> Message-ID: On 27/07/07, Hakan Mattsson wrote: > > > Chandru, do you still have the highscore of the number > of Mnesia nodes in a production environment? > > /H?kan > I don't think so :-) At one point we had 24 nodes participating in an mnesia schema. It used to work quite well. The only problem was that recovering from partitioned networks was a bit of a pain. Eventually we got fed up and bought a slightly bigger machine. Now, the entire database fits in two erlang nodes running on the same box (we needed two nodes because of the 4GB limit). But now with 64 bit erlang, I'm getting rid of this scheme as well and putting the entire database in a single erlang node with 128 fragments for the customer table. It's amazing how much memory you can get on a single blade server these days. Chandru From 0x6e6562@REDACTED Wed Aug 1 00:48:55 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 31 Jul 2007 23:48:55 +0100 Subject: [erlang-questions] Sending message to process already listening on a socket In-Reply-To: <18094.62380.145458.235142@antilipe.corelatus.se> References: <269388e30707301529u74ec7f98l4621674419948055@mail.gmail.com> <18094.62380.145458.235142@antilipe.corelatus.se> Message-ID: <269388e30707311548r610085c3u9515c41eff07defb@mail.gmail.com> Thanks for you help. On 7/31/07, Matthias Lang wrote: > > 1. Yes, messages are queued up until consumed. I've been wondering about the formal semantics of erlang message passing. Do you know of a reference where this is described in more detail (like a language or VM spec), or do you just have to read the source code? > 3. If your message handling starts getting complicated and you > complicate your code to try and prevent blocking, then that's > often a sign that you're trying to get one process to solve a > problem which would be more cleanly solved by two or more processes. Fair point. The code up until now was receiving frames from the socket and then based on frame content, was dispatching to different consuming processes. The routing decision was based on a channel number in the frame for which there was a channel-to-pid mapping in the process dictionary. I was just trying to find a way to register new processes for new channel numbers with the process implementing the loop. I ended up solving this by doing a short blocking receive on the process mailbox for a new registration if a got a cache miss from the process dictionary, thereby only blocking the socket listener if it didn't know what to do with the received data anyway. However, by using the {active, once} option, I could probably listen for new process registrations more elegantly. Thanks, Ben From ok@REDACTED Wed Aug 1 03:30:52 2007 From: ok@REDACTED (ok) Date: Wed, 1 Aug 2007 13:30:52 +1200 Subject: [erlang-questions] A* algorithm In-Reply-To: <14f0e3620707310729r6dc6569cyd30c2f0faa377a68@mail.gmail.com> References: <14f0e3620707290617rda259acq6167baa546c81173@mail.gmail.com> <46AE9162.1040008@pmp.com.au> <14f0e3620707310729r6dc6569cyd30c2f0faa377a68@mail.gmail.com> Message-ID: Someone asked about implementations of A* in Erlang or any other functional language. One important thing to understand about A* is that it is not a complicated algorithm at all; the Haskell version someone pointed to is harder to read than need be. Here's the pseudo-code from the Wikipedia page: function A*(start,goal) var closed := the empty set var q := make_queue(path(start)) while q is not empty var p := remove_first(q) var x := the last node of p if x in closed continue if x = goal return p add x to closed foreach y in successors(x) enqueue(q, p, y) return failure From that we can easily see that there are two key data structures: a "closed" set and a min-priority-queue (q). Suitable data structures are available for Erlang, meaning that finishing the job is about a page of code. (My Prolog version is 307 lines including blank lines and comments, 159 SLOC including implementations of all data structures, 61 lines excluding data structures.) However, we can also see the second important thing about A*, which is that *every* state it has ever heard of is *stored* in one of those two data structures. If (number of nodes) * (new space required per node) is high, that is, if it is a non-trivial problem, you probably don't want A*. You want IDA*. I note that there was a paper about parallel IDA*: Efficient Parallel Execution of IDA on Shared and Distributed Memory Multiprocessors Saletore, V.A. Kale, L.V. Oregon State University; This paper appears in: Distributed Memory Computing Conference, 1991. Proceedings., The Sixth Publication Date: 28 Apr-1 May 1991 On page(s): 355-361 ISBN: 0-8186-2290-3 I haven't actually seen that paper myself. From david.hopwood@REDACTED Wed Aug 1 02:49:26 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Wed, 01 Aug 2007 01:49:26 +0100 Subject: [erlang-questions] Sending message to process already listening on a socket In-Reply-To: <269388e30707311548r610085c3u9515c41eff07defb@mail.gmail.com> References: <269388e30707301529u74ec7f98l4621674419948055@mail.gmail.com> <18094.62380.145458.235142@antilipe.corelatus.se> <269388e30707311548r610085c3u9515c41eff07defb@mail.gmail.com> Message-ID: <46AFD896.5090908@industrial-designers.co.uk> Ben Hood wrote: > Thanks for you help. > > On 7/31/07, Matthias Lang wrote: >> 1. Yes, messages are queued up until consumed. > > I've been wondering about the formal semantics of erlang message > passing. It is 1-1 FIFO; that is, messages are queued in FIFO order between any given pair of processes, but there are no other constraints on ordering. For a formal definition of 1-1 FIFO, see Definition 3.3 in: Bernadette Charron?Bost, Friedemann Mattern, Gerard Tel "Synchronous, asynchronous, and causally ordered communication" Distributed Computing (1996) 2:173--191, Springer-Verlag. or (that paper just calls it "FIFO"). A brief explanation, so you don't necessarily have to read the whole paper: a pair (s, r) represents a message transmission where s is the send event, and r is the receive event. So Definition 3.3 says that if two messages are sent by the same process (s ~ s') and received by the same process (r ~ r'), then they are received in the same order they were sent (s < s' => r' < r'). Note that messages will be dropped if the target process dies, or if there is a network error when a message is being sent between nodes. -- David Hopwood From bengt.kleberg@REDACTED Wed Aug 1 07:30:54 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 01 Aug 2007 07:30:54 +0200 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com> <46AE9057.0@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> Message-ID: <46B01A8E.3080709@ericsson.com> On 2007-07-31 23:35, Jim McCoy wrote: > One > interesting bit that py2exe enables is a variety of options regarding > how to handle the archive file itself; python imports are pulled out > of the zip archive, but DLLs can be provided as individual files that > are distributed with the collection of file if it is ok to run your program from a single archive, but have the erlang runtime separately installed (via CEAN :-) you can use escript. i have made an escript called besea that will create archives that are themselfs escripts. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From bengt.kleberg@REDACTED Wed Aug 1 10:07:42 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 01 Aug 2007 10:07:42 +0200 Subject: [erlang-questions] input too fast In-Reply-To: References: <6616D98C65DD514BA2E1DDC5F9223155022F9A68@esealmw115.eemea.ericsson.se> Message-ID: <46B03F4E.206@ericsson.com> On 2007-07-13 15:00, Daniel Kwiecinski wrote: > Hi, > > After further investigation I can see that under Windows eof is not > detected at all :(. that is a known bug since ages ago. first time i reported it was when when the shootout (original site (http://www.bagley.org/~doug/shootout) no longer responding) was hosted on windows (http://dada.perl.it/shootout). there erlang had no scores for io benchmarks. i could not understand why since my programs worked on unix. in those days io was more dominant. see Timing Trials, or, the Trials of Timing (http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html), for background. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From bengt.kleberg@REDACTED Wed Aug 1 10:14:09 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 01 Aug 2007 10:14:09 +0200 Subject: [erlang-questions] input too fast In-Reply-To: <6296397.3321184355347805.JavaMail.root@zimbra> References: <6296397.3321184355347805.JavaMail.root@zimbra> Message-ID: <46B040D1.9030803@ericsson.com> On 2007-07-13 21:35, Michael FIG wrote: > Fredrik Svahn writes: > >> While I agree that "" seems to be a perfectly valid (although not >recommended) filename in all(?) unix systems I do not think that using an atom will >help. > > Why not use a Unix convention, "/dev/stdin" and "/dev/stdout"? in case you missed it i think my latest suggestion(*) sidesteps the problem neatly. (*) add the possibility to handle the atom standard_io as an IoDevice in file:read/2, write/2, pread/2-3, pwrite/2-3. 1 this is backwards compatible since nobody can have used an atom here. 2 it is consistent since the io module has this possibility already. it might be a good idea to add a access stderr, too. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From Chris.Curtis@REDACTED Wed Aug 1 15:11:07 2007 From: Chris.Curtis@REDACTED (Chris Curtis) Date: Wed, 1 Aug 2007 09:11:07 -0400 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> Message-ID: <36E4692623C5974BA6661C0B18EE8EDF7FF9EE@MAILSERV.hcrest.com> Peter Chan wrote: > I understand how a fully packaged executable could be difficult to do > hot code replacement and updates. > > It may be an issue of deployment scenario. If I am deploying on the > server, I value hot code replacement, but if I am deploying on client > side, I value compactness. > > I personally think that for a client side deployment with no need to do > hot code replacement or package updates, something like the > RubyScript2Exe would be perfect (for me, anyway). Yep, I'm pretty much in agreement. None of the desktop-distributed applications I have in mind really need the hot-update model. I've been poking around a little at SAE R9 and it seems relatively straightforward -- at least at the general level -- except for how to actually build it. ;-) As far as I can make out so far, it's a bootstrap issue. Building anything requires ecc, which is what I'm trying to build. I may be completely misunderstanding something, though... I'm not a seasoned Erlangist by any means. --chris From matthew.pflueger@REDACTED Wed Aug 1 15:01:14 2007 From: matthew.pflueger@REDACTED (Matthew Pflueger) Date: Wed, 1 Aug 2007 09:01:14 -0400 Subject: [erlang-questions] Encrypted Mnesia database? Message-ID: <7037df270708010601m2df5925ev613bbea73fe4aee2@mail.gmail.com> I have an application I would like to write in Erlang. I would also like to utilize Mnesia. A stringent requirement however be that each user's information be encrypted and be kept separate from other user's information. I was looking at utilizing an embedded database like Db4o with encryption capabilities for each user but that would mean using Java or .NET as my platform (ugh). Does anybody have any ideas on how to encrypt a Mnesia database table? I would like to create a disk based table for each user. The user's credentials would be used to locate the appropriate Mnesia table and also as the key to decrypt the table on the fly at the file IO layer. Any thoughts on the matter would be greatly appreciated... -Matthew -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Aug 1 15:40:50 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Aug 2007 14:40:50 +0100 Subject: [erlang-questions] Encrypted Mnesia database? In-Reply-To: <7037df270708010601m2df5925ev613bbea73fe4aee2@mail.gmail.com> References: <7037df270708010601m2df5925ev613bbea73fe4aee2@mail.gmail.com> Message-ID: <0DF34E81-996C-4622-ACEC-166AE5E9DA68@gmail.com> Add a new table type by hacking Mnesia, e.g. encrypted_disc_copies? I did it for Amazon S3 and I'm available for consulting assignments ;-). On Aug 1, 2007, at 2:01 PM, Matthew Pflueger wrote: > Does anybody have any ideas on how to encrypt a Mnesia database > table? I would like to create a disk based table for each user. > The user's credentials would be used to locate the appropriate > Mnesia table and also as the key to decrypt the table on the fly at > the file IO layer. -- http://topdog.cc - EasyLanguage to C# compiler http://wagerlabs.com - Blog From pete@REDACTED Wed Aug 1 17:45:56 2007 From: pete@REDACTED (Pete Young) Date: Wed, 1 Aug 2007 16:45:56 +0100 Subject: [erlang-questions] Question on implementing a Megaco MGC Message-ID: <20070801154556.GA22726@server30077.uk2net.com> Greetings, I'd like to implement a Megaco Media Gateway Controller, and as a lapsed functional programming enthusiast it seems that doing it in Erlang would be a good way to go about it. Ideally I'd like to be able to set up voice calls between two media gateways. I've been studying the megaco_simple_mgc example and the megaco_test_mgc code from the test directory in the distribution. I'm having more success with the latter, chiefly because I don't fully understand how the behaviour concept used in the megaco_simple_mgc code works. But that's not my question. I can see from the test code how the MGC handles a serviceChange request and sends the response. What I'm unable to understand at this point is how to program the MGC to send a request to the MG as a consequence of recieving this message - maybe an audit request, or setting up a termination as in the example message flow in Appendix A of the ITUT H.248 spec. Somewhat tangentially, I'd also like to know where the documentation is for built-in functions, particularly spawn_link() which is used in the megaco_test_mgc code. Kind regards, Pete -- ------------------------------------------------------------------------ Pete Young pete@REDACTED Remove dot. to reply "Just another crouton, floating on the bouillabaisse of life" From jan@REDACTED Wed Aug 1 18:10:05 2007 From: jan@REDACTED (Jan Henry Nystrom) Date: Wed, 01 Aug 2007 18:10:05 +0200 Subject: [erlang-questions] Question on implementing a Megaco MGC In-Reply-To: <20070801154556.GA22726@server30077.uk2net.com> References: <20070801154556.GA22726@server30077.uk2net.com> Message-ID: <46B0B05D.7080501@erlang-consulting.com> Hi Pete, Most built-in functions notionally belong to the erlang module. But I would recomend the reference manual under processes: http://www.erlang.org/doc/reference_manual/processes.html#10 /Cheers Henry Pete Young wrote: > Greetings, > > I'd like to implement a Megaco Media Gateway Controller, and as a lapsed > functional programming enthusiast it seems that doing it in Erlang would > be a good way to go about it. Ideally I'd like to be able to set up > voice calls between two media gateways. > > I've been studying the megaco_simple_mgc example and the megaco_test_mgc > code from the test directory in the distribution. I'm having more success > with the latter, chiefly because I don't fully understand how the behaviour > concept used in the megaco_simple_mgc code works. But that's not my question. > > I can see from the test code how the MGC handles a serviceChange request > and sends the response. What I'm unable to understand at this point is > how to program the MGC to send a request to the MG as a consequence of > recieving this message - maybe an audit request, or setting up a > termination as in the example message flow in Appendix A of the > ITUT H.248 spec. > > Somewhat tangentially, I'd also like to know where the documentation > is for built-in functions, particularly spawn_link() which is used > in the megaco_test_mgc code. > > Kind regards, > > Pete > -- Jan Henry Nystrom Training & Research Manager @ Erlang Training and Consulting Ltd http://www.erlang-consulting.com From S.J.Thompson@REDACTED Wed Aug 1 17:48:21 2007 From: S.J.Thompson@REDACTED (S.J.Thompson) Date: Wed, 1 Aug 2007 16:48:21 +0100 (BST) Subject: [erlang-questions] Sixth ACM SIGPLAN Erlang Workshop, 5 October 2007 Message-ID: We are very pleased to announce the programme for the Sixth ACM SIGPLAN Erlang Workshop, taking place on 5 October 2007 in Freiburg, Germany, as a satellite event of the ACM SIGPLAN International Conference on Functional Programming. http://www.erlang.se/workshop/2007/ Simon Thompson Lars-Ake Fredlund From igwan@REDACTED Wed Aug 1 19:17:28 2007 From: igwan@REDACTED (igwan) Date: Wed, 01 Aug 2007 19:17:28 +0200 Subject: [erlang-questions] sending packets using gen_udp In-Reply-To: References: <46AE3475.9040706@free.fr> Message-ID: <46B0C028.5090508@free.fr> Chandru a ?crit : > > Where are you sending the packets? When you say you see only 9 packets > on your network interface, which n/w interface are you talking about? > The source or the destination? If it is the destination, probably your > receiving end has a small receive buffer? > I'm talking about the source interface. I checked the stats with "ip -s link" and the counter increments only by nine packets and of course the destination doesn't get more. This is on a 100 Mbps ethernet interface and I'm able to reach a decent sending rate if I wait between each sending, but this puts a high load on my emulator and complicates programming. From jim.mccoy@REDACTED Wed Aug 1 19:35:57 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Wed, 1 Aug 2007 10:35:57 -0700 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: <46B01A8E.3080709@ericsson.com> References: <46A6F881.5070208@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com> <46AE9057.0@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> <46B01A8E.3080709@ericsson.com> Message-ID: On 7/31/07, Bengt Kleberg wrote: [...] > if it is ok to run your program from a single archive, but have the > erlang runtime separately installed (via CEAN :-) you can use escript. > i have made an escript called besea that will create archives that are > themselfs escripts. > This is definitely a win, but setting aside my current use of Erlang and taking the perspective of previous work distributing an end-user application written in Python I would have to say that this is not quite good enough. The use-case I am thinking of here is distributing an application to my mom. Telling her to first install a runtime for a programming language is just not sufficient; this is one reason that Java apps are just barely clinging to life even when companies like Sun, Microsoft, and Apple are throwing millions of dollars at the issue of making the runtime ubiquitous. At the end of the day what is needed is an exe file that can be dropped onto a USB drive and executed on any PC to which I attach the drive. Jim From christophe.romain@REDACTED Wed Aug 1 19:54:57 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Wed, 1 Aug 2007 19:54:57 +0200 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com> <46AE9057.0@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> <46B01A8E.3080709@ericsson.com> Message-ID: > At the end of the day what is needed is an exe file that can be > dropped onto a USB drive and executed on any PC to which I attach the > drive. well, do not forget CEAN installers actually target 18 different platforms looking at CEAN downloads stats, windows is 42%, Linux is 30% and MacOS is 23% if we give CEAN the ability to build a standalone exe, then the solution should be usable on all common platforms. so now, i'm just wondering how to do such a thing. while i can help on unix systems, i have no clue how to do that on windows. From Chris.Curtis@REDACTED Wed Aug 1 20:08:16 2007 From: Chris.Curtis@REDACTED (Chris Curtis) Date: Wed, 1 Aug 2007 14:08:16 -0400 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com><46B01A8E.3080709@ericsson.com> Message-ID: <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> Christophe Romain wrote: > so now, i'm just wondering how to do such a thing. > while i can help on unix systems, i have no clue how to do that on > windows. > It seems to me the really hard part is already done... the BEAM VM runs on all those platforms. What it looks like SAE does is just bundle it up a little differently and modify the code loader to deal with a special all-in-one format. --chris From dot@REDACTED Wed Aug 1 19:56:47 2007 From: dot@REDACTED (Tony Finch) Date: Wed, 1 Aug 2007 18:56:47 +0100 Subject: [erlang-questions] Sending message to process already listening on a socket In-Reply-To: <46AFD896.5090908@industrial-designers.co.uk> References: <269388e30707301529u74ec7f98l4621674419948055@mail.gmail.com> <18094.62380.145458.235142@antilipe.corelatus.se> <269388e30707311548r610085c3u9515c41eff07defb@mail.gmail.com> <46AFD896.5090908@industrial-designers.co.uk> Message-ID: On Wed, 1 Aug 2007, David Hopwood wrote: > > It is 1-1 FIFO; that is, messages are queued in FIFO order between > any given pair of processes, but there are no other constraints on > ordering. > > A brief explanation, so you don't necessarily have to read the > whole paper: a pair (s, r) represents a message transmission where > s is the send event, and r is the receive event. So Definition 3.3 > says that if two messages are sent by the same process (s ~ s') and > received by the same process (r ~ r'), then they are received in > the same order they were sent (s < s' => r' < r'). Um, those two paragraphs don't mean the same thing in the presence of selective receive. If s sends r two messages and r is waiting with a pattern that matches the second and not the first, then your second paragraph says that the messages cannot be delivered until some other process sends a message that matches r's pattern, otherwise the ordering constraint on s's messages would be violated. If the ordering constraint only applies to enqueueing messages and not dequeueing them (as your first paragraph implies) then r unblocks since it can receive s's messages in the opposite order to which they were sent and queued. Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From dmitry.kargapolov@REDACTED Wed Aug 1 21:17:45 2007 From: dmitry.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Wed, 01 Aug 2007 15:17:45 -0400 Subject: [erlang-questions] bug or feature? Message-ID: <46B0DC59.1090800@corp.idt.net> Is it a bug or some magic feature in erlang shell when using atom query with no quotes? Eshell V5.5.4 (abort with ^G) 1> {query, "lalala"}. ** 1: syntax error before: ',' ** 1> {'query', "lalala"}. {'query',"lalala"} 2> From jan@REDACTED Wed Aug 1 21:26:04 2007 From: jan@REDACTED (Jan Henry Nystrom) Date: Wed, 01 Aug 2007 21:26:04 +0200 Subject: [erlang-questions] bug or feature? In-Reply-To: <46B0DC59.1090800@corp.idt.net> References: <46B0DC59.1090800@corp.idt.net> Message-ID: <46B0DE4C.5080706@erlang-consulting.com> Dmitriy Kargapolov wrote: > Is it a bug or some magic feature in erlang shell when using atom query > with no quotes? > > Eshell V5.5.4 (abort with ^G) > 1> {query, "lalala"}. > ** 1: syntax error before: ',' ** > 1> {'query', "lalala"}. > {'query',"lalala"} > 2> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Hi Dmitriy, It is a (mis)feature, query is a keyword that is used by the Mnesia query language Mnmosyne. It bit me quite a few times when it had been introduced :-). /Cheers Henry -- Jan Henry Nystrom Training & Research Manager @ Erlang Training and Consulting Ltd http://www.erlang-consulting.com From qrilka@REDACTED Wed Aug 1 21:26:37 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 1 Aug 2007 23:26:37 +0400 Subject: [erlang-questions] [erlang-bugs] bug or feature? In-Reply-To: <46B0DC59.1090800@corp.idt.net> References: <46B0DC59.1090800@corp.idt.net> Message-ID: <337538cb0708011226md91d66ap583f41b6940fcf06@mail.gmail.com> I second that and there is a bit simpler variant: Erlang (BEAM) emulator version 5.5.5 [async-threads:0] Eshell V5.5.5 (abort with ^G) (stupid@REDACTED)1> query. ** 1: syntax error before: '.' ** So I do not see how is it possible to use this atom with no quotes. Regards, Kirill. On 8/1/07, Dmitriy Kargapolov wrote: > > Is it a bug or some magic feature in erlang shell when using atom query > with no quotes? > > Eshell V5.5.4 (abort with ^G) > 1> {query, "lalala"}. > ** 1: syntax error before: ',' ** > 1> {'query', "lalala"}. > {'query',"lalala"} > 2> > _______________________________________________ > erlang-bugs mailing list > erlang-bugs@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-bugs > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter@REDACTED Wed Aug 1 21:28:12 2007 From: peter@REDACTED (Peter K Chan) Date: Wed, 1 Aug 2007 21:28:12 +0200 Subject: [erlang-questions] bug or feature? In-Reply-To: <46B0DC59.1090800@corp.idt.net> References: <46B0DC59.1090800@corp.idt.net> Message-ID: I seem to remember that "query" is a keyword in Erlang. I am still a novice, so I don't know what query actually does. Peter -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dmitriy Kargapolov Sent: Wednesday, August 01, 2007 2:18 PM To: erlang-bugs@REDACTED Cc: erlang-questions@REDACTED Subject: [erlang-questions] bug or feature? Is it a bug or some magic feature in erlang shell when using atom query with no quotes? Eshell V5.5.4 (abort with ^G) 1> {query, "lalala"}. ** 1: syntax error before: ',' ** 1> {'query', "lalala"}. {'query',"lalala"} 2> _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55@REDACTED Wed Aug 1 21:29:58 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 1 Aug 2007 19:29:58 +0000 Subject: [erlang-questions] bug or feature? In-Reply-To: <46B0DC59.1090800@corp.idt.net> References: <46B0DC59.1090800@corp.idt.net> Message-ID: <95be1d3b0708011229r333a0484v97b8f2ac5977316b@mail.gmail.com> Hi, On 8/1/07, Dmitriy Kargapolov wrote: > Is it a bug or some magic feature in erlang shell when using atom query > with no quotes? The atom 'query' is also a keyword in the language. Just like 'begin', 'end', 'if', 'receive' and the others, it has to be quoted to be interpreted as an atom. See the Erlang Reference Manual, ?1.5 best regards, Vlad From dmitriid@REDACTED Thu Aug 2 08:42:27 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Thu, 02 Aug 2007 09:42:27 +0300 Subject: [erlang-questions] Erlang vs. Stackless Python Message-ID: <46B17CD3.3040000@gmail.com> Remember Joe Armstrong's call in his book: " Write a ring benchmark. Create N processes in a ring. Send a message round the ring M times so that a total of N*M messages get sent. Time how long this takes [..] Write a similar program in some other programming language you are familiar with. Compare the results. Write a blog, and publish the results on the internet! " Here's the first answer: http://muharem.wordpress.com/2007/07/31/erlang-vs-stackless-python-a-first-benchmark/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hakan@REDACTED Thu Aug 2 09:45:12 2007 From: hakan@REDACTED (Hakan Mattsson) Date: Thu, 2 Aug 2007 09:45:12 +0200 (CEST) Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com><46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> Message-ID: On Wed, 1 Aug 2007, Chris Curtis wrote: CC> Christophe Romain wrote: CC> > so now, i'm just wondering how to do such a thing. CC> > while i can help on unix systems, i have no clue how to do that on CC> > windows. CC> > CC> CC> It seems to me the really hard part is already done... the BEAM VM runs CC> on all those platforms. What it looks like SAE does is just bundle it up CC> a little differently and modify the code loader to deal with a special CC> all-in-one format. But how do you fit drivers, port programs and other stuff that may reside on priv_dir into the all-in-one format? /H?kan From christophe.romain@REDACTED Thu Aug 2 09:57:36 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 2 Aug 2007 09:57:36 +0200 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com><46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> Message-ID: <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> > But how do you fit drivers, port programs and other stuff > that may reside on priv_dir into the all-in-one format? CEAN supports that already. example: one installation can contains stuff for linux mac and windows all priv directory contains platform specific subdirectory, selected at runtime. From avindev@REDACTED Thu Aug 2 11:05:43 2007 From: avindev@REDACTED (Arbow) Date: Thu, 2 Aug 2007 17:05:43 +0800 Subject: [erlang-questions] module exmpp_xmlstream not found Message-ID: When I using jabberlang(version jabberlang-2007.0405 from cean), I got these errors: =ERROR REPORT==== 2-Aug-2007::16:55:00 === ** State machine <0.33.0> terminating ** Last message in was {'$gen_sync_event',{<0.30.0>,#Ref<0.0.0.30>},{connect}} ** When State == ready_to_connect ** Data == {state,undefined, undefined, undefined, [], xmpp_gtalk, "xlandsibox", {password,"ED_Boy"}, "ErlangTalk", "127.0.0.1", 5222, "127.0.0.1", "0", "normal", [], "Jabberlang", "0.3", true} ** Reason for termination = ** {'module could not be loaded', [{exmpp_xmlstream, start, [{gen_fsm,<0.33.0>}, [namespace, name_as_atom, ns_check, names_check, attrs_check, no_maxsize]]}, {xmpp,ready_to_connect,3}, {gen_fsm,handle_msg,7}, {proc_lib,init_p,5}]} ** exited: {undef,[{exmpp_xmlstream,start, [{gen_fsm,<0.33.0>}, [namespace, name_as_atom, ns_check, names_check, attrs_check, no_maxsize]]}, {xmpp,ready_to_connect,3}, {gen_fsm,handle_msg,7}, {proc_lib,init_p,5}]} ** I tried to find "exmpp_xmlstream" at https://forge.process-one.net/browse/Jabberlang, but still can't find it :( Is it exmpp_xmlstream not implemented yet ? From christophe.romain@REDACTED Thu Aug 2 11:50:39 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 2 Aug 2007 11:50:39 +0200 Subject: [erlang-questions] module exmpp_xmlstream not found In-Reply-To: References: Message-ID: jabberlang is actually being worked on. it has been deeply optimized and improved, depending on exmpp. exmpp is almost ready to be published (release in comming days). then jabberlang will be usable again. if you are in a hurry to use jabberlang, please use revision 10. From xpdoka@REDACTED Thu Aug 2 12:05:37 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 2 Aug 2007 12:05:37 +0200 (CEST) Subject: [erlang-questions] example of race conditions ? Message-ID: <15075.217.128.75.198.1186049137.squirrel@www.geekisp.com> >> The problem is that only one process can have a certain name >> and what happens if more then one process want a certain name? > > This example is basically identical to mine (and sent a few > minutes before mine), so I'm glad to see that my concern about > it is warranted. > > What is considered "the" solution to this? My advice is not to register processes at all, design for passing Pid's around. Much healthier, easier to test, to reuse code, etc. A bit less pleasant to debug or monitor, but still worth it. Best regards, Dominic Williams http://dominicwilliams.net ---- From hakan@REDACTED Thu Aug 2 14:05:57 2007 From: hakan@REDACTED (Hakan Mattsson) Date: Thu, 2 Aug 2007 14:05:57 +0200 (CEST) Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com><46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> Message-ID: On Thu, 2 Aug 2007, Christophe Romain wrote: CR> > But how do you fit drivers, port programs and other stuff CR> > that may reside on priv_dir into the all-in-one format? CR> CR> CEAN supports that already. example: one installation CR> can contains stuff for linux mac and windows all priv CR> directory contains platform specific subdirectory, CR> selected at runtime. Ok, but that means that the standalone deliverable contains more files than just the executable file. Even if it would be nice, I think that it is very hard to bundle the emulator with port programs, other priv dir stuff, heart, epmd etc. as one single executable. The selfcontained standalone executable is certainly something to strive for, but I think that we need to be realistic and accept that it is not possible without suffering vital system characteristics. /H?kan From lcoquelle@REDACTED Thu Aug 2 16:29:35 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Thu, 2 Aug 2007 22:29:35 +0800 Subject: [erlang-questions] Erlang on VPS Message-ID: Anyone has experiences to share about using Erlang in VPS? In the following blogpost Roberto wrote about some problems with Erlang running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? experience? http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-hosting/ Also, another question a bit off-topic of erlang-question, but that could interest many Erlang users: I'm interested in a cheap VPS hosting, to try out some of the great Erlang applications in the real world (I mean internet :) ). Those 2 hosting providers have been listed by Erlang users: http://www.jaguarpc.com http://tektonic.net Again, same question: any comment, any other good experience with those or other providers? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter@REDACTED Thu Aug 2 16:43:40 2007 From: peter@REDACTED (Peter K Chan) Date: Thu, 2 Aug 2007 16:43:40 +0200 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: I have used Erlang in an OpenVZ VPS. I have not encountered any problem yet, although I didn't try kpoll or HIPE. Peter From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ludovic Coquelle Sent: Thursday, August 02, 2007 9:30 AM To: Erlang Users' List Subject: [erlang-questions] Erlang on VPS Anyone has experiences to share about using Erlang in VPS? In the following blogpost Roberto wrote about some problems with Erlang running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? experience? http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-host ing/ Also, another question a bit off-topic of erlang-question, but that could interest many Erlang users: I'm interested in a cheap VPS hosting, to try out some of the great Erlang applications in the real world (I mean internet :) ). Those 2 hosting providers have been listed by Erlang users: http://www.jaguarpc.com http://tektonic.net Again, same question: any comment, any other good experience with those or other providers? Thanks From rsaccon@REDACTED Thu Aug 2 16:58:55 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Thu, 2 Aug 2007 11:58:55 -0300 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: well, the bad experience at that time was specific to a particular combination of OS, gcc, compiler settings, XEN and OTP version (which I don't remember). For just trying out things, Amazon EC2 is by far the cheapest, because you can turn it off when you are not "trying out" things, and you only get billed (by the hour) when it is running. On 8/2/07, Ludovic Coquelle wrote: > Anyone has experiences to share about using Erlang in VPS? > > In the following blogpost Roberto wrote about some problems with Erlang > running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? > experience? > http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-hosting/ > > Also, another question a bit off-topic of erlang-question, but that could > interest many Erlang users: > I'm interested in a cheap VPS hosting, to try out some of the great Erlang > applications in the real world (I mean internet :) ). Those 2 hosting > providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with those or > other providers? > > Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Roberto Saccon From pjdtech2000@REDACTED Thu Aug 2 18:00:37 2007 From: pjdtech2000@REDACTED (PJ Durai) Date: Thu, 2 Aug 2007 10:00:37 -0600 Subject: [erlang-questions] erl_interface and multithreading. Message-ID: <4f712c6f0708020900h1c663e8bq39f9def3348fb2f3@mail.gmail.com> Greetings. I am writing a CNode in Win32. It is written as a server node. It will be talking to only one peer erlang node. I am wondering if I could use the file handle returned from erl_accept in two different threads simultaneously? One thread to read incoming messages and another to erl_send outgoing messages ? Thanks pj From chandrashekhar.mullaparthi@REDACTED Thu Aug 2 19:41:14 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 2 Aug 2007 18:41:14 +0100 Subject: [erlang-questions] sending packets using gen_udp In-Reply-To: <46B0C028.5090508@free.fr> References: <46AE3475.9040706@free.fr> <46B0C028.5090508@free.fr> Message-ID: On 01/08/07, igwan wrote: > Chandru a ?crit : > > > > Where are you sending the packets? When you say you see only 9 packets > > on your network interface, which n/w interface are you talking about? > > The source or the destination? If it is the destination, probably your > > receiving end has a small receive buffer? > > > > I'm talking about the source interface. I checked the stats with "ip -s > link" and the counter increments only by nine packets and of course the > destination doesn't get more. This is on a 100 Mbps ethernet interface > and I'm able to reach a decent sending rate if I wait between each > sending, but this puts a high load on my emulator and complicates > programming. > I wrote some C code to test this and it turns out that I get a similar behaviour. I actually see more lost packets when running the C program compared to erlang. So I don't think this is an erlang specific problem. I think the packets are being dropped somewhere in the kernel and this being UDP, you are not being told about it. I've attached the C code in case you are interested in trying. Edit the macros in the code to change the "destination host" and "send buffer size". cheers, Chandru -------------- next part -------------- #include #include #include #include #include #define DEST_HOST "172.24.19.78" #define DEST_PORT 12345 #define SEND_BUFFER_SIZE 100000 #define NUM_PACKETS_TO_SEND 100 #define SEND_DATAGRAM_SIZE 1472 int main (void) { int s = socket (AF_INET, SOCK_DGRAM, 0); /* open UDP socket */ char datagram[SEND_DATAGRAM_SIZE]; struct sockaddr_in cli_addr; struct sockaddr_in sin; int count = 0; int send_buffer = SEND_BUFFER_SIZE; sin.sin_family = AF_INET; sin.sin_port = htons (12345); sin.sin_addr.s_addr = inet_addr (DEST_HOST); cli_addr.sin_family = AF_INET; cli_addr.sin_port = htons (DEST_PORT); cli_addr.sin_addr.s_addr = htonl(INADDR_ANY); bind(s, (struct sockaddr *) &cli_addr, sizeof(cli_addr)); if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &send_buffer, sizeof(send_buffer))) { printf("setsockopt error %d, %s\n", errno, strerror(errno)); exit(errno); } memset (datagram, 0, SEND_DATAGRAM_SIZE); while (count < NUM_PACKETS_TO_SEND) { /* Indicate the packet count in the first two bytes */ datagram[0] = (count & 0xff00) >> 8; datagram[1] = count & 0xff; if (sendto (s, datagram, sizeof(datagram), 0, (struct sockaddr *) &sin, sizeof (sin)) < 0) printf ("error\n"); else printf ("."); count++; } printf ("Sent %d packets\n", count); return 0; } From christophe.romain@REDACTED Thu Aug 2 20:09:37 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 2 Aug 2007 20:09:37 +0200 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46A6F881.5070208@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9DF@MAILSERV.hcrest.com><36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com><46AE9057.0@pmp.com.au><36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com><46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> Message-ID: is there any windows guru inhere that could help on making a CEAN packaged app be bundled in a standalone exe ? From jim.mccoy@REDACTED Thu Aug 2 20:45:26 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Thu, 2 Aug 2007 11:45:26 -0700 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> Message-ID: On 8/2/07, Christophe Romain wrote: > is there any windows guru inhere that could help on making a CEAN > packaged app be bundled in a standalone exe ? I am not that person, but watched from the sidelines as the py2exe people wrestled with a lot of the same problems. I think that the first steps will be to figure out what parts have to be there and the see what solutions we can mimic from the py2exe and Rubyscript2exe examples. As the first interesting bit to look at, if you poke through the py2exe CVSweb interface you will see a very nice README file in py2exe/source that describes how you can load DLLs from memory (a mmap()'d zip file in this case.) The basic process that py2exe uses, as I understand thigns, is to create a small executable that is basically used as a bootstrap loader for the rest of the system, with the remainder of the data appended to this loader as a compressed file. The bootstrap loader does the equivalent of mmap() over this appended data and then hands things off to a version of the interpreter that has been tweaked to support loading bytecode-compiled modules (and DLL versions of Python extension modules) from this mmap()'d data. The primary change to the core of Erlang that would seem to be necessary would be to changing the module loading process to support pulling in data from a zip file or from a chunk of address space made available via mmap(). I guess it is time to get erlang installed under parallels so that I can poke around a bit... Jim [1] http://py2exe.cvs.sourceforge.net/py2exe/py2exe/source/README-MemoryModule.txt?revision=1.1&view=markup From jim.mccoy@REDACTED Thu Aug 2 20:46:07 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Thu, 2 Aug 2007 11:46:07 -0700 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> <46B01A8E.3080709@ericsson.com> <36E4692623C5974BA6661C0B18EE8EDF7FF9F1@MAILSERV.hcrest.com> <960345BE-074F-410B-A753-2BD7106EBBA9@process-one.net> Message-ID: On 8/2/07, Hakan Mattsson wrote: > Even if it would be nice, I think that it is very hard > to bundle the emulator with port programs, other priv > dir stuff, heart, epmd etc. as one single executable. Ouch. I had forgotten about epmd; "distributed Erlang" will be a bit harder, but there are platform-specific ways to create components like this that could be shared across all locally-installed SAE applications. I guess the first step in such an effort should really be trying to define the minimum set of components that are necessary just to get the VM working in a manner that most people would expect. CEAN and REPOS are probably the best examples I am aware of regarding how far you can trim things and still get an Erlang program to run. Drivers, port programs, and other non-core items will take more work, but should be possible. Jim From jim.mccoy@REDACTED Thu Aug 2 21:02:44 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Thu, 2 Aug 2007 12:02:44 -0700 Subject: [erlang-questions] Question about priority receive and "large" mailboxes Message-ID: In Programming Erlang an example of using a receive with an "after 0" timeout to implement a priority receive is provided. A small warning is given after the example suggestion that one should avoid using this for "large" mailboxes. Is "large" a measure of the number of waiting messages or the total size of all waiting messages? Is it a bad idea to use this sort of a priority queue for the incoming messages if I have a mailbox which will only have a few messages in it at any given time if it is possible that some of these messages might be very large? Each message would be a {type, payload} tuple with the high-priority messages having a very small payload and the low priority messages having a very large payload. Regards, Jim From alex.arnon@REDACTED Thu Aug 2 21:09:49 2007 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 2 Aug 2007 22:09:49 +0300 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: <944da41d0708021209i2ae631cap585ecfb5598f045@mail.gmail.com> I'm using GridZones' VPS (www.gridzones.com). Mind you, it's been a light kind of usage, a bit of Yaws and local testing. $10 a month is hard to beat, whatever the CPU slice :) Oh, and regarding CPU time - their systems seem to be lightly loaded, so I usually got full CPU power in the times I ran heavy tasks (e.g. recompiling the OTP distribution). On 8/2/07, Ludovic Coquelle wrote: > > Anyone has experiences to share about using Erlang in VPS? > > In the following blogpost Roberto wrote about some problems with Erlang > running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? > experience? > > http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-hosting/ > > Also, another question a bit off-topic of erlang-question, but that could > interest many Erlang users: > I'm interested in a cheap VPS hosting, to try out some of the great Erlang > applications in the real world (I mean internet :) ). Those 2 hosting > providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with those or > other providers? > > Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From igwan@REDACTED Thu Aug 2 21:40:09 2007 From: igwan@REDACTED (igwan) Date: Thu, 02 Aug 2007 21:40:09 +0200 Subject: [erlang-questions] sending packets using gen_udp In-Reply-To: References: <46AE3475.9040706@free.fr> <46B0C028.5090508@free.fr> Message-ID: <46B23319.7080002@free.fr> Chandru a ?crit : > I wrote some C code to test this and it turns out that I get a similar > behaviour. I actually see more lost packets when running the C program > compared to erlang. > > So I don't think this is an erlang specific problem. I think the > packets are being dropped somewhere in the kernel and this being UDP, > you are not being told about it. I've attached the C code in case you > are interested in trying. Edit the macros in the code to change the > "destination host" and "send buffer size". > > cheers, > Chandru > Many thanks for taking time reproducing this. Well, I modified kernel parameters /proc/net/core/wmem_* and /proc/net/core/rmem_* (they're buffer sizes) then restarting the emulator with no effect. Besides, I notice in prim_inet.erl, this funny little comment : %% SENDTO(insock(), IP, Port, Data) -> ok | {error, Reason} %% %% send Datagram to the IP at port (Should add sync send!) So there exists a sync send call that erlang could use and that blocks until - i'm speculating - the datagram is taken out of the kernel send buffer ? I'm no C programmer, but the socket interface seems to have different calls (send sendto sendmsg) for sending datagrams. I'll give a try at the TunTap driver from Jungerl to see if I can go around the problem. igwan From wglozer@REDACTED Thu Aug 2 22:21:50 2007 From: wglozer@REDACTED (Will) Date: Thu, 2 Aug 2007 13:21:50 -0700 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: I've run Erlang on a number of different Xen VPS instances running Linux, in both 32 and 64 bit variants, and have not encountered any problems whatsoever. I highly recommend ServerAxis (http://www.serveraxis.com/) who I've been using for about 8 months. Their plans are very well priced and have great performance. From vladdu55@REDACTED Thu Aug 2 22:32:31 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 2 Aug 2007 20:32:31 +0000 Subject: [erlang-questions] Bug in code_server:del_path Message-ID: <95be1d3b0708021332r7f75e57djea9e02e8721eab87@mail.gmail.com> Hi! For code:add_path* and code:replace_path, the code_server implementation first applies a filename:join to the directory name, normalizing it. The implementation of del_path doesn't do the same, making it impossible to remove paths that aren't already normalized (for example if the drive letter in Windows is uppercased). I couldn't test extensively, but I believe that the following change will fix that. delete_name_dir(Dir, Db) -> case get_name(Dir) of Dir -> false; Name -> - Dir0 = del_ebin(Dir), + Dir0 = del_ebin(filename:join([Dir])), case lookup_name(Name, Db) of {ok, Dir0} -> ets:delete(Db, Name), true; _ -> false end end. BTW, there is a code_server:normalize/1 function, why isn't that one used for normalization? best regards, Vlad From vladdu55@REDACTED Thu Aug 2 23:10:40 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 2 Aug 2007 21:10:40 +0000 Subject: [erlang-questions] ErlIde In-Reply-To: <20070731122127.437DD19DC400@mail.wavenet.lk> References: <95be1d3b0707310338n70773183n4bf103b428d18742@mail.gmail.com> <20070731122127.437DD19DC400@mail.wavenet.lk> Message-ID: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> Hi, Fixed in 0.3.30, now available on the update site. In the project properties, you can choose to use code:add_patha or code:add_pathz. By default, pathz is used. regards, Vlad From jim.mccoy@REDACTED Thu Aug 2 20:44:43 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Thu, 2 Aug 2007 11:44:43 -0700 Subject: [erlang-questions] Stand Alone Erlang Still Updated? In-Reply-To: References: <36E4692623C5974BA6661C0B18EE8EDF7FF9E6@MAILSERV.hcrest.com> <46AE9057.0@pmp.com.au> <36E4692623C5974BA6661C0B18EE8EDF7FF9EC@MAILSERV.hcrest.com> <46B01A8E.3080709@ericsson.com> Message-ID: On 8/1/07, Christophe Romain wrote: > > At the end of the day what is needed is an exe file that can be > > dropped onto a USB drive and executed on any PC to which I attach the > > drive. > > well, do not forget CEAN installers actually target 18 different > platforms I think this is the sort of thinking that bogged down the last effort to discuss SAE on this list. Windows and OS X are the two target platforms that I and most everyone else interested in SAE care about. Other platforms have a long history of sophisticated users who know how to build from source, download a runtime, etc.; this is something that is possible on Windows and OS X but is unfamiliar territory for most users. Rather than aiming for a solution that fits every possible platform I am interested in a solution that fits one of these platforms. Once that part is done it is possible to move on to the others. The abject failure of every attempt to create a one-size-fits-all approach to distribution across platforms should be a sufficient disincentive for us. Jim From chsu79@REDACTED Thu Aug 2 23:40:01 2007 From: chsu79@REDACTED (Christian S) Date: Thu, 2 Aug 2007 23:40:01 +0200 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: 2007/8/2, Ludovic Coquelle : > Anyone has experiences to share about using Erlang in VPS? > I've been running erlang on a 128Mb vps running linux/fedora for years now. I'm not happy with the uptime of my hosting, but they are cheap so i get what i pay for. Anyone know if we (as in erlang people) could get VPS rebates somewhere? We could give back by updating a wiki on how to set up erlang from cean on their VPS and populate a forum about it, and related questions. In my experience 128Mb is plenty for a yaws. Even 32Mb vpses would probably be enough. It is quite tight to have only 1Gb of storage. Especially when you want to have a few development tools and host git projects. Anyone got connections in the VPS business? From rpwjanze@REDACTED Wed Aug 1 23:58:45 2007 From: rpwjanze@REDACTED (rpwjanze@REDACTED) Date: Wed, 1 Aug 2007 15:58:45 -0600 (MDT) Subject: [erlang-questions] Erlang compiler concurrency Message-ID: <34913.136.159.169.6.1186005525.squirrel@136.159.169.6> Hello all, Since Erlang is a concurrent language by design, I was wondering how concurrent the Erlang compiler is. Thanks for any information, Ryan -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From rsaccon@REDACTED Fri Aug 3 04:02:19 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Thu, 2 Aug 2007 23:02:19 -0300 Subject: [erlang-questions] does compile/file option compressed exist ? Message-ID: looking for hints to further minimize a minimal erlang distribution, I found in the official faq http://erlang.org/faq/faq.html# the compiling option compressed: compile:file("foo", [compressed,no_debug_info]). But it is only mentioned there and nowhere else and does not show up with compile:options(). Does this option actually exist ? regards -- Roberto Saccon From casper2000a@REDACTED Fri Aug 3 04:22:28 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Fri, 3 Aug 2007 07:52:28 +0530 Subject: [erlang-questions] ErlIde In-Reply-To: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> Message-ID: <20070803022230.D421219DC3FA@mail.wavenet.lk> Hi, This is great news. Thanks a lot. I am newbie to Eclipse Plug-in development, but I will see if I can learn and contribute to this project. Thanks, - Eranga -----Original Message----- From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] Sent: Friday, August 03, 2007 2:41 AM To: Eranga Udesh Cc: Erlang Questions Subject: Re: [erlang-questions] ErlIde Hi, Fixed in 0.3.30, now available on the update site. In the project properties, you can choose to use code:add_patha or code:add_pathz. By default, pathz is used. regards, Vlad From casper2000a@REDACTED Fri Aug 3 05:05:34 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Fri, 3 Aug 2007 08:35:34 +0530 Subject: [erlang-questions] ErlIde In-Reply-To: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> Message-ID: <20070803030537.0F15919DC4DA@mail.wavenet.lk> Hi, It seems the ErlIde update site is not working. Also the files to download are still ver 0.3.23. Server returned HTTP response code: "404 Not Found" for URL: http://erlide.sourceforge.net/update32/. Thanks, - Eranga -----Original Message----- From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] Sent: Friday, August 03, 2007 2:41 AM To: Eranga Udesh Cc: Erlang Questions Subject: Re: [erlang-questions] ErlIde Hi, Fixed in 0.3.30, now available on the update site. In the project properties, you can choose to use code:add_patha or code:add_pathz. By default, pathz is used. regards, Vlad From avindev@REDACTED Fri Aug 3 05:39:20 2007 From: avindev@REDACTED (Arbow) Date: Fri, 3 Aug 2007 11:39:20 +0800 Subject: [erlang-questions] ErlIde In-Reply-To: <20070803030537.0F15919DC4DA@mail.wavenet.lk> References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> Message-ID: try http://erlide.sourceforge.net/update/ :) On 8/3/07, Eranga Udesh wrote: > Hi, > > It seems the ErlIde update site is not working. Also the files to download > are still ver 0.3.23. > > Server returned HTTP response code: "404 Not Found" for URL: > http://erlide.sourceforge.net/update32/. > > Thanks, > - Eranga > > > > -----Original Message----- > From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] > Sent: Friday, August 03, 2007 2:41 AM > To: Eranga Udesh > Cc: Erlang Questions > Subject: Re: [erlang-questions] ErlIde > > Hi, > > Fixed in 0.3.30, now available on the update site. In the project > properties, you can choose to use code:add_patha or code:add_pathz. By > default, pathz is used. > > regards, > Vlad > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jeffm@REDACTED Fri Aug 3 06:22:21 2007 From: jeffm@REDACTED (jm) Date: Fri, 03 Aug 2007 14:22:21 +1000 Subject: [erlang-questions] ErlIde In-Reply-To: References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> Message-ID: <46B2AD7D.7090204@ghostgun.com> Arbow wrote: > try http://erlide.sourceforge.net/update/ :) > Decided to give eclipse and erlide ago while watching this thread. The platform is macosx 10.3.9 with a newly downloaded eclipse 3.3.0 which has been decopressed and extracted into a directory from which it is being run. I've managed to install erlide from the above URL and restart. When I go to Eclipse -> Preference the erlide options appear in the left panel, but when clicking on any of these options the error message "An error has occurred when creating this preference page." appears in the left panel and an accompanying dialog appears saying Unable to create the selected preference page. org/erlide/basicui/prefs/ErlangPreferencePage (Unsupported major.minor version 49.0) Does this mean I should be using an earlier version of eclipse? Jeff. From ke.han@REDACTED Fri Aug 3 05:21:18 2007 From: ke.han@REDACTED (ke han) Date: Fri, 3 Aug 2007 11:21:18 +0800 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: I have used erlang / yaws OTP 10-?? on a VPS (XEN, I believe) hosted by rimuhosting.com It was a plain Centos 4.4 host. No problems. On Aug 2, 2007, at 10:29 PM, Ludovic Coquelle wrote: > Anyone has experiences to share about using Erlang in VPS? > > In the following blogpost Roberto wrote about some problems with > Erlang running in Xen; Yariv said he had no problem with Virtuozzo. > Any comment? experience? > http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp- > hosting/ > > Also, another question a bit off-topic of erlang-question, but that > could interest many Erlang users: > I'm interested in a cheap VPS hosting, to try out some of the great > Erlang applications in the real world (I mean internet :) ). Those > 2 hosting providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with > those or other providers? > > Thanks > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From casper2000a@REDACTED Fri Aug 3 07:55:06 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Fri, 3 Aug 2007 11:25:06 +0530 Subject: [erlang-questions] Mnesia distributed fragmented table In-Reply-To: <20070803022230.D421219DC3FA@mail.wavenet.lk> Message-ID: <20070803055509.60DCB19DC612@mail.wavenet.lk> Hi, How do I create a fragmented distributed table in multiple Erlang nodes, where each node will have the full set of fragments, so that even without other nodes, that node can run in isolation? For eg. I want to create test_table distributed in 2 Erlang nodes (node1@REDACTED and node2@REDACTED) and with 20 fragments. I need all 20 fragments in node1@REDACTED, so that even if the node2@REDACTED goes down, still I can use the full database in node1@REDACTED When both the nodes are available, any update to test_table in node1@REDACTED will get reflected in node2@REDACTED and vice versa (distributed). Thanks, - Eranga From ngpestelos@REDACTED Fri Aug 3 07:18:40 2007 From: ngpestelos@REDACTED (Nestor G. Pestelos, Jr.) Date: Fri, 3 Aug 2007 13:18:40 +0800 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: I've compiled and used R10B-10, R11B-4, and R11B-5 on Xen 3.1 VMs, although in all cases I've encountered compiler errors when enabling HiPE. Aside from my local setup (Xen 3.1 + Ubuntu Dapper), I also use Rimuhosting. No problems running Erlang/OTP there. So far, Rimuhosting's support is OK for me. Nestor On 8/3/07, ke han wrote: > > I have used erlang / yaws OTP 10-?? on a VPS (XEN, I believe) hosted by > rimuhosting.com > It was a plain Centos 4.4 host. No problems. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Aug 3 08:56:21 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 03 Aug 2007 08:56:21 +0200 Subject: [erlang-questions] Question about priority receive and "large" mailboxes In-Reply-To: References: Message-ID: <46B2D195.20309@ericsson.com> On 2007-08-02 21:02, Jim McCoy wrote: > In Programming Erlang an example of using a receive with an "after 0" > timeout to implement a priority receive is provided. A small warning > is given after the example suggestion that one should avoid using this > for "large" mailboxes. Is "large" a measure of the number of waiting > messages or the total size of all waiting messages? it is the total size of all waiting messages. the idea is that if you have a steady input of high priority messages you might never have the time to handle/remove the low priority messages. thus making the mailbox grow without bounds. sooner or later that will exhaust your memory. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From 0x6e6562@REDACTED Fri Aug 3 08:58:42 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Fri, 3 Aug 2007 07:58:42 +0100 Subject: [erlang-questions] ErlIde In-Reply-To: <46B2AD7D.7090204@ghostgun.com> References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> <46B2AD7D.7090204@ghostgun.com> Message-ID: <269388e30708022358t49071987yf39aa537cb41a97b@mail.gmail.com> Jeff, > Unable to create the selected preference page. > org/erlide/basicui/prefs/ErlangPreferencePage (Unsupported major.minor > version 49.0) That sounds like you're running Java 1.4, which supports 48.0. What version of java are you using? Ben From bengt.kleberg@REDACTED Fri Aug 3 09:03:25 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 03 Aug 2007 09:03:25 +0200 Subject: [erlang-questions] Bug in code_server:del_path In-Reply-To: <95be1d3b0708021332r7f75e57djea9e02e8721eab87@mail.gmail.com> References: <95be1d3b0708021332r7f75e57djea9e02e8721eab87@mail.gmail.com> Message-ID: <46B2D33D.5000006@ericsson.com> On 2007-08-02 22:32, Vlad Dumitrescu wrote: ...deleted > BTW, there is a code_server:normalize/1 function, why isn't that one > used for normalization? what erlang version are you using? i have no (exported) code_server:normalize/1. neither do i have a code:normalize/1, something i checked since the code_server module is not documented. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From christophe.romain@REDACTED Fri Aug 3 09:38:38 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Fri, 3 Aug 2007 09:38:38 +0200 Subject: [erlang-questions] does compile/file option compressed exist ? In-Reply-To: References: Message-ID: <89E19260-E92A-4979-9DDA-3080CC158FA9@process-one.net> > looking for hints to further minimize a minimal erlang distribution, i don't know about the file compression by now, CEAN uses beam_lib:strip/1 which performs a good job anyway example: standard stdlib/string is 11K, cean stdlib/string is 2K From vladdu55@REDACTED Fri Aug 3 10:21:41 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 3 Aug 2007 10:21:41 +0200 Subject: [erlang-questions] Bug in code_server:del_path In-Reply-To: <46B2D33D.5000006@ericsson.com> References: <95be1d3b0708021332r7f75e57djea9e02e8721eab87@mail.gmail.com> <46B2D33D.5000006@ericsson.com> Message-ID: <95be1d3b0708030121p3e044356id0d23fb99ee6cb24@mail.gmail.com> Hi, On 8/3/07, Bengt Kleberg wrote: > On 2007-08-02 22:32, Vlad Dumitrescu wrote: > ...deleted > > BTW, there is a code_server:normalize/1 function, why isn't that one > > used for normalization? > > what erlang version are you using? i have no (exported) > code_server:normalize/1. R11B-5 code_server:normalize is not exported. regards, Vlad From vladdu55@REDACTED Fri Aug 3 10:23:37 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 3 Aug 2007 10:23:37 +0200 Subject: [erlang-questions] ErlIde In-Reply-To: <46B2AD7D.7090204@ghostgun.com> References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> <46B2AD7D.7090204@ghostgun.com> Message-ID: <95be1d3b0708030123v61d37c2dx6ce792a2f39cc308@mail.gmail.com> Hi, On 8/3/07, jm wrote: > Unable to create the selected preference page. > org/erlide/basicui/prefs/ErlangPreferencePage (Unsupported major.minor > version 49.0) You need to use Java 5. For a moment I was worried that I might have had compiled with Java 6, I will check anyway when I get home. best regards, Vlad From simonpeterchappell@REDACTED Fri Aug 3 14:00:54 2007 From: simonpeterchappell@REDACTED (Simon Chappell) Date: Fri, 3 Aug 2007 07:00:54 -0500 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: <8ed733900708030500ue9b1a8ew9314a39e0f267a9d@mail.gmail.com> I'm serving my personal site (simonpeter.org) using Yaws running on a VPS (Xen-based if I remember correctly) provided by Slicehost (slicehost.com) and it seems to be going well after about a month. No problems to report so far. :-) $20 per month, with no long-term contracts. Simon On 8/2/07, Ludovic Coquelle wrote: > Anyone has experiences to share about using Erlang in VPS? > > In the following blogpost Roberto wrote about some problems with Erlang > running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? > experience? > http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-hosting/ > > Also, another question a bit off-topic of erlang-question, but that could > interest many Erlang users: > I'm interested in a cheap VPS hosting, to try out some of the great Erlang > applications in the real world (I mean internet :) ). Those 2 hosting > providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with those or > other providers? > > Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- simonpeter.org | simonpeter.com | newlife-upc.org From hakan@REDACTED Fri Aug 3 16:02:56 2007 From: hakan@REDACTED (Hakan Mattsson) Date: Fri, 3 Aug 2007 16:02:56 +0200 (CEST) Subject: [erlang-questions] Mnesia distributed fragmented table In-Reply-To: <20070803055509.60DCB19DC612@mail.wavenet.lk> References: <20070803055509.60DCB19DC612@mail.wavenet.lk> Message-ID: On Fri, 3 Aug 2007, Eranga Udesh wrote: EU> How do I create a fragmented distributed table in multiple Erlang nodes, EU> where each node will have the full set of fragments, so that even without EU> other nodes, that node can run in isolation? EU> EU> For eg. I want to create test_table distributed in 2 Erlang nodes EU> (node1@REDACTED and node2@REDACTED) and with 20 fragments. I need all 20 EU> fragments in node1@REDACTED, so that even if the node2@REDACTED goes down, EU> still I can use the full database in node1@REDACTED When both the nodes EU> are available, any update to test_table in node1@REDACTED will get EU> reflected in node2@REDACTED and vice versa (distributed). Read about n_fragments, node_pool and n_ram_copies in the Mnesia Users Guide in the chapter about fragmented tables: http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.3 The following create_table command creates a table with 20 fragments where each fragment has a ram_copies replica on both node a@REDACTED and b@REDACTED (a@REDACTED)9> mnesia:create_table(t, [{frag_properties, [{n_fragments, 20}, {node_pool, [a@REDACTED,b@REDACTED]}, {n_ram_copies, 2}]}]). {atomic,ok} (a@REDACTED)10> [{T, mnesia:table_info(T, ram_copies)} || T <- mnesia:system_info(tables), lists:prefix("t", atom_to_list(T))]. [{t,[b@REDACTED,a@REDACTED]}, {t_frag2,[b@REDACTED,a@REDACTED]}, {t_frag3,[b@REDACTED,a@REDACTED]}, {t_frag4,[b@REDACTED,a@REDACTED]}, {t_frag5,[b@REDACTED,a@REDACTED]}, {t_frag6,[b@REDACTED,a@REDACTED]}, {t_frag7,[b@REDACTED,a@REDACTED]}, {t_frag8,[b@REDACTED,a@REDACTED]}, {t_frag9,[b@REDACTED,a@REDACTED]}, {t_frag10,[b@REDACTED,a@REDACTED]}, {t_frag11,[b@REDACTED,a@REDACTED]}, {t_frag12,[b@REDACTED,a@REDACTED]}, {t_frag13,[b@REDACTED,a@REDACTED]}, {t_frag14,[b@REDACTED,a@REDACTED]}, {t_frag15,[b@REDACTED,a@REDACTED]}, {t_frag16,[b@REDACTED,a@REDACTED]}, {t_frag17,[b@REDACTED,a@REDACTED]}, {t_frag18,[b@REDACTED,a@REDACTED]}, {t_frag19,[b@REDACTED,a@REDACTED]}, {t_frag20,[b@REDACTED,a@REDACTED]}] /H?kan From Erik.Stenman@REDACTED Fri Aug 3 16:12:41 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Fri, 03 Aug 2007 16:12:41 +0200 Subject: [erlang-questions] Erlang positions in Stockholm Message-ID: <46B337D9.7030700@Kreditor.se> Kreditor continues to expand and we have yet another opening at our Stockholm office. (We are still looking for a senior developer, see http://kreditor.se/jobb/wanted-developer.html ) The new position is as operator/maintainer/tester, the following ad will be posted on Swedish recruitment sites soon: Wanted: Software tester/Software Operations Engineer Kreditor is a leader in development of financial services for companies and consumers in Sweden. In just two years the company has grown from 0 to 30 employees and grown from 0 SEK to 30 million SEK in turnover. Our ambition is to continue to grow at an even faster rate. We have a flat organizational structure, we believe that superior technology is the key to success, and we nurture a free and open development environment to stimulate the employee. The tech department has a foundation of highly skilled developers of good name. If you join us you will find an open and stimulating environment where we welcome initiatives and clever solutions. You will be trusted with a high level of responsibility and great opportunities to grow in your position. You will often work close to our customers which will give new angles of approach and motivation for your work. If you like to be deeply engaged in your workplace this is the place for you. Job Description: In this position you will work both as a tester and as an operations Engineer. As a tester you will develop and maintain test suites and test environments to continuously test the software systems developed by Kreditor. You will be responsible for the quality of our systems and work to find and eliminate bugs. As an operations engineer you will operate and maintain our software systems, perform upgrades and backups. You will also monitor the functionality, security, and performance of our live systems. Qualifications: You have at least a bachelor's degree in software engineering or a similar education. You have documented experience of software testing and debugging, and you have good knowledge of: * Erlang * Functional programming languages * OTP, Mnesia, Yaws Experience of object oriented programming languages is not considered a merit. You are a problem solver, you have a knack of identifying problems, analyzing their cause, and finding solutions. You also have a habit of working with a tough problem until it is solved. You are careful and goal oriented, and you are motivated by working at a successful company with capable and passionate coworkers. -- If you are interested, feel free to contact me. Erik Happi Stenman, Director of Engineering _______________________________________ KREDITOR EUROPE AB Sveav?gen 33 111 34 Stockholm, Sweden Tel: +46 8 - 586 126 00 Direct: +46 8 - 586 126 40 Fax: +46 8 - 586 126 99 Web: www.kreditor.se From lenartlad@REDACTED Fri Aug 3 16:16:29 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 03 Aug 2007 16:16:29 +0200 Subject: [erlang-questions] [Q] How to delete a table during mnesia startup Message-ID: <46B338BD.8010508@volny.cz> Hello, upon my application startup, I want to recreate a table from a given (XML) configuration (i.e. delete it and then create). Mnesia is already running at this time (it has been started from the boot script). To make this work I ended up with the following code: mnesia:create_table(table, TableSpec), mnesia:wait_for_tables([table], Timeout), mnesia:delete_table(table), mnesia:create_table(table, TableSpec), mnesia:wait_for_tables([table], Timeout), The first create_table/2 call returns {aborted, {already_exists, table}} but it must be present, because otherwise: * first wait_for_tables/2 returns {timeout, [table]}, * delete_table/1 returns {aborted, {no_exists, table}}, * create_table/2 returns {aborted, {already_exists, table}} and * as a result the table is not deleted at all. Is the above code a correct "solution" or am I doing something wrong? Thanks in advance, Ladislav Lenart From zac@REDACTED Fri Aug 3 16:37:57 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 03 Aug 2007 10:37:57 -0400 Subject: [erlang-questions] Erlang vs. Stackless Python References: <46B17CD3.3040000@gmail.com> Message-ID: That benchmark has some pitfalls in that it doesn't really demonstrate the scalabilty of erlang that well. I feel confident saying that erlang would scale to a much larger scale far better than stackless python would. Interesting post no doubt, but could've been a little less biased. Regards, Zac On Thu, 02 Aug 2007 09:42:27 +0300, Dmitrii 'Mamut' Dimandt wrote: > Remember Joe Armstrong's call in his book: > " > > Write a ring benchmark. Create N processes in a ring. Send a message > round the ring M times so that a total of N*M messages get sent. > Time how long this takes [..] > > Write a similar program in some other programming language you are > familiar with. Compare the results. Write a blog, and publish the > results on the internet! > > " > Here's the first answer: > http://muharem.wordpress.com/2007/07/31/erlang-vs-stackless-python-a-first-benchmark/ > > > > > > > > > > Remember Joe Armstrong's call in his book:
> "
>
>

Write a ring benchmark. Create N processes in a ring. > Send a message round the ring M times so that a total of N*M messages > get sent. Time how long this takes [..]

>

Write a similar program in some other programming language you are > familiar with. Compare the results. Write a blog, and publish the > results on the internet!
>

>
> "
> Here's the first answer: > http://muharem.wordpress.com/2007/07/31/erlang-vs-stackless-python-a-first-benchmark/
>


>

> > From hakan@REDACTED Fri Aug 3 16:49:02 2007 From: hakan@REDACTED (Hakan Mattsson) Date: Fri, 3 Aug 2007 16:49:02 +0200 (CEST) Subject: [erlang-questions] Encrypted Mnesia database? In-Reply-To: <0DF34E81-996C-4622-ACEC-166AE5E9DA68@gmail.com> References: <7037df270708010601m2df5925ev613bbea73fe4aee2@mail.gmail.com> <0DF34E81-996C-4622-ACEC-166AE5E9DA68@gmail.com> Message-ID: What about implementing an own Activity Access Callback module? Perhaps you can hide all the encryption stuff there. See also: http://www.erlang.org/doc/apps/mnesia/Mnesia_chap4.html#4.5 http://www.erlang.org/doc/apps/mnesia/Mnesia_App_C.html#10 /H?kan On Wed, 1 Aug 2007, Joel Reymont wrote: JR> Date: Wed, 1 Aug 2007 14:40:50 +0100 JR> From: Joel Reymont JR> To: Matthew Pflueger JR> Cc: erlang-questions@REDACTED JR> Subject: Re: [erlang-questions] Encrypted Mnesia database? JR> JR> Add a new table type by hacking Mnesia, e.g. encrypted_disc_copies? JR> JR> I did it for Amazon S3 and I'm available for consulting assignments ;-). JR> JR> On Aug 1, 2007, at 2:01 PM, Matthew Pflueger wrote: JR> JR> > Does anybody have any ideas on how to encrypt a Mnesia database JR> > table? I would like to create a disk based table for each user. JR> > The user's credentials would be used to locate the appropriate JR> > Mnesia table and also as the key to decrypt the table on the fly at JR> > the file IO layer. JR> JR> -- JR> http://topdog.cc - EasyLanguage to C# compiler JR> http://wagerlabs.com - Blog From dmitriid@REDACTED Fri Aug 3 17:02:33 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Fri, 03 Aug 2007 18:02:33 +0300 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: References: <46B17CD3.3040000@gmail.com> Message-ID: <46B34389.6070906@gmail.com> Zac Brown wrote: > That benchmark has some pitfalls in that it doesn't really demonstrate the > scalabilty of erlang that well. I feel confident saying that erlang would > scale to a much larger scale far better than stackless python would. > Interesting post no doubt, but could've been a little less biased. > > Indeed. There's a longish discussion on hat in the comments. It looks like erlang is unbeatable still :) From tsuraan@REDACTED Fri Aug 3 18:07:27 2007 From: tsuraan@REDACTED (tsuraan) Date: Fri, 3 Aug 2007 11:07:27 -0500 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: <46B34389.6070906@gmail.com> References: <46B17CD3.3040000@gmail.com> <46B34389.6070906@gmail.com> Message-ID: <84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> An interesting result was that the -smp flag caused erlang to slow down for that test. Should that ever happen? On 03/08/07, Dmitrii 'Mamut' Dimandt wrote: > > Zac Brown wrote: > > That benchmark has some pitfalls in that it doesn't really demonstrate > the > > scalabilty of erlang that well. I feel confident saying that erlang > would > > scale to a much larger scale far better than stackless python would. > > Interesting post no doubt, but could've been a little less biased. > > > > > Indeed. There's a longish discussion on hat in the comments. It looks > like erlang is unbeatable still :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Aug 3 18:34:17 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 3 Aug 2007 18:34:17 +0200 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: <84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> References: <46B17CD3.3040000@gmail.com><46B34389.6070906@gmail.com> <84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F9223155025D03F0@esealmw115.eemea.ericsson.se> Well, sure. The ring benchmark serializes all processes, which means that there is practically no parallelism in there. There's a similar benchmark, called big.erl (big bang), where a thousand or so processes are created, and all start talking to everyone else. http://www.erlang.org/doc/highlights.html http://www.franklinmint.fm/blog/archives/000792.html It gives excellent speedup on SMP Erlang. That might be another good benchmark to try in other languages. BR, Ulf W ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of tsuraan Sent: den 3 augusti 2007 18:07 To: Dmitrii 'Mamut' Dimandt Cc: Zac Brown; erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang vs. Stackless Python An interesting result was that the -smp flag caused erlang to slow down for that test. Should that ever happen? On 03/08/07, Dmitrii 'Mamut' Dimandt wrote: Zac Brown wrote: > That benchmark has some pitfalls in that it doesn't really demonstrate the > scalabilty of erlang that well. I feel confident saying that erlang would > scale to a much larger scale far better than stackless python would. > Interesting post no doubt, but could've been a little less biased. > > Indeed. There's a longish discussion on hat in the comments. It looks like erlang is unbeatable still :) _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From zac@REDACTED Fri Aug 3 18:51:10 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 03 Aug 2007 12:51:10 -0400 Subject: [erlang-questions] Erlang vs. Stackless Python References: <46B17CD3.3040000@gmail.com> <46B34389.6070906@gmail.com> <84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> Message-ID: The reason for that is that its not really even a parallel test since there's only one process running at a time so you're just making one big line, that could easily be accomplished by one process constantly talking to itself. Dumb way to show erlang's power if you ask me :). On Fri, 03 Aug 2007 11:07:27 -0500, tsuraan wrote: > An interesting result was that the -smp flag caused erlang to slow down for > that test. Should that ever happen? > > On 03/08/07, Dmitrii 'Mamut' Dimandt wrote: >> >> Zac Brown wrote: >> > That benchmark has some pitfalls in that it doesn't really demonstrate >> the >> > scalabilty of erlang that well. I feel confident saying that erlang >> would >> > scale to a much larger scale far better than stackless python would. >> > Interesting post no doubt, but could've been a little less biased. >> > >> > >> Indeed. There's a longish discussion on hat in the comments. It looks >> like erlang is unbeatable still :) >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > An interesting result was that the -smp flag caused erlang to slow down for that test.  Should that ever happen?

On 03/08/07, Dmitrii 'Mamut' Dimandt > <dmitriid@REDACTED> wrote:
> Zac Brown wrote:
> That benchmark has some pitfalls in that it doesn't really demonstrate the
> scalabilty of erlang that well. I feel confident saying that erlang would
> scale to a much larger scale far better than stackless python would. >
> Interesting post no doubt, but could've been a little less biased.
>
>
Indeed. There's a longish discussion on hat in the comments. It looks
like erlang is unbeatable still :)
_______________________________________________ >
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions >

From ulf.wiger@REDACTED Fri Aug 3 19:15:06 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 3 Aug 2007 19:15:06 +0200 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: References: <46B17CD3.3040000@gmail.com><46B34389.6070906@gmail.com><84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F9223155025D03F4@esealmw115.eemea.ericsson.se> Zac Brown wrote: > > The reason for that is that its not really even a parallel > test since there's only one process running at a time so > you're just making one big line, that could easily be > accomplished by one process constantly talking to itself. > Dumb way to show erlang's power if you ask me :). Well, it does illustrate the cost of spawning and the cost of message passing, and how the cost depends on the number of concurrent processes. It's been a while since I looked at Stackless Python, but I believe its "processes" are not quite as capable as Erlang processes, esp. in terms of fault tolerance and debug support. By all rights, they should be cheaper than Erlang processes... BR, Ulf W From chadrwilson@REDACTED Fri Aug 3 16:49:59 2007 From: chadrwilson@REDACTED (Chad Wilson) Date: Fri, 3 Aug 2007 10:49:59 -0400 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: References: <46B17CD3.3040000@gmail.com> Message-ID: On 8/3/07, Zac Brown wrote: > That benchmark has some pitfalls in that it doesn't really demonstrate the > scalabilty of erlang that well. I feel confident saying that erlang would > scale to a much larger scale far better than stackless python would. > Interesting post no doubt, but could've been a little less biased. An effective answer to the blogger might be to run his programs as he had written them on a machine that would provide that challenge. Anyone got a many-core/distributed system to run some competitive benchmarks? -w From zac@REDACTED Fri Aug 3 19:35:06 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 03 Aug 2007 13:35:06 -0400 Subject: [erlang-questions] Erlang vs. Stackless Python References: <46B17CD3.3040000@gmail.com> <46B34389.6070906@gmail.com> <84fb38e30708030907l344d2ce7h72e327f9316a5f7b@mail.gmail.com> <6616D98C65DD514BA2E1DDC5F9223155025D03F4@esealmw115.eemea.ericsson.se> Message-ID: On Fri, 03 Aug 2007 19:15:06 +0200, Ulf Wiger (TN/EAB) wrote: > > Zac Brown wrote: >> >> The reason for that is that its not really even a parallel >> test since there's only one process running at a time so >> you're just making one big line, that could easily be >> accomplished by one process constantly talking to itself. >> Dumb way to show erlang's power if you ask me :). > > Well, it does illustrate the cost of spawning and > the cost of message passing, and how the cost depends > on the number of concurrent processes. > > It's been a while since I looked at Stackless Python, > but I believe its "processes" are not quite as > capable as Erlang processes, esp. in terms of fault > tolerance and debug support. By all rights, they should > be cheaper than Erlang processes... > > BR, > Ulf W So its more of a minimum critical mass you need to meet kinda thing? As in you need at least a certain amount of concurrency before the cost of spawning procs pays off in scalability? A scalability vs proc creation cost graph I guess? Zac From zac@REDACTED Fri Aug 3 19:35:37 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 03 Aug 2007 13:35:37 -0400 Subject: [erlang-questions] Erlang vs. Stackless Python References: <46B17CD3.3040000@gmail.com> Message-ID: On Fri, 03 Aug 2007 10:49:59 -0400, Chad Wilson wrote: > On 8/3/07, Zac Brown wrote: >> That benchmark has some pitfalls in that it doesn't really demonstrate the >> scalabilty of erlang that well. I feel confident saying that erlang would >> scale to a much larger scale far better than stackless python would. >> Interesting post no doubt, but could've been a little less biased. > > An effective answer to the blogger might be to run his programs as he > had written them on a machine that would provide that challenge. > Anyone got a many-core/distributed system to run some competitive > benchmarks? > > -w I've got a cluster of XServe's we could run it on. Zac From ulf@REDACTED Fri Aug 3 22:20:16 2007 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 3 Aug 2007 22:20:16 +0200 Subject: [erlang-questions] lock-free hash table Message-ID: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> I just caught Dr. Cliff Click's Google TechTalk on his lock-free hash table. http://video.google.com/videoplay?docid=2139967204534450862 The (Java) source is also available at sourceforge: http://sourceforge.net/projects/high-scale-lib According to his talk, the algorithm "scales well up to 768 cpus". I don't know if there is anything in this that would not fit Erlang well, but perhaps it's something to look into? Anyway, it's always interesting to listen to these performance geeks. ;-) BR, Ulf W From jason@REDACTED Fri Aug 3 21:35:22 2007 From: jason@REDACTED (Jason A. Hoffman) Date: Fri, 3 Aug 2007 12:35:22 -0700 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: References: <46B17CD3.3040000@gmail.com> Message-ID: <6EE7EF9A-3CEA-4DAF-9F9D-B5781ECD646A@joyent.com> On Aug 3, 2007, at 7:49 AM, Chad Wilson wrote: > On 8/3/07, Zac Brown wrote: >> That benchmark has some pitfalls in that it doesn't really >> demonstrate the >> scalabilty of erlang that well. I feel confident saying that >> erlang would >> scale to a much larger scale far better than stackless python would. >> Interesting post no doubt, but could've been a little less biased. > > An effective answer to the blogger might be to run his programs as he > had written them on a machine that would provide that challenge. > Anyone got a many-core/distributed system to run some competitive > benchmarks? > > -w I have a bunch (few racks) of T1000s with 16GB RAM and 32x1.0Ghz sparc CPUs each and have no problem running some benchmarks. Let me know. Regards, Jason From jeffm@REDACTED Sat Aug 4 03:36:04 2007 From: jeffm@REDACTED (jm) Date: Sat, 04 Aug 2007 11:36:04 +1000 Subject: [erlang-questions] ErlIde In-Reply-To: <269388e30708022358t49071987yf39aa537cb41a97b@mail.gmail.com> References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> <46B2AD7D.7090204@ghostgun.com> <269388e30708022358t49071987yf39aa537cb41a97b@mail.gmail.com> Message-ID: <46B3D804.3090607@ghostgun.com> Ben Hood wrote: > Jeff, > >> Unable to create the selected preference page. >> org/erlide/basicui/prefs/ErlangPreferencePage (Unsupported major.minor >> version 49.0) > > That sounds like you're running Java 1.4, which supports 48.0. What > version of java are you using? > Your correct. $ java -version java version "1.4.2_12" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-270) Java HotSpot(TM) Client VM (build 1.4.2-70, mixed mode) Is there an update available somewhere? I found an update for 10.4.x but am unable to find an update for 10.3.x. While I could try to install it via fink's apt-get I'd rather update the main version than having unnecessary multiple copies. Does anyone know if and where I can find this update? Jeff. From lucindo@REDACTED Fri Aug 3 22:04:11 2007 From: lucindo@REDACTED (Renato Lucindo) Date: Fri, 3 Aug 2007 17:04:11 -0300 Subject: [erlang-questions] VM & BEAM Specs Message-ID: <49376cdb0708031304l635fea6dg404e0b4256d4e570@mail.gmail.com> Hello, The ErlangVM and BEAM file specifications are available? Thanks, Lucindo From dmitriid@REDACTED Sat Aug 4 13:58:28 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Sat, 04 Aug 2007 14:58:28 +0300 Subject: [erlang-questions] The Book, lib_chan and IRC Lite Message-ID: <46B469E4.60707@gmail.com> I'm stupid and I am not afraid to admit it :) I'm currently battling the IRC Lite from chapter 11 of "Programming Erlang". Whatever I do (copy paste, run make in the code directory obtained from the biik's site etc.) I get the following error when I run the example: lib_chan_mm: protocol error:{login,"general","joe"} Does anyone else run into the same problem? Of course, I am going to dig deeper into the code and try and locate the error myself. But I was surprised to be bitten by this :( -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtvd@REDACTED Sat Aug 4 14:11:57 2007 From: rtvd@REDACTED (Denys Rtveliashvili) Date: Sat, 04 Aug 2007 16:11:57 +0400 Subject: [erlang-questions] VM & BEAM Specs Message-ID: <46B46D0D.9010302@mail.ru> > > Hello, > > The ErlangVM and BEAM file specifications are available? > > Thanks, > > Lucindo I join to this question. I was also looking for the specifications once as I had an idea how to improve the performance of list operations by changing the underlying implementation. However, I found none. So I took a look into the source code of the VM and came to a thought that the code is too complicated for me to change anything. By the way, in case there is a specification for BEAM files and VM it would be (theoretically) possible to create a concurrent implementation which might bring a bit "fresh blood" into the development of ErlangVM and OTP. Diversity is a great thing, especially if it is based on open specifications. With kind regards, Denis Rtveliashvili From smangano@REDACTED Sat Aug 4 18:09:25 2007 From: smangano@REDACTED (Salvatore Mangano) Date: Sat, 4 Aug 2007 12:09:25 -0400 Subject: [erlang-questions] MySQl vs. mnesia Message-ID: <002701c7d6b1$d431afd0$6400a8c0@einstein> Can someone with experience using both the native MySql driver and mnesia comment on the pro's and con's of each approach. Context: I will be building a complex web service with a very large database. I expect the database to evolve (change) rapidly over the lifetime of the project. Thanks, Sal Mangano From matthias@REDACTED Sat Aug 4 19:36:00 2007 From: matthias@REDACTED (Matthias Lang) Date: Sat, 4 Aug 2007 19:36:00 +0200 Subject: [erlang-questions] VM & BEAM Specs In-Reply-To: <46B46D0D.9010302@mail.ru> References: <46B46D0D.9010302@mail.ru> Message-ID: <18100.47360.572196.225023@antilipe.corelatus.se> Lucindo> The ErlangVM and BEAM file specifications are available? Denys > I join to this question. The BEAM file format is documented. The VM is not. | The internals of the BEAM file format are described on Bj?rn's | homepage . Eventually this will/might include a description of the | virtual machine's instructions. Bj?rn also includes some benchmarks | comparing different versions of the BEAM machine. You may also want to | take a look at the beam_lib module. | | http://erlang.org/faq/faq.html Bj?rn's homepage is, of course, http://www.erlang.se/~bjorn/ Matthias From bneppert@REDACTED Sat Aug 4 21:06:23 2007 From: bneppert@REDACTED (Burkhard Neppert) Date: Sat, 04 Aug 2007 21:06:23 +0200 Subject: [erlang-questions] Formatting question Message-ID: <46B4CE2F.6020709@gmx.de> Hello, I've two question about string handling I'd like to convert binary data to its hex string representation. E.g. bin2hex(<<255:16>>) -> "00FF" The (buggy) solution I've come with so far is bin2hex(X) -> lists:foldr(fun (Byte, R) -> [hd(io_lib:fwrite("~.16B", [Byte]))|R] end, [], binary_to_list(X))e. First thing to note is, that it does not do the things it should :-( Reason is that io_lib:fwrite does not insert a leading zero if Byte is less than F. Question no. 1: how do I specify pad characters with ~B formatting option ? Question no. 2: the solution somehow looks ugly. That cannot be right. Does anyone have a more succinct solution for bin2hex ? Regards Burkhard From vances@REDACTED Sat Aug 4 21:58:47 2007 From: vances@REDACTED (Vance Shipley) Date: Sat, 4 Aug 2007 15:58:47 -0400 Subject: [erlang-questions] Formatting question In-Reply-To: <46B4CE2F.6020709@gmx.de> References: <46B4CE2F.6020709@gmx.de> Message-ID: <20070804195847.GA26963@little-black-book.motivity.ca> On Sat, Aug 04, 2007 at 09:06:23PM +0200, Burkhard Neppert wrote: } I'd like to convert binary data to its hex string representation. } E.g. bin2hex(<<255:16>>) -> "00FF" 2> t:bin2hex(<<255:16>>). 00FF ok -module(t). -export([bin2hex/1]). bin2hex(<<>>) -> io:fwrite("~n"); bin2hex(<>) -> io:fwrite("~2.16.0B", [I]), bin2hex(Rest). From nm@REDACTED Sat Aug 4 22:58:27 2007 From: nm@REDACTED (Gaspar Chilingarov) Date: Sun, 05 Aug 2007 01:58:27 +0500 Subject: [erlang-questions] Formatting question In-Reply-To: <46B4CE2F.6020709@gmx.de> References: <46B4CE2F.6020709@gmx.de> Message-ID: <46B4E873.7090107@web.am> > Question no. 2: the solution somehow looks ugly. That cannot be right. > Does anyone have a more succinct solution for bin2hex ? > I use this code (probably copied from http_util or something like this). byte2hex(X) -> % {{{ {nibble2hex(X bsr 4), nibble2hex(X band 15)}. % }}} nibble2hex(X) when X < 10 -> $0 + X; % {{{ nibble2hex(X) -> $A + X - 10. % }}} bin2hexstring(Bin) -> % {{{ lists:flatten(lists:map( fun(X) -> tuple_to_list(byte2hex(X)) end, binary_to_list(Bin))). % }}} -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED w http://zanazan.am/ From kenneth.lundin@REDACTED Sat Aug 4 23:26:35 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Sat, 4 Aug 2007 23:26:35 +0200 Subject: [erlang-questions] VM & BEAM Specs In-Reply-To: <46B46D0D.9010302@mail.ru> References: <46B46D0D.9010302@mail.ru> Message-ID: On 8/4/07, Denys Rtveliashvili wrote: > > > > Hello, > > > > The ErlangVM and BEAM file specifications are available? > > > > Thanks, > > > > Lucindo > I join to this question. > > I was also looking for the specifications once as I had an idea how to > improve the performance of list operations by changing the underlying > implementation. It would be interesting to share your ideas about improving the performance of list operations. What improvements did you have in mind? If you have some good ideas that we have not thought about we might implement them. I am also curious about which list operation you don't find effiecient as it is today. /Kenneth (Erlang/OTP team at Ericsson) > However, I found none. So I took a look into the source code of the VM > and came to a thought that the code is too complicated for me to change > anything. > > By the way, in case there is a specification for BEAM files and VM it > would be (theoretically) possible to create a concurrent implementation > which might bring a bit "fresh blood" into the development of ErlangVM > and OTP. Diversity is a great thing, especially if it is based on open > specifications. > > With kind regards, > Denis Rtveliashvili > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From monch1962@REDACTED Sun Aug 5 10:53:40 2007 From: monch1962@REDACTED (David Mitchell) Date: Sun, 5 Aug 2007 18:53:40 +1000 Subject: [erlang-questions] xmerl_xpath difficulties Message-ID: Hello group, I'm having trouble getting my head around xmerl_xpath - I've gone through a bunch of Google searches, but can't find the "Simple guide to xmerl_xpath" I'm looking for ;-> I've reduced my problem to 3 lines of code: 15> {XmlFull, _} = xmerl_scan:string("Hello"). {{xmlElement,text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{text,1}],1,[],"Hello",text}], [], "/home/davidm", undeclared}, []} 16> xmerl:export([XmlFull], xmerl_xml). ["",[[["<","text",">"],["Hello"],[""]]]] 17> xmerl_xpath:string("//text/*", XmlFull). [] Line 16 seems to confirm that XmlFull contains my XML string. However, I'd expect line 17 to give me something like "Hello" or ["Hello"], yet it returns an empty list. Could someone please point out the (no doubt very simple) mistake I've made? Also, if a "Simple guide to xmerl_xpath" exists somewhere, could someone please point me towards it? Thanks in advance Dave M. From yerl@REDACTED Sun Aug 5 11:36:22 2007 From: yerl@REDACTED (yerl@REDACTED) Date: Sun, 5 Aug 2007 11:36:22 +0200 Subject: [erlang-questions] erlang-questions server problem Message-ID: Hi! I didn't receive any message since 08/02/2007. Is there any problem with the mailing list server ? cheers Y. From juneaftn@REDACTED Sun Aug 5 12:15:10 2007 From: juneaftn@REDACTED (June Kim) Date: Sun, 5 Aug 2007 19:15:10 +0900 Subject: [erlang-questions] Erlang on VPS In-Reply-To: References: Message-ID: <6f80c1520708050315u54dcaa92wae4e4807516ffc8e@mail.gmail.com> I've been using JaguarPC's VPS(the cheapest one) for about a month. It runs the most recent erlang version with HiPe without any problem. I am quite satisfied with it. However, there seems to be some problem in communicating and passing the jobs between their departments in the JaguarPC. I lost a couple of days due to their mistake with regard to IP assignment, when setting up the account. When I issued a ticket they passed it around between the departments, and it took a long time to be solved and sometimes the issue was miscommunicated and misunderstood. 2007/8/2, Ludovic Coquelle : > Anyone has experiences to share about using Erlang in VPS? > > In the following blogpost Roberto wrote about some problems with Erlang > running in Xen; Yariv said he had no problem with Virtuozzo. Any comment? > experience? > http://yarivsblog.com/articles/2006/08/17/options-for-erlang-webapp-hosting/ > > Also, another question a bit off-topic of erlang-question, but that could > interest many Erlang users: > I'm interested in a cheap VPS hosting, to try out some of the great Erlang > applications in the real world (I mean internet :) ). Those 2 hosting > providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with those or > other providers? > > Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rtvd@REDACTED Sun Aug 5 13:09:25 2007 From: rtvd@REDACTED (Denys Rtveliashvili) Date: Sun, 05 Aug 2007 15:09:25 +0400 Subject: [erlang-questions] VM & BEAM Specs : idea for improving the lists support In-Reply-To: References: <46B46D0D.9010302@mail.ru> Message-ID: <46B5AFE5.40706@mail.ru> >> I join to this question. >> >> I was also looking for the specifications once as I had an idea how to >> improve the performance of list operations by changing the underlying >> implementation. >> > > It would be interesting to share your ideas about improving the > performance of list operations. What improvements did you have in > mind? If you have some good ideas > that we have not thought about we might implement them. > > I am also curious about which list operation you don't find effiecient > as it is today. > > /Kenneth (Erlang/OTP team at Ericsson) Hi Kenneth, As far as I understand, the underlying implementation of lists which is used in Erlang is based on linked lists. So, each list is a number of objects with a value (the n'th element of the list) or a reference to it plus a link to the next element (if it exists). My understanding is that only a number of operations take O(1) time to complete. These are: * Adding an element to the beginning of the list * Taking the first element of the list or its remainder. However, the following operations take O(n) time: * Finding out the length of the list * Adding an element at the end of the list * Taking the last element of the list or everything before it As a result, one of the common patterns in Erlang is to construct a list by appending the elements from the beginning and then reversing the list. The problems I see with the current implementation are: - The computational complexity required to do certain list operations is O(n), not O(1) - The linked list is not CPU cache - friendly. It can be dispersed in the memory, reducing the cache - hits and thus killing the performance. - Each of the list items is a quite big object. It takes 64bits if I am not mistaken. So, if you'd like to store a list of, say, 16bit characters / ordinary Unicode strings it takes 4 times more memory. ------------------ I believe, the current implementation can be (theoretically) improved. Of course, you will never know the exact numbers until someone implements the ideas. And the main factor which stops me is that (as far as I understand) Erlang uses that 64bit objects for almost everything so the change will be enormous. --- Idea #1: "Use unrolled linked lists to improve the performance" The unrolled linked lists (http://en.wikipedia.org/wiki/Unrolled_linked_list) should give a slightly better cache-hit ratio and consume less memory. Also, they will maintain strict O(1) time complexity for operations which are O(1) now. --- Idea #2: "Use resize-able vectors to store lists" I guess this change would give even more benefits comparing to the Idea #1. These are: - The _amortized_ computational complexity is O(1) for adding/removing/taking a remainder no matter if it is done from the beginning or from the end of the list. - It takes O(1) time to find out the size of the list. - Cache-hits ratio is seriously improved as the list is located in a single chunk of memory. - Much less work for a GC. However, I am not sure if it is an issue. The drawback is that the time complexity is amortized. Again, it is not clear what is better: an amortized O(1) or strict O(1) and strict O(n). I'd prefer the amortized O(1). A few words regarding the implementation: If you take a look at Java LinkedList and ArrayList, the ArrayList is generally 3 times faster. It can be used as a reference to some extent. However, it does not allow O(1) adding/removing at the beginning of the list. So, instead of implementation of a list which can grow only in one direction, it is necessary to implement the one which can grow any way. I am sure that you can also benefit from pureness or the functional approach in Erlang and from the fact that only one thread accesses the list all the time as you will not need to care about synchronization much. --- Idea #3: "Typed lists" Both kinds of list implementations can benefit from knowing what type of data is going to be stored in them. It would lead to a decrease in the consumed space and improved performance. It is possible to implement a "general" kind of list which can hold anything plus some specific implementations for storing 8bit and 16bit values. If a value is appended to the list and it can not be (potentially) stored within it, the list changes its type. The operation will take O(N) time. However, it will benefit from the flat memory structure. The type checks are not necessary to implement in runtime. They can be made by analyzing the possible scenarios during the compile-time or during the loading of the module. However, in most cases it will not be necessary to change the type of the list and lists of 8bit / 16bit values will do their job. Also, you will not need to change the syntax of the programs as everything can be done on VM/OTP side. The benefit is again in both performance and memory consumption. Imagine that a program has consumes a large text document with English, Arabic and Russian characters. The current implementation will consume 4 times more memory than an automatically-typed vector-based version. In case the document contains only ASCII characters, the memory consumption will drop 8 times. --- With kind regards, Denys Rtveliashvili From monch1962@REDACTED Sun Aug 5 14:51:41 2007 From: monch1962@REDACTED (David Mitchell) Date: Sun, 5 Aug 2007 22:51:41 +1000 Subject: [erlang-questions] xmerl_xpath difficulties In-Reply-To: References: Message-ID: Thanks Caoyuan, but it didn't work for me: davidm@REDACTED:~$ erl Erlang (BEAM) emulator version 5.4.9 [64-bit] [source] [threads:0] Eshell V5.4.9 (abort with ^G) 1> {XmlFull,_} = xmerl_scan:string("Hello"). {{xmlElement,text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{text,1}],1,[],"Hello",text}], [], "/home/davidm", undeclared}, []} 2> [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). =ERROR REPORT==== 5-Aug-2007::22:48:45 === Error in process <0.31.0> with exit value: {{badmatch,[]},[{erl_eval,expr,3}]} ** exited: {{badmatch,[]},[{erl_eval,expr,3}]} ** 3> Any thoughts? Regards Dave M. On 05/08/07, Caoyuan wrote: > > [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). > [{xmlText,[{text,1}],1,[],"Hello",text}] > > element(5, XmlText). > "Hello" > > > On 8/5/07, David Mitchell wrote: > > Hello group, > > > > I'm having trouble getting my head around xmerl_xpath - I've gone > > through a bunch of Google searches, but can't find the "Simple guide > > to xmerl_xpath" I'm looking for ;-> > > > > I've reduced my problem to 3 lines of code: > > > > 15> {XmlFull, _} = xmerl_scan:string("Hello"). > > {{xmlElement,text, > > text, > > [], > > {xmlNamespace,[],[]}, > > [], > > 1, > > [], > > [{xmlText,[{text,1}],1,[],"Hello",text}], > > [], > > "/home/davidm", > > undeclared}, > > []} > > > > 16> xmerl:export([XmlFull], xmerl_xml). > > ["",[[["<","text",">"],["Hello"],[""]]]] > > > > 17> xmerl_xpath:string("//text/*", XmlFull). > > [] > > > > > > Line 16 seems to confirm that XmlFull contains my XML string. > > However, I'd expect line 17 to give me something like "Hello" or > > ["Hello"], yet it returns an empty list. > > > > Could someone please point out the (no doubt very simple) mistake I've > > made? Also, if a "Simple guide to xmerl_xpath" exists somewhere, > > could someone please point me towards it? > > > > Thanks in advance > > > > Dave M. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > - Caoyuan > From patrickerj@REDACTED Sun Aug 5 15:05:45 2007 From: patrickerj@REDACTED (Patrick) Date: Sun, 5 Aug 2007 15:05:45 +0200 Subject: [erlang-questions] MySQl vs. mnesia Message-ID: Sal, I recommend that you use MySQL because of the cluster capacity that MySQL team is developing. Mnesia is O.K. but for the business environment like web services i can only recommend MySQL... for development first use ErlyWeb + ErlyDB, later if you wish you can develop something more that will suite you and your team. BR, Patrick From jerith@REDACTED Sun Aug 5 15:07:41 2007 From: jerith@REDACTED (Jeremy Thurgood) Date: Sun, 05 Aug 2007 15:07:41 +0200 Subject: [erlang-questions] xmerl_xpath difficulties In-Reply-To: References: Message-ID: <46B5CB9D.50408@jerith.za.net> David Mitchell wrote: > I'm having trouble getting my head around xmerl_xpath - I've gone > through a bunch of Google searches, but can't find the "Simple guide > to xmerl_xpath" I'm looking for ;-> You might want to look at the W3C's xpath tutorial at http://www.w3schools.com/xpath/default.asp > I've reduced my problem to 3 lines of code: > > 15> {XmlFull, _} = xmerl_scan:string("Hello"). > {{xmlElement,text, > text, > [], > {xmlNamespace,[],[]}, > [], > 1, > [], > [{xmlText,[{text,1}],1,[],"Hello",text}], > [], > "/home/davidm", > undeclared}, > []} > > 16> xmerl:export([XmlFull], xmerl_xml). > ["",[[["<","text",">"],["Hello"],[""]]]] > > 17> xmerl_xpath:string("//text/*", XmlFull). > [] > > > Line 16 seems to confirm that XmlFull contains my XML string. > However, I'd expect line 17 to give me something like "Hello" or > ["Hello"], yet it returns an empty list. You're asking it for xml elements below , of which there are none. 5> xmerl_xpath:string("//text/text()", XmlFull). [{xmlText,[{text,1}],1,[],"Hello",text}] Look like you'll still have to extract the string from the #xmlText record. HTH, --J From dcaoyuan@REDACTED Sun Aug 5 15:56:23 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Sun, 5 Aug 2007 21:56:23 +0800 Subject: [erlang-questions] xmerl_xpath difficulties In-Reply-To: References: Message-ID: It's a bit strange, it works in my computer. You may try: 1> {XmlFull, _} = xmerl_scan:string("Hello"). {{xmlElement,text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{text,1}],1,[],"Hello",text}], [], "/Users/dcaoyuan/polebeans/ewp", undeclared}, []} 2> XmlTexts = xmerl_xpath:string("/text/text()", XmlFull). [{xmlText,[{text,1}],1,[],"Hello",text}] The xpath query should return a list of result, it maybe [], or more than one element, so it's better to do: 3> lists:flatten([element(5,X) || X <- XmlTexts, element(1, X) == xmlText]). "Hello" If you are in writing a module, by including xmerl.hrl, you can: lists:flatten([X#xmlText.value || X <- XmlTexts, is_record(X, xmlText)]). On 8/5/07, David Mitchell wrote: > Thanks Caoyuan, but it didn't work for me: > > davidm@REDACTED:~$ erl > Erlang (BEAM) emulator version 5.4.9 [64-bit] [source] [threads:0] > > Eshell V5.4.9 (abort with ^G) > 1> {XmlFull,_} = xmerl_scan:string("Hello"). > {{xmlElement,text, > text, > [], > {xmlNamespace,[],[]}, > [], > 1, > [], > [{xmlText,[{text,1}],1,[],"Hello",text}], > [], > "/home/davidm", > undeclared}, > []} > 2> [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). > > =ERROR REPORT==== 5-Aug-2007::22:48:45 === > Error in process <0.31.0> with exit value: {{badmatch,[]},[{erl_eval,expr,3}]} > > ** exited: {{badmatch,[]},[{erl_eval,expr,3}]} ** > 3> > > Any thoughts? > > Regards > > Dave M. > > On 05/08/07, Caoyuan wrote: > > > [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). > > [{xmlText,[{text,1}],1,[],"Hello",text}] > > > element(5, XmlText). > > "Hello" > > > > > > On 8/5/07, David Mitchell wrote: > > > Hello group, > > > > > > I'm having trouble getting my head around xmerl_xpath - I've gone > > > through a bunch of Google searches, but can't find the "Simple guide > > > to xmerl_xpath" I'm looking for ;-> > > > > > > I've reduced my problem to 3 lines of code: > > > > > > 15> {XmlFull, _} = xmerl_scan:string("Hello"). > > > {{xmlElement,text, > > > text, > > > [], > > > {xmlNamespace,[],[]}, > > > [], > > > 1, > > > [], > > > [{xmlText,[{text,1}],1,[],"Hello",text}], > > > [], > > > "/home/davidm", > > > undeclared}, > > > []} > > > > > > 16> xmerl:export([XmlFull], xmerl_xml). > > > ["",[[["<","text",">"],["Hello"],[""]]]] > > > > > > 17> xmerl_xpath:string("//text/*", XmlFull). > > > [] > > > > > > > > > Line 16 seems to confirm that XmlFull contains my XML string. > > > However, I'd expect line 17 to give me something like "Hello" or > > > ["Hello"], yet it returns an empty list. > > > > > > Could someone please point out the (no doubt very simple) mistake I've > > > made? Also, if a "Simple guide to xmerl_xpath" exists somewhere, > > > could someone please point me towards it? > > > > > > Thanks in advance > > > > > > Dave M. > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > -- > > - Caoyuan > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- - Caoyuan From a2800276@REDACTED Sun Aug 5 16:22:42 2007 From: a2800276@REDACTED (Tim Becker) Date: Sun, 5 Aug 2007 16:22:42 +0200 Subject: [erlang-questions] VM & BEAM Specs In-Reply-To: <18100.47360.572196.225023@antilipe.corelatus.se> References: <46B46D0D.9010302@mail.ru> <18100.47360.572196.225023@antilipe.corelatus.se> Message-ID: <254c7bfb0708050722y1d2ef07geacef51f70b6b16d@mail.gmail.com> > The BEAM file format is documented. > > The VM is not. > > | The internals of the BEAM file format are described on Bj?rn's > | homepage . Eventually this will/might include a description of the > | virtual machine's instructions. > | http://erlang.org/faq/faq.html > > Bj?rn's homepage is, of course, http://www.erlang.se/~bjorn/ I've had a look at this the other day (to play around with .beam files), and it's a bit dated (May 2000). At the very least, the "Abstract Code" chunk isn't described, I've only implemented a cursory beam dump, so I don't know if other bits are left out as well. You can glean some information from the lib/compiler/src/beam_asm.erl, beam_disasm.erl and /lib/stdlib/src/beam_lib.erl implementations. -tim From smangano@REDACTED Sun Aug 5 16:27:34 2007 From: smangano@REDACTED (Salvatore Mangano) Date: Sun, 5 Aug 2007 10:27:34 -0400 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: References: Message-ID: <005501c7d76c$c40e4da0$6400a8c0@einstein> Thanks. I was kind of leaning toward MySQL but wanted to see if anyone could convince me to stick with mnesia. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Patrick Sent: Sunday, August 05, 2007 9:06 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] MySQl vs. mnesia Sal, I recommend that you use MySQL because of the cluster capacity that MySQL team is developing. Mnesia is O.K. but for the business environment like web services i can only recommend MySQL... for development first use ErlyWeb + ErlyDB, later if you wish you can develop something more that will suite you and your team. BR, Patrick _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From a2800276@REDACTED Sun Aug 5 15:11:09 2007 From: a2800276@REDACTED (Tim Becker) Date: Sun, 5 Aug 2007 15:11:09 +0200 Subject: [erlang-questions] VM & BEAM Specs In-Reply-To: <18100.47360.572196.225023@antilipe.corelatus.se> References: <46B46D0D.9010302@mail.ru> <18100.47360.572196.225023@antilipe.corelatus.se> Message-ID: <254c7bfb0708050611l62ce3b92we997ab033eb62d0@mail.gmail.com> > | The internals of the BEAM file format are described on Bj?rn's > | homepage . Eventually this will/might include a description of the > | virtual machine's instructions. Bj?rn also includes some benchmarks > | comparing different versions of the BEAM machine. You may also want to > | take a look at the beam_lib module. I've had a look at this the other day (to play around with .beam files), and it's a bit dated (May 2000). At the very least, the "Abstract Code" chunk isn't described, I've only implemented a cursory beam dump, so I don't know if other bits are left out as well. You can glean some information from the lib/compiler/src/beam_asm.erl, beam_disasm.erl and /lib/stdlib/src/beam_lib.erl implementations. -tim From casper2000a@REDACTED Sun Aug 5 21:09:50 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Mon, 6 Aug 2007 00:39:50 +0530 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: <005501c7d76c$c40e4da0$6400a8c0@einstein> Message-ID: <20070805190954.2B6B319DC3CB@mail.wavenet.lk> Well, we use Mnesia in some production systems with over 500 transaction/s kind of capacity with over 500,000 records and it performance quite well. So far I haven't faced unrecoverable issue with Mnesia. - Eranga -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Salvatore Mangano Sent: Sunday, August 05, 2007 7:58 PM To: 'Patrick'; erlang-questions@REDACTED Subject: Re: [erlang-questions] MySQl vs. mnesia Thanks. I was kind of leaning toward MySQL but wanted to see if anyone could convince me to stick with mnesia. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Patrick Sent: Sunday, August 05, 2007 9:06 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] MySQl vs. mnesia Sal, I recommend that you use MySQL because of the cluster capacity that MySQL team is developing. Mnesia is O.K. but for the business environment like web services i can only recommend MySQL... for development first use ErlyWeb + ErlyDB, later if you wish you can develop something more that will suite you and your team. BR, Patrick _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From mberrow1@REDACTED Sun Aug 5 22:22:34 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Sun, 5 Aug 2007 13:22:34 -0700 Subject: [erlang-questions] Problem with socket-based distribution example in the "Programming Erlang" book Message-ID: <002c01c7d79e$5e89c400$6401a8c0@rubicon> Hi, I am trying to following along with Joe's tutorial on socket-based distribution from "Programming Erlang" book. On page 190 we are asked to start the name server (and the module kvs). So in the first session, I set up my environment, then do as asked. Eshell V5.5.4 (abort with ^G) 1> os:putenv("HOME","C:\\Documents and Settings\\mberrow"). true 2> code:add_patha("./socket_dist"). true 3> kvs:start(). true 4> lib_chan:start_server(). lib_chan starting:"C:\\Documents and Settings\\mberrow/.erlang_config/lib_chan.conf" ConfigData=[{port,1234}, {service,nameServer, password, "ABXy45", mfa, mod_name_server, start_me_up, notUsed}] true That looks happy. And it has found the config file (placed as directed). So (as directed) I start up the second session (1st adding "./socket_dist" to my code path) as follows: Eshell V5.5.4 (abort with ^G) 1> code:add_patha("./socket_dist"). true 2> {ok, Pid} = lib_chan:connect("localhost", 1234, nameServer, "ABXy45", ""). {ok,<0.34.0>} That looked OK, but immediately in the 1st session, I get 5> server error:{undef,[{mod_name_server,start_me_up,[<0.40.0>,[],notUsed]}, {lib_chan,really_start,3}]} And there I am stuck. but mod_name_server.beam is sitting right there in ./socket_dist dir with all the others. Why am I getting 'undef' ? -- Mike Berrow From dev@REDACTED Mon Aug 6 01:05:23 2007 From: dev@REDACTED (Jonathan Gold) Date: Sun, 5 Aug 2007 16:05:23 -0700 Subject: [erlang-questions] (JInterface): Some subclasses of OtpErlangObject override equals() but not hashCode()? Message-ID: <20070805230523.GA17091@samizdatdigital.com> I was looking through the jinterface source to find out some things about how the encoding/decoding worked, and noticed that OtpErlangAtom and OtpErlangDouble (and perhaps others) override equals() based on compareTo, but does not override hashCode(). This seems like it could violate the contract of Object.hashCode(), so was just curious to see whether I've misread the jinterface code somehow. jon From monch1962@REDACTED Mon Aug 6 00:08:19 2007 From: monch1962@REDACTED (David Mitchell) Date: Mon, 6 Aug 2007 08:08:19 +1000 Subject: [erlang-questions] xmerl_xpath difficulties In-Reply-To: References: Message-ID: Thanks again Caoyuan, OK, I think I've got it - there's a bug in Erlang on Ubuntu 6.06. No idea if it's a bug in Erlang itself (i.e. version 5.4.9 vs. 5.5.5), or a bug in the implementation of Erlang in Ubuntu, but it seems pretty straightforward. The Windows version works OK, but the Ubuntu version doesn't. Here's 2 sessions: the first on Ubuntu and the 2nd on Windows davidm@REDACTED:~$ erl Erlang (BEAM) emulator version 5.4.9 [64-bit] [source] [threads:0] Eshell V5.4.9 (abort with ^G) 1> {XmlFull,_} = xmerl_scan:string("Hello"). {{xmlElement,text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{text,1}],1,[],"Hello",text}], [], "/home/davidm", undeclared}, []} 2> XmlText = xmerl_xpath:string("/text/text()", XmlFull). [] 3> lists:flatten([element(5,X)|| X <- XmlTexts, element(1,X) == xmlText]). [] 4> Now the Windows version: D:\Program Files\erl5.5.5\bin>erl Eshell V5.5.5 (abort with ^G) 1> {XmlFull, _} = xmerl_scan:string("Hello"). {{xmlElement,text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{text,1}],1,[],"Hello",text}], [], "D:/Program Files/erl5.5.5/bin", undeclared}, []} 2> XmlText = xmerl_xpath:string("/text/text()", XmlFull). [{xmlText,[{text,1}],1,[],"Hello",text}] 3> Note the difference in the value of XmlText in both cases - this is a fairly trivial issue to reproduce, being only 2 lines of code. I'm still finding my feet in the Erlang world - can someone pls give me a pointer as to how I should file a bug report on this? Even if it doesn't get fixed, I'd like it documented (and searchable) so that the next person who stumbles on it doesn't get bogged down as I did. Thanks to everyone for their help tracking this down. Regards Dave M. On 05/08/07, Caoyuan wrote: > It's a bit strange, it works in my computer. You may try: > 1> {XmlFull, _} = xmerl_scan:string("Hello"). > {{xmlElement,text, > text, > [], > {xmlNamespace,[],[]}, > [], > 1, > [], > [{xmlText,[{text,1}],1,[],"Hello",text}], > [], > "/Users/dcaoyuan/polebeans/ewp", > undeclared}, > []} > 2> XmlTexts = xmerl_xpath:string("/text/text()", XmlFull). > [{xmlText,[{text,1}],1,[],"Hello",text}] > > The xpath query should return a list of result, it maybe [], or more > than one element, so it's better to do: > > 3> lists:flatten([element(5,X) || X <- XmlTexts, element(1, X) == xmlText]). > "Hello" > > If you are in writing a module, by including xmerl.hrl, you can: > lists:flatten([X#xmlText.value || X <- XmlTexts, is_record(X, xmlText)]). > > > On 8/5/07, David Mitchell wrote: > > Thanks Caoyuan, but it didn't work for me: > > > > davidm@REDACTED:~$ erl > > Erlang (BEAM) emulator version 5.4.9 [64-bit] [source] [threads:0] > > > > Eshell V5.4.9 (abort with ^G) > > 1> {XmlFull,_} = xmerl_scan:string("Hello"). > > {{xmlElement,text, > > text, > > [], > > {xmlNamespace,[],[]}, > > [], > > 1, > > [], > > [{xmlText,[{text,1}],1,[],"Hello",text}], > > [], > > "/home/davidm", > > undeclared}, > > []} > > 2> [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). > > > > =ERROR REPORT==== 5-Aug-2007::22:48:45 === > > Error in process <0.31.0> with exit value: {{badmatch,[]},[{erl_eval,expr,3}]} > > > > ** exited: {{badmatch,[]},[{erl_eval,expr,3}]} ** > > 3> > > > > Any thoughts? > > > > Regards > > > > Dave M. > > > > On 05/08/07, Caoyuan wrote: > > > > [XmlText] = xmerl_xpath:string("/text/text()", XmlFull). > > > [{xmlText,[{text,1}],1,[],"Hello",text}] > > > > element(5, XmlText). > > > "Hello" > > > > > > > > > On 8/5/07, David Mitchell wrote: > > > > Hello group, > > > > > > > > I'm having trouble getting my head around xmerl_xpath - I've gone > > > > through a bunch of Google searches, but can't find the "Simple guide > > > > to xmerl_xpath" I'm looking for ;-> > > > > > > > > I've reduced my problem to 3 lines of code: > > > > > > > > 15> {XmlFull, _} = xmerl_scan:string("Hello"). > > > > {{xmlElement,text, > > > > text, > > > > [], > > > > {xmlNamespace,[],[]}, > > > > [], > > > > 1, > > > > [], > > > > [{xmlText,[{text,1}],1,[],"Hello",text}], > > > > [], > > > > "/home/davidm", > > > > undeclared}, > > > > []} > > > > > > > > 16> xmerl:export([XmlFull], xmerl_xml). > > > > ["",[[["<","text",">"],["Hello"],[""]]]] > > > > > > > > 17> xmerl_xpath:string("//text/*", XmlFull). > > > > [] > > > > > > > > > > > > Line 16 seems to confirm that XmlFull contains my XML string. > > > > However, I'd expect line 17 to give me something like "Hello" or > > > > ["Hello"], yet it returns an empty list. > > > > > > > > Could someone please point out the (no doubt very simple) mistake I've > > > > made? Also, if a "Simple guide to xmerl_xpath" exists somewhere, > > > > could someone please point me towards it? > > > > > > > > Thanks in advance > > > > > > > > Dave M. > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > -- > > > - Caoyuan > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > - Caoyuan > From saleyn@REDACTED Mon Aug 6 01:43:53 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 05 Aug 2007 18:43:53 -0500 Subject: [erlang-questions] lock-free hash table In-Reply-To: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> Message-ID: <46B660B9.3090802@gmail.com> There have been quite a number of publications on the subject of lock-free data structures since around mid 90's, most notably by Maged Michael (IBM) and Philippas Tsigas / Yi Zhang (Chambers University). Here are some selected links: http://erdani.org/publications/cuj-2004-12.pdf http://citeseer.ist.psu.edu/sundell04scalable.html http://www.noble-library.com/ http://research.sun.com/techrep/2002/abstract-110.html The lock-free algorithms indeed perform exceptionally well in shared memory concurrent systems with a large number of CPUs since they don't require OS synchronization primitives (relying on a single instruction such as compare-and-swap). I also think that taking advantage of these algorithms in Erlang's emulator would make it even more scalable on large number of cores, especially if interfaces to ports (via shared memory) and drivers (via lock-free FIFO circular queues) would offer lock-free synchronization with emulator threads. Serge Ulf Wiger wrote: > I just caught Dr. Cliff Click's Google TechTalk on his > lock-free hash table. > > http://video.google.com/videoplay?docid=2139967204534450862 > > The (Java) source is also available > at sourceforge: http://sourceforge.net/projects/high-scale-lib > > According to his talk, the algorithm "scales well up to 768 cpus". > > I don't know if there is anything in this that would not fit Erlang > well, but perhaps it's something to look into? > > Anyway, it's always interesting to listen to these performance geeks. ;-) > > BR, > Ulf W > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mberrow1@REDACTED Mon Aug 6 03:37:29 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Sun, 5 Aug 2007 18:37:29 -0700 Subject: [erlang-questions] Problem with socket-based distribution example in the "Programming Erlang" book References: <002c01c7d79e$5e89c400$6401a8c0@rubicon> <290b3ba10708051453y3afadd0fs35f41cb865f86210@mail.gmail.com> Message-ID: <002301c7d7ca$5f1955d0$6401a8c0@rubicon> Aha!! ... that was it. the beam file for mod_name_server in the zip file I downloaded for the book did not correspond to the source. It had 'startMeUp' in the beam file (the mod_name_server.erl file and the config file has 'start_me_up'). 4> l(mod_name_server). {module,mod_name_server} 5> 5> mod_name_server: module_info/0 module_info/1 startMeUp/3 ... re-compiling ... 2> c(mod_name_server). {ok,mod_name_server} ... 8> mod_name_server: module_info/0 module_info/1 start_me_up/3 Now it works as prescribed. 2> {ok, Pid} = lib_chan:connect("localhost", 1234, nameServer, "ABXy45", ""). {ok,<0.34.0>} 3> lib_chan:cast(Pid, {store, joe, "writing a book"}). {send,{store,joe,"writing a book"}} 4> lib_chan:rpc(Pid, {lookup, joe}). {ok,"writing a book"} 5> lib_chan:rpc(Pid, {lookup, jim}). undefined 6> Thanks much. I'll know how to track that kind of thing down in future. (and also not take pre-compiled beams as gospel). -- Mike Berrow ----- Original Message ----- From: "t ty" To: "Mike Berrow" Sent: Sunday, August 05, 2007 2:53 PM Subject: Re: [erlang-questions] Problem with socket-based distribution example in the "Programming Erlang" book > Is there are start_me_up function in the module. And is it exported ? > From the shell do > > 1> l(mod_name_server). > 2> mod_name_server: > > this should show you the list of available functions. > > t From ok@REDACTED Mon Aug 6 05:47:32 2007 From: ok@REDACTED (ok) Date: Mon, 6 Aug 2007 15:47:32 +1200 Subject: [erlang-questions] Erlang vs. Stackless Python In-Reply-To: References: <46B17CD3.3040000@gmail.com> Message-ID: >> Remember Joe Armstrong's call in his book: >> " Write a ring benchmark. Create N processes in a ring. Send a >> message >> round the ring M times so that a total of N*M messages get sent. >> Time how long this takes [..] >> >> Write a similar program in some other programming language you >> are >> familiar with. Compare the results. Write a blog, and publish the >> results on the internet! >> " It's not worth a blog, but here's a Smalltalk version, using Squeak. SharedQueue>> ring: numberOfProcesses benchmark: numberOfRounds "Create a ring of processes and send a message around that ring repeatedly. Report how long it takes. Each process has access to two SharedQueues 'in' and 'out' and a Semaphore 'done'." |queues done t0 t1| t0 := Time primMillisecondClock. queues := (1 to: numberOfProcesses) collect: [:i | SharedQueue new: 1]. done := Semaphore new. 1 to: numberOfProcesses do: [:i | |in out| in := queues at: i. out := queues at: (i \\ numberOfProcesses) + 1. [ 1 to: numberOfRounds do: [:j | |message| message := in next. out nextPut: message - 1]. i = numberOfProcesses ifTrue: [done signal] ] fixTemps fork]. "Fire off the first message." (queues at: 1) nextPut: numberOfProcesses * numberOfRounds. done wait. t1 := Time primMillisecondClock. ^t1 - t0 Performance scales fairly linearly with the number of rounds. With the number of processes, it is not so good: 10 -> 152 msec 100 -> 1557 msec 1000 -> 29480 msec 10000 -> 408182 msec (All on a 1GHz G4 PowerMac). These numbers are tolerably well fitted by a curve time ~ c * nprocs**1.16. There seems to be more garbage collection going on than I expected (I love how easy it is to take a quick profile of any running MacOS process). SharedQueues are roughly equivalent to Erlang mailboxes, but they are a heavyweight for this benchmark. Creating a 'Mailbox' class that can hold only a single message and using that instead gave 10 -> 25 100 -> 267 1000 -> 12788 10000 -> 161545 This is tolerably well fitted by time ~ c * nprocs**1.31, making the point that "is faster than" is not the same as "scales better than". The really important point here is that I *would* considering using Squeak for a program with low hundreds of processes, but not for a program with thousands. From saleyn@REDACTED Mon Aug 6 06:47:05 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 06 Aug 2007 00:47:05 -0400 Subject: [erlang-questions] new tutorial Message-ID: <46B6A7C9.7040504@gmail.com> I added a new tutorial to trapexit: http://www.trapexit.org/index.php/Building_a_Non-blocking_TCP_server_using_OTP_principles Serge From joelr1@REDACTED Mon Aug 6 06:51:16 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Aug 2007 05:51:16 +0100 Subject: [erlang-questions] Booting over the network Message-ID: Folks, I've got another exciting Erlang project to complete and so I'd like to ask... How exactly do you boot a node over the network? I know that you can do erl -loader inet ... but what happens then? Do any attempts to l(module). get redirected to the boot server? What about attempts to compile a module? Can you fetch complete apps from the network boot server, e.g. Mnesia? How would you do this? The documentation for erl_prim_loader says: "The start script is also fetched with this low level loader." What is the start script that's being referred to here? Is this the boot file that you pass to erl - boot? How do you set up a network boot server? Is this just a regular Erlang node that does not require special configuration? Thanks, Joel -- http://topdog.cc - EasyLanguage to C# compiler http://wagerlabs.com - Blog From bent@REDACTED Mon Aug 6 08:30:04 2007 From: bent@REDACTED (Ben Munat) Date: Sun, 05 Aug 2007 20:30:04 -1000 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: References: Message-ID: <46B6BFEC.1010307@munat.com> Patrick wrote: > I recommend that you use MySQL because of the cluster capacity that > MySQL team is developing. Mnesia is O.K. but for the business > environment like web services i can only recommend MySQL... for > development first use ErlyWeb + ErlyDB, later if you wish you can > develop something more that will suite you and your team. I'm curious why you recommend MySQL over mnesia? Are thinking of "business environment" folks who would just be more comfortable with something well known like MySQL? Or do you know of data-integrity or performance issues that I should know about? I'm just curious because mnesia is a big chunk of why I'm learning erlang. I have only been at it for a month or two, but in that time I have not come across a single story of data-loss, performance issues or other problems/disasters with mnesia. Ben From ok@REDACTED Mon Aug 6 08:41:18 2007 From: ok@REDACTED (ok) Date: Mon, 6 Aug 2007 18:41:18 +1200 Subject: [erlang-questions] VM & BEAM Specs : idea for improving the lists support In-Reply-To: <46B5AFE5.40706@mail.ru> References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> Message-ID: On 5 Aug 2007, at 11:09 pm, Denys Rtveliashvili wrote: > As far as I understand, the underlying implementation of lists > which is > used in Erlang is based on linked lists. Just like lists in Lisp, Prolog, ML, CAML, Clean, and Haskell, amongst others. > > The problems I see with the current implementation are: > - The computational complexity required to do certain list > operations is > O(n), not O(1) Just like the computational complexity required to do certain operations with tuples is O(n), not O(1). > - The linked list is not CPU cache - friendly. It can be dispersed in > the memory, reducing the cache - hits and thus killing the > performance. Half true. One of the oldest ideas in list processing (1960s?) is a garbage collector that automatically straightens lists. And the Interlisp-D "cons" function used to go to some trouble to put new pairs on the same page as the tail (if possible) or the head (if not). > - Each of the list items is a quite big object. It takes 64bits if > I am > not mistaken. So, if you'd like to store a list of, say, 16bit > characters / ordinary Unicode strings it takes 4 times more memory. Which is why you don't do that for large strings, but use binaries, lists of binaries, or lists of tokens, or whatever. > I believe, the current implementation can be (theoretically) improved. Of the many systems I've used in the past, the ones with "smart" lists were invariably worse than the ones with "dumb" ones. My favourite example is Interlisp-D, with CDR-coding and a smart CONS. Xerox Quintus Prolog, with "dumb" lists, ran list processing code 5 times faster on the same hardware. One would expect *idiomatic* Erlang code to be similarly slowed down by a "smart" implementation of lists. > "Use unrolled linked lists to improve the performance" > I have unrolled strict list code for Haskell and Clean. See http://www.cs.otago.ac.nz/staffpriv/ok/software.htm/ A neural net program written in Haskell used 3650 seconds with plain lists and 3057 seconds (about 1.2 times faster). The best I've ever seen, on a benchmark doing practically nothing else, was 2 times faster. (By making it GHC-specific I could probably do somewhat better, but probably not much.) That was for numeric code where GHC's ability to treat !Double as unboxed paid off. Erlang has no such ability, so I suspect that we are looking at the 1.2 factor at best. > > --- Idea #2: > > "Use resize-able vectors to store lists" > > I guess this change would give even more benefits comparing to the > Idea > #1 My guess is that this would have higher COSTS for existing code. > > - The _amortized_ computational complexity is O(1) for > adding/removing/taking a remainder no matter if it is done from the > beginning or from the end of the list. We can get that with a pair of singly linked lists right now. > - It takes O(1) time to find out the size of the list. It is amazing just how seldom this is interesting. > - Cache-hits ratio is seriously improved as the list is located in a > single chunk of memory. You are assuming that the list *elements* are not scattered all over the place. There seems to be no reason to believe that (except for strings). If you are mapping along a list doing some computation that produces a new result, e.g., zip([X|Xs], [Y|Ys]) -> [{X,Y}|zip(Xs, Ys)]; zip(_, _) -> []. the present scheme tends to put the list cell near the newly created element it points to. (If we ran heaps DOWN instead of up, the list cell would precede the element, which would be perfect for a cache. That's an experiment someone should try some day.) Your proposal would put a list element and the cell that points to it far apart, which is bad for the cache. > - Much less work for a GC. That may well be true, but it is very far from obvious. > A few words regarding the implementation: > If you take a look at Java LinkedList and ArrayList, the ArrayList is > generally 3 times faster. Yes, but that's not really comparable. A Java LinkedList is a record containing a stored size (this is one of the things you are arguing FOR) and a pointer to a DOUBLY linked list. An Entry has to be at least 4 words and could be 6 depending on the Java implementation. Oh yes, it's a doubly linked list with a header, so a completely empty Java LinkedList starts out holding at least as much space as an Erlang list with 4 elements. Adding a single new element at the front (a) is destructive, unlike Erlang (b) has to initialise at least four words of memory, has to change two existing pointers, and has to increment two counters. An Erlang cons just has to initialise two words of memory. Java's LinkedList is, in short, a textbook example of how *NOT* to do linked lists, and if ArrayLists are only 3 times faster, that is a really damning criticism of the implementation quality of ArrayList. The functional programming literature has many interesting data structures, including ones with fast cons, fast snoc, fast append, and fast index. I've tried a couple of them out. They generally have high constant factors. --- Idea #3: > > "Typed lists" > > Both kinds of list implementations can benefit from knowing what > type of > data is going to be stored in them. It would lead to a decrease in the > consumed space and improved performance. > > It is possible to implement a "general" kind of list which can hold > anything plus some specific implementations for storing 8bit and 16bit > values. The NuProlog implementation of Prolog from the University of Melbourne did this. I've spoken in person with the guy who implemented that, and he said it was a big headache and if they were doing it all again that's one hack they would never ever try again. Again a data point: Interlisp-D handled strings as packed arrays of bytes (or packed arrays of 16-bit codes) and had special microcode support for them. Xerox Quintus Prolog, running on the same hardware, in the Interlisp environment, used ordinary Prolog list cells (just like Erlang ones). Guess which one was faster at string manipulation? > The benefit is again in both performance and memory consumption. > Imagine that a program has consumes a large text document with > English, > Arabic and Russian characters. The current implementation will > consume 4 > times more memory than an automatically-typed vector-based version. In > case the document contains only ASCII characters, the memory > consumption > will drop 8 times. Only if someone is daft enough to store the whole thing as a simple list of characters. There are much better ways, in the language and using the implementation that we now have. From heinrich@REDACTED Mon Aug 6 09:51:17 2007 From: heinrich@REDACTED (Heinrich Venter) Date: Mon, 6 Aug 2007 09:51:17 +0200 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: <46B6BFEC.1010307@munat.com> References: <46B6BFEC.1010307@munat.com> Message-ID: <005901c7d7fe$94a36630$bdea3290$@com> We have been using MySQL and Mnesia in production environments for a while now. The answer is that both have a place. MySQL has the advantage of interoperability and the SQL language that is known and used by third party tools. Mnesia has the advantage of being fast, distributed and embedded in Erlang. Our rules of thumb are: If it is data that is mostly read at runtime use mnesia (like configs and internal queues). If it is large volumes of data that needs to be reported on, use MySQL. Mnesia == runtime data MySQL == archived data -]-[ From gleber.p@REDACTED Mon Aug 6 11:43:24 2007 From: gleber.p@REDACTED (Gleber) Date: Mon, 6 Aug 2007 11:43:24 +0200 Subject: [erlang-questions] erlang-questions server problem In-Reply-To: References: Message-ID: <14f0e3620708060243t2f93fbc9l29c33f8f92d45ea6@mail.gmail.com> Hello. No, there is no problems with the mailing list server. Maybe mails from this mailing list are being blocked by your (or your's ISP or your's mail server) spam filter. Good luck figuring out what is going on. Regards, Gleb Peregud On 8/5/07, yerl@REDACTED wrote: > Hi! > > I didn't receive any message since 08/02/2007. > Is there any problem with the mailing list server ? > > cheers > Y. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -- Albert Einstein From 0x6e6562@REDACTED Wed Aug 1 01:53:45 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Wed, 1 Aug 2007 00:53:45 +0100 Subject: [erlang-questions] [rabbitmq-discuss] FW: Multiple consumers In-Reply-To: <269388e30707311653x339b0efehdda8cf91c1385675@mail.gmail.com> References: <269388e30707280654ha7b6ef7hc185221530f57131@mail.gmail.com> <269388e30707281726l7f9d2acfp19fbc765bf8f677d@mail.gmail.com> <269388e30707290201r715fbbcdm2a0a41faa64ee8e1@mail.gmail.com> <269388e30707290519h27e37a1ck58d0625948a5f231@mail.gmail.com> <269388e30707311653x339b0efehdda8cf91c1385675@mail.gmail.com> Message-ID: <269388e30707311653j3abfc4c6k6b52155451c80895@mail.gmail.com> Matthias, Here is the latest patch based on the design discussion we have been having. This demonstrates how the connection initiation, opening channel 0, opening channel 1 and doing an access request for both the direct and networked cases. Please bear in mind that I was concentrating on getting a working prototype to you based on the design you described, so there are a lot of rough edges that require refactoring, cleaning up and polishing, as well as going through the complete spec for each case (direct and network). You can best see the flow by executing the amqp_client_test module which has a test case for the direct and network cases. To get a unified API, what I have done is to parameterize the client with a direct driver and a network driver that implement the necessary callbacks to provide connectivity in the 2 scenarios (amqp_direct_driver and amqp_network_driver). By doing this I can use amqp_send() and amqp_receive() functions in the higher level client in a transparent fashion, so the actual protocol handling is common. In the direct case, a new process for a client channel is spawned and this maintains connectivity to the server peer. In the network case, a new process for the initial AMQP network connection is spawned which handles the connection tuning. This process handles the socket connectivity (to be exact, there's a reader process and a writer process). Then when a user calls open_channel, a new amqp_client process is spawned for that channel, this process is registered with the relevant socket reader/writer processes, and normal message passing occurs from here on in. This way the same send() and recv() for AMQP can be used in the direct and network cases. There are a lot of things that require attention, for example - The way the new channel processes are send to the socket reader (I have been reading the gen_tcp man pages for a cleaner way to do this) - Making sure that exits are trapped correctly - Taking out all of the io:format() statements (is a logging strategy worth considering?) - Streamlining the messages that get passed, so the amqp_send/receive functions are simpler and easier to understand (there's probably redundancy in there) and to get rid of some case statements that currently exist. - General refactoring in the client to make it neater and easier to maintain. - Considering refactoring commonalities between the client and the server, such as the header files and the server modules used by the client - I patched rabbit_framing.erl, which I have subsequently learned is a generated file, so that needs cleaning up. - The patch probably also contains changes to server modules that are not entirely necessary, these need to be identified and reviewed. - Do some real testing with it :-) - Benchmark the direct and network drivers to see what difference it makes, if any ;-) But I just wanted to find out if this is going in the right direction before I do too much on these points. Also, there are some dependencies on refactoring the server modules. So I'll just answer some of your comments now: > > 1. In the direct case, the host and channel would be set in the > > start() call, so just passing the Pid is fine. > > There is no 'host' in the direct case. Fine. This is how it has been implemented. > The initialisation sequence for the networked client is: > > 1) open socket, > > 2) spawn reader process, parameterised by the socket. > > 3) open channels by sending a message to the reader process. This should > result in the spawning a new channel process, parameterised by the > channel number, ReaderPid and WriterPid, and the necessary book-keeping > (mapping channel numbers to pids) - i.e. everything > rabbit_reader:open_channel does currently. The reply message to the > sender of the 'open_channel' message should contain the Pid of the new > channel process. This is IMHO exactly how it works now. > > > 2. Should the processes be linked at all? That is, if a channel > > process dies, should the user process die as well? This requires some review to check that it is done properly in the code, but is not really a big deal. > > Channel processes should be (and are) linked to their reader process. As > for linking them to the user process, i.e. the process that initiated > the opening of a channel, I reckon we should leave that up to the user. OK. HTH, Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: erlang_client_3.patch Type: application/octet-stream Size: 50802 bytes Desc: not available URL: From bjorn@REDACTED Mon Aug 6 14:08:32 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 06 Aug 2007 14:08:32 +0200 Subject: [erlang-questions] does compile/file option compressed exist ? In-Reply-To: References: Message-ID: "Roberto Saccon" writes: > > But it is only mentioned there and nowhere else and does not show up > with compile:options(). Does this option actually exist ? > Yes, it exists and it will be documented in the next release. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From joelr1@REDACTED Mon Aug 6 14:42:17 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Aug 2007 13:42:17 +0100 Subject: [erlang-questions] Booting over the network In-Reply-To: References: Message-ID: On Aug 6, 2007, at 5:51 AM, Joel Reymont wrote: > How exactly do you boot a node over the network? node 1) erl -sname boot node 1) erl_boot_server:start(['127.0.0.1']). node 2) erl -sname foo -hosts 127.0.0.1 -id foo -loader inet > I know that you can do erl -loader inet ... but what happens then? The config file (-config ...) as well as the boot file are loaded using erl_prim_loader, i.e. fetched from the boot server using the full path. > Do any attempts to l(module). get redirected to the boot server? > What about attempts to compile a module? I'm not sure about this but the code server positively uses erl_prim_loader. > Can you fetch complete apps from the network boot server, e.g. > Mnesia? How would you do this? Using the boot script. The script can contain application upgrade instructions and all the apps that need to be started up. > The documentation for erl_prim_loader says: "The start script is > also fetched with this low level loader." What is the start script > that's being referred to here? Is this the boot file that you pass > to erl -boot? Yes, that boot script. > How do you set up a network boot server? Is this just a regular > Erlang node that does not require special configuration? Correct. Just run erl_boot_server:start([...]). Did I answer my own questions in-depth? Thanks, Joel -- http://topdog.cc - EasyLanguage to C# compiler http://wagerlabs.com - Blog From jim.menard@REDACTED Mon Aug 6 15:32:00 2007 From: jim.menard@REDACTED (Jim Menard) Date: Mon, 6 Aug 2007 09:32:00 -0400 Subject: [erlang-questions] Mnesia and Yaws Message-ID: I've defined a Mnesia database and can access it from within the erl command line. However, when I try to access it from my Yaws web app, I see the error message: ERROR erlang code crashed: File: /Users/jimm/src/jimm/src/erlang/fake/www/do_login.yaws:1 Reason: {{badmatch,{aborted,{node_not_running,nonode@REDACTED}}}, ... I haven't stopped Mnesia from the command line, and can still access it. The database directory Mnesia.nonode@REDACTED exists in the root directory for my Yaws project, and that's where I run the yaws command from. What do I have to do in Yaws to connect to the same database? Have I missed something in the Yaws or Mnesia documentation? The Yaws docs about yapps mentions Mnesia---do I have to create a Yaws app to use Mnesia? Thank you for any help or pointers to documentation. Jim -- Jim Menard, jimm@REDACTED, jim.menard@REDACTED http://www.io.com/~jimm/ From tsuraan@REDACTED Mon Aug 6 17:02:06 2007 From: tsuraan@REDACTED (tsuraan) Date: Mon, 6 Aug 2007 10:02:06 -0500 Subject: [erlang-questions] ErlIde In-Reply-To: <46B3D804.3090607@ghostgun.com> References: <95be1d3b0708021410s23d8af8fj215c14c83e77f04f@mail.gmail.com> <20070803030537.0F15919DC4DA@mail.wavenet.lk> <46B2AD7D.7090204@ghostgun.com> <269388e30708022358t49071987yf39aa537cb41a97b@mail.gmail.com> <46B3D804.3090607@ghostgun.com> Message-ID: <84fb38e30708060802l5d2bb93fn925d3ba422f2e929@mail.gmail.com> > > $ java -version > java version "1.4.2_12" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-270) > Java HotSpot(TM) Client VM (build 1.4.2-70, mixed mode) > > Is there an update available somewhere? I found an update for 10.4.x but > am unable to find an update for 10.3.x. While I could try to install it > via fink's apt-get I'd rather update the main version than having > unnecessary multiple copies. Does anyone know if and where I can find > this update? I'm pretty sure that the official OSX Java is tied to the OS. You won't find an Apple-provided JVM for Java 1.5 and OSX.3 because they expose a lot of the actual OSX core libraries to the JVM. Since 10.4 added a bunch of stuff to CoreImage, etc, the Java 1.5 machine that they modified to support that won't work in 10.3. You'll have to upgrade OSX (I'm personally waiting for 10.5 before doing that), or try to get a free JVM like Blackdown or OpenJDK working. -------------- next part -------------- An HTML attachment was scrubbed... URL: From icfp.publicity@REDACTED Mon Aug 6 17:53:46 2007 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Mon, 6 Aug 2007 10:53:46 -0500 Subject: [erlang-questions] ICFP07 Call for Participation Message-ID: <53ff55480708060853m2f7d8068t713b04cd175dc971@mail.gmail.com> ===================================================================== Call for Participation The 12th ACM SIGPLAN International Conference on Functional Programming (ICFP 2007) http://www.informatik.uni-bonn.de/~ralf/icfp07.html Freiburg, Germany, 1-3 October 2007 ===================================================================== ICFP 2007 provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. The conference covers the entire spectrum of work, from practice to theory, including its peripheries. Preliminary program: * http://www.informatik.uni-bonn.de/~ralf/schedule.html * Invited speakers: + John Hughes (Chalmers University of Technology) + Frank Pfenning (Carnegie Mellon University) + John Lloyd (Australian National University) * The Program committee has *deliberately* created extra breaks so as to give participants more time to talk with colleagues. Schedule including related workshops: * 30 Sep: ACM SIGPLAN Haskell Workshop * 30 Sep: ACM SIGPLAN Workshop on Scheme and Functional Programming * 1-3 Oct: ICFP07 * 4 Oct: ACM SIGPLAN Commercial Users of Functional Programming * 4 Oct: ACM SIGPLAN Workshop on Mechanizing Metatheory * 5 Oct: ACM SIGPLAN Erlang Workshop * 5 Oct: ACM SIGPLAN Workshop on ML * 5 Oct: ACM SIGPLAN Programming Languages meets Program Verification Registration information: * http://proglang.informatik.uni-freiburg.de/ICFP2007/registration.shtml * Early registration deadline: September 7, 2007 Accommodations information: * http://proglang.informatik.uni-freiburg.de/ICFP2007/accommodation.shtml * Conference reservation/rate deadline: September 1, 2007 * September/October is Freiburg's main tourist season; participants are advised to book rooms as early as possible. Conference organizers: * General Chair: Ralf Hinze (Universit?t Bonn) * Program Chair: Norman Ramsey (Harvard University) * Local Arrangements Chair: Peter Thiemann (Universit?t Freiburg) * Workshop Co-Chairs: Graham Hutton (University of Nottingham) and Matthias Blume (Toyota Technological Institute at Chicago) * Programming Contest Chair: Johan Jeuring (Universiteit Utrecht) * Publicity Chair: Matthew Fluet (Toyota Technological Institute at Chicago) From rtvd@REDACTED Mon Aug 6 19:41:57 2007 From: rtvd@REDACTED (Denys Rtveliashvili) Date: Mon, 06 Aug 2007 21:41:57 +0400 Subject: [erlang-questions] VM & BEAM Specs : idea for improving, the lists support In-Reply-To: References: Message-ID: <46B75D65.3050107@mail.ru> > Of the many systems I've used in the past, the ones with "smart" lists > were invariably worse than the ones with "dumb" ones. My favourite > example is Interlisp-D, with CDR-coding and a smart CONS. Xerox Quintus > Prolog, with "dumb" lists, ran list processing code 5 times faster on > the same hardware. One would expect *idiomatic* Erlang code to be > similarly slowed down by a "smart" implementation of lists. > Well.. Your mileage may vary. The difference of performance depends on lots of things. So, you can tell the difference only if there are two finely tuned implementations. >> "Use unrolled linked lists to improve the performance" > I have unrolled strict list code for Haskell and Clean. > See http://www.cs.otago.ac.nz/staffpriv/ok/software.htm/ > > A neural net program written in Haskell used 3650 seconds with > plain lists and 3057 seconds (about 1.2 times faster). The best > I've ever seen, on a benchmark doing practically nothing else, > was 2 times faster. (By making it GHC-specific I could probably > do somewhat better, but probably not much.) That was for > numeric code where GHC's ability to treat !Double as unboxed > paid off. Erlang has no such ability, so I suspect that we are > looking at the 1.2 factor at best. > OK, you've got a performance penalty here. However, I assume you would not argue that an unrolled list consumes less space. Also it has sense to compare native implementations of dumb linked list and an unrolled linked list. Otherwise you can have additional penalties you would not get with a native version. >> --- Idea #2: >> >> "Use resize-able vectors to store lists" >> >> I guess this change would give even more benefits comparing to the >> Idea #1 >> > > My guess is that this would have higher COSTS for existing code. > Which costs do you mean? Could you give an example where an vector-based list would be slower or consume more space than a linked list? >> - The _amortized_ computational complexity is O(1) for >> adding/removing/taking a remainder no matter if it is done from the >> beginning or from the end of the list. >> > We can get that with a pair of singly linked lists right now. > Of course, you can emulate almost everything. It's just not too much convenient. >> - It takes O(1) time to find out the size of the list. >> > It is amazing just how seldom this is interesting. > Sure it is. But if you can get it for free, then why not? >> - Cache-hits ratio is seriously improved as the list is located in a >> single chunk of memory. >> > You are assuming that the list *elements* are not scattered all over > the place. There seems to be no reason to believe that (except for > strings). If you are mapping along a list doing some computation that > produces a new result, e.g., > zip([X|Xs], [Y|Ys]) -> [{X,Y}|zip(Xs, Ys)]; > zip(_, _) -> []. > the present scheme tends to put the list cell near the newly created > element it points to. (If we ran heaps DOWN instead of up, the list > cell would precede the element, which would be perfect for a cache. > That's an experiment someone should try some day.) Your proposal > would put a list element and the cell that points to it far apart, > which is bad for the cache. > I might be missing something. However, I don't think it matters if the cells and elements are close to each other. There are different architectures of CPU caches, however I do not remember any modern one which would map, say, the whole 2M of cache to a flat block of memory. Instead, the cache is a number of cells, each of them maps to its small piece of memory. As a result, both current implementation and the one with cells and elements grouped into lines apart would have similar performance while zipping. >> A few words regarding the implementation: >> If you take a look at Java LinkedList and ArrayList, the ArrayList is >> generally 3 times faster. >> > > Yes, but that's not really comparable. > A Java LinkedList is a record containing a stored size (this is one of > the things you are arguing FOR) and a pointer to a DOUBLY linked list. > An Entry has to be at least 4 words and could be 6 depending on the > Java implementation. Oh yes, it's a doubly linked list with a header, > so a completely empty Java LinkedList starts out holding at least as > much space as an Erlang list with 4 elements. Adding a single new > element > at the front > (a) is destructive, unlike Erlang > (b) has to initialise at least four words of memory, > has to change two existing pointers, and > has to increment two counters. > An Erlang cons just has to initialise two words of memory. > > Java's LinkedList is, in short, a textbook example of how *NOT* to do > linked lists, and if ArrayLists are only 3 times faster, that is a > really damning criticism of the implementation quality of ArrayList. > I understand your dislike to Java, but I think you are too biased against it. Java lists _are_ mutable. They _do_ allow you to iterate in both directions. If you can, you can always try to invent a better way to implement a doubly linked mutable list. But I guess its not easy. As for a simple immutable linked list, the Erlang version is great. There is no doubt about it. By the way, in case you are attentive, you probably noticed that I did not mean to say that the Java version of LinkedList is a great thing. What I said is that Java's ArrayList can be an example of a vector-based list, nothing more. And of course, a much better thing can be implemented for a purely functional language. > --- Idea #3: > >> "Typed lists" >> >> Both kinds of list implementations can benefit from knowing what >> type of >> data is going to be stored in them. It would lead to a decrease in the >> consumed space and improved performance. >> >> It is possible to implement a "general" kind of list which can hold >> anything plus some specific implementations for storing 8bit and 16bit >> values. >> > > The NuProlog implementation of Prolog from the University of Melbourne > did this. I've spoken in person with the guy who implemented that, and > he said it was a big headache and if they were doing it all again that's > one hack they would never ever try again. Again a data point: > Interlisp-D > handled strings as packed arrays of bytes (or packed arrays of 16-bit > codes) > and had special microcode support for them. Xerox Quintus Prolog, > running > on the same hardware, in the Interlisp environment, used ordinary Prolog > list cells (just like Erlang ones). Guess which one was faster at > string > manipulation? > Yes, I heard such stories. Are you sure they have implemented that _properly_? I mean, not just like endless runtime checks for type and all such horrid stuff. I mean an implementation were all possible conversions and type checks are eliminated. For some reason, I am sure they did not do that. :-) You might want to look at modern implementations of Common LISP, for instance. They do such kind of job nicely. Also, you can for instance compare Erlang HIPE to SBCL on http://shootout.alioth.debian.org/. The only test case where Erlang wins is a cheap concurrency. Do you think it is a coincidence? Take a look at "reverse-complement" for example. What is so special in SBCL Lisp that it is 50 times faster and consume 12 times less memory? I do not know the answer, but I guess it is because it can do much more when analyzing the bytecode. I do not want to say that SBCL Lisp is superior to Erlang. No way! I just want to bring your attention to the fact, that there are approaches in implementation of VM which can be considered valuable for experimenting with. The bottom line is: I believe there are some ways which can be probed to improve Erlang performance. I do not say that they surely will give you a boost. They are just some things that can be tried. And two more points: - I do not see any easy way to try it except for deviating from the standard and creating a different implementation of VM and some basic libraries. - Perhaps everybody is happy about the speed, so let's just forget about it. Regards, Denys Rtveliashvili From dmercer@REDACTED Mon Aug 6 19:57:45 2007 From: dmercer@REDACTED (David Mercer) Date: Mon, 6 Aug 2007 12:57:45 -0500 Subject: [erlang-questions] VM & BEAM Specs : idea for improving thelists support In-Reply-To: References: <46B46D0D.9010302@mail.ru><46B5AFE5.40706@mail.ru> Message-ID: <005801c7d853$4bced5c0$891ea8c0@SSI.CORP> This has been an interesting thread. Thanks! Question below... On Monday, August 06, 2007 01:41 ok wrote: > > The benefit is again in both performance and memory consumption. > > Imagine that a program has consumes a large text document with > > English, > > Arabic and Russian characters. The current implementation will > > consume 4 > > times more memory than an automatically-typed vector-based version. In > > case the document contains only ASCII characters, the memory > > consumption > > will drop 8 times. > > Only if someone is daft enough to store the whole thing as a simple list > of characters. There are much better ways, in the language and using > the > implementation that we now have. For newbies among us, are you referring to storing it as a binary, or something else? Thanks. Cheers, David From david.hopwood@REDACTED Sun Aug 5 01:36:05 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Sun, 05 Aug 2007 00:36:05 +0100 Subject: [erlang-questions] VM & BEAM Specs In-Reply-To: <18100.47360.572196.225023@antilipe.corelatus.se> References: <46B46D0D.9010302@mail.ru> <18100.47360.572196.225023@antilipe.corelatus.se> Message-ID: <46B50D65.8020409@industrial-designers.co.uk> Matthias Lang wrote: > Lucindo> The ErlangVM and BEAM file specifications are available? > > Denys > I join to this question. > > The BEAM file format is documented. No it isn't. is not even close to being complete documentation. It says very little about how the data in each chunk is encoded, and it doesn't say anything about the BEAM instruction set. -- David Hopwood From sean.hinde@REDACTED Mon Aug 6 20:24:03 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Mon, 6 Aug 2007 19:24:03 +0100 Subject: [erlang-questions] VM & BEAM Specs : idea for improving thelists support In-Reply-To: <005801c7d853$4bced5c0$891ea8c0@SSI.CORP> References: <46B46D0D.9010302@mail.ru><46B5AFE5.40706@mail.ru> <005801c7d853$4bced5c0$891ea8c0@SSI.CORP> Message-ID: <25F72B9A-EC3F-4CE6-936D-1DA0A9901664@gmail.com> It has been interesting, and I also wondered about some of the same things in my early days of using Erlang. Since then, over the last 8 years or so (lost track..) of using Erlang I've never had any reason to be concerned about the amount of memory that strings as lists wastes. If you want to process a very large text file then do it in chunks (and 4 times less memory usage will not save you from a text file that is 1000 times larger than "expected"). If you want to store a lot of text in mnesia then either convert it to a binary first, or rely on the ets optimisation that automatically flattens short "string lists" into byte arrays for storage. Inevitably such things will eventually end up being shipped down a socket or into a file. Both operations can take deep lists of binaries and other Byte sized pieces so the processing overhead is small. In short, it has been a total non-issue in the problem domains I've tackled (quite varied) Sean On 6 Aug 2007, at 18:57, David Mercer wrote: > This has been an interesting thread. Thanks! Question below... > > On Monday, August 06, 2007 01:41 ok wrote: >>> The benefit is again in both performance and memory consumption. >>> Imagine that a program has consumes a large text document with >>> English, >>> Arabic and Russian characters. The current implementation will >>> consume 4 >>> times more memory than an automatically-typed vector-based >>> version. In >>> case the document contains only ASCII characters, the memory >>> consumption >>> will drop 8 times. >> >> Only if someone is daft enough to store the whole thing as a >> simple list >> of characters. There are much better ways, in the language and using >> the >> implementation that we now have. > > For newbies among us, are you referring to storing it as a binary, or > something else? > > Thanks. > > Cheers, > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vances@REDACTED Tue Aug 7 01:14:39 2007 From: vances@REDACTED (Vance Shipley) Date: Mon, 6 Aug 2007 19:14:39 -0400 Subject: [erlang-questions] Erlang/OTP Embedded Systems in Solaris 10 Message-ID: <20070806231439.GD312@little-black-book.motivity.ca> For many years now I have been following the Embedded Systems User's Guide for installing Erlang/OTP on servers which will run applications in a production environment. I have refined the procedures documented there over the years but in general I follow the recommendations with an "otpuser" account with the "otp" group and installing in that user's home directory. I have over the years rewriten the S75otp.system rc script but it still calls the start script provided by OTP. I have added a stop script and made other subtle improvements. The Embedded Systems User's Guide hasn't changed in all that time. This can be seen in this statement: "Several of the procedures described below require expert knowledge of the Solaris 2 operating system." ^^^^^^^^^ Since everything I am doing these days is on Solaris 10 I have reached the point where I want to make some fundamental changes. Solaris 10 has introduced the Service Management Facility (SMF) which replaces init with advanced functionality for managing services as collections of processes with dependencies and making sure they keep running. While SMF has replaced init it does support legacy rc scripts however without the extended functionality. I have started to build the service bundles which are XML files describing the dependencies, start up methods, etc. This could be simple enough but I started to wonder about things like whether I should start epmd from SMF and should I assume the role of the OTP start script and possible run_erl. I'd like to ask for any experiences or suggestions before I go too far. Ultimately I would like to see a new version of the Embedded Systems User's Guide for Solaris. I'll be happy to write it if I have support for it. For a while now I have also been packaging new Erlang/OTP releases into Solaris packages which can be installed with pkgadd(1M) to create running embedded systems. I was planning to document this as well, possibly in a trapexit howto. -Vance From ryan@REDACTED Tue Aug 7 02:01:21 2007 From: ryan@REDACTED (Ryan Tecco) Date: Mon, 6 Aug 2007 17:01:21 -0700 Subject: [erlang-questions] August San Francisco Bay Area ErlLounge Message-ID: Hello all, The San Francisco Bay Area ErlLounge will be held on Wednesday, August 15th at 7:00 at the Thoughtworks office (410 Townsend St.) in downtown San Francisco. Thoughtworks is less than block away from the 4th and King Caltrain station for those who might be coming up from the South Bay. Pizza and beer will be provided as well as wi-fi and whiteboards, so bring your laptop if you are so inclined. RSVP with me off-list so that I can get a rough head count. rt -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim.mccoy@REDACTED Tue Aug 7 02:17:02 2007 From: jim.mccoy@REDACTED (Jim McCoy) Date: Mon, 6 Aug 2007 17:17:02 -0700 Subject: [erlang-questions] binary to bigint? Message-ID: After bouncing through the various bits of doc related to io_lib I can't quite seem to put together a quick function that will convert an arbitrary binary to a big int (e.g. I want the integer for crypto:rand_bytes(40)...) Any hints? jim From lcoquelle@REDACTED Tue Aug 7 02:43:43 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Tue, 7 Aug 2007 08:43:43 +0800 Subject: [erlang-questions] Mnesia and Yaws In-Reply-To: References: Message-ID: Just few idea coming in mind: Are you trying to configure 2 nodes (the erlang shell and the yaws server) to use the same mnesia directory? is this possible? I'm quite newby with mnesia, but my assumption (may be wrong) was that each node should at least have it's own mnesia schema directory. Or maybe a problem with nodes which can not see each other (looks like you haven't named your nodes). Mnesia need communication between nodes, so have to start the nodes with names (-sname). Ludo On 8/6/07, Jim Menard wrote: > I've defined a Mnesia database and can access it from within the erl > command line. However, when I try to access it from my Yaws web app, I > see the error message: > > ERROR erlang code crashed: > File: /Users/jimm/src/jimm/src/erlang/fake/www/do_login.yaws:1 > Reason: {{badmatch,{aborted,{node_not_running,nonode@REDACTED}}}, > ... > > I haven't stopped Mnesia from the command line, and can still access > it. The database directory Mnesia.nonode@REDACTED exists in the root > directory for my Yaws project, and that's where I run the yaws command > from. > > What do I have to do in Yaws to connect to the same database? Have I > missed something in the Yaws or Mnesia documentation? The Yaws docs > about yapps mentions Mnesia---do I have to create a Yaws app to use > Mnesia? > > Thank you for any help or pointers to documentation. > > Jim > -- > Jim Menard, jimm@REDACTED, jim.menard@REDACTED > http://www.io.com/~jimm/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Tue Aug 7 04:43:32 2007 From: ok@REDACTED (ok) Date: Tue, 7 Aug 2007 14:43:32 +1200 Subject: [erlang-questions] VM & BEAM Specs : idea for improving, the lists support In-Reply-To: <46B75D65.3050107@mail.ru> References: <46B75D65.3050107@mail.ru> Message-ID: <6019CCA3-31F2-48E3-BCA7-A373E3E8052E@cs.otago.ac.nz> On 7 Aug 2007, at 5:41 am, Denys Rtveliashvili wrote: > > Well.. Your mileage may vary. The difference of performance depends > on lots of things. So, you can tell the difference only if there > are two finely tuned implementations. in the Xerox Quintus Prolog case, an implementation that *wasn't* finely tuned beat the pants off an implementation that *was* finely tuned by the same people who designed and built the hardware that it ran on. Only the loser needs to be "finely tuned"; it's even more impressive when the winner isn't. >>> "Use unrolled linked lists to improve the performance" > OK, you've got a performance penalty here. NO! That is not what I wrote at all! My point was that unrolled lists ***DO*** improve performance. It's just that they don't improve it *much*. Unrolling lists by a factor of four (typically 6 words for 4 elements = 1.5 words per element, instead of 2 or 3) could be expected to improve space by a factor of 2 in the systems I tried (Clean and Haskell) and we expect the space factor to be an upper bound on the time factor, as indeed it was. > Also it has sense to compare native implementations of dumb linked > list and an unrolled linked list. But that is EXACTLY what I did. The GHC compiler doesn't know anything about built-in lists that it doesn't know (or more precisely, cannot be told) about any other data structure. Ditto Clean. >>> --- Idea #2: >>> >>> "Use resize-able vectors to store lists" >>> >>> I guess this change would give even more benefits comparing to >>> the Idea #1 >>> >> >> My guess is that this would have higher COSTS for existing code. >> > Which costs do you mean? Could you give an example where an vector- > based list would be slower or consume more space than a linked list? Of course I can. Can't you? There are many MANY implementations of the "sequence" abstract data type in the literature. What distinguishes them is the space and time costs of the basic operations. As you must know, inserting an element as the kth element of an n element sequence takes O(k) time and space with singly linked lists but O(n) time and space with a vector. Existing code has been written with knowledge of the costs of the basic operations. If you change those costs, what *was* efficient code may become very *in*efficient. >>> - The _amortized_ computational complexity is O(1) for >>> adding/removing/taking a remainder no matter if it is done from the >>> beginning or from the end of the list. >>> >> We can get that with a pair of singly linked lists right now. >> > Of course, you can emulate almost everything. It's just not too > much convenient. That particular one is very convenient. There is an interesting paper "An Applicative Control-Flow Graph Based on Huet's Zipper" by Norman Ramsey and Jo?o Dias, in the 2005 ACM SIGPLAN Workshop on ML. They moved from an imperative-style implementation of control flow graphs to one which worked in a way strongly reminiscent of the back-to-back lists. (It's known as "Huet's zipper" in the literature, although David H. D. Warren was using it in 1979.) This approach turned out to be smaller, easier to work with, and best of all, faster than the imperative approach. >>> - It takes O(1) time to find out the size of the list. >>> >> It is amazing just how seldom this is interesting. >> > Sure it is. But if you can get it for free, then why not? But you CAN'T get the list size for free. You just can't. You are right that _at the point of use_ some sequence implementations let you just fetch the size. But you paid, heavily, for it to get there. I've implemented sequences about a dozen different ways, and keeping the size has two kinds of costs: - direct: it takes TIME to update the size whenever you update a list. it takes SPACE to hold the size. So if I do X0 = [], X1 = [e|X0], % space needed for 1, time to compute it X2 = [d|X1], % space needed for 2, time to compute it X3 = [c|X2], % space needed for 3, time to compute it X4 = [b|X3], % space needed for 4, time to compute it X5 = [a|X4] % space needed for 5, time to compute it We need a minimum of 3 words per cell instead of 2 (and if you don't share tails, you will need even more), and we not only have to fill in the new count, we have to fetch the old one and increment it. So we can confidently expect that the cost is at least 1.5 times the existing cost. - indirect: it limits the kinds of implementation you are prepared to countenance. By the way, if you don't allow lists to be built as shown above, then what you are implementing is not Erlang lists. This has an even more interesting consequence: not all Erlang "lists" *have* a length. We can make a data structure like Rect = [[A|B]|[C|D]] where A, B, C, D are all numbers. Rect doesn't have a length. So what do you store for its size? > I might be missing something. Paging. There is a program I've written that wants to use about 400 GiB of memory. (It's in C, not Erlang, and I think I've figured out a way to get that down to 200 MiB, but haven't had time to try it yet.) > However, I don't think it matters if the cells and elements are > close to each other. That's tantamount to saying "caching doesn't matter", because "close" means "sometimes in the same L2 cache line". >>> A few words regarding the implementation: >>> If you take a look at Java LinkedList and ArrayList, the >>> ArrayList is >>> generally 3 times faster. >>> >> >> Yes, but that's not really comparable. >> A Java LinkedList is a record containing a stored size (this is >> one of >> the things you are arguing FOR) and a pointer to a DOUBLY linked >> list. >> An Entry has to be at least 4 words and could be 6 depending on >> the >> Java implementation. Oh yes, it's a doubly linked list with a >> header, >> so a completely empty Java LinkedList starts out holding at least as >> much space as an Erlang list with 4 elements. Adding a single new >> element >> at the front >> (a) is destructive, unlike Erlang >> (b) has to initialise at least four words of memory, >> has to change two existing pointers, and >> has to increment two counters. >> An Erlang cons just has to initialise two words of memory. >> >> Java's LinkedList is, in short, a textbook example of how *NOT* to do >> linked lists, and if ArrayLists are only 3 times faster, that is a >> really damning criticism of the implementation quality of ArrayList. >> > I understand your dislike to Java, but I think you are too biased > against it. You h ave completely mistaken my point. I am not attacking ***JAVA***, I am attacking ***LinkedList***. Here's another example: in our Information Retrieval paper students have to write a small IR Engine. Every year we say "do in in C" and every year some students insist on doing it in Java. And whenever they do, the performance is really dreadful. Like 150 times slower than the model answer. Why? Because the basic random I/O class does no buffering. Staying in Java, it is possible to speed these student programs up by about a factor of 15. (They are still slower than AWK, but you can't have everything.) To say that that one *class* is horrible is not to attack the whole language. > Java lists _are_ mutable. And Erlang's aren't. Which is why your comparison of LinkedList with Erlang's lists is invalid. Erlang's lists just don't pay that price. > They _do_ allow you to iterate in both directions. And Erlang's don't. Which is why your comparison of LinkedList with Erlang's lists is invalid. Erlang's lists just don't pay that price. > If you can, you can always try to invent a better way to implement > a doubly linked mutable list. Actually, it isn't in the least difficult to implement doubly linked lists better than Java's LinkedList class does, as in "require less memory" and "take less time". But that's not the point. YOU made the argument that because ArrayList is faster than LinkedList in Java, it should be easy to beat Erlang's lists. But LinkedList is slow because (a) it's in Java (b) it is not that well written (c) it is a doubly linked list with a header and stored size. For what it's worth, I just ran three benchmarks on a 500 MHz machine. Erlang: R11B-4. Java: Sun JDK 1.5.0_08, with Sun's HotSpot JIT, running on an UltraSPARC II (a machine designed and built by the same company that made the JDK (:-)). The benchmark was a trivial one: make a list of 2000 elements, add up all its elements, 10 000 times. Java LinkedList: 5.26 seconds of CPU Java ArrayList: 7.74 seconds of CPU Erlang: 3.56 seconds Erlang? Better than twice as fast as ArrayList? Yes. Of course different benchmarks will show different things. But it has to be of *some* interest. > But I guess its not easy. > As for a simple immutable linked list, the Erlang version is great. > There is no doubt about it. > > By the way, in case you are attentive, you probably noticed that I > did not mean to say that the Java version of LinkedList is a great > thing. What I said is that Java's ArrayList can be an example of a > vector-based list, nothing more. Not quite. What you said, paraphrased, was "Java's ArrayList is three times faster than Java's LinkedList, so we can expect vector-based lists to be an improvement for Erlang." > And of course, a much better thing can be implemented for a purely > functional language. Why "of course"? Better in what ways? There certainly are many other implementations of the sequence abstract data type which are good at things (like snoc or append) that Erlang lists are not great at. It would be nice to have some of them, and indeed, some are available as contributed libraries. It would be even nicer to have one or two "native". But while *adding* such a thing would be good, we have as yet no reason to believe that *replacing* the built in list implementation with something else would be an improvement. > Yes, I heard such stories. Are you sure they have implemented that > _properly_? I mean, not just like endless runtime checks for type > and all such horrid stuff. I mean an implementation were all > possible conversions and type checks are eliminated. For some > reason, I am sure they did not do that. :-) Possibly because Prolog, like Erlang, is not a statically typed language? I have to go and pick my elder daughter up from school. > > You might want to look at modern implementations of Common LISP, Look at? I *have* some, and use them. However, I never take advantage of the ability to turn off runtime checks... > I believe there are some ways which can be probed to improve Erlang > performance. Everyone knows that much. > I do not say that they surely will give you a boost. They are just > some things that can be tried. The point is that this *specific* one is unlikely to do anything to speed up *EXISTING* Erlang code which was written for the cost profile Erlang lists currently have. > And two more points: > - I do not see any easy way to try it except for deviating from the > standard and creating a different implementation of VM and some > basic libraries. Trying small scale experiments would be a darned good start. > - Perhaps everybody is happy about the speed, so let's just forget > about it. Everyone would say "thank you" for something that made existing code faster. My point is that intuitions about what makes for a fast list, based on other languages, can be an extremely unreliable guide. From rtvd@REDACTED Tue Aug 7 06:36:15 2007 From: rtvd@REDACTED (Denys Rtveliashvili) Date: Tue, 07 Aug 2007 08:36:15 +0400 Subject: [erlang-questions] VM & BEAM Specs Message-ID: <46B7F6BF.50705@mail.ru> Hi again, It looks like my posting has raised a too emotional discussion. I'm sorry for that, as it is not what I intended. And I am not a person who likes arguing. I still believe that a different implementation of lists can improve speed of Erlang. Just like an ability to call arbitrary C functions cheaply (so that there is no need to pass boxed values) and probably other things. But I see no way to do a small step towards it. So I prefer to wait until a more suitable for for experimenting with implementation of Erlang appears. However, as David points out, the BEAM file format is not really documented. And I guess VM is neither documented too. So I don't think somebody will rush into implementation of a different Erlang flavor. That's all. %( With kind regards, Denys Rtveliashvili From pwa@REDACTED Tue Aug 7 09:16:13 2007 From: pwa@REDACTED (Peter Wang) Date: Tue, 7 Aug 2007 17:16:13 +1000 Subject: [erlang-questions] Static binary data Message-ID: <20070807071612.GC4560@missioncriticalit.com> Hello, How does HiPE treat static binaries? I tried a microbenchmark which simply evaluates a function that returns a static data structure (in a loop) and it runs much faster if the strings in the structure are represented as lists of integers, rather than binaries. I'm trying the use binaries to represent strings in the Mercury to Erlang compiler, and I think this is having a negative performance impact, as we generate a lot of static data functions which may be evaluated many times. Peter From erlang@REDACTED Tue Aug 7 09:28:50 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 7 Aug 2007 09:28:50 +0200 Subject: [erlang-questions] The Book, lib_chan and IRC Lite In-Reply-To: <46B469E4.60707@gmail.com> References: <46B469E4.60707@gmail.com> Message-ID: <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> This is very strange - Possible some software rot has set it, or the distributed code is corrupt - we'll have to try and get to the bottom of this. Just to test, I downloaded *everything* from the prag site and tested things. here's what I did. Download the code from the link on http://www.pragmaticprogrammer.com/titles/jaerlang/code.html unpacked the archive. Then: cd code > make ... lots of output $ cd socket_dist $ make mkdir -p /home/ejoearm/.erlang_config/ cp conf /home/ejoearm/.erlang_config/lib_chan.conf make clean - clean up To run the chat test program 1) start two xterms 2) in xterm one type -- make chat_server 3) in xterm two type -- make chat_client Note: remember to type make in the directory above this before running make in this directory To run the lib_chan test program 1) start two xterms 2) in xterm one type -- make server 3) in xterm two type -- make client You should get something like this - "ejoarm" is the value of my $HOME environment variable. Then I just obey the instructions. start two xterms and do make chat_server in one and make chat_client in the other. This worked for me just as in the book. >From your mail I cannot see what you did. Can you repeat what I've just done starting with a clean copy of the code, and see if it works. If it does not work I'll need to see *all* the output to figure out what is going wrong. With a little poking around we should be able to find out what's going wrong. Cheers /Joe Armstrong On 8/4/07, Dmitrii 'Mamut' Dimandt wrote: > > I'm stupid and I am not afraid to admit it :) > > I'm currently battling the IRC Lite from chapter 11 of "Programming > Erlang". Whatever I do (copy paste, run make in the code directory obtained > from the biik's site etc.) I get the following error when I run the example: > > lib_chan_mm: protocol error:{login,"general","joe"} > Does anyone else run into the same problem? Of course, I am going to dig > deeper into the code and try and locate the error myself. But I was > surprised to be bitten by this :( > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Tue Aug 7 10:04:26 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 07 Aug 2007 11:04:26 +0300 Subject: [erlang-questions] The Book, lib_chan and IRC Lite In-Reply-To: <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> References: <46B469E4.60707@gmail.com> <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> Message-ID: <46B8278A.3070002@gmail.com> Joe Armstrong wrote: > >From your mail I cannot see what you did. > > Can you repeat what I've just done starting with a clean copy of the code, > and see if it works. > > This is *really* odd :) I downloaded the code and went through all the steps again and it worked :) I guess I might have downloaded some intermediate code from the site or something went wrong with my code, but now it works :) Even though it didn't work before. Actually the same problem bit at least one other person on the list, avindev at gmail dot com, he sent me a patch for my code. I guess he must've downloaded the same version of the code as I did. However, everything works ok now, so I guess i learned my lesson: download the latest code before trying anything out :) From nick.linker@REDACTED Tue Aug 7 10:29:14 2007 From: nick.linker@REDACTED (Nick) Date: Tue, 07 Aug 2007 15:29:14 +0700 Subject: [erlang-questions] "How to build reliable system" literature Message-ID: <46B82D5A.60009@rambler.ru> Hello, all! We are building distributed system (using Java, sorry :-)) and the system is expected to have the following properties: 1. It consists of several (>=5) quite distributed servers (500-1500 km), each of them is mirror of another (in the future probably servers will become small clusters). 2. It expected to have throughput at least 4000-5000 messages/sec (messages are short in general, like new coordinates of something, power on/off etc). 3. It expected to be as reliable as possible, this includes guarantee delivering, handling failover without losing active sessions, add/remove server on the fly and so on. "Guarantee delivering" buzzword in our case is message protocol of sending messages with acknowledgement and this is not very happy solution - problems arise with growing queues of pending messages/acknowledgements and performance. Yes, the throughput is not terribly huge, but still considerable. Mirroring also cause a number of problems with merging replicas (though on this theme I've found "Optimistic replication" paper by Y.Saito and M.Shapiro). So, I wonder how does "The Ideal System" of such type looks like, if we assume that communication between servers is not reliable. Hence, my question (I suspect Erlang developers are familiar with the problems above) is to find good books and papers on the themes: 1. Finding optimal protocol to provide best reliability with given performance bound. 2. Maybe there exists better literature on replication. 3. Performance bottlenecks, architectural problems and other difficulties in distributed systems. 4. Personal experience of others who have built such systems. 5. Anything you consider has close relation with the task. Thanks everyone in advance, Nick --- %1% Yes, I've read the "Four-fold Increase in Productivity and Quality" %2% Yes, I've read the Joe's thesis, but want more :-) From saleyn@REDACTED Tue Aug 7 14:05:43 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Tue, 07 Aug 2007 07:05:43 -0500 Subject: [erlang-questions] Erlang/OTP Embedded Systems in Solaris 10 In-Reply-To: <20070806231439.GD312@little-black-book.motivity.ca> References: <20070806231439.GD312@little-black-book.motivity.ca> Message-ID: <46B86017.2030200@gmail.com> I also think it would be quite helpful for the Erlang development community to have such tutorials for both Solaris and Linux. We also always followed embedded systems installation approach for deploying Erlang/OTP projects. In terms of installation, in our case it turned out to be more convenient to have subdirectories under the home directory of the user account (such as "otpuser") for different embedded systems. We would normally create different user accounts for production/qa/dev environments (otpuser, otpuserqa, otpuserdev) that would have installation configured for a corresponding environment (actually all configuration files would be pulled and cached from some centralized place over HTTP using inets, so that local installation would only need to explicitly specify the environment type, and system/release/host/node would be auto-inferred). Here's a typical layout for a project consisting of two embedded systems ("SystemA" and "SystemB"): otpuser | +-- SystemA | +-- bin - For user binaries and scripts | +-- lib - Erlang apps | | +-- app1-X.Y | | +-- app2-X.Y | +-- erts-X.Y.Z - Run-time system | +-- releases | | +-- 1.0 - Release specific config/boot stuff | +-- var/log - Log files | +-- var/mnesia - Mnesia files | +-- tmp - Volatile data | +-- sbin - SysV startup and other scripts +-- SystemB | +-- bin | +-- lib | | +-- app1-X.Y | | +-- app2-X.Y | +-- erts-X.Y.Z | +-- releases | | +-- 1.0 | +-- var/log | +-- var/mnesia | +-- tmp | +-- sbin +-- SystemC ... with this approach it is possible to run different projects independently using the same operational guidelines. Also upgrading becomes easier as the systems are completely independent. Serge Vance Shipley wrote: > For many years now I have been following the Embedded Systems > User's Guide for installing Erlang/OTP on servers which will > run applications in a production environment. I have refined > the procedures documented there over the years but in general > I follow the recommendations with an "otpuser" account with > the "otp" group and installing in that user's home directory. > > I have over the years rewriten the S75otp.system rc script > but it still calls the start script provided by OTP. I have > added a stop script and made other subtle improvements. > > The Embedded Systems User's Guide hasn't changed in all that > time. This can be seen in this statement: > > "Several of the procedures described below require expert > knowledge of the Solaris 2 operating system." > ^^^^^^^^^ > > Since everything I am doing these days is on Solaris 10 I have > reached the point where I want to make some fundamental changes. > Solaris 10 has introduced the Service Management Facility (SMF) > which replaces init with advanced functionality for managing > services as collections of processes with dependencies and > making sure they keep running. While SMF has replaced init it > does support legacy rc scripts however without the extended > functionality. > > I have started to build the service bundles which are XML files > describing the dependencies, start up methods, etc. This > could be simple enough but I started to wonder about things > like whether I should start epmd from SMF and should I assume > the role of the OTP start script and possible run_erl. > > I'd like to ask for any experiences or suggestions before I > go too far. Ultimately I would like to see a new version of > the Embedded Systems User's Guide for Solaris. I'll be happy > to write it if I have support for it. > > For a while now I have also been packaging new Erlang/OTP releases > into Solaris packages which can be installed with pkgadd(1M) to > create running embedded systems. I was planning to document > this as well, possibly in a trapexit howto. > > -Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Tue Aug 7 13:32:16 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 7 Aug 2007 12:32:16 +0100 Subject: [erlang-questions] Design of the Erlang VM Message-ID: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> Would someone kindly point me to existing resources on the design of the Erlang VM? I would like to know if it's a stack-based VM, for example (think Forth) without digging through lots of code. Thanks, Joel -- http://wagerlabs.com From chandrashekhar.mullaparthi@REDACTED Tue Aug 7 13:54:48 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Tue, 7 Aug 2007 12:54:48 +0100 Subject: [erlang-questions] Erlang/OTP Embedded Systems in Solaris 10 In-Reply-To: <20070806231439.GD312@little-black-book.motivity.ca> References: <20070806231439.GD312@little-black-book.motivity.ca> Message-ID: Hi Vance, On 07/08/07, Vance Shipley wrote: > Since everything I am doing these days is on Solaris 10 I have > reached the point where I want to make some fundamental changes. > Solaris 10 has introduced the Service Management Facility (SMF) > which replaces init with advanced functionality for managing > services as collections of processes with dependencies and > making sure they keep running. While SMF has replaced init it > does support legacy rc scripts however without the extended > functionality. > > I have started to build the service bundles which are XML files > describing the dependencies, start up methods, etc. This > could be simple enough but I started to wonder about things > like whether I should start epmd from SMF and should I assume > the role of the OTP start script and possible run_erl. > > I'd like to ask for any experiences or suggestions before I > go too far. Ultimately I would like to see a new version of > the Embedded Systems User's Guide for Solaris. I'll be happy > to write it if I have support for it. > We have used SMF with erlang. While we succeeded in using SMF to start/stop erlang at startup/shutdown of the message, we found out that we still required heart. One problem with using SMF to start erlang nodes is that epmd is placed under the same process group. So when an erlang node dies, because epmd is still alive SMF thinks that this "service" is still alive. One solution to this is to start epmd separately before any of your erlang nodes as a separate SMF service. A similar problem exists if one of your port programs (or even something launched using os:cmd/1) doesn't quit when the erlang node dies. SMF will not recognise node termination. One good thing about SMF though is that you can specify dependencies among erlang nodes on the same box, OTP style. It is definitely an improvement over rc scripts. cheers Chandru From chlorophil@REDACTED Tue Aug 7 14:06:42 2007 From: chlorophil@REDACTED (Philip Robinson) Date: Tue, 7 Aug 2007 22:06:42 +1000 Subject: [erlang-questions] binary to bigint? In-Reply-To: References: Message-ID: One possibility... -module(test). -export([foldl_bin/4]). foldl_bin(_Fun, Acc, <<>>, _BytesElem) -> Acc; foldl_bin(Fun, Acc, Bin, BytesElem) -> {Elem,Rest} = split_binary(Bin, BytesElem), foldl_bin(Fun, Fun(Elem, Acc), Rest, BytesElem). 1> c(test), test:foldl_bin(fun(<>, Acc) -> Acc * 256 + I end, 0, crypto:rand_bytes(40), 1). This makes a few assumptions regarding the integer interpretation of that 40-byte binary. Cheers, Philip On 8/7/07, Jim McCoy wrote: > After bouncing through the various bits of doc related to io_lib I > can't quite seem to put together a quick function that will convert an > arbitrary binary to a big int (e.g. I want the integer for > crypto:rand_bytes(40)...) > > Any hints? > > jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bjorn@REDACTED Tue Aug 7 14:12:34 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 07 Aug 2007 14:12:34 +0200 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> Message-ID: Joel Reymont writes: > I would like to know if it's a stack-based VM, for example (think > Forth) without digging through lots of code. It is not stack-based; it is register-based. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From lemenkov@REDACTED Tue Aug 7 14:27:50 2007 From: lemenkov@REDACTED (Peter Lemenkov) Date: Tue, 7 Aug 2007 16:27:50 +0400 Subject: [erlang-questions] How to gain acces to shared memory (shm_open, mmap)? Message-ID: Hello All! I've got a couple of utilities which written in C and communicates with each other using shared memory. >From my erlang application I need to access to that area. So how can I do this? -- With best regards! From kenneth.lundin@REDACTED Tue Aug 7 14:53:10 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 7 Aug 2007 14:53:10 +0200 Subject: [erlang-questions] How to gain acces to shared memory (shm_open, mmap)? In-Reply-To: References: Message-ID: You have to write either a linked in driver in C or a separate port program (which gives access to the necessary shared memory primitives). You can then use the driver or the port program from your Erlang code. Or if you are lucky you find a driver that someone else aleady have written. /Regards Kenneth (Erlang/OTP team at Ericsson) On 8/7/07, Peter Lemenkov wrote: > Hello All! > I've got a couple of utilities which written in C and communicates > with each other using shared memory. > > >From my erlang application I need to access to that area. So how can I do this? > -- > With best regards! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Tue Aug 7 13:57:37 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 7 Aug 2007 13:57:37 +0200 Subject: [erlang-questions] The Book, lib_chan and IRC Lite In-Reply-To: <46B8278A.3070002@gmail.com> References: <46B469E4.60707@gmail.com> <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> <46B8278A.3070002@gmail.com> Message-ID: <9b08084c0708070457o6a466cd7mcfed209003eb8f2c@mail.gmail.com> Strange, there is a report of an error (and a patch) on the book's errata page but I have not been able to reproduce the error. I don't think there ever was a broken version on the prag site - you might having forgotten to do a make or have some weird paths setup. The command "code:clash()" will report any irregularities in your code loading paths. Otherwise I have no idea what went wrong. It's possible there is some weird error but in that case I don't know how to reproduce it - I think the program is correct. Cheers /Joe On 8/7/07, Dmitrii 'Mamut' Dimandt wrote: > Joe Armstrong wrote: > > >From your mail I cannot see what you did. > > > > Can you repeat what I've just done starting with a clean copy of the code, > > and see if it works. > > > > > This is *really* odd :) > I downloaded the code and went through all the steps again and it worked :) > I guess I might have downloaded some intermediate code from the site or > something went wrong with my code, but now it works :) Even though it > didn't work before. > > Actually the same problem bit at least one other person on the list, > avindev at gmail dot com, he sent me a patch for my code. I guess he > must've downloaded the same version of the code as I did. > > However, everything works ok now, so I guess i learned my lesson: > download the latest code before trying anything out :) > > > From dmitriid@REDACTED Tue Aug 7 15:35:12 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 07 Aug 2007 16:35:12 +0300 Subject: [erlang-questions] The Book, lib_chan and IRC Lite In-Reply-To: <9b08084c0708070457o6a466cd7mcfed209003eb8f2c@mail.gmail.com> References: <46B469E4.60707@gmail.com> <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> <46B8278A.3070002@gmail.com> <9b08084c0708070457o6a466cd7mcfed209003eb8f2c@mail.gmail.com> Message-ID: <46B87510.3040102@gmail.com> Joe Armstrong wrote: > Strange, there is a report of an error (and a patch) on the book's errata page > but I have not been able to reproduce the error. > > I don't think there ever was a broken version on the prag site - you > might having forgotten > to do a make or have some weird paths setup. The command > "code:clash()" will report > any irregularities in your code loading paths. > > funny thing is that I've started getting the same "protocol error" from lib_chan_mm right after I wrote that everything worked ok :) I haven't had time to investigate the problem, though... I'll write as son as I can lay my habds on the code... From bob@REDACTED Tue Aug 7 15:47:03 2007 From: bob@REDACTED (Bob Ippolito) Date: Tue, 7 Aug 2007 06:47:03 -0700 Subject: [erlang-questions] binary to bigint? In-Reply-To: References: Message-ID: <6a36e7290708070647h7b2b4f70w3f768032cdbf0d72@mail.gmail.com> 1> Bin2Int = fun (Bin) -> L = 8 * size(Bin), <> = Bin, Int end. #Fun 2> crypto:start(). ok 3> Bin2Int(crypto:rand_bytes(40)). 627266637011650447231137234977838010396277839317351827811606595385624201947967310123742917146068 -bob On 8/6/07, Jim McCoy wrote: > After bouncing through the various bits of doc related to io_lib I > can't quite seem to put together a quick function that will convert an > arbitrary binary to a big int (e.g. I want the integer for > crypto:rand_bytes(40)...) > > Any hints? > > jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jim.menard@REDACTED Tue Aug 7 16:04:39 2007 From: jim.menard@REDACTED (Jim Menard) Date: Tue, 7 Aug 2007 10:04:39 -0400 Subject: [erlang-questions] Mnesia and Yaws In-Reply-To: References: Message-ID: On 8/6/07, I wrote: [snip] > What do I have to do in Yaws to connect to the same database? Have I > missed something in the Yaws or Mnesia documentation? The Yaws docs > about yapps mentions Mnesia---do I have to create a Yaws app to use > Mnesia? Here's what I've learned: You don't need yapp to access mnesia but yaws needs to know about mnesia. You turn this on by using '--mnesiadir full-path-to-mnesia-directory' (but that only works when yaws is running as a daemon). Or, you have to connect to the yaws (erl)runtime and create a schema/ start mnesia. PS! If you started yaws with -sname and cookie you can connect to it like any other erlang runtime :) Finally, the simplest way to do this is to run yaws from the command line and start mnesia from within the yaws session. Thanks to Primanathan Reddy, t ty, Andy Gross, Chandru, and Ludovic Coquelle for their help. Jim -- Jim Menard, jimm@REDACTED, jim.menard@REDACTED http://www.io.com/~jimm/ From goryachev@REDACTED Tue Aug 7 17:10:29 2007 From: goryachev@REDACTED (Igor Goryachev) Date: Tue, 07 Aug 2007 19:10:29 +0400 Subject: [erlang-questions] Erlang on VPS In-Reply-To: (Ludovic Coquelle's message of "Thu\, 2 Aug 2007 22\:29\:35 +0800") References: Message-ID: <87ejifjs7u.fsf@yandex-team.ru> "Ludovic Coquelle" writes: > I'm interested in a cheap VPS hosting, to try out some of the great Erlang > applications in the real world (I mean internet :) ). Those 2 hosting > providers have been listed by Erlang users: > http://www.jaguarpc.com > http://tektonic.net > Again, same question: any comment, any other good experience with those or > other providers? Erlang works nice inside http://tektonic.net/ VPS. At list ejabberd, which is running there with epoll support. -- Igor Goryachev Yandex development team. From jakob@REDACTED Tue Aug 7 17:31:45 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Tue, 07 Aug 2007 17:31:45 +0200 Subject: [erlang-questions] binary to bigint? In-Reply-To: References: Message-ID: <46B89061.4010801@erix.ericsson.se> In crypto you also have rand_uniform/2 which accepts large integers, and mpint/1 that converts from binary form. /Jakob Jim McCoy wrote: > After bouncing through the various bits of doc related to io_lib I > can't quite seem to put together a quick function that will convert an > arbitrary binary to a big int (e.g. I want the integer for > crypto:rand_bytes(40)...) > > Any hints? > > jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From alceste@REDACTED Tue Aug 7 17:22:41 2007 From: alceste@REDACTED (Alceste Scalas) Date: Tue, 07 Aug 2007 17:22:41 +0200 Subject: [erlang-questions] RFC: Erlang FFI Message-ID: <1186500161.7109.21.camel@gnatziu.crs4.it> Hello, following the rules of the EEP workflow [1], I'd like to know your opinions about extending Erlang with a Foreign Function Interface (FFI). I've got an implementation based on GCC's FFI library [2], that is mostly complete [3] and tested on GNU/Linux on AMD64. The first part of the following description refers to this implementation, while the rest of the email contains ideas for possible enhancements. Depending on your feedback, I'll provide the patch for my current Erlang FFI implementation, extend it and/or write a proper Erlang Enhacement Proposal. A few notes about the GCC FFI library: it is released under a very permissive license, it supports a whole lot of architectures, and it is available as a separate package (for Debian/Ubuntu users: apt-get install libffi4 libffi4-dev ). If there's any Pythonista out there: it's the library on which Python ctype module is built. Regards, alceste - - - - 1. The basic API ================ The Erlang FFI would consist in (at least) one BIF: ffi:call(Handler, Call::call_tuple(), Types::types_tuple()) -> return_type() call_tuple() -> {Fn, Arg1, ...} types_typle() -> {RetType, TypeArg1, ...} "Handler" is an handler for the dynamic library containing the function to be called (in the current implementation, it is a port obtained by loading an Erlang linked-in driver). "Fn" is an atom or an io_list with the function name. RetType, TypeArg1 etc. are atoms representing the C type of the function and its arguments. The return_type() of ffi:call/3 is thus determined by RetType. A simple example: Hello = list_to_binary(["Hello, world!", 0]), RetVal = ffi:call(Handler, {puts, Hello}, {sint, pointer}). It causes the C function puts() to output the null-terminated string contained in the "Hello" binary. Its C return value (a signed integer) is converted into an Erlang integer (small or big depending on its value). The supported C types are represented with the following atoms: uint uint8 float sint sint8 double ushort uint16 longdouble sshort sint16 pointer ulong uint32 void slong sint32 uchar uint64 schar sint64 The Erlang terms passed as ffi:call/3 arguments are converted to the proper C types. Binaries are passed as pointers. If the call returns a pointer, it is converted into an Erlang integer (small or big). 2. Enhancement: the library handler =================================== In the current implementation, ffi:call/3 expects "Handler" to be a (possibly registered) port. It is not optimal, expecially because in order to call functions from the "foo" library it is necessary to create a C file with a void ErlDrvEntry structure, compile and link it against libfoo itself, and finally load it inside the Erlang VM (by using ddll:load_driver/2 and friends). A cleaner interface for loading an arbitrary DLL would be handy, e.g. something like: Handler = ddll:load_library(Path, Name, OptionList). Where "Handler" would be an opaque reference to the proper entry in the VM's internal list of loaded drivers. Maybe it could be just a port, that ddll:load_library/3 could automatically associate with a void ErlDrvEntry structure: it would be very easy to implement, and quite consistent with the rest of the Erlang port machinery. 3. Enhancement: FFI call optimizations ====================================== The OptionList parameter of ddll:load_library/3 could be used for a very effective optimization: preloading some symbols and precompiling their FFI call structure. One example: Handler = ddll:load_library("/lib", c, {preload, [{puts, {sint, pointer}}, {putchar, {sint, sint}}, {malloc, {pointer, uint}}, {free, {void, pointer}}]}). This preloading mechanism would be used by another BIF, ffi:call/2: MemPtr = ffi:call(Handler, {3, 1024}) ffi:call(Handler, {4, MemPtr}) Where "3" and "4" are the positions of the functions in the "preload" list. This call would be definitely faster than the one performed by ffi:call/3. 4. Enhancement: BIF-like external functions =========================================== The FFI support opens the possibility to pass Erlang terms directly to the C world. For example, with a ffi:ecall/3 BIF like: ffi:ecall(Handler, do_something, {Arg1, ...}) The terms given as arguments may be passed directly to the C side, eventually along with the current Process* (thus making external functions something like add-on BIFs). Of course, in order to make it work, it would be necessary to compile the C source against a matching version of the OTP header files. Since it's extremely powerful and gives developers enough rope to shoot themselves in their foots, the ffi:ecall/3 BIF could be a not-so-visible-and-documented resource (i.e. something like the powerful HiPE BIFs). Notes and references ==================== [1] http://www.erlang.org/eeps/eep-0001.html [2] http://gcc.gnu.org/viewcvs/trunk/libffi/ [3] The only thing left to be done is converting C signed int and signed long variables to/from Erlang signed big integers. -- Alceste Scalas CRS4 - http://www.crs4.it/ From dking@REDACTED Tue Aug 7 20:16:18 2007 From: dking@REDACTED (David King) Date: Tue, 7 Aug 2007 11:16:18 -0700 Subject: [erlang-questions] Mnesia is overloaded Message-ID: I have an application that uses mnesia (through erlydb) that, at the moment, gets very little traffic, except occasionally it has a few tens of thousand records inserted all at once (well, two or three at a time, but several thousand in a row). When this happens, I get the following: =ERROR REPORT==== 7-Aug-2007::10:48:50 === Mnesia('hostname'): ** WARNING ** Mnesia is overloaded: {dump_log, write_threshold} The data makes it into the database just fine, but I get that message quite a few times. According to , that message "is generated when a log dump has been triggered before the previous one completed". Is there any way that I can temporary lengthen the amount of time between log dumps? Or is it possible to make the database- saves synchronous, to keep from overloading mnesia? From fritchie@REDACTED Wed Aug 8 04:01:13 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 07 Aug 2007 21:01:13 -0500 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: Message of "Sun, 05 Aug 2007 15:05:45 +0200." Message-ID: <200708080201.l7821DGR073307@snookles.snookles.com> >>>>> "p" == Patrick writes: p> Sal, I recommend that you use MySQL because of the cluster capacity p> that MySQL team is developing. ... until you need to expand the size of the back-end cluster because you've run out of capacity. Then you're stuck, because you can't expand that cluster. Or wait until MySQL developers add the ability to resize the cluster. Whenever that is. {shrug} Mnesia can add and remove storage nodes on-the-fly without difficulty.(*) I've done it with clusters up to 22 nodes. Over in land of PostgreSQL, the folks at Greenplum have a very interesting, shared-nothing product that can be expanded on-the-fly. -Scott (*) There is one *extremely* irritating performance bug that can hit you if your tables are extremely large. Using fragmentation to split an extremely large table into lots of smaller tables makes it possible to avoid. For large databases, you're likely using fragmentation for other reasons anyway.... From saleyn@REDACTED Wed Aug 8 05:37:18 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Tue, 07 Aug 2007 22:37:18 -0500 Subject: [erlang-questions] lock-free hash table In-Reply-To: <46B660B9.3090802@gmail.com> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> <46B660B9.3090802@gmail.com> Message-ID: <46B93A6E.10305@gmail.com> Another useful application of SMP-safe lock-free FIFO queues could be inside the emulator. Correct me if I am wrong but in the emulator with SMP support different schedulers use mutex synchronization in order to get the next process descriptor off of a shared linked list of all processes waiting to be dispatched. Also when copying a message sent by some Erlang process to a mailbox of another Erlang process the emulator with SMP support uses POSIX locking to ensure thread safety (if I remember it correctly). In both of these cases using lock-free FIFO queues can provide a much better scalability when used on multi-core CPUs compared to traditional mutex-based locking primitives. Serge Serge Aleynikov wrote: > There have been quite a number of publications on the subject of > lock-free data structures since around mid 90's, most notably by Maged > Michael (IBM) and Philippas Tsigas / Yi Zhang (Chambers University). > Here are some selected links: > > http://erdani.org/publications/cuj-2004-12.pdf > http://citeseer.ist.psu.edu/sundell04scalable.html > http://www.noble-library.com/ > http://research.sun.com/techrep/2002/abstract-110.html > > The lock-free algorithms indeed perform exceptionally well in shared > memory concurrent systems with a large number of CPUs since they don't > require OS synchronization primitives (relying on a single instruction > such as compare-and-swap). I also think that taking advantage of these > algorithms in Erlang's emulator would make it even more scalable on > large number of cores, especially if interfaces to ports (via shared > memory) and drivers (via lock-free FIFO circular queues) would offer > lock-free synchronization with emulator threads. > > Serge > > Ulf Wiger wrote: >> I just caught Dr. Cliff Click's Google TechTalk on his >> lock-free hash table. >> >> http://video.google.com/videoplay?docid=2139967204534450862 >> >> The (Java) source is also available >> at sourceforge: http://sourceforge.net/projects/high-scale-lib >> >> According to his talk, the algorithm "scales well up to 768 cpus". >> >> I don't know if there is anything in this that would not fit Erlang >> well, but perhaps it's something to look into? >> >> Anyway, it's always interesting to listen to these performance geeks. ;-) >> >> BR, >> Ulf W >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm@REDACTED Wed Aug 8 05:10:16 2007 From: jeffm@REDACTED (jm) Date: Wed, 08 Aug 2007 13:10:16 +1000 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: <200708080201.l7821DGR073307@snookles.snookles.com> References: <200708080201.l7821DGR073307@snookles.snookles.com> Message-ID: <46B93418.2030008@ghostgun.com> Scott Lystig Fritchie wrote: >>>>>> "p" == Patrick writes: > > p> Sal, I recommend that you use MySQL because of the cluster capacity > p> that MySQL team is developing. > > ... until you need to expand the size of the back-end cluster because > you've run out of capacity. Then you're stuck, because you can't > expand that cluster. > > Or wait until MySQL developers add the ability to resize the cluster. > Whenever that is. {shrug} Or mirgate to Mnesia. Is there any howtos and/or tools to migrate back and forth between sql databases and Mnesia? I'm currently playing around with erlyweb using mysql as a backend. Having just entered 144 rows of data manually yesterday I wouldn't want to repeat the exercise if I decided to change over to Mnesia. Jeff. From bjorn@REDACTED Wed Aug 8 07:26:37 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 08 Aug 2007 07:26:37 +0200 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> Message-ID: Tony Finch writes: > On Tue, 7 Aug 2007, Bjorn Gustavsson wrote: > > > > It is not stack-based; it is register-based. > > I get the impression from a quick look at Joe's HOPL paper that the > registers are special-purpose and implicit, and the instruction format is > suitable for a threaded code interpreter. This implies to me that it isn't > like a CPU instruction set in the way that Lua 5 VM instructions are (see > http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/jucs05.pdf). This is a guess so > I'm probably wrong... Yes, but Joe described the original JAM (Joe Armstrong Machine) virtual machine. JAM has been replaced by BEAM. The BEAM instructions actually are executed by a threaded code interpreter, but BEAM does not the stack in the way that FORTH does; instead it uses registers, only putting values that need to survive function calls into a stack frame. The first word in each instruction points to the executable C code for the instruction. That first instruction word is followed by zero or more operand words. The operands can be constants such as atoms or integers, or the number of the registers to operate on. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bjorn@REDACTED Wed Aug 8 07:41:03 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 08 Aug 2007 07:41:03 +0200 Subject: [erlang-questions] lock-free hash table In-Reply-To: <46B93A6E.10305@gmail.com> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> <46B660B9.3090802@gmail.com> <46B93A6E.10305@gmail.com> Message-ID: Serge Aleynikov writes: > Another useful application of SMP-safe lock-free FIFO queues could be > inside the emulator. Correct me if I am wrong but in the emulator with > SMP support different schedulers use mutex synchronization in order to > get the next process descriptor off of a shared linked list of all > processes waiting to be dispatched. Also when copying a message sent by > some Erlang process to a mailbox of another Erlang process the emulator > with SMP support uses POSIX locking to ensure thread safety (if I > remember it correctly). > > In both of these cases using lock-free FIFO queues can provide a much > better scalability when used on multi-core CPUs compared to traditional > mutex-based locking primitives. We will definitely consider using lock-free data structure in future releases of the SMP emulator. Thanks for the references. Now that the SMP emulator seem to be stable, most of our future work on it will be to improve its performance. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ok@REDACTED Wed Aug 8 07:50:25 2007 From: ok@REDACTED (ok) Date: Wed, 8 Aug 2007 17:50:25 +1200 Subject: [erlang-questions] VM & BEAM Specs : idea for improving thelists support In-Reply-To: <005801c7d853$4bced5c0$891ea8c0@SSI.CORP> References: <46B46D0D.9010302@mail.ru><46B5AFE5.40706@mail.ru> <005801c7d853$4bced5c0$891ea8c0@SSI.CORP> Message-ID: <08674972-D5A5-4411-B47B-81F855A91D67@cs.otago.ac.nz> I wrote: >> Only if someone is daft enough to store the whole thing as a >> simple list of characters. There are much better ways, in the >> language and >> using the implementation that we now have. On 7 Aug 2007, at 5:57 am, David Mercer asked: > > For newbies among us, are you referring to storing it as a binary, or > something else? First possibility: don't store the whole thing. Work on it a chunk at a time. (Think "SAX" rather than "DOM".) Processing stuff in chunks often lets you produce summaries as you go instead of waiting until everything has been read. Second possibility: use binaries (carefully). With the <<"string">> syntax this is readable, and in effect gives you precisely the byte strings that other languages give you. (We could do with more string functions supporting this form, but that's another issue.) Third possibility: represent structured text as tree structures with only the "free" stuff as strings, which might themselves be binaries. This can be so much easier to generate and manipulate that it really isn't funny. As a rule, "strings" are useful for input and output, but not for processing. Fourth possiblity: hold large chunks of "free" text as data in DETS or Mnesia, and just keep keys pointing to these chunks in memory. Only pull a chunk in when you have an immediate use for it. Once a potential customer was visiting Quintus and they expressed a concern about working with hundreds of megabytes of text in Prolog: I went off to a terminal and 90 minutes later had a library module that held "Character Large Objects" in a file and in Prolog only kept {offset, length} references. Doing it with DETS should be even easier. Fifth possibility: build a dictionary of words and represent text as a list of word numbers. (Look up "spaceless word encoding"; a good description can be found in the book "Managing Gigabytes".) Sixth possibility: oh the heck with it; it's _easy_ to think these up. From nick.linker@REDACTED Wed Aug 8 07:50:03 2007 From: nick.linker@REDACTED (Nick) Date: Wed, 08 Aug 2007 12:50:03 +0700 Subject: [erlang-questions] "How to build reliable system" literature In-Reply-To: <200708072210.l77MAY8v016759@krumkake.jetcafe.org> References: <200708072210.l77MAY8v016759@krumkake.jetcafe.org> Message-ID: <46B9598B.5040401@rambler.ru> Jim Larson wrote: > I'd suggest you look at the considerable literature on "group > communication" for the details of protocols for optimistic replication. > Thank you very much, Jim! I've googled for the term and now have quite a few material to read and think about. Nick. From raimo+erlang-questions@REDACTED Wed Aug 8 09:31:08 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 8 Aug 2007 09:31:08 +0200 Subject: [erlang-questions] : lock-free hash table In-Reply-To: <46B93A6E.10305@gmail.com> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> <46B660B9.3090802@gmail.com> <46B93A6E.10305@gmail.com> Message-ID: <20070808073108.GA26407@erix.ericsson.se> Since I am not really into these problems my comments may be rumour'ish, but anyway... We are trying to use Atomic operations, in combination with appropriate algorithms, when possible. Using Atomic-based (lock-free) research paper data structures is however not something we have done yet. There may not be that many data structures in the Emulator that fit well to e.g FIFO queues, but it sure is worth keeping in mind. As an example, the most heavily used locks in the Emulator are the process locks, so we already do a number of tricks to firstly save memory not having to use some 10 mutexes per process, and secondly avoid taking locks all the time. Up to just recently the SMP work has been about correctness. If it is not as stable as the non-SMP version, it is mostly useless. We will optimize while it is stable enough. One of the first optimizations we are planning is to use Atomic operations for locking the process table, making it lock-free. We know of no lock-free data structure suitable for the job, but we think we can use Atomic operations anyway. After that we will see which locks are next to be optimized. For the record: Atomic operations (necessary for lock-free data structures) are not that innocent. "single instructions such as compare-and-swap" sure sound harmless, but for such an instruction to work in a multiprocessor machine it will have to invalidate caches on all other processors as well as write through to real (slow) memory, so it is a heavy operation. Lighter then mutexes, but the gain is much smaller than one might expect. On Tue, Aug 07, 2007 at 10:37:18PM -0500, Serge Aleynikov wrote: > Another useful application of SMP-safe lock-free FIFO queues could be > inside the emulator. Correct me if I am wrong but in the emulator with > SMP support different schedulers use mutex synchronization in order to > get the next process descriptor off of a shared linked list of all > processes waiting to be dispatched. Also when copying a message sent by > some Erlang process to a mailbox of another Erlang process the emulator > with SMP support uses POSIX locking to ensure thread safety (if I > remember it correctly). > > In both of these cases using lock-free FIFO queues can provide a much > better scalability when used on multi-core CPUs compared to traditional > mutex-based locking primitives. > > Serge > > Serge Aleynikov wrote: > > There have been quite a number of publications on the subject of > > lock-free data structures since around mid 90's, most notably by Maged > > Michael (IBM) and Philippas Tsigas / Yi Zhang (Chambers University). > > Here are some selected links: > > > > http://erdani.org/publications/cuj-2004-12.pdf > > http://citeseer.ist.psu.edu/sundell04scalable.html > > http://www.noble-library.com/ > > http://research.sun.com/techrep/2002/abstract-110.html > > > > The lock-free algorithms indeed perform exceptionally well in shared > > memory concurrent systems with a large number of CPUs since they don't > > require OS synchronization primitives (relying on a single instruction > > such as compare-and-swap). I also think that taking advantage of these > > algorithms in Erlang's emulator would make it even more scalable on > > large number of cores, especially if interfaces to ports (via shared > > memory) and drivers (via lock-free FIFO circular queues) would offer > > lock-free synchronization with emulator threads. > > > > Serge > > > > Ulf Wiger wrote: > >> I just caught Dr. Cliff Click's Google TechTalk on his > >> lock-free hash table. > >> > >> http://video.google.com/videoplay?docid=2139967204534450862 > >> > >> The (Java) source is also available > >> at sourceforge: http://sourceforge.net/projects/high-scale-lib > >> > >> According to his talk, the algorithm "scales well up to 768 cpus". > >> > >> I don't know if there is anything in this that would not fit Erlang > >> well, but perhaps it's something to look into? > >> > >> Anyway, it's always interesting to listen to these performance geeks. ;-) > >> > >> BR, > >> Ulf W > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From hakan@REDACTED Wed Aug 8 09:43:39 2007 From: hakan@REDACTED (Hakan Mattsson) Date: Wed, 8 Aug 2007 09:43:39 +0200 (CEST) Subject: [erlang-questions] Mnesia is overloaded In-Reply-To: References: Message-ID: On Tue, 7 Aug 2007, David King wrote: DK> I have an application that uses mnesia (through erlydb) that, at the DK> moment, gets very little traffic, except occasionally it has a few DK> tens of thousand records inserted all at once (well, two or three at DK> a time, but several thousand in a row). When this happens, I get the DK> following: DK> DK> =ERROR REPORT==== 7-Aug-2007::10:48:50 === DK> Mnesia('hostname'): ** WARNING ** Mnesia is overloaded: {dump_log, DK> write_threshold} DK> DK> The data makes it into the database just fine, but I get that message DK> quite a few times. According to erlang-questions/2000-July/001477.html>, that message "is generated DK> when a log dump has been triggered before the previous one DK> completed". Is there any way that I can temporary lengthen the amount DK> of time between log dumps? Or is it possible to make the database- DK> saves synchronous, to keep from overloading mnesia? No, there is no such function in the API. The setting is read at the startup of Mnesia. A small burst of overload warnings is nothing to bother about. But as it will clutter the Erlang log, it is probably a good idea to implement an Mnesia event callback module in order to supress the printout. See the event_module parameter in the Mnesia documentation for more details: http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.7 The original idea of issuing these overload events was to enable the Mnesia user to implement some clever overload protection algorithm. But i don't know if anyone has succeeded in doing that. /H?kan From casper2000a@REDACTED Wed Aug 8 09:49:48 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Wed, 8 Aug 2007 13:19:48 +0530 Subject: [erlang-questions] Abnormal Erl process behaviour? In-Reply-To: Message-ID: <20070808074952.034D819DC431@mail.wavenet.lk> Hi, I am running an Erlang 11B-5 system with SMP enabled (8 schedulers) and with 196 System Threads in RH Linux ES 4 system. Occasionally I experience system stalls/pauses for few seconds (10-20). However all the messages and processes spawn continues after that pause like nothing happened. Is there's a possibility to, 1. stop all message deliveries in the system for few seconds due to any reason? Eg. system time shifts, etc. 2. running processes stop or context switch due to a problem in process scheduler Has anybody experienced anything like this? Thanks, - Eranga From erlang@REDACTED Wed Aug 8 11:09:15 2007 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 8 Aug 2007 11:09:15 +0200 Subject: [erlang-questions] The Book, lib_chan and IRC Lite In-Reply-To: <46B87510.3040102@gmail.com> References: <46B469E4.60707@gmail.com> <9b08084c0708070028t913142uf972d576f0841b1d@mail.gmail.com> <46B8278A.3070002@gmail.com> <9b08084c0708070457o6a466cd7mcfed209003eb8f2c@mail.gmail.com> <46B87510.3040102@gmail.com> Message-ID: <9b08084c0708080209v37ce7d88r104a36c55d44ebe8@mail.gmail.com> There *was* a bug after all - there was a patch by Kazuya Sakakihara on the errata list for the book. I missed this since I when I retested the version I distributed it seemed to work (very strange). I've now fixed the code and the changes should make it into the next printing of the book. The corrected versions of code/socket_dist/chat_client.erl and code/socket_dist/chat_group.erl are attached to this mail. I hope they are correct now. Sorry for all the confusion. /Joe On 8/7/07, Dmitrii 'Mamut' Dimandt wrote: > Joe Armstrong wrote: > > Strange, there is a report of an error (and a patch) on the book's errata page > > but I have not been able to reproduce the error. > > > > I don't think there ever was a broken version on the prag site - you > > might having forgotten > > to do a make or have some weird paths setup. The command > > "code:clash()" will report > > any irregularities in your code loading paths. > > > > > funny thing is that I've started getting the same "protocol error" from > lib_chan_mm right after I wrote that everything worked ok :) I haven't > had time to investigate the problem, though... I'll write as son as I > can lay my habds on the code... > -------------- next part -------------- A non-text attachment was scrubbed... Name: chat_group.erl Type: application/octet-stream Size: 1484 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: chat_client.erl Type: application/octet-stream Size: 3352 bytes Desc: not available URL: From jakob@REDACTED Wed Aug 8 11:33:24 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Wed, 08 Aug 2007 11:33:24 +0200 Subject: [erlang-questions] binary to bigint? In-Reply-To: <46B89061.4010801@erix.ericsson.se> References: <46B89061.4010801@erix.ericsson.se> Message-ID: <46B98DE4.40804@erix.ericsson.se> To make an erlang integer from crypto:rand_bytes: big_random_int(Bytes) -> B = crypto:rand_bytes(Bytes), crypto:erlint(<>). I'd rather use rand_uniform/2, though. /Jakob Jakob Cederlund wrote: > In crypto you also have rand_uniform/2 which accepts large integers, and > mpint/1 that converts from binary form. > > /Jakob > > Jim McCoy wrote: > >> After bouncing through the various bits of doc related to io_lib I >> can't quite seem to put together a quick function that will convert an >> arbitrary binary to a big int (e.g. I want the integer for >> crypto:rand_bytes(40)...) >> >> Any hints? >> >> jim >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Wed Aug 8 12:59:19 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 08 Aug 2007 05:59:19 -0500 Subject: [erlang-questions] : lock-free hash table In-Reply-To: <20070808073108.GA26407@erix.ericsson.se> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> <46B660B9.3090802@gmail.com> <46B93A6E.10305@gmail.com> <20070808073108.GA26407@erix.ericsson.se> Message-ID: <46B9A207.30104@gmail.com> Raimo Niskanen wrote: > Since I am not really into these problems my comments may be > rumour'ish, but anyway... > > We are trying to use Atomic operations, in combination with > appropriate algorithms, when possible. Using Atomic-based > (lock-free) research paper data structures is however not > something we have done yet. > > There may not be that many data structures in the Emulator > that fit well to e.g FIFO queues, but it sure is worth > keeping in mind. As far as I know there are implementations of most common data structures available (trees, hash tables, lists, stacks, heap, dynamic memory allocators, ets) built around lock-free ideas. See Tony Finch's email in this thread and also: http://www.research.ibm.com/people/m/michael/podc-2002.pdf http://www.research.ibm.com/people/m/michael/spaa-2002.pdf http://www.cs.chalmers.se/%7Etsigas/pubs.html > Up to just recently the SMP work has been about correctness. > If it is not as stable as the non-SMP version, it is > mostly useless. We will optimize while it is stable enough. Indeed. > For the record: Atomic operations (necessary for lock-free > data structures) are not that innocent. "single instructions > such as compare-and-swap" sure sound harmless, but for > such an instruction to work in a multiprocessor machine > it will have to invalidate caches on all other processors > as well as write through to real (slow) memory, so it is > a heavy operation. Lighter then mutexes, but the gain > is much smaller than one might expect. In both Uniform Memory Access (UMA) and Cache-Coherent Non-Uniform Memory Access (ccNUMA) shared memory architectures, if they support compare-and-swap (or load-linked/store-conditional) hardware primitive (which most of the modern systems do), it's implemented in a way that since CPUs share the same bus to accessing memory, the atomicity is accomplished by retaining a lock of the bus during compare and swap operations. If the memory location is cached, the content of memory is modified internally in the cache, and the cache coherency hardware mechanism propagates this to caches of other processors and slow memory (*). (*) See Section 7.1.4: http://www.intel.com/design/processor/manuals/253667.pdf When I last tested FIFO circular queues in producer/consumer model on a dual-core CPU (**) I observed 3 times performance gain compared to mutex-locking approach for threads in the same process and about 9 times performance increase for the same application between two OS processes using shared memory. From references in other papers one could see as much at 10x performance boost as the number of threads & CPUs increases. In any event, I am glad to hear that you are considering some atomic synchronization improvements in the SMP emulator and look forward to seeing the outcome! (**) It was based on this algorithm: http://www.cs.chalmers.se/%7Etsigas/papers/latest-spaa01.pdf Regards, Serge > On Tue, Aug 07, 2007 at 10:37:18PM -0500, Serge Aleynikov wrote: >> Another useful application of SMP-safe lock-free FIFO queues could be >> inside the emulator. Correct me if I am wrong but in the emulator with >> SMP support different schedulers use mutex synchronization in order to >> get the next process descriptor off of a shared linked list of all >> processes waiting to be dispatched. Also when copying a message sent by >> some Erlang process to a mailbox of another Erlang process the emulator >> with SMP support uses POSIX locking to ensure thread safety (if I >> remember it correctly). >> >> In both of these cases using lock-free FIFO queues can provide a much >> better scalability when used on multi-core CPUs compared to traditional >> mutex-based locking primitives. >> >> Serge >> >> Serge Aleynikov wrote: >>> There have been quite a number of publications on the subject of >>> lock-free data structures since around mid 90's, most notably by Maged >>> Michael (IBM) and Philippas Tsigas / Yi Zhang (Chambers University). >>> Here are some selected links: >>> >>> http://erdani.org/publications/cuj-2004-12.pdf >>> http://citeseer.ist.psu.edu/sundell04scalable.html >>> http://www.noble-library.com/ >>> http://research.sun.com/techrep/2002/abstract-110.html >>> >>> The lock-free algorithms indeed perform exceptionally well in shared >>> memory concurrent systems with a large number of CPUs since they don't >>> require OS synchronization primitives (relying on a single instruction >>> such as compare-and-swap). I also think that taking advantage of these >>> algorithms in Erlang's emulator would make it even more scalable on >>> large number of cores, especially if interfaces to ports (via shared >>> memory) and drivers (via lock-free FIFO circular queues) would offer >>> lock-free synchronization with emulator threads. >>> >>> Serge >>> >>> Ulf Wiger wrote: >>>> I just caught Dr. Cliff Click's Google TechTalk on his >>>> lock-free hash table. >>>> >>>> http://video.google.com/videoplay?docid=2139967204534450862 >>>> >>>> The (Java) source is also available >>>> at sourceforge: http://sourceforge.net/projects/high-scale-lib >>>> >>>> According to his talk, the algorithm "scales well up to 768 cpus". >>>> >>>> I don't know if there is anything in this that would not fit Erlang >>>> well, but perhaps it's something to look into? >>>> >>>> Anyway, it's always interesting to listen to these performance geeks. ;-) >>>> >>>> BR, >>>> Ulf W >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Wed Aug 8 15:53:24 2007 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 8 Aug 2007 15:53:24 +0200 Subject: [erlang-questions] bignums in erlang Message-ID: <9b08084c0708080653q45463a30u16fd7a28e78ee4af@mail.gmail.com> Dear list Has anybody implemented bignums in Erlang using lists of small integers. Failing that has anybody any tips on how to implement bignums using Erlang type lists of small integers in an efficient manner /Joe From dot@REDACTED Mon Aug 6 19:09:34 2007 From: dot@REDACTED (Tony Finch) Date: Mon, 6 Aug 2007 18:09:34 +0100 Subject: [erlang-questions] lock-free hash table In-Reply-To: <46B660B9.3090802@gmail.com> References: <8209f740708031320r14b1c7e0q80b9a5992a1d65f0@mail.gmail.com> <46B660B9.3090802@gmail.com> Message-ID: On Sun, 5 Aug 2007, Serge Aleynikov wrote: > > http://erdani.org/publications/cuj-2004-12.pdf > http://citeseer.ist.psu.edu/sundell04scalable.html > http://www.noble-library.com/ > http://research.sun.com/techrep/2002/abstract-110.html also http://www.cl.cam.ac.uk/research/srg/netos/lock-free/ Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From dmercer@REDACTED Wed Aug 8 18:06:04 2007 From: dmercer@REDACTED (David Mercer) Date: Wed, 8 Aug 2007 11:06:04 -0500 Subject: [erlang-questions] inet:getopts Message-ID: <009c01c7d9d6$0601abb0$891ea8c0@SSI.CORP> I can never get any good response out of inet:getopts/2: 1> S = gen_tcp:connect("localhost", 1210, [{active, once}]). {ok,#Port<0.110>} 2> inet:getopts(S, [active]). =ERROR REPORT==== 8-Aug-2007::10:36:53 === Error in process <0.62.0> with exit value: {function_clause,[{prim_inet,getopts, [{ok,#Port<0.110>},[active]]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,e val_ loop,3}]} ** exited: {function_clause,[{prim_inet,getopts,[{ok,#Port<0.110>},[active]]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** I have confirmed that I am successfully making the connection. What am I doing wrong? I do not understand the error report. Please advise. Thank-you. David Mercer -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Wed Aug 8 18:11:10 2007 From: dmercer@REDACTED (David Mercer) Date: Wed, 8 Aug 2007 11:11:10 -0500 Subject: [erlang-questions] inet:getopts Message-ID: <00a101c7d9d6$bc9923d0$891ea8c0@SSI.CORP> Yes, I am an idiot. The problem, of course, is that S is the tuple {ok,#Port<0.110>}. It works fine when I actually pay attention: 32> {ok, S} = gen_tcp:connect("localhost", 1210, [{active, once}]). {ok,#Port<0.113>} 33> inet:getopts(S, [active]). {ok,[{active,once}]} Sorry for the waste of bandwidth. David _____ From: David Mercer [mailto:dmercer@REDACTED] Sent: Wednesday, August 08, 2007 11:06 To: 'Erlang Questions' Subject: inet:getopts I can never get any good response out of inet:getopts/2: 1> S = gen_tcp:connect("localhost", 1210, [{active, once}]). {ok,#Port<0.110>} 2> inet:getopts(S, [active]). =ERROR REPORT==== 8-Aug-2007::10:36:53 === Error in process <0.62.0> with exit value: {function_clause,[{prim_inet,getopts, [{ok,#Port<0.110>},[active]]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,e val_ loop,3}]} ** exited: {function_clause,[{prim_inet,getopts,[{ok,#Port<0.110>},[active]]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** I have confirmed that I am successfully making the connection. What am I doing wrong? I do not understand the error report. Please advise. Thank-you. David Mercer -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcaoyuan@REDACTED Wed Aug 8 20:48:40 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Thu, 9 Aug 2007 02:48:40 +0800 Subject: [erlang-questions] ErlyBird 0.12.0 released - Erlang IDE based on NetBeans Message-ID: I'm pleased to announce ErlyBird 0.12.0, an Erlang IDE based on NetBeans. This is a bug-fix, performance improvement release. This release will only provide all-in-one IDE package, which is in size of 15.9M. Java JRE 5.0+ is requested. To download, please go to: http://sourceforge.net/project/showfiles.php?group_id=192439 To install: 1. Unzip erlybird-bin-0.12.0-ide.zip to somewhere. For Windows user, execute 'bin/erlybird.exe'. For *nix user, 'bin/erlybird'. 2. Check/set your OTP path. From [Tools]->[Options], click on 'Miscellanous', then expand 'Erlang Installation', fill in the full path of your 'erl.exe' or 'erl' file. For instance: "C:/erl/bin/erl.exe" 3. The default -Xmx option for jvm is set to 256M, if you want to increase it, please open the config file that is located at etc/erlybird.conf, set -J-Xmx of 'default_options'. When you run ErlyBird first time, the OTP libs will be indexed. The indexing time varies from 30 to 60 minutes deponding on your computer. Notice: If you have previous version of ErlyBird installed, please delete the old cache files which are located at: * *nix: "${HOME}/.erlybird/dev" * mac os x: "${HOME}/Library/Application Support/erlybird/dev" * windows: "C:\Documents and Settings\yourusername\.erlybird\dev" or some where The status of ErlyBird is still Alpha, feedback and bug reports are welcome. CHANGELOG: * Performance improvement, especially source code rendering performance. * Highlighting for unbound/unused variables. * Completion for macros and records. * Go to source files of -include and -include_lib. * Erlang shell window in Mac OS X should work now. * Various bug fixes. - Caoyuan Deng http://blogtrader.net/page/dcaoyuan From joelr1@REDACTED Wed Aug 8 21:03:46 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Aug 2007 20:03:46 +0100 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> Message-ID: <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> On Aug 8, 2007, at 6:26 AM, Bjorn Gustavsson wrote: > The first word in each instruction points to the executable C code > for the instruction. That first instruction word is followed by > zero or more operand words. Would it be right to say that Erlang VM instructions are C function calls? This is my understanding of the above. Is there significant overhead of function call setup per instruction? Thanks, Joel -- http://wagerlabs.com From rsaccon@REDACTED Wed Aug 8 23:11:30 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Wed, 8 Aug 2007 18:11:30 -0300 Subject: [erlang-questions] emacs compilation command Message-ID: there was a lengthy thread a few weeks ago about custom emacs commands to compile erlang (and what was recommended there worked well for me) But what I would like to try next, is to hack the the erlang.el, so that the outdir can be set to ../ebin instead of current directory (or maybe even the possibility of setting the compiling options in the ~.emacs file. Unfortunately I am not proficient enough in elisp, is there anybody who has more elisp experience and can point me into the right direction ? I see below at the relevant code-snippet of the function inferior-erlang-compile, that the current directory is retrieved with file:get_cwd(), but how can I go from there in elisp to ../ebin ? (if erlang-compile-use-outdir (if current-prefix-arg (format "c(\"%s\", [{outdir, \"%s\"}, debug_info, export_all])." noext dir) (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir)) (format (concat "f(%s), {ok, %s} = file:get_cwd(), " "file:set_cwd(\"%s\"), " (if current-prefix-arg "%s = c(\"%s\", [debug_info, export_all]), file:set_cwd(%s), f(%s), %s." "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s.")) tmpvar2 tmpvar dir tmpvar2 noext tmpvar tmpvar tmpvar2)) nil)) -- Roberto Saccon - http://rsaccon.com From fritchie@REDACTED Thu Aug 9 00:46:26 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 08 Aug 2007 17:46:26 -0500 Subject: [erlang-questions] RFC: Erlang FFI In-Reply-To: Message of "Tue, 07 Aug 2007 17:22:41 +0200." <1186500161.7109.21.camel@gnatziu.crs4.it> Message-ID: <200708082246.l78MkQvg025535@snookles.snookles.com> >>>>> "as" == Alceste Scalas writes: as> A few notes about the GCC FFI library: it is released under a very as> permissive license, it supports a whole lot of architectures, and as> it is available as a separate package (for Debian/Ubuntu users: as> apt-get install libffi4 libffi4-dev ). If there's any Pythonista as> out there: it's the library on which Python ctype module is built. Alceste: This is good news. A couple months ago, I'd stumbled across libffi and Python's interface to it. I thought, "That'd be nifty, in a very-easy-to-shoot-yourself-in-the-foot kind of way." I also had absolutely no time to pursue it, so I'm glad that someone else is. Most of the Erlang<->C/C++ efforts have been SWIG-like efforts to present as smooth an interface to the non-C side as possible. In Erlang, IMHO(*), such integration has been even more important. At least half of Erlang's advantage is its ability to survive faults(*), and creating arbitrary interfaces into unknown shared libraries is a good way to invalidate much/all of those survival mechanisms. However, such control is difficult to manage. And more than a bit chafing, mentally. And so there still aren't any easy-to-use FFI thingies. Such an interface to libffi makes it possible to create Erlang interfaces to *any* shared library, without recompiling or relinking or other steps. To create the same "smooth" interface, the glue ends up being on the Erlang side of the divide. That philosophy is opposite from most FFI efforts in the Erlang world. There are 2 main FFI camps, it seems to me(*): 1. I don't care about fault tolerance, I *must* access to function F in library L, and to hell with the consequences of buggy code. 2. I really care about fault tolerance ... because if I didn't, I wouldn't bother with Erlang at all. I used to be in the first camp. As I've developed more apps, and seen Erlang generic servers and supervisor trees and other Erlang/OTP wizardry keep my emergency 24-hour support pager completely silent, I'm quite firmly in the second camp. 8-) A raw interface with libffi would fall into the first camp. My suggestion for you is to think long and hard about also supporting the 2nd camp, as much as possible. Because there are plenty of us that would love to use special library L in an Erlang app in a *production* environment, but won't run the risk of using L without as many Erlang'ish safeguards as possible. For example, being able to choose whether to use the FFI via dlopen() 1. inside the Erlang VM, or 2. in a separate OS process (communicating via pipe, socket, whatever). Preferably using the same interface. Personally, I'm a big fan of the VM's efforts to clean up ports, file handles, sockets, etc. whenever a process crashes. For long term survivability, it is extremely useful if resources allocated by library L can also be cleaned up/freed/closed/whatever when the "owner" process crashes. Such bookkeeping in Erlang is trickier to avoid leaks than if it's done inside a driver/BIF on the C side, but perhaps it's as feasible (with some creative thinking)? Prior FFI efforts have tried to make it difficult to do suicidal stuff like: BadBufferAddress = 88044, % Clobber something else, if you wish! Fmt = list_to_binary(["Hello, world!", 0]), ffi:call(Handler, {sprintf, BadBufferAddress, Fmt}, {sint, pointer}), ... by first requiring a memory allocation for the buffer, and somehow tagging that pointer so that a random integer (or some other pointer type) can't be accidentally used by sprintf(). Hm, for a first libffi effort, such safety probably isn't worth it. Camp #1 people won't want to wait for the safety feature, and Camp #2 people will be either a) patient and will wait, or b) implement their own safety net. For either camp, releasing an implementation of a libffi interface would be better sooner than waiting for zillions of features(**). -Scott (*) An opinion probably not shared by everybody. :-) (**) Less disagreement, I think? From jefcrane@REDACTED Thu Aug 9 01:28:39 2007 From: jefcrane@REDACTED (Jeff Crane) Date: Wed, 8 Aug 2007 16:28:39 -0700 (PDT) Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: <46B6BFEC.1010307@munat.com> Message-ID: <428862.59200.qm@web31608.mail.mud.yahoo.com> MySQL > mnesia. I'm an erlang fan, but technically you dont really have much of a choice. I'm not sure mnesia shines anywhere but in theory. Someone needs to talk about a DB's performance over millions of rows. I can use MSAccess tables for 30,000 records a pop and I get decent performance and no data loss, until a table flatfile that is over 2G. MySQL4, I get no data loss until a table is over 4T and that's FINE. Note the first paragraph: http://erlang-consulting.com/thesis/dbms_eval.html If I can't do a 6 table FK'd join (on tables containing hundreds of thousands of rows) I can't use a DB for real work. *shrug* --- Ben Munat wrote: > Patrick wrote: > I'm curious why you recommend MySQL over mnesia? Are > thinking of "business environment" folks who > would just be more comfortable with something well > known like MySQL? Or do you know of > data-integrity or performance issues that I should > know about? > > ...I have not come > across a single story of data-loss, performance > issues or other problems/disasters with mnesia. ____________________________________________________________________________________ Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. http://smallbusiness.yahoo.com/webhosting From vances@REDACTED Thu Aug 9 03:00:26 2007 From: vances@REDACTED (Vance Shipley) Date: Wed, 8 Aug 2007 21:00:26 -0400 Subject: [erlang-questions] MySQl vs. mnesia In-Reply-To: <428862.59200.qm@web31608.mail.mud.yahoo.com> References: <46B6BFEC.1010307@munat.com> <428862.59200.qm@web31608.mail.mud.yahoo.com> Message-ID: <20070809010026.GB8096@little-black-book.motivity.ca> On Wed, Aug 08, 2007 at 04:28:39PM -0700, Jeff Crane wrote: } I'm not sure mnesia shines anywhere but in theory. You miss the point of Erlang/OTP entirely then. } If I can't do a 6 table FK'd join (on tables } containing hundreds of thousands of rows) I can't use } a DB for real work. *shrug* If your problem domain is such the so be it. Can you not imagine that other problem domains are significantly different from your own? Mnesia is used in demanding real life production use in several problem domains where you would not feel at home. -Vance From cyberlync@REDACTED Thu Aug 9 07:41:42 2007 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 08 Aug 2007 22:41:42 -0700 Subject: [erlang-questions] RFC: Erlang FFI In-Reply-To: <200708082246.l78MkQvg025535@snookles.snookles.com> (Scott Lystig Fritchie's message of "Wed\, 08 Aug 2007 17\:46\:26 -0500") References: <200708082246.l78MkQvg025535@snookles.snookles.com> Message-ID: <87wsw5clih.fsf@gmail.com> It would seem that providing the 'safe' version would mean just coming up with a simple protocol and implementing a very thin c program that translates that protocol to libffi calls. Then talking to said c program via pipes or what have you. This should give you the best of both worlds at some cost in speed but a huge increas in reliability. From bjorn@REDACTED Thu Aug 9 07:50:16 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 09 Aug 2007 07:50:16 +0200 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> Message-ID: Joel Reymont writes: > On Aug 8, 2007, at 6:26 AM, Bjorn Gustavsson wrote: > > > The first word in each instruction points to the executable C code > > for the instruction. That first instruction word is followed by > > zero or more operand words. > > Would it be right to say that Erlang VM instructions are C function > calls? This is my understanding of the above. No. We use the "first-class label" in feature in GCC. All instructions are in the same huge function (process_main()). The addresses are address to labels within that function. Each instruction is responsible for picking up the address for the C code for the next instruction and *jump* to it. We use an old plain switch statement if the emulator is compiled with a C compiler that doesn't support first-class labels. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From vladdu55@REDACTED Thu Aug 9 08:59:52 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 9 Aug 2007 08:59:52 +0200 Subject: [erlang-questions] RFC: Erlang FFI In-Reply-To: <87wsw5clih.fsf@gmail.com> References: <200708082246.l78MkQvg025535@snookles.snookles.com> <87wsw5clih.fsf@gmail.com> Message-ID: <95be1d3b0708082359h9df5a20g340610ee1a6334cc@mail.gmail.com> Hi, On 8/9/07, Eric Merritt wrote: > It would seem that providing the 'safe' version would mean just coming > up with a simple protocol and implementing a very thin c program that > translates that protocol to libffi calls. Then talking to said c program > via pipes or what have you. This should give you the best of both worlds > at some cost in speed but a huge increas in reliability. That is indeed one of the best ways to interface to the outside world from Erlang. The trouble is that while it is relatively easy (i.e. there are tools to automate it) to take some C headers and generate wrappers, it isn't as straightforward to come up with an efficient protocol implementation that is generic[*]. (Or at least I'm not aware of any, the closest match I can come up with would be the eX11 bindings) In the meantime, the developers for each library binding are going to have to implement their own protocol and supporting code. Which imho is a big pain... [*] One issue I see is that given an API, it would need to be annotated so that one knows which arguments are "in" and which are "out", because "in" parameters can be serialized and sent in full instead as as a pointer, significantly reducing the communication overhead. [*] Then, as Scott pointed out, memory management issues are also to be considered. best regards, Vlad From dmorton@REDACTED Thu Aug 9 08:22:54 2007 From: dmorton@REDACTED (Damien Morton) Date: Thu, 09 Aug 2007 02:22:54 -0400 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> Message-ID: <46BAB2BE.1060601@bitfurnace.com> Quite a few years back, I did an analysis of Python bytecode execution traces and the main interpreter loop. It turns out that there are some sequences of bytecodes that occur more frequently than others, and that you can structure the main interpreter loop so that common traces will result in straight through execution, that is, you test to see if the next instruction is the same as for the following code block, and either fall through or jump to the appropriate label. In my case I took statistics on bytecode sequences of length 4 and applied simulated annealing to produce a ordering of bytecodes that minimised the need for jumps, though a good layout can me made by hand. The result was a small but measurable increase in performance. Might the same technique be applicable to the Erlang VM. > Joel Reymont writes: > > >> On Aug 8, 2007, at 6:26 AM, Bjorn Gustavsson wrote: >> >> >>> The first word in each instruction points to the executable C code >>> for the instruction. That first instruction word is followed by >>> zero or more operand words. >>> >> Would it be right to say that Erlang VM instructions are C function >> calls? This is my understanding of the above. >> > > No. > > We use the "first-class label" in feature in GCC. All instructions > are in the same huge function (process_main()). The addresses are > address to labels within that function. Each instruction is responsible > for picking up the address for the C code for the next instruction and > *jump* to it. > > We use an old plain switch statement if the emulator is compiled with a C compiler > that doesn't support first-class labels. > > /Bjorn > From raimo+erlang-questions@REDACTED Thu Aug 9 09:20:13 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 9 Aug 2007 09:20:13 +0200 Subject: [erlang-questions] : Design of the Erlang VM In-Reply-To: <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> <62B65A91-2BFE-4ADE-BBF3-624D52A9AD96@gmail.com> Message-ID: <20070809072013.GA18285@erix.ericsson.se> No, they are not C function calls. C function calls push the arguments (that may come not only from the calling code, but also from other places, nevertheless there is explicit code to place them ---) on the processor stack, pushes the return addresss on the processor stack and then jumps to the function address. When the function returns the return instruction pops the return address from the stack and jumps back to where it came from. Then the calling code restores the stack pointer to remove the call arguments from the processor stack. BEAM instructions are the instruction word followed by zero or more operand words. The instruction word is an address to the processor instruction sequence that implements the BEAM instruction, as Bjorn said below. The BEAM instructions are just straight processor code that do not expect arguments on the processor stack and do not end in a processor return instruction. The BEAM instructions themselves increment the BEAM instruction pointer and pick up operand words into processor registers. They end by reading the next instruction and since it is a jump address - jump to that address and then BEAM is performing the next BEAM instruction. If the BEAM instruction is a (conditional) jump or call et.al, the instruction just sets the BEAM instruction pointer to point to the next BEAM instruction to actually perform, reads it and jumps. So there is no call setup overhead per instruction. On Wed, Aug 08, 2007 at 08:03:46PM +0100, Joel Reymont wrote: > > On Aug 8, 2007, at 6:26 AM, Bjorn Gustavsson wrote: > > > The first word in each instruction points to the executable C code > > for the instruction. That first instruction word is followed by > > zero or more operand words. > > Would it be right to say that Erlang VM instructions are C function > calls? This is my understanding of the above. > > Is there significant overhead of function call setup per instruction? > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ahmed.nawras@REDACTED Thu Aug 9 11:13:50 2007 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Thu, 9 Aug 2007 13:13:50 +0400 Subject: [erlang-questions] Erlang with BDB Message-ID: Hi All, I'd like to use an external BerkeleyDB (BDB) with Erlang. Mnesia is good for me but requirements are to use BDB or MySQL. I searched in the internet and found that MySQL has more support for Erlang than BDB but I want to use BDB. Has any one here used BDB with Erlang before? Can anyone share his experience with Erlang & BDB? Any information is appreciated. Thanks. Best regards, Ahmed Al-Issaei -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Aug 9 12:10:43 2007 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Aug 2007 11:10:43 +0100 Subject: [erlang-questions] Loaded module version on a diskless node Message-ID: <73C645C3-83A1-4D3B-A818-2F7A765497C5@gmail.com> Folks, I need to get the version of a module on a diskless node. How does beam_lib:version/1 work in this scenario? Will it ask erl_prim_loader to grab the module code and get the version from there? If the module has been recompiled on the boot server after it was fetched by the diskless node then the module versions will be different. Will the boot server version be reported then? I thought there was a way to ask for the version of the module loaded into memory but can't find the option to do this. Thanks, Joel -- http://wagerlabs.com From saleyn@REDACTED Thu Aug 9 13:38:29 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 09 Aug 2007 06:38:29 -0500 Subject: [erlang-questions] Loaded module version on a diskless node In-Reply-To: <73C645C3-83A1-4D3B-A818-2F7A765497C5@gmail.com> References: <73C645C3-83A1-4D3B-A818-2F7A765497C5@gmail.com> Message-ID: <46BAFCB5.6030800@gmail.com> How about this: version(Module) -> Attrs = proplists:get_value(attributes, Module:module_info()), [Vsn] = proplists:get_value(vsn, Atts), Vsn. Joel Reymont wrote: > Folks, > > I need to get the version of a module on a diskless node. > > How does beam_lib:version/1 work in this scenario? Will it ask > erl_prim_loader to grab the module code and get the version from there? > > If the module has been recompiled on the boot server after it was > fetched by the diskless node then the module versions will be > different. Will the boot server version be reported then? > > I thought there was a way to ask for the version of the module loaded > into memory but can't find the option to do this. > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dot@REDACTED Tue Aug 7 16:59:22 2007 From: dot@REDACTED (Tony Finch) Date: Tue, 7 Aug 2007 15:59:22 +0100 Subject: [erlang-questions] Design of the Erlang VM In-Reply-To: References: <17B3E2BE-FAF4-4F2B-BE87-CDFC1275FEFB@gmail.com> Message-ID: On Tue, 7 Aug 2007, Bjorn Gustavsson wrote: > > It is not stack-based; it is register-based. I get the impression from a quick look at Joe's HOPL paper that the registers are special-purpose and implicit, and the instruction format is suitable for a threaded code interpreter. This implies to me that it isn't like a CPU instruction set in the way that Lua 5 VM instructions are (see http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/jucs05.pdf). This is a guess so I'm probably wrong... Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From bjorn@REDACTED Thu Aug 9 13:53:32 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 09 Aug 2007 13:53:32 +0200 Subject: [erlang-questions] Loaded module version on a diskless node In-Reply-To: <73C645C3-83A1-4D3B-A818-2F7A765497C5@gmail.com> References: <73C645C3-83A1-4D3B-A818-2F7A765497C5@gmail.com> Message-ID: Joel Reymont writes: > > I thought there was a way to ask for the version of the module loaded > into memory but can't find the option to do this. If you have the binary containing the beam code (the contents of the .beam file): beam_lib:version(BinaryContainingCode). This is documented. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From xpdoka@REDACTED Thu Aug 9 14:23:00 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 9 Aug 2007 14:23:00 +0200 (CEST) Subject: [erlang-questions] emacs compilation command In-Reply-To: References: Message-ID: <25840.217.128.75.198.1186662180.squirrel@www.geekisp.com> Hi Roberto, > Unfortunately I am not proficient enough in elisp, is there anybody > who has more elisp experience and can point me into the right > direction ? I see below at the relevant code-snippet of the function > inferior-erlang-compile, that the current directory is retrieved with > file:get_cwd(), but how can I go from there in elisp to ../ebin ? I think that code snippet can be left alone. However, it uses the elisp variable "dir" to set the "outdir" option of c(). The dir variable gets set a few lines up like this: (let ((dir (file-name-directory (buffer-file-name))) ... I.e. it uses the buffer's directory. So, setting dir to a different value is what you want. The following elisp code uses ../ebin if it exists, and otherwise reverts to the current behaviour: (let* ((buffer-dir (file-name-directory (buffer-file-name))) (ebin (concat buffer-dir "../ebin/")) (dir (if (file-readable-p ebin) ebin buffer-dir)) ... Hope that helps! Regards, Dominic Williams http://dominicwilliams.net ---- From denis.bilenko@REDACTED Thu Aug 9 13:03:38 2007 From: denis.bilenko@REDACTED (Denis Bilenko) Date: Thu, 9 Aug 2007 18:03:38 +0700 Subject: [erlang-questions] RFC: Erlang FFI Message-ID: <95d6e98c0708090403v6262bdcbpd1c28a239d9ef9e5@mail.gmail.com> On Tue, 07 Aug 2007 Alceste Scalas wrote: > Hello, > > following the rules of the EEP workflow [1], I'd like to know your > opinions about extending Erlang with a Foreign Function Interface > (FFI). > > I've got an implementation based on GCC's FFI library [2], that is > mostly complete [3] and tested on GNU/Linux on AMD64. The first > part of the following description refers to this implementation, > while the rest of the email contains ideas for possible > enhancements. > That's great news. I've asked for such a library sometime ago: http://forum.trapexit.org/viewtopic.php?p=26036&sid=39dc56963cb8e2442bef91d8a4492b12 and even tried to implement it but using driver api, not BIFs. I have not finished it (got new job), but did manage to call simple functions, e.g. printf: http://effi.googlecode.com/svn/trunk/examples/ It's nice to see someone has done it. Erlang will become more interesting to the masses once such a library will come out. On Wed, 08 Aug 2007 Scott Lystig Fritchie > There are 2 main FFI camps, it seems to me(*): > > 1. I don't care about fault tolerance, I *must* access to function > F in library L, and to hell with the consequences of buggy > code. > > 2. I really care about fault tolerance ... because if I didn't, I > wouldn't bother with Erlang at all. > > I used to be in the first camp. As I've developed more apps, and seen > Erlang generic servers and supervisor trees and other Erlang/OTP > wizardry keep my emergency 24-hour support pager completely silent, > I'm quite firmly in the second camp. 8-) > > A raw interface with libffi would fall into the first camp. My > suggestion for you is to think long and hard about also supporting the > 2nd camp, as much as possible. Because there are plenty of us that > would love to use special library L in an Erlang app in a *production* > environment, but won't run the risk of using L without as many > Erlang'ish safeguards as possible. > > For example, being able to choose whether to use the FFI via dlopen() > 1. inside the Erlang VM, or 2. in a separate OS process (communicating > via pipe, socket, whatever). Preferably using the same interface. Why can't we just start another node for all the unsafe stuff, or even a node per library? Some erlang glue will make it invisible to library's user, but FFI library itself doesn't have to implement delegation of all calls to auxiliary OS process. From thomasl_erlang@REDACTED Fri Aug 10 00:25:37 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 9 Aug 2007 15:25:37 -0700 (PDT) Subject: [erlang-questions] "Erlang, the next Java" Message-ID: <414336.73225.qm@web38802.mail.mud.yahoo.com> http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&entry=3364027251 Ralph Johnson (gang of four) praises Erlang in a longish review of Joe's book. Great stuff from a veteran; here is the payoff: "Erlang is going to be a very important language. It could be the next Java. Its main problem is that there is no big company behind it. Instead, it is being pushed as an open source project. Its main advantage is that it is perfectly suited for the multi-core, web services future. In fact, it is the ONLY mature, rock-solid language that is suitable for writing highly scalable systems to run on multicore machines. ... I do not believe that other languages can catch up with Erlang anytime soon. It will be easy for them to add language features to be like Erlang. It will take a long time for them to build such a high-quality VM and the mature libraries for concurrency and reliability. So, Erlang is poised for success. If you want to build a multicore application in the next few years, you should look at Erlang." Best, Thomas ____________________________________________________________________________________ Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. http://smallbusiness.yahoo.com/webhosting From chris@REDACTED Fri Aug 10 06:28:58 2007 From: chris@REDACTED (Chris Wong) Date: Thu, 9 Aug 2007 21:28:58 -0700 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <414336.73225.qm@web38802.mail.mud.yahoo.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> Message-ID: <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> I enjoy this article. Thanks for forwarding. As much as I like to focus on the positive aspects of Erlang, there are at least a couple short-comings of Erlang. One of them are mentioned by Ralph Johnson in this article; Erlang doesn't have a large company behind it. Second, I heard a lot that distributed Erlang doesn't scale in a large distributed environment with thousands of machine. I personally don't have any experience to assert it one way or the other. Both have been used by anti-Erlang camp. It makes it really hard to advocate Erlang in a large company. For example, in a large ccompany, there is usually a large investment already to solve the large distributed computing problem in Java or C++. The usual argument is that the tested and proven home-grown solution should be used instead despite how much concurrency gain you'd have using Erlang. It's a huge disappointment for me and a touch battle to fight. What are the mitigation for such short-comings in Erlang? Thanks for any insight. Chris On Aug 9, 2007, at 3:25 PM, Thomas Lindgren wrote: > http://www.cincomsmalltalk.com/userblogs/ralph/blogView? > showComments=true&entry=3364027251 > > Ralph Johnson (gang of four) praises Erlang in a > longish review of Joe's book. Great stuff from a > veteran; here is the payoff: > > "Erlang is going to be a very important language. It > could be the next Java. Its main problem is that there > is no big company behind it. Instead, it is being > pushed as an open source project. Its main advantage > is that it is perfectly suited for the multi-core, web > services future. In fact, it is the ONLY mature, > rock-solid language that is suitable for writing > highly scalable systems to run on multicore machines. > > ... > > I do not believe that other languages can catch up > with Erlang anytime soon. It will be easy for them to > add language features to be like Erlang. It will take > a long time for them to build such a high-quality VM > and the mature libraries for concurrency and > reliability. So, Erlang is poised for success. If you > want to build a multicore application in the next few > years, you should look at Erlang." > > Best, > Thomas > > > > > ______________________________________________________________________ > ______________ > Building a website is a piece of cake. Yahoo! Small Business gives > you all the tools to get online. > http://smallbusiness.yahoo.com/webhosting > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dunceor@REDACTED Fri Aug 10 07:49:23 2007 From: dunceor@REDACTED (=?UTF-8?Q?Karl_Sj=C3=B6dahl_-_dunceor?=) Date: Fri, 10 Aug 2007 07:49:23 +0200 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <414336.73225.qm@web38802.mail.mud.yahoo.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> Message-ID: <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> Hello. A nice review that one thing that I keep hearing is that there is no big company behind Erlang and I feel that is not quite true. Ericsson is still a supporter of it and has full-time employees I thought to develop OTP? He even spelled Ericsson wrong in his blog also :P Nice blog at least. And this weekend I will finally have time to sit down and read Joe's book that I got almost two weeks ago. BR Dunceor On 8/10/07, Thomas Lindgren wrote: > http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&entry=3364027251 > > Ralph Johnson (gang of four) praises Erlang in a > longish review of Joe's book. Great stuff from a > veteran; here is the payoff: > > "Erlang is going to be a very important language. It > could be the next Java. Its main problem is that there > is no big company behind it. Instead, it is being > pushed as an open source project. Its main advantage > is that it is perfectly suited for the multi-core, web > services future. In fact, it is the ONLY mature, > rock-solid language that is suitable for writing > highly scalable systems to run on multicore machines. > > ... > > I do not believe that other languages can catch up > with Erlang anytime soon. It will be easy for them to > add language features to be like Erlang. It will take > a long time for them to build such a high-quality VM > and the mature libraries for concurrency and > reliability. So, Erlang is poised for success. If you > want to build a multicore application in the next few > years, you should look at Erlang." > > Best, > Thomas > > > > > ____________________________________________________________________________________ > Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. > http://smallbusiness.yahoo.com/webhosting > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chris@REDACTED Fri Aug 10 10:21:43 2007 From: chris@REDACTED (Chris Wong) Date: Fri, 10 Aug 2007 01:21:43 -0700 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> Message-ID: <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> I think Ralph is referring to a big company as some company like Sun or Microsoft who has a vested interest in seeing Java or C++/C# become popular. They have a business plan for whatever programming language they are pushing. For Ericsson, what's their incentive to push Erlang to make it popular? Popularity of Erlang isn't going to help selling more Ericsson switches or cell phones, is it? Chris On Aug 9, 2007, at 10:49 PM, Karl Sj?dahl - dunceor wrote: > Hello. > > A nice review that one thing that I keep hearing is that there is no > big company behind Erlang and I feel that is not quite true. Ericsson > is still a supporter of it and has full-time employees I thought to > develop OTP? He even spelled Ericsson wrong in his blog also :P > > Nice blog at least. > And this weekend I will finally have time to sit down and read Joe's > book that I got almost two weeks ago. > > BR > Dunceor > > On 8/10/07, Thomas Lindgren wrote: >> http://www.cincomsmalltalk.com/userblogs/ralph/blogView? >> showComments=true&entry=3364027251 >> >> Ralph Johnson (gang of four) praises Erlang in a >> longish review of Joe's book. Great stuff from a >> veteran; here is the payoff: >> >> "Erlang is going to be a very important language. It >> could be the next Java. Its main problem is that there >> is no big company behind it. Instead, it is being >> pushed as an open source project. Its main advantage >> is that it is perfectly suited for the multi-core, web >> services future. In fact, it is the ONLY mature, >> rock-solid language that is suitable for writing >> highly scalable systems to run on multicore machines. >> >> ... >> >> I do not believe that other languages can catch up >> with Erlang anytime soon. It will be easy for them to >> add language features to be like Erlang. It will take >> a long time for them to build such a high-quality VM >> and the mature libraries for concurrency and >> reliability. So, Erlang is poised for success. If you >> want to build a multicore application in the next few >> years, you should look at Erlang." >> >> Best, >> Thomas >> >> >> >> >> _____________________________________________________________________ >> _______________ >> Building a website is a piece of cake. Yahoo! Small Business gives >> you all the tools to get online. >> http://smallbusiness.yahoo.com/webhosting >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From mazen@REDACTED Fri Aug 10 10:26:05 2007 From: mazen@REDACTED (Mazen Harake) Date: Fri, 10 Aug 2007 09:26:05 +0100 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <414336.73225.qm@web38802.mail.mud.yahoo.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> Message-ID: <46BC211D.1090406@erlang-consulting.com> Although I might be put on the cross for this but I really enjoyed his way of reasoning about OO in Erlang. This is something I have frequently discussed with both co workers and others and the general opinion seems (note _seems_) to be that OO is a *bad* thing. However in this article I think we come across on something that is very important to note: "programming is modeling". The kind of programming I do (and I'm sure many with me in the commercial field) has to do more with design patterns and models more then math and theory (which sometimes can be nice as well :) ). I have to admit that when thinking processes I sometimes think "objects", but not object in the sense of a Java object, but rather more like Ralph describes in his review (mystical view I guess). Thinking about processes as object I find it easier for example to think about their state, their data include how they fit in the pattern or model. OO and Concurrency can work together and I think that sooner or later we will start to drift towards a happy marriage. Reading this article (http://www.pragmaticprogrammer.com/articles/erlang.html) I read: "The world IS concurrent. It IS parallel." And what does this world consist of? Well... objects... My 2 cents :) Thomas Lindgren wrote: > http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&entry=3364027251 > > Ralph Johnson (gang of four) praises Erlang in a > longish review of Joe's book. Great stuff from a > veteran; here is the payoff: > > "Erlang is going to be a very important language. It > could be the next Java. Its main problem is that there > is no big company behind it. Instead, it is being > pushed as an open source project. Its main advantage > is that it is perfectly suited for the multi-core, web > services future. In fact, it is the ONLY mature, > rock-solid language that is suitable for writing > highly scalable systems to run on multicore machines. > > ... > > I do not believe that other languages can catch up > with Erlang anytime soon. It will be easy for them to > add language features to be like Erlang. It will take > a long time for them to build such a high-quality VM > and the mature libraries for concurrency and > reliability. So, Erlang is poised for success. If you > want to build a multicore application in the next few > years, you should look at Erlang." > > Best, > Thomas > > > > > ____________________________________________________________________________________ > Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. > http://smallbusiness.yahoo.com/webhosting > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Mazen Harake From dunceor@REDACTED Fri Aug 10 10:41:25 2007 From: dunceor@REDACTED (=?UTF-8?Q?Karl_Sj=C3=B6dahl_-_dunceor?=) Date: Fri, 10 Aug 2007 10:41:25 +0200 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> Message-ID: <5d84cb30708100141s2898576bwdbb0b5bf81256c15@mail.gmail.com> Well, Ericsson is twice the size of Sun so I think it's kinda fair to call Ericsson a big company =) Well they do invest time and money in OTP but sure they do not use Erlang and try to market is like Sun is doing with Java. I do not think you can compare it like that, but I still feel it's wrong to claim that there isn't a big company behind Erlang. Br Dunceor On 8/10/07, Chris Wong wrote: > I think Ralph is referring to a big company as some company like Sun > or Microsoft who has a vested interest in seeing Java or C++/C# > become popular. They have a business plan for whatever programming > language they are pushing. > > For Ericsson, what's their incentive to push Erlang to make it > popular? Popularity of Erlang isn't going to help selling more > Ericsson switches or cell phones, is it? > > Chris > > On Aug 9, 2007, at 10:49 PM, Karl Sj?dahl - dunceor wrote: > > > Hello. > > > > A nice review that one thing that I keep hearing is that there is no > > big company behind Erlang and I feel that is not quite true. Ericsson > > is still a supporter of it and has full-time employees I thought to > > develop OTP? He even spelled Ericsson wrong in his blog also :P > > > > Nice blog at least. > > And this weekend I will finally have time to sit down and read Joe's > > book that I got almost two weeks ago. > > > > BR > > Dunceor > > > > On 8/10/07, Thomas Lindgren wrote: > >> http://www.cincomsmalltalk.com/userblogs/ralph/blogView? > >> showComments=true&entry=3364027251 > >> > >> Ralph Johnson (gang of four) praises Erlang in a > >> longish review of Joe's book. Great stuff from a > >> veteran; here is the payoff: > >> > >> "Erlang is going to be a very important language. It > >> could be the next Java. Its main problem is that there > >> is no big company behind it. Instead, it is being > >> pushed as an open source project. Its main advantage > >> is that it is perfectly suited for the multi-core, web > >> services future. In fact, it is the ONLY mature, > >> rock-solid language that is suitable for writing > >> highly scalable systems to run on multicore machines. > >> > >> ... > >> > >> I do not believe that other languages can catch up > >> with Erlang anytime soon. It will be easy for them to > >> add language features to be like Erlang. It will take > >> a long time for them to build such a high-quality VM > >> and the mature libraries for concurrency and > >> reliability. So, Erlang is poised for success. If you > >> want to build a multicore application in the next few > >> years, you should look at Erlang." > >> > >> Best, > >> Thomas > >> > >> > >> > >> > >> _____________________________________________________________________ > >> _______________ > >> Building a website is a piece of cake. Yahoo! Small Business gives > >> you all the tools to get online. > >> http://smallbusiness.yahoo.com/webhosting > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > From chsu79@REDACTED Fri Aug 10 10:47:44 2007 From: chsu79@REDACTED (Christian S) Date: Fri, 10 Aug 2007 10:47:44 +0200 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> Message-ID: What programming language do you want to be pushed into using today? 2007/8/10, Chris Wong : > For Ericsson, what's their incentive to push Erlang to make it > popular? Popularity of Erlang isn't going to help selling more > Ericsson switches or cell phones, is it? From francesco@REDACTED Fri Aug 10 11:01:20 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Fri, 10 Aug 2007 10:01:20 +0100 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <46BC211D.1090406@erlang-consulting.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> Message-ID: <46BC2960.6000705@erlang-consulting.com> Mazen Harake wrote: > Although I might be put on the cross for this but I really enjoyed his > way of reasoning about OO in Erlang. Yeah, you're fired ;-) Francesco -- http://www.erlang-consulting.com From rvg@REDACTED Fri Aug 10 11:31:29 2007 From: rvg@REDACTED (Rudolph van Graan) Date: Fri, 10 Aug 2007 11:31:29 +0200 Subject: [erlang-questions] Modelling question - concurrency and scalability Message-ID: <2873196D-B605-4FE1-9CD8-B6F234E5CB01@patternmatched.com> Hi Guys, Suppose you write an accounting system (like in an ordinary set of T accounts). Now you have a lot of transactions running concurrently, each one debiting one account and crediting another. An account may look like this: {account, ID, Debits, Credits} When we start the set of accounts look like this: (The debits and credits add up to 0) {account, 1, 0, 0} {account, 2, 0, 0} {account, 3, 0, 0} We define a transaction so: {transaction, ID, Amount, DebitAccount, CreditAccount} So we run these transactions against the accounts: {transaction, 1, 10 , 1, 2} {transaction, 2, 20 , 2, 3} {transaction, 3, 40 , 3, 1} {transaction, 4, 20 , 2, 1} The accounts should look like this at the end: {account, 1, 10, 60} (Balance = Credit 50) {account, 2, 40, 10} (Balance = Debit 30) {account, 3, 40, 20} (Balance = Debit 20) The Debits == Credits == 90 --> This means the system is in balance as it should be. Each transaction does the following: 1. Check if an account has sufficient credits to continue 2. Credit this account, Debit the other The problem here is that you need to modify two accounts for each transaction, but before you do that you need to know atomically what it's current balance is. In essence, if you have a small number of accounts and a large number of transactions you will have a large contention ratio on a single account. If you use mnesia (or any database for that matter), your system will only scale to the maximum rate at which the DBMS process transactions atomically. And then it seems as though you cannot scale anymore. Concurrency will not solve this problem. If you use SQL you have exactly the same problem: - start transaction - select the current balance of the account - if sufficient -- debit account 1 -- credit account 2 - commit transaction The key property here seems to be the fact that you always ADD to the values, never SUBTRACT. If you never had to know in a transaction what the "current" balance is, you can fix the problem. But IMO not when you need to check values atomically. Does anyone have suggestions on how one can solve the scalability problem here taking into account that you must know the current balance of the account before modifying it? A scheme where you split each account into smaller ones won't work, as you will have to sum all the smaller accounts to get the balance of the larger one. The more accounts you have and the more even the transactions are spread over the different accounts the easier it is to scale. But what do you do if this is not true? Rudolph From sean.hinde@REDACTED Fri Aug 10 11:44:31 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Fri, 10 Aug 2007 10:44:31 +0100 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <46BC2960.6000705@erlang-consulting.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> <46BC2960.6000705@erlang-consulting.com> Message-ID: <70660262-7B04-4866-907C-B407869CDDAD@gmail.com> On 10 Aug 2007, at 10:01, Francesco Cesarini wrote: > Mazen Harake wrote: >> Although I might be put on the cross for this but I really enjoyed >> his >> way of reasoning about OO in Erlang. > > Yeah, you're fired ;-) I'm reminded of a conversation with a previous manager ;-) He argued that as an Erlang user I was more object oriented in thinking than most of his C++ guys. And he did have a point, by some definition of object oriented (an old one I guess, where objects were "things" that communicated by sending messages - smalltalk). Sean From twa@REDACTED Fri Aug 10 11:06:43 2007 From: twa@REDACTED (Tom Ayerst) Date: Fri, 10 Aug 2007 10:06:43 +0100 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> Message-ID: <46BC2AA3.201@post.com> Hi, Do you have any links to articles about this problem? Thanks Tom Chris Wong wrote: > Second, I heard a lot that distributed Erlang doesn't scale in a large distributed environment with thousands of machine. I personally don't have any experience to > assert it one way or the other. > From kenneth.lundin@REDACTED Fri Aug 10 13:43:45 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 10 Aug 2007 13:43:45 +0200 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> Message-ID: I don't agree with you about the shortcomings, see below. On 8/10/07, Chris Wong wrote: > I enjoy this article. Thanks for forwarding. > > As much as I like to focus on the positive aspects of Erlang, there > are at least a couple short-comings of Erlang. One of them are > mentioned by Ralph Johnson in this article; Erlang doesn't have a > large company behind it. Ericsson is a wordleading telecommunications company and stands behind Erlang. It is true however that Ericsson is not marketing Erlang because Ericsson does not currently have sales and support of generic SW as a business case. But maybe that can change at least I hope that. Second, I heard a lot that distributed > Erlang doesn't scale in a large distributed environment with > thousands of machine. I personally don't have any experience to > assert it one way or the other. Erlang's internal distribution mechanism (between Erlang VM's) was not designed with the intention to support thousands of VM's communicating over the open internet. It was built to be used on a LAN with a relatively static number of VM's in a cluster (max 255 from the beginning, but that limit is removed now). Because of this there can be some problems with very large setups where thousends of VM's are connected simultaneously. It very much depends on what you do if it scales well. Erlang's distribution protocol is based on TCP/IP with a handshake and marshalling layer on top of that. Erlang's distribution protocol can easily be changed to be carried over something else than plain TCP/IP. There is a plugin architechture to do this. Distribution over SSL is one example which is included in the Open Source release. Erlang is also a superior language when it comes to implementation of application level protocols carried over TCP, UDP or other transport protocols. > > Both have been used by anti-Erlang camp. It makes it really hard to > advocate Erlang in a large company. For example, in a large > ccompany, there is usually a large investment already to solve the > large distributed computing problem in Java or C++. The usual > argument is that the tested and proven home-grown solution should be > used instead despite how much concurrency gain you'd have using Erlang. I am not aware of that Java or C++ has any built in distribution mechanisms that scales well or better than Erlang. As long as there is a protocol (home grown or standard) implemented in Java or C++ there is no problem to use the same protocol from Erlang. What I mean is that you can't put something as a shortcoming for Erlang and then comparing it with Java and C++ where there is no distribution concept at all(comparable with Erlangs) built in. > > It's a huge disappointment for me and a touch battle to fight. So what do you have to be dissapointed about when you compare with Java or C++? It can't be the distribution capabilities, can it? > > What are the mitigation for such short-comings in Erlang? See above. There are still shortcomings even in Erlang , I agree and how to adress them very much depends on what problems you want to solve with Erlang. Defining the problem or problems that are generic enough to be solved is the key. Then solving them should be straight forward. > > Thanks for any insight. > > Chris > /Kenneth (Responsible for Erlang/OTP within Ericsson > On Aug 9, 2007, at 3:25 PM, Thomas Lindgren wrote: > > > http://www.cincomsmalltalk.com/userblogs/ralph/blogView? > > showComments=true&entry=3364027251 > > > > Ralph Johnson (gang of four) praises Erlang in a > > longish review of Joe's book. Great stuff from a > > veteran; here is the payoff: > > > > "Erlang is going to be a very important language. It > > could be the next Java. Its main problem is that there > > is no big company behind it. Instead, it is being > > pushed as an open source project. Its main advantage > > is that it is perfectly suited for the multi-core, web > > services future. In fact, it is the ONLY mature, > > rock-solid language that is suitable for writing > > highly scalable systems to run on multicore machines. > > > > ... > > > > I do not believe that other languages can catch up > > with Erlang anytime soon. It will be easy for them to > > add language features to be like Erlang. It will take > > a long time for them to build such a high-quality VM > > and the mature libraries for concurrency and > > reliability. So, Erlang is poised for success. If you > > want to build a multicore application in the next few > > years, you should look at Erlang." > > > > Best, > > Thomas > > > > > > > > > > ______________________________________________________________________ > > ______________ > > Building a website is a piece of cake. Yahoo! Small Business gives > > you all the tools to get online. > > http://smallbusiness.yahoo.com/webhosting > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From alceste@REDACTED Fri Aug 10 12:30:49 2007 From: alceste@REDACTED (Alceste Scalas) Date: Fri, 10 Aug 2007 12:30:49 +0200 Subject: [erlang-questions] RFC: Erlang FFI In-Reply-To: <200708082246.l78MkQvg025535@snookles.snookles.com> References: <200708082246.l78MkQvg025535@snookles.snookles.com> Message-ID: <20070810123049.dxfxewefi80k8gwg@webmail.crs4.it> Scott Lystig Fritchie wrote: > Most of the Erlang<->C/C++ efforts have been SWIG-like efforts to > present as smooth an interface to the non-C side as possible. In > Erlang, IMHO(*), such integration has been even more important. At > least half of Erlang's advantage is its ability to survive faults(*), > and creating arbitrary interfaces into unknown shared libraries is a > good way to invalidate much/all of those survival mechanisms. > [...] > Such an interface to libffi makes it possible to create Erlang > interfaces to *any* shared library, without recompiling or relinking > or other steps. To create the same "smooth" interface, the glue ends > up being on the Erlang side of the divide. That philosophy is > opposite from most FFI efforts in the Erlang world. > > There are 2 main FFI camps, it seems to me(*): > > 1. I don't care about fault tolerance, I *must* access to function > F in library L, and to hell with the consequences of buggy > code. > > 2. I really care about fault tolerance ... because if I didn't, I > wouldn't bother with Erlang at all. I would like to point out something that I forgot to emphasize in my previous email: the expected uses of the FFI BIFs I'm proposing. Just like ddll:load/3, erlang:port_control/3 and friends, the FFI BIFs (ffi:call/3, ddll:load_library/3, ffi:call/2, ffi:ecall/3) are *not* intended to be used by "standard" Erlang developers. They are actually targeted at two kinds of, let's say, Erlang power developers: 1. library bindings developers; 2. developers that need to interface Erlang code with C/Fortran/Assembly/whatever (e.g. for performance reasons, thus making even the call speed a relevant factor). This is directly related to your fault-tolerance and stability worries. The FFI BIFs could be used to crash the Erlang VM more or less like a linked-in driver could [1]. But unaware developers that just want to use libfoo from Erlang are usually *not* directly exposed to the gore details of Erlang drivers: they don't see erlang:port_control/3 (or ffi:call/3), but a documented Erlang libfoo API that takes care of validating the parameters and performing the underlying machinery. If a developer decides to bypass this API layer and access libfoo by fiddling with erlang:port_control/3 (or ffi:call/3), then he/she is definitely on his/her own. The main difference between linked-in drivers and FFI BIFs, IMHO, is that ffi:call/3 and friends make it a lot easier to develop library bindings and to interface external code to Erlang, both for quick'n'dirty hacks and well-refined products. The FFI approach is also more powerful, expecially with the proposed ffi:ecall/3 BIF [2]. I agree when you write that, when safety and fault-tolerance are fundamental and "untrusted" code could not be allowed, the ideal solution would be to run the untrusted FFI code in a separate process. But it may require quite some work. From this point of view, I agree with Denis: instead of developing more-or-less transparent pipe driver with complicated serialization (as pointed out by Vlad), one may run one or more Erlang nodes with the unsafe stuff, and issue remote calls through a simplified API layer. This could be the cheaper and possibly more flexible way to obtain both FFI and greater fault-tolerance (at the price of speed, of course). And this approach could even be used with "untrusted" linked-in drivers. Regards, alceste Notes: [1] Well, one may program an erlang:port_control/3 C callback that reacts gracefully to every possible kind of garbage being received as binary data. But the same defensive programming could be done for C functions expected to be called through ffi:call/3. Being able to call arbitrary C functions through FFI BIFs doesn't prevent a library binding developer to create and document a set of "safe" C functions that could be called from Erlang, with the warning that other calls may have unexpected consequences. [2] Let's see an "extreme" scenario: something like ffi:ecall/3 with some glue code based on libffi closures would allow (at least in theory) to pass an Erlang fun() to the C side to be used as a callback, even from code that is completely Erlang-unaware (as an example: write a differential equation in Erlang and let the GNU Scientific Library integrate it). I didn't find a way (yet) to apply/3 an Erlang fun() from C code, but I didn't do much investigation in the Erlang VM internals. The possibility to call C-from-Erlang and Erlang-from-C, however, would increase the Erlang language interoperability to the levels of Python, Java, etc. -- Alceste Scalas CRS4 - http://www.crs4.it/ ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From joelr1@REDACTED Fri Aug 10 14:34:10 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 10 Aug 2007 13:34:10 +0100 Subject: [erlang-questions] What modules belong to an application? In-Reply-To: <595CD750-618F-4B00-81C9-DAE95AAFB59A@gmail.com> References: <595CD750-618F-4B00-81C9-DAE95AAFB59A@gmail.com> Message-ID: <532C0ADC-D70E-4CD4-BF7B-2437409638AC@gmail.com> Further research reveals that application:get_all_key(app) does the trick. On Aug 10, 2007, at 1:17 PM, Joel Reymont wrote: > What is the easiest way to determine the modules belonging to a > particular application? -- http://wagerlabs.com From joelr1@REDACTED Fri Aug 10 14:17:12 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 10 Aug 2007 13:17:12 +0100 Subject: [erlang-questions] What modules belong to an application? Message-ID: <595CD750-618F-4B00-81C9-DAE95AAFB59A@gmail.com> What is the easiest way to determine the modules belonging to a particular application? I would prefer to avoid having to parse the app file. I also notice that the module list is being kept in ETS by the application controller but there seems to be no way to pull this info out. Thanks, Joel -- http://wagerlabs.com From raimo+erlang-questions@REDACTED Fri Aug 10 14:47:42 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 10 Aug 2007 14:47:42 +0200 Subject: [erlang-questions] EEP activity Message-ID: <20070810124742.GB28558@erix.ericsson.se> I just want to announce that the first actual EEPs has entered the Erlang Enhancement Process. They are EEP 4, 5 and 6. Read more at http://www.erlang.org/eep.html and http://www.erlang.org/eeps/ -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From david.stokar@REDACTED Fri Aug 10 17:11:45 2007 From: david.stokar@REDACTED (David Stokar) Date: Fri, 10 Aug 2007 17:11:45 +0200 Subject: [erlang-questions] Question regarding problems in Joe's book Message-ID: <566df1990708100811w6fd0f3c1y24b02e80a966c62c@mail.gmail.com> Agreeing to Toby ( http://www.erlang.org/pipermail/erlang-questions/2007-July/028133.html) I got the following: -module(conc_problems). -export([start/2,start_server/0]). %% 2> c(conc_problems). %% {ok,conc_problems} %% 3> conc_problems:start_server(). This starts the registration server (A singleton) %% true %% 4> conc_problems:start(foo2, fun area_server1:loop/0). This calls the registration method on the above singleton server %% Received:{foo2,#Fun} %% Undef:foo2 %% {foo2,#Fun,{success,<0.46.0>}} %% 5> conc_problems:start(foo2, fun area_server1:loop/0). %% Received:{foo2,#Fun} %% Def: <0.46.0>:{foo2,#Fun} %% {foo2,#Fun,{fail,<0.46.0>}} %% 6> foo2 ! {self(),{circle, 9}}. %% {<0.31.0>,{circle,9}}Server: Area of circle is 254.469 %% start/2 %% start(AnAtom, Fun) to register AnAtom as spawn(Fun). %% Make sure your program works correctly in the case when two %% parallel processes simultaneously evaluate start/2. In this case, %% you must guarantee that one of these processes succeeds and the %% other fails. start(AnAtom,Fun) -> rpc(starter, {AnAtom,Fun}). %% start_server() %% Starts the server loop and registers %% the process as starter start_server() -> register(starter,spawn(fun() -> loop([]) end)). %% rpc(Pid, Request) %% Forwards Request to Server Pid %% Makes process wait for Response from Server rpc(Pid, Request) -> Pid ! {self(), Request}, receive {Pid, Response} -> Response after 3000 -> io:format("Rpc timed out") end. %% start_fun %% Starts fun Fun and registers %% it as AnAtom if undefined %% Returns: %% {success, PID} if undefined %% {fail, PID} if allready registered start_fun(undefined,{AnAtom,Fun}) -> io:format("Undef:~p~n" ,[AnAtom]), PID = spawn(Fun), register(AnAtom,PID), {success,PID}; start_fun(PID,X) -> io:format("Def: ~p:~p~n", [PID,X]), {fail,PID}. %% loop(x) %% Processes messages send to the server %% Prints the message out loop(X) -> receive {Pid, {AnAtom, Fun}} -> io:format("Received:~p~n" ,[{AnAtom, Fun}]), REG = whereis(AnAtom), Status = start_fun(REG, {AnAtom,Fun}), %% self() has to be replaced by starter %% because self() == starter evaluates to false %% rpc waits for {starter, Response} Pid ! {starter,{AnAtom, Fun, Status}}, loop(X) end. The circle: (Without timer) -module(conc_problems_ring). -compile(export_all). %% start_ring(N,M, Mesg) %% N number of processes in Ring %% M number of roundings %% Mesg the message to transport start_ring(N,M,Mesg) -> [Head|Pids] = [ start() || _ <- lists:seq(1,N)], Head ! {self(), {Pids, [], M}, Mesg}. %% start() %% Starts the server loop start() -> spawn(fun() -> loop([]) end). %% rpc(Pid, Request) %% Forwards Request to Server Pid %% Makes process wait for Response from Server rpc(Pid, Request) -> Pid ! {self(), Request}, receive {Pid, Response} -> Response end. %% loop(x) %% Processes messages send to the server %% Prints the message out loop(X) -> receive {_, {Pids,VisitedPids,Rounds}, Message} -> io:format("~nReceived: ~p Pid: ~p Round: ~p~n" ,[Message, self(), Rounds]), {TagNP, {NPs, NVPs, NRounds}} = next_pid(Pids, VisitedPids, Rounds), case {TagNP, NRounds} of {last,_} -> io:format(" finished last~n"), true; {NP,0} -> io:format(" finished~n"), NP ! {self(), {NPs, NVPs, NRounds}, Message}, true; {NP,_} -> io:format(" pass on~n"), NP ! {self(), {NPs, NVPs, NRounds}, Message}, loop(X) end end. %% next_pid(NextPids, PassedPids, Rounds) %% Returns the next Pid out of the NextPids list %% If NextPids is empty, we finished a round %% and decrease the value of Rounds. %% We can then restart by taking PassedPids as next Pids next_pid([],_,0) -> {last,{[],[],[]}}; next_pid([],[NP|R],M) -> {NP,{R,[self()],M-1}}; next_pid([NP|R],X,M) -> {NP,{R,[self()|X],M}}. Session: 1> c(conc_problems_ring). {ok,conc_problems_ring} 2> conc_problems_ring:start_ring(3,2,"Hi"). {<0.31.0>,{[<0.39.0>,<0.40.0>],[],2},"Hi"} Received: "Hi" Pid: < 0.38.0> Round: 2 pass on Received: "Hi" Pid: <0.39.0> Round: 2 pass on Received: "Hi" Pid: <0.40.0> Round: 2 pass on Received: "Hi" Pid: < 0.39.0> Round: 1 pass on Received: "Hi" Pid: <0.38.0> Round: 1 finished Received: "Hi" Pid: <0.39.0> Round: 0 finished Received: "Hi" Pid: < 0.40.0> Round: 0 finished last 3> Enjoy David Stokar -------------- next part -------------- An HTML attachment was scrubbed... URL: From zac@REDACTED Fri Aug 10 16:39:53 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 10 Aug 2007 10:39:53 -0400 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <46BC211D.1090406@erlang-consulting.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> Message-ID: <46BC78B9.1080906@zacbrown.org> Well any server-client model could be thought of as object oriented, if you're considering threading etc. Since you're spawning multiple processes that do the same thing, its the same idea as having multiple objects doing the same thing though I think creating a group of objects in Java with the same kind of concurrency would be somewhat more difficult. Either way I understand your reasoning and I would say that concurrent programming in Erlang "resembles" object oriented programming but isn't true object orientation in the Java/C++ sense. My only other qualm with that article is (at least to me) the author seemed to belittle the functional aspect of Erlang. I think thats somewhat of a naive look at the language seeing as the functional aspect is what helps make Erlang reliable. All the minimizing of most of the side effects is an important trait in Erlang due to its functional nature. I can see his point but I still think he counted that aspect of the language a little too trivially. Zac Mazen Harake wrote: > Although I might be put on the cross for this but I really enjoyed his > way of reasoning about OO in Erlang. This is something I have frequently > discussed with both co workers and others and the general opinion seems > (note _seems_) to be that OO is a *bad* thing. However in this article I > think we come across on something that is very important to note: > "programming is modeling". The kind of programming I do (and I'm sure > many with me in the commercial field) has to do more with design > patterns and models more then math and theory (which sometimes can be > nice as well :) ). > > I have to admit that when thinking processes I sometimes think > "objects", but not object in the sense of a Java object, but rather more > like Ralph describes in his review (mystical view I guess). Thinking > about processes as object I find it easier for example to think about > their state, their data include how they fit in the pattern or model. OO > and Concurrency can work together and I think that sooner or later we > will start to drift towards a happy marriage. Reading this article > (http://www.pragmaticprogrammer.com/articles/erlang.html) I read: "The > world IS concurrent. It IS parallel." And what does this world consist > of? Well... objects... > > My 2 cents :) > > Thomas Lindgren wrote: >> http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&entry=3364027251 >> >> Ralph Johnson (gang of four) praises Erlang in a >> longish review of Joe's book. Great stuff from a >> veteran; here is the payoff: >> >> "Erlang is going to be a very important language. It >> could be the next Java. Its main problem is that there >> is no big company behind it. Instead, it is being >> pushed as an open source project. Its main advantage >> is that it is perfectly suited for the multi-core, web >> services future. In fact, it is the ONLY mature, >> rock-solid language that is suitable for writing >> highly scalable systems to run on multicore machines. >> >> ... >> >> I do not believe that other languages can catch up >> with Erlang anytime soon. It will be easy for them to >> add language features to be like Erlang. It will take >> a long time for them to build such a high-quality VM >> and the mature libraries for concurrency and >> reliability. So, Erlang is poised for success. If you >> want to build a multicore application in the next few >> years, you should look at Erlang." >> >> Best, >> Thomas >> >> >> >> >> ____________________________________________________________________________________ >> Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. >> http://smallbusiness.yahoo.com/webhosting >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From chris@REDACTED Fri Aug 10 19:22:00 2007 From: chris@REDACTED (Chris Wong) Date: Fri, 10 Aug 2007 10:22:00 -0700 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> Message-ID: <54852223-6BCD-4B01-8C08-9D21B3B782A8@chriswongstudio.com> On Aug 10, 2007, at 4:43 AM, Kenneth Lundin wrote: > I don't agree with you about the shortcomings, see below. > > Ericsson is a wordleading telecommunications company and stands > behind Erlang. > It is true however that Ericsson is not marketing Erlang because > Ericsson does not currently have sales and support of generic SW as a > business case. But maybe that can change at least I hope that. I agree. That's precisely the problem. i.e., no company is behind pushing the language to make it popular. Ideally, we don't have to do that in order for a programming language to succeed (by popular votes). I'm finding out that executives have a tough time swallowing something based on purely technical reasons. They want insurance. Someone to support them if problem arises. It's not in their core competency to build up expertise in how an Erlang VM works, for example. (Just one of the many arguments...) And they're cheap, they want a large community like Java and with free indirect support from Sun because Sun is totally committed to the Java platform. I personally think this is lame because there are other languages used in a company successfully with less than such level of implied support behind it. >> Second, I heard a lot that distributed >> Erlang doesn't scale in a large distributed environment with >> thousands of machine. I personally don't have any experience to >> assert it one way or the other. > Erlang's internal distribution mechanism (between Erlang VM's) was > not designed > with the intention to support thousands of VM's communicating over the > open internet. It was built to be used on a LAN with a relatively > static number of VM's in a cluster (max 255 from the beginning, but > that limit is removed now). > Because of this there can be some problems with very large setups > where thousends of VM's are connected simultaneously. It very much > depends on what you do if it scales well. I was reading the doc on this. It's consistent with what you say here. Basically, if you have to wait for thousands of Erlang nodes to establish communications with each other before you it can do anything, the whole will crawl to its knees when one node is down. Correct me if I'm wrong. > Erlang's distribution protocol is based on TCP/IP with a handshake and > marshalling layer on top of that. > Erlang's distribution protocol can easily be changed to be carried > over something else than plain TCP/IP. There is a plugin architechture > to do this. Distribution over SSL is one example which is included in > the Open Source release. > Erlang is also a superior language when it comes to implementation of > application level protocols carried over TCP, UDP or other transport > protocols. This is no difference from Java/C++. i.e., my company has already built that in Java/C++, for example. >> >> Both have been used by anti-Erlang camp. It makes it really hard to >> advocate Erlang in a large company. For example, in a large >> ccompany, there is usually a large investment already to solve the >> large distributed computing problem in Java or C++. The usual >> argument is that the tested and proven home-grown solution should be >> used instead despite how much concurrency gain you'd have using >> Erlang. > I am not aware of that Java or C++ has any built in distribution > mechanisms that No, Java/C++ doesn't have built-in distribution mechanism. That actually makes it worse since a company would have already invested heavily in some kind of home-grown solution. > scales well or better than Erlang. As long as there is a protocol > (home grown or standard) implemented in Java or C++ there is no > problem to use the same protocol from Erlang. > What I mean is that you can't put something as a shortcoming for > Erlang and then comparing it with Java and C++ where there is no > distribution concept at all(comparable with Erlangs) built in. So, if a company has already had home-grown solutions that scales better than Erlang's built-in distributed feature set, Erlang's builti-in distributed feature isn't a selling point any more. >> >> It's a huge disappointment for me and a touch battle to fight. > So what do you have to be dissapointed about when you compare with > Java or C++? It can't be the distribution capabilities, can it? It's not about the language. It's the platform that's already built internal in a company. If this was a new start-up, the decision would be easy. :-) Generally, I'm not disagreeing with you at all. Thanks Chris From jilani@REDACTED Fri Aug 10 16:50:56 2007 From: jilani@REDACTED (Jilani Khaldi) Date: Fri, 10 Aug 2007 16:50:56 +0200 Subject: [erlang-questions] Erlang is 47th, Java firtst! In-Reply-To: <46BC438C.3080309@cheapnet.it> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> <46BC2960.6000705@erlang-consulting.com> <70660262-7B04-4866-907C-B407869CDDAD@gmail.com> <46BC438C.3080309@cheapnet.it> Message-ID: <46BC7B50.8060603@cheapnet.it> http://www.tiobe.com/tpci.htm Erlang is 47th, but Java is first!!! Marketing has done a miracle. jk -- Jilani KHALDI http://jkhaldi.oltrelinux.com From fritchie@REDACTED Fri Aug 10 21:05:53 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 10 Aug 2007 14:05:53 -0500 Subject: [erlang-questions] Erlang with BDB In-Reply-To: Message of "Thu, 09 Aug 2007 13:13:50 +0400." Message-ID: <200708101905.l7AJ5sHM049652@snookles.snookles.com> >>>>> "aai" == Ahmed Ali writes: aai> I'd like to use an external BerkeleyDB (BDB) with Erlang. Ahmed -- See http://www.snookles.com/erlang/edtk/. Again, many thanks to Chris Newcombe for the many Berkeley DB-specific enhancements to that package. -Scott From zac@REDACTED Fri Aug 10 19:40:07 2007 From: zac@REDACTED (Zac Brown) Date: Fri, 10 Aug 2007 13:40:07 -0400 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> <46BC78B9.1080906@zacbrown.org> Message-ID: <46BCA2F7.9020203@zacbrown.org> Well I suppose thats true in ways though to me when different functions are written functionally you're drastically narrowing down where your bugs are and more often than not you can just take a moment to think about the code and rationalize where your bottleneck in your message passing is but I do see your point no less. Zac Nohl Attila Rajmund wrote: > On Fri, 10 Aug 2007, Zac Brown wrote: > [...] >> My only other qualm with that article is (at least to me) the author >> seemed to belittle the functional aspect of Erlang. I think thats >> somewhat of a naive look at the language seeing as the functional aspect >> is what helps make Erlang reliable. All the minimizing of most of the >> side effects is an important trait in Erlang due to its functional >> nature. I can see his point but I still think he counted that aspect of >> the language a little too trivially. > > I'm not sure he's wrong. The "no side effect" slogans of functional > languages sound great, but as soon as you put a ! into your function, > you've got a side effect - and you do it pretty soon, because the strong > point of Erlang is the concurrency, so you have a good number of > processes (even if it's hidden in OTP). So - in my experience - the > functional nature is a drawback of the language, it leads to clumsy code > like this: > > HR1=HugeRecord#hugeRecord{someField=NewValue}, > ... > HR2=HR1#hugeRecord{someOtherField=OtherValue}, > ... > HR3=HR2#hugeRecord{someReallyOtherField=ReallyOtherValue}, > > In one function I saw HR7 (some earlier HR* were deleted). It could lead > to really hard to catch bugs if someone uses HR1 even after HR2 was > updated. > Bye,NAR > From toby@REDACTED Sat Aug 11 00:31:57 2007 From: toby@REDACTED (Toby Thain) Date: Fri, 10 Aug 2007 19:31:57 -0300 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <5d84cb30708092249n2902b884yf3b564a0a89e03b8@mail.gmail.com> <9220553F-A360-4CD8-B5C4-109B0FBD1F99@chriswongstudio.com> Message-ID: <72EE4DBA-BD34-44EF-A15C-72870A9EBC2D@smartgames.ca> On 10-Aug-07, at 5:47 AM, Christian S wrote: > What programming language do you want to be pushed into using today? TOUCH?!!!! --Toby > > 2007/8/10, Chris Wong : >> For Ericsson, what's their incentive to push Erlang to make it >> popular? Popularity of Erlang isn't going to help selling more >> Ericsson switches or cell phones, is it? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm@REDACTED Sat Aug 11 04:05:34 2007 From: jeffm@REDACTED (jm) Date: Sat, 11 Aug 2007 12:05:34 +1000 Subject: [erlang-questions] Modelling question - concurrency and scalability In-Reply-To: <2873196D-B605-4FE1-9CD8-B6F234E5CB01@patternmatched.com> References: <2873196D-B605-4FE1-9CD8-B6F234E5CB01@patternmatched.com> Message-ID: <46BD196E.8010401@ghostgun.com> Some random thoughts: * Use multiple mnesia databases, if this proves implausible, * write your own database with say 5-100 accounts per process (group) and one DETS instance for each of these process (groups). Then, construct an account name server (acct) which is responsible for locating the account and provides interface functions for carrying out the transaction. The basic process may go something like this, very rough, For {transaction, ID, Amount, DebitAccount, CreditAccount} DAPid = acct:find_account_pid(DebitAccount), CAPid = acct:find_account_pid(CreditAccount), acct:transaction(DAPid, DebitAccount, CAPid, CreditAccount, Amount). -module(acct). register_acct(Pid, Acct) -> %% puts account in an ETS table unregister_acct(Pid, Acct) -> %% remove account from ETS table find_acct(Acct) -> %% finds Pid in ETS table transaction(TransFun, DAPid, DAcct, CAPid, CAcct, Amount) -> %% here be dragons - race condition exist %% this is the key function suggest looking at Mnesia code DAOldState = get_state(DAPid, DAcct), CAOldState = get_state(CAPid, CAPid), try debit(DAPid, DAcct, Amount), credit(CAPid, CAcct, Amount) ok catch %% unwind/rollback on failure restore_state(DAPid, DAcct, Amount) restore_state(CAPid, CAcct, Amount) fail end. start() -> % starts server process by calling init stop() -> % stops server process init(Args) -> % real I was flipping through "Programming Erlang" as I remember seeing something on transaction in chapter 12 that deals with OTP Genric Server and found example server 2 on page 297 which may be of interest. Lastly, I'd record the steps between account balances so that you have an audit trail, eg {account, ID, Debit, Credit} would be come {account, ID, Debit, Credit, [Transactions]} at least logically. Though it would be more like a journal in the sense of a file system, not an accounting journal. Thinking about it modeling each account as a journal may reduce or elimiate the need for cross process locking. As I said in the open random thoughts. Let me know how you go as I'm interested to know the solution. Jeff. From henrique.ferreiro@REDACTED Sat Aug 11 11:27:17 2007 From: henrique.ferreiro@REDACTED (Henrique Ferreiro) Date: Sat, 11 Aug 2007 11:27:17 +0200 Subject: [erlang-questions] time consuming process Message-ID: <1186824437.11445.2.camel@macbook> Hello! I have developed an erlang application but sometimes it consumes 100% of the CPU. I found a set of tools on the net called eper to help debugging this kind of problems, being sherk a profiler which could help me. The problem is that there are no docs and I don't know how to use it. I hope somebody could help me with this program or suggest another way to profile my application. Thanks in advance, -- Henrique Ferreiro From dcaoyuan@REDACTED Sat Aug 11 18:26:37 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Sun, 12 Aug 2007 00:26:37 +0800 Subject: [erlang-questions] ErlyBird 0.12.1 released - Erlang IDE based on NetBeans Message-ID: By refining the LL(k) definition of Erlang syntax, I've got ErlyBird parsing performance improved a lot, for example, the time of indexing whole OTP libs is cut to half now. The LL(k) definition of Erlang syntax can be found at: http://erlybird.svn.sourceforge.net/viewvc/erlybird/trunk/erlybird/erlybird-erlang-editor/src/org/netbeans/modules/languages/erlang/Erlang.nbs?revision=296&view=markup And this is the first time, ErlyBird works smoothly enough in my compter. For more information, please go to http://blogtrader.net/page/dcaoyuan?entry=erlybird_0_12_1_released -- - Caoyuan From jilani@REDACTED Sat Aug 11 19:17:18 2007 From: jilani@REDACTED (Jilani Khaldi) Date: Sat, 11 Aug 2007 19:17:18 +0200 Subject: [erlang-questions] How to put a guard? Message-ID: <46BDEF1E.5000906@cheapnet.it> Hi All, I am trying to write a function that returns the position of an element inside a list and the code works "partially", seen I couldn't find a way to obtain what I want: position:pos1(a,[e,r,l,a,n,g]). => 4 (ok), but position:pos1(k,[e,r,l,a,n,g]). => Error in process <0.30.0> with exit... I want it to return 0 This is the code: -module(position). -export([pos1/2, pos2/2]). % recurion % pos1(X, []) -> 0; doesn't work pos1(X, [X|_]) -> 1; pos1(X, [_|T]) -> 1+position(X,T). %tail recursion pos2(X, L) -> position(X, L, 0). position(X, [X|_], N) -> 1+N; position(X, [_|T], N) -> mypos(X, T, 1+N). Thanks! Jilani From dae@REDACTED Sat Aug 11 18:24:38 2007 From: dae@REDACTED (dae@REDACTED) Date: Sat, 11 Aug 2007 09:24:38 -0700 Subject: [erlang-questions] gs:read Message-ID: <20070811092438.4D5E48BA@resin11.mta.everyone.net> An HTML attachment was scrubbed... URL: From igwan@REDACTED Sat Aug 11 20:38:22 2007 From: igwan@REDACTED (igwan) Date: Sat, 11 Aug 2007 20:38:22 +0200 Subject: [erlang-questions] How to put a guard? In-Reply-To: <46BDEF1E.5000906@cheapnet.it> References: <46BDEF1E.5000906@cheapnet.it> Message-ID: <46BE021E.1060902@free.fr> Hello, > %tail recursion > pos2(X, L) -> position(X, L, 0). > position(X, [X|_], N) -> 1+N; > position(X, [_|T], N) -> mypos(X, T, 1+N). > Where does mypos/3 come from ? Also, in your tail recursion code, you don't handle the case where the list is empty. You don't need a guard to do this. Something like this should work pos(List, X) -> pos(List, X, 1). pos([], _, _) -> 0; pos([X|_], X, N) -> N; pos([_|T], X, N) -> pos(T, X, N + 1). igwan From gamehack@REDACTED Sat Aug 11 20:41:55 2007 From: gamehack@REDACTED (Milen Georgiev Dzhumerov) Date: Sat, 11 Aug 2007 19:41:55 +0100 Subject: [erlang-questions] General advice on FP (& Erlang) Message-ID: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> Hi all, I've got a couple of questions. I'm probably not the first person who is struggling to switch to a functional mindset. So, hopefully, any replies to my questions will help other people too! The way I got started is by reading the "Programming Erlang" book by Joe (great book btw). As I was reading the book, everything seemed so obvious and easy but when I'm trying to do something myself - I just can't. I always go back to my "shared state" mind and don't seem to be able come up with a design and a plan on how to implement it. So, what are you guys (who get FP) suggesting I do? I think the problem comes from having C hardwired into my brain and I can't get it out. And I definitely have got to ask this - how are we supposed to mutate state? Using processes? Function calls? I just can't wrap my head around how some C code is going to be translated. Let's take a simple example. I'm writing a network app in Erlang which accepts "messages" on a socket, where a "message" is defined as length:content. If I was to do this in C, I would have a function which gets called every time bytes arrive on the socket and then depending on which state I'm in, I'm either going to append the bytes to a length buffer and when I reach the ":" character, I'll change the state and start appending to the content buffer (while decrementing the number of bytes still left to be read). Now all of this depends on having access to mutable buffers (& a counter) outside the scope of the functions - at this point I'm lost on how to do it in Erlang. How would guys start solving this problem? Obviously, the more experience you have, the less thinking you're going to put into this and the solution is going to come up naturally, but what about people who haven't had any real world experience with FP? Thanks, Milen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2419 bytes Desc: not available URL: From jesper.louis.andersen@REDACTED Sat Aug 11 21:16:29 2007 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sat, 11 Aug 2007 21:16:29 +0200 Subject: [erlang-questions] General advice on FP (& Erlang) In-Reply-To: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> References: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> Message-ID: <56a0a2840708111216s73d12e1ft38695204d1a49029@mail.gmail.com> On 8/11/07, Milen Georgiev Dzhumerov wrote: > And I definitely have got to ask this - how are we supposed to mutate > state? Using processes? Function calls? I just can't wrap my head > around how some C code is going to be translated. If your code is a basic block, you are effectively writing in a form where each value you declare is 'fresh': A1 = foo(), A2 = bar(A1), A3 = baz(A2). % etc In the above case you are lucky and able to change that into: baz(bar(foo())). So as long as no loops are involved, things are somewhat uncomplicated. As soon as you want a loop, you must think in recursion and preferably tail-recursion at that so you won't produce any excess stack. It will take a couple of days to wrap your brain around. And then you will never ever look back >:-) Let's take a simple example. I'm writing a network app in Erlang > which accepts "messages" on a socket, where a "message" is defined as > length:content. If I was to do this in C, I would have a function > which gets called every time bytes arrive on the socket and then > depending on which state I'm in, I'm either going to append the bytes > to a length buffer and when I reach the ":" character, I'll change > the state and start appending to the content buffer (while > decrementing the number of bytes still left to be read). > Now all of this depends on having access to mutable buffers (& a > counter) outside the scope of the functions - at this point I'm lost > on how to do it in Erlang. How would guys start solving this problem? > Obviously, the more experience you have, the less thinking you're > going to put into this and the solution is going to come up > naturally, but what about people who haven't had any real world > experience with FP? The above looks a lot like a bittorrent bencoding. The socket reads apart, that can be parsed with: attempt_string_decode(String) -> {Number, Data} = lists:splitwith(charPred($:), String), {ParsedNumber, _} = string:to_integer(Number), Rest1 = tl(Data), % Skip the $: {StrData, Rest} = lists:split(ParsedNumber, Rest1), {{string, StrData}, Rest}. Since we expect a number, we use lists:splitwith to find the first occurence of a ':' character. Then we are given back a Number and some Data. In the next line, we convert the Number (which is a string) into an integer. Then we skip the ':' character in the original data stream. Now, the call lists:split can break apart the Data you call 'content'. We return the string with a tag and the part of the original string we did not parse in this run. Subsequent calls with different functions on this Rest parameter can parse the following data in the String. Note, though, that we are not taking the socket into account with the above. If you want to do that, you must read enough data off the socket to do the integer-part of the parse and then read the missing amount of bytes in order to fetch the whole message. If you have control over the socket-format you may wish to chose a format where data arrives as a 4-byte 32-bit big endian integer which is the size of a message that follows. That is, the format is <> where size(Rest) = Size. The reason for this is that a process controlling a socket may then call inet:setopts(Socket, [{active, true}, {packet, 4}]). which will wire the socket such that Erlangs C-layer will parse the 4-byte 32-bit big endian size, fetch the message and send it as a message to your process as {tcp, Socket, Message}. For more information, see the kernel documentation for inet and gen_tcp. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jilani@REDACTED Sat Aug 11 21:20:42 2007 From: jilani@REDACTED (Jilani Khaldi) Date: Sat, 11 Aug 2007 21:20:42 +0200 Subject: [erlang-questions] How to put a guard? Solved! In-Reply-To: <46BE021E.1060902@free.fr> References: <46BDEF1E.5000906@cheapnet.it> <46BE021E.1060902@free.fr> Message-ID: <46BE0C0A.2090403@cheapnet.it> igwan wrote: > Hello, >> %tail recursion >> pos2(X, L) -> position(X, L, 0). >> position(X, [X|_], N) -> 1+N; >> position(X, [_|T], N) -> mypos(X, T, 1+N). >>Where does mypos/3 come from ? Sorry, it is "position(X, T, 1+N).". The question has been solved, thank you. Jilani From erlangx@REDACTED Sat Aug 11 21:40:52 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Sat, 11 Aug 2007 12:40:52 -0700 Subject: [erlang-questions] General advice on FP (& Erlang) In-Reply-To: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> References: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> Message-ID: <20070811194052.GL6200@delora.autosys.us> Here's an old post I did. Other than version numbers, I think it will still be pertinent ... http://www.erlang.org/pipermail/erlang-questions/2005-December/018239.html ~Michael On Sat, Aug 11, 2007 at 07:41:55PM +0100, Milen Georgiev Dzhumerov wrote: > Hi all, > > I've got a couple of questions. I'm probably not the first person who > is struggling to switch to a functional mindset. So, hopefully, any > replies to my questions will help other people too! > > The way I got started is by reading the "Programming Erlang" book by > Joe (great book btw). As I was reading the book, everything seemed so > obvious and easy but when I'm trying to do something myself - I just > can't. I always go back to my "shared state" mind and don't seem to > be able come up with a design and a plan on how to implement it. > > So, what are you guys (who get FP) suggesting I do? I think the > problem comes from having C hardwired into my brain and I can't get > it out. > > And I definitely have got to ask this - how are we supposed to mutate > state? Using processes? Function calls? I just can't wrap my head > around how some C code is going to be translated. > > Let's take a simple example. I'm writing a network app in Erlang > which accepts "messages" on a socket, where a "message" is defined as > length:content. If I was to do this in C, I would have a function > which gets called every time bytes arrive on the socket and then > depending on which state I'm in, I'm either going to append the bytes > to a length buffer and when I reach the ":" character, I'll change > the state and start appending to the content buffer (while > decrementing the number of bytes still left to be read). > Now all of this depends on having access to mutable buffers (& a > counter) outside the scope of the functions - at this point I'm lost > on how to do it in Erlang. How would guys start solving this problem? > Obviously, the more experience you have, the less thinking you're > going to put into this and the solution is going to come up > naturally, but what about people who haven't had any real world > experience with FP? > > Thanks, > Milen > > !DSPAM:52,46be032273321257317690! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,46be032273321257317690! -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From chris.newcombe@REDACTED Fri Aug 10 21:13:52 2007 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Fri, 10 Aug 2007 12:13:52 -0700 Subject: [erlang-questions] Erlang with BDB In-Reply-To: <781dd98c0708091448s3b71360bk72a6f0e039349fd3@mail.gmail.com> References: <781dd98c0708091448s3b71360bk72a6f0e039349fd3@mail.gmail.com> Message-ID: <781dd98c0708101213t11090c60t71147cfe20754a2d@mail.gmail.com> Sending this again as I apparently hit 'reply' instead of 'reply all'. Chris On 8/9/07, Chris Newcombe wrote: > > > >> Has any one here used BDB with Erlang before? > >> Can anyone share his experience with Erlang & BDB? > > Yes. In my opinion and experience, BDB is an excellent match for Erlang. > For instance, BDB is implemented as a C library and it has such > high code-quality that it is relatively low risk to use it directly from > inside the Erlang VM as a port-driver (shared library). This gives you a > very high performance, concurrent, local-disk transactional store for > arbitrary Erlang data. > > Also, BDB's replication technology is a very interesting option for adding > fault-tolerance and scalability to many types of system. > > I recently spent considerable time enhancing Scott Lystig Fritchie's EDTK > project to improve support for BDB, and add support for BDB-HA. You can > find it here: > > http://www.snookles.com/erlang/edtk/ > > Important: BDB a 'sharp tool' that can be painful if you mis-use it. I > spent a lot of time making the interface between Erlang and BDB as seemless, > natural, and safe as possible (while retaining high performance). But if > you abuse the BDB API ( i.e. violate the documented pre-conditions on a > given function, by calling them in the wrong order) then you can still cause > any amount of havoc. Please read the following file careful before use. > > http://www.snookles.com/erlang/edtk/edtk-1.5.1.README-cnewcom > > I hope this helps, > > Chris > > > On 8/9/07, Ahmed Ali wrote: > > > Hi All, > > > > I'd like to use an external BerkeleyDB (BDB) with Erlang. Mnesia is good > > for me but requirements are to use BDB or MySQL. I searched in the internet > > and found that MySQL has more support for Erlang than BDB but I want to use > > BDB. Has any one here used BDB with Erlang before? Can anyone share his > > experience with Erlang & BDB? Any information is appreciated. Thanks. > > > > Best regards, > > > > Ahmed Al-Issaei > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Sat Aug 11 21:30:37 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 11 Aug 2007 14:30:37 -0500 Subject: [erlang-questions] How to put a guard? In-Reply-To: <46BDEF1E.5000906@cheapnet.it> References: <46BDEF1E.5000906@cheapnet.it> Message-ID: <46BE0E5D.3090206@gmail.com> Jilani Khaldi wrote: > Hi All, > I am trying to write a function that returns the position of an element > inside a list and the code works "partially", seen I couldn't find a way > to obtain what I want: > position:pos1(a,[e,r,l,a,n,g]). => 4 (ok), but > position:pos1(k,[e,r,l,a,n,g]). => Error in process <0.30.0> with exit... > I want it to return 0 > > This is the code: > -module(position). > -export([pos1/2, pos2/2]). > > % recurion > % pos1(X, []) -> 0; doesn't work > pos1(X, [X|_]) -> 1; > pos1(X, [_|T]) -> 1+position(X,T). Because of the nature of recursion by the time the whole list is scanned, the result already performed N additions, so returning 0 at the last step won't be expected result. You can resolve this with an accumulator so that the decision on what needs to be returned performed by the last iteration of the function, or throw/catch an exception. Here's a solution that does what you need: -module(position). -export([position/2, p/2, t/2]). % recursion p(X, L) -> catch pos(X, L). pos(X, [X|_]) -> 1; pos(X, [_|T]) -> 1+pos(X,T); pos(_, []) -> throw(0). % tail recursion position(X, L) -> position(X, L, 1). position(X, [X|_], N) -> N; position(X, [_|T], N) -> position(X, T, 1+N); position(_, [], _) -> 0. t(1, F) -> F(); t(N, F) -> F(), t(N-1, F). Note that throwing an exception as well as traversing call stack adds a cost (~ 600 ns/call): 28> F1 = fun()->position:p(a,[e,r,l,a,n,g]) end. #Fun 29> F2 = fun()->position:p(k,[e,r,l,a,n,g]) end. #Fun 32> F3 = fun()->position:position(a,[e,r,l,a,n,g]) end. #Fun 33> F4 = fun()->position:position(k,[e,r,l,a,n,g]) end. #Fun 34> Eval = fun(F, N) -> {T, _} = timer:tc(position, t, [N, F])), T/N end. #Fun 35> [Eval(F, 100000) || F <- [F1, F2, F3, F4]]. [10.0000,10.6200,9.84999,9.99999] % mks/call Serge From igwan@REDACTED Sat Aug 11 22:40:45 2007 From: igwan@REDACTED (igwan) Date: Sat, 11 Aug 2007 22:40:45 +0200 Subject: [erlang-questions] General advice on FP (& Erlang) In-Reply-To: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> References: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> Message-ID: <46BE1ECD.4030603@free.fr> Hello Milen, Milen Georgiev Dzhumerov a ?crit : > And I definitely have got to ask this - how are we supposed to mutate > state? Using processes? Function calls? I just can't wrap my head > around how some C code is going to be translated. In FP, your state is kept in your function arguments. You call your function with your initial state in the arguments, you do your stuff and pass modified state (arguments) to the same function, and again ... This is recursion and this is how you modify your state. When you reach a certain state (certain conditions are met on your arguments), you return the result. > > Let's take a simple example. I'm writing a network app in Erlang which > accepts "messages" on a socket, where a "message" is defined as > length:content. If I was to do this in C, I would have a function > which gets called every time bytes arrive on the socket and then > depending on which state I'm in, I'm either going to append the bytes > to a length buffer and when I reach the ":" character, I'll change the > state and start appending to the content buffer (while decrementing > the number of bytes still left to be read). I'll give a quick example with comments. Let's suppose the list of received bytes is a list. I'm not going to pass the length/content states across a big function, but instead decompose them into two functions. -module(simple). -export([parse_bytes/1]). parse_bytes(Received_bytes) -> % We set an initial state Length_buffer = [], parse_length(Received_bytes, Length_buffer). %% We handle the case where we finished parsing the "length" first parse_length(":" ++ Rest, Length_buffer) -> Length = list_to_integer(lists:reverse(Length_buffer)), % we now parse the rest of our message parse_content(Rest, Length); %% We handle one byte of the length field parse_length([Byte | Rest], Length_buffer) -> % Here we accumulate our Byte in the buffer New_length_buffer = [Byte|Length_buffer], % And we call ourself with the modified state parse_length(Rest, New_length_buffer). parse_content(Bytes, Length) -> % We need a list to accumulate the content Content_buffer = [], parse_content(Bytes, Length, Content_buffer). %% We first handle the case where length is 0 %% (in the original message, or after we finished parsing the whole Content field) parse_content(Bytes_left, 0, Content_buffer) -> % return Content_buffer and remaining bytes (from the next "message") {lists:reverse(Content_buffer), Bytes_left}; parse_content([Byte | Rest], N, Content_buffer) -> % accumulate the Byte New_content_buffer = [Byte|Content_buffer], % call ourself with the modified state parse_content(Rest, N - 1, New_content_buffer). And then call my function : 1> simple:parse_bytes("6:erlang2:is3:easy"). {"erlang","2:is3:easy"} 2> {Content, Rest} = simple:parse_bytes("6:erlang2:is3:easy"). {"erlang","2:is3:easy"} 3> Content. "erlang" 4> Rest. "2:is3:easy" 5> simple:parse_bytes(Rest). {"is","3:easy"} Then you can write a function that makes use of parse_bytes(Bytes) calling it recursively and accumulating the result. As a simple rule of thumb, in a functional computation, you work only with the data you were provided in the arguments or that you obtain by calling another function, you then do your transformations, and either return, call yourself with a modified "state", or call another function (as a tail call). The control flow in Erlang is achieved with pattern-matching your "state" with the different clauses of the function. Hope this helps. igwan From hokan.stenholm@REDACTED Sat Aug 11 23:43:51 2007 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Sat, 11 Aug 2007 23:43:51 +0200 Subject: [erlang-questions] General advice on FP (& Erlang) In-Reply-To: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> References: <9353DDCB-FAD1-46CF-A583-01A649AD103A@gmail.com> Message-ID: <46BE2D97.7070100@bredband.net> Milen Georgiev Dzhumerov wrote: > Hi all, > > I've got a couple of questions. I'm probably not the first person who > is struggling to switch to a functional mindset. So, hopefully, any > replies to my questions will help other people too! > > The way I got started is by reading the "Programming Erlang" book by > Joe (great book btw). As I was reading the book, everything seemed so > obvious and easy but when I'm trying to do something myself - I just > can't. I always go back to my "shared state" mind and don't seem to be > able come up with a design and a plan on how to implement it. > > So, what are you guys (who get FP) suggesting I do? I think the > problem comes from having C hardwired into my brain and I can't get it > out. > > And I definitely have got to ask this - how are we supposed to mutate > state? Using processes? Function calls? I just can't wrap my head > around how some C code is going to be translated. C style loops (for/while) are replaced by recursive functions (, lists:map/foldl/foreach calls or list comprehensions which hide most of the recursive boilerplate code) e.g.: list_sum(L) -> list_sum(L, 0). % set intial value of sum accumulator % base case of recursion ("loop condition = false"), nothing more to do, return the accumulator value % Note: it is possible to have more than one base case, this may occur if more than one list % is processed at the same time, if some MaxNumberOfListElementsToProcess is supplied ... etc list_sum([], Sum) -> Sum; % process a single list element in each recursive call (invocation of list_sum/2) % "action of loop when loop condition = true" list_sum([V|R], Sum) -> NewSum = Sum + V, list_sum(R, NewSum). % process the rest There are several important properties here: * Variabels are constant inside the scoop of the function clause that they are defined in, they are basically local names for elements on the stack * Each function invocation creates a new set of variables on the stack - or in other words each call gets a new copy of the values passed to it (remember that erlang acts as call by value). example: list_sum([1,2]) calls list_sum([1,2], 0) stack = [1,2] list_sum([1,2], 0) calls list_sum([2], 1) stack = [1,2] 0 [1,2] list_sum([2], 1) calls list_sum([], 3) stack = [2] 1 [1,2] 0 [1,2] list_sum([], 3) returns 3 unwind the stack and return 3 from list_sum/1 Note: the code above is actually tail recursive - nothing needs to be calculated after a recursive call has been done in any of the clauses in lists_sum/2, which means that the stack will not be used, the internal beam code will work like a regular C loop. Compare this to the code below which doesn't use a accumulator, which must use the stack to keep track of all the invocations of list_sum/2 to be able to do the + operation when the base case is reached. list_sum([]) -> 0; list_sum([V|R], Sum) -> V + list_sum(R). Using lists:foldl/3, which hides most of the recursive stuff: list_sum(L) -> F = fun(V, Sum) -> % a fun that is essentially the same thing as a C loop body V + Sum end, lists:foldl(F, 0, L). ======================== So mutable state is achieved by passing new values to the next function call, this could in some cases even be a series of mutually recursive functions like: foo1(...) -> case ... of ... -> foo2(...); ... -> foo3(...) end. foo2(...) -> ... foo1(...). foo3(...) -> ... foo1(...). This is useful for things like processing parse trees or implementing state machines where each state matches a function. Also note that code like foo([E|R], ...) -> ... [f(E) | foo(R, ...)] often avoids the need to explicitly keep track of state, as the new state (the new list) is created when each call to foo(...) returns and assembles a updated list, in each stack unwind step. > > Let's take a simple example. I'm writing a network app in Erlang which > accepts "messages" on a socket, where a "message" is defined as > length:content. If I was to do this in C, I would have a function > which gets called every time bytes arrive on the socket and then > depending on which state I'm in, I'm either going to append the bytes > to a length buffer and when I reach the ":" character, I'll change the > state and start appending to the content buffer (while decrementing > the number of bytes still left to be read). > Now all of this depends on having access to mutable buffers (& a > counter) outside the scope of the functions - at this point I'm lost > on how to do it in Erlang. How would guys start solving this problem? > Obviously, the more experience you have, the less thinking you're > going to put into this and the solution is going to come up naturally, > but what about people who haven't had any real world experience with FP? > > Thanks, > Milen > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf@REDACTED Sat Aug 11 23:54:02 2007 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 11 Aug 2007 23:54:02 +0200 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <54852223-6BCD-4B01-8C08-9D21B3B782A8@chriswongstudio.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> <54852223-6BCD-4B01-8C08-9D21B3B782A8@chriswongstudio.com> Message-ID: <8209f740708111454x77c9fa29y962fe7ab62376871@mail.gmail.com> 2007/8/10, Chris Wong : > > I was reading the doc on this. It's consistent with what you say > here. Basically, if you have to wait for thousands of Erlang nodes > to establish communications with each other before you it can do > anything, the whole will crawl to its knees when one node is down. > Correct me if I'm wrong. If you're going to build a distributed system that makes use of thousands of nodes, you have to make it very loosely coupled, and make sure that you use localized communication patterns (refrain from using broadcasts and global voting mechanisms, for example). This takes a lot of planning. Erlang's distribution concept is based on loosely coupled nodes. There are a few libraries that default to "connect-all" semantics (global comes to mind), but you don't have to use them. You can turn off the behaviour that erlang automatically tries to connect to a node as soon as one sends a message to it. Since it's quite easy to make your own tcp-based rpc mechanism (or similar), you can create clusters of Erlang nodes which connect to each other using some other form of communication (say, ORBER, which comes with OTP). If you want just 1000 CPUs, why not connect 32 nodes, each using 32 cores? Then you don't even have to resort to trickery. ;-) It obviously depends on exactly what application is going to make use of this many CPUs, but the fact that Erlang makes it easy to build small distributed systems by offering lots of convenient features, is not in itself proof that you can't build much larger systems by avoiding the patterns that don't scale well. They _are_ optional. BR, Ulf W From joelr1@REDACTED Sun Aug 12 01:15:30 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 12 Aug 2007 00:15:30 +0100 Subject: [erlang-questions] Parse-transforming !! to a function call Message-ID: Folks, Suppose I wanted !! to send a synchronous message via a function call. How would I write a parse transform to do it? I would like x !! y to be transformed into mod:func(x, y). Is this possible? Thanks in advance, Joel -- http://wagerlabs.com From chsu79@REDACTED Sun Aug 12 01:41:34 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 12 Aug 2007 01:41:34 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: Message-ID: It doesnt even parse, so the parse-transform cant work on it. {ok, Tokens, Lines} = erl_scan:string("foo(X) -> foo !! X."). erl_parse:parse_form(Tokens). It has been suggested before that the backtick or similar could be used to create an infix operator out of an arity-two function, like in haskell. X `add` Y vs add(X, Y) or in your case x `!!` y instead of '!!'(x, y) http://www-users.cs.york.ac.uk/~mfn/hacle/issues/node2.html#SECTION00028000000000000000 I'm not all that crazy about the idea though. LispErlang would be cooler. :) 2007/8/12, Joel Reymont : > Suppose I wanted !! to send a synchronous message via a function > call. How would I write a parse transform to do it? > > I would like x !! y to be transformed into mod:func(x, y). Is this > possible? > > Thanks in advance, Joel From chlorophil@REDACTED Sun Aug 12 01:52:08 2007 From: chlorophil@REDACTED (Philip Robinson) Date: Sun, 12 Aug 2007 09:52:08 +1000 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: Message-ID: On 8/12/07, Joel Reymont wrote: > I would like x !! y to be transformed into mod:func(x, y). Is this > possible? AFAIK a parse_transform can only work on a legal AST. x !! y is not turned into a valid AST via c(module). -module(show_ast). -export([parse_transform/2]). parse_transform(AST, _Options) -> [io:format("~p~n", [Node]) || Node <- AST], AST. -module(test). -compile([export_all]). -compile({parse_transform, show_ast}). test() -> x !! y. 1> c(show_ast), c(test). {attribute,1,file,{"./test.erl",1}} {attribute,1,module,test} {attribute,2,compile,[export_all]} {error,{5,erl_parse,["syntax error before: ",["'!'"]]}} {eof,7} ./test.erl:5: syntax error before: '!' error 2> i.e.: An error is produced before show_ast can do anything about it. I do not know if it would be possible to get around this by using any of the various Erlang parse tools. (If you do find a way then please let me know!) Cheers, Philip From joelr1@REDACTED Sun Aug 12 02:37:48 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 12 Aug 2007 01:37:48 +0100 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: Message-ID: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> On Aug 12, 2007, at 12:41 AM, Christian S wrote: > I'm not all that crazy about the idea though. LispErlang would be > cooler. :) I'm looking for a neat way to express a synchronous call for ObjC/ Cocoa. I'm not all that crazy about having (objc:send(objc:send (objc:send(...), ...), ...). I would rather have a shortcut! -- http://wagerlabs.com From chsu79@REDACTED Sun Aug 12 03:09:56 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 12 Aug 2007 03:09:56 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> Message-ID: Objective-C looks like this: [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz]; Which is pretty close to something parsable in erlang. Using imagination. The qlc module manages to use the LC syntax. How about you use nested list syntax? Imagine that objc:call is special like qlc:q and you implement this: Value = objc:call([[[Object, do_stuff(Foo, Bar)], more_stuff()], last_stuff(Baz)]). where do_stuff(Foo, Bar) and friends implements optional sugar such as: do_stuff(Foo, Bar) -> {'doStuffWith:and:', Foo, Bar}. But just chaining like this is probably sugar enough and skips all of parse transforms: objc:msgs([Object, do_stuff(Foo, Bar), more_stuff(), last_stuff(Baz)]). where msgs sends messages like this: msgs([Object |Methods]) -> lists:foldl(fun(M, Object) -> objc:send(Object, M) end, Object, Methods). 2007/8/12, Joel Reymont : > > On Aug 12, 2007, at 12:41 AM, Christian S wrote: > > > I'm not all that crazy about the idea though. LispErlang would be > > cooler. :) > > I'm looking for a neat way to express a synchronous call for ObjC/ > Cocoa. I'm not all that crazy about having (objc:send(objc:send > (objc:send(...), ...), ...). I would rather have a shortcut! > > -- > http://wagerlabs.com > > > > > > From ryanobjc@REDACTED Sun Aug 12 03:57:58 2007 From: ryanobjc@REDACTED (Ryan Rawson) Date: Sat, 11 Aug 2007 18:57:58 -0700 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> Message-ID: One weird thing is the "with" and "and" that you elide aren't really semantic sugar or ignorable. They are a meaningful part of the selector's name. Destroying objective c to fit with erlang fills me with a special sad since the NS API is probably the best one I have ever seen. Also practically there are many selectors that start with the same prefix and differ only by the 2nd arguments. Your scheme would create some confusion there too. -ryan On Aug 11, 2007, at 6:09 PM, "Christian S" wrote: > Objective-C looks like this: > > [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz]; > > Which is pretty close to something parsable in erlang. Using > imagination. > > The qlc module manages to use the LC syntax. How about you use nested > list syntax? > Imagine that objc:call is special like qlc:q and you implement this: > > Value = objc:call([[[Object, do_stuff(Foo, Bar)], more_stuff()], > last_stuff(Baz)]). > > where do_stuff(Foo, Bar) and friends implements optional sugar such > as: > > do_stuff(Foo, Bar) -> > {'doStuffWith:and:', Foo, Bar}. > > But just chaining like this is probably sugar enough and skips all of > parse transforms: > > objc:msgs([Object, do_stuff(Foo, Bar), more_stuff(), last_stuff > (Baz)]). > > where msgs sends messages like this: > > msgs([Object |Methods]) -> > lists:foldl(fun(M, Object) -> objc:send(Object, M) end, Object, > Methods). > > > > 2007/8/12, Joel Reymont : >> >> On Aug 12, 2007, at 12:41 AM, Christian S wrote: >> >>> I'm not all that crazy about the idea though. LispErlang would be >>> cooler. :) >> >> I'm looking for a neat way to express a synchronous call for ObjC/ >> Cocoa. I'm not all that crazy about having (objc:send(objc:send >> (objc:send(...), ...), ...). I would rather have a shortcut! >> >> -- >> http://wagerlabs.com >> >> >> >> >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From chsu79@REDACTED Sun Aug 12 04:36:02 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 12 Aug 2007 04:36:02 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> Message-ID: 2007/8/12, Ryan Rawson : > One weird thing is the "with" and "and" that you elide aren't really > semantic sugar or ignorable. They are a meaningful part of the > selector's name. Destroying objective c to fit with erlang fills me > with a special sad since the NS API is probably the best one I have > ever seen. Also practically there are many selectors that start with > the same prefix and differ only by the 2nd arguments. Your scheme > would create some confusion there too. > > -ryan So you have issues with example names? Do you have anything to say about Foo, Bar and Baz as variable names too? I'm not writing the objc gateway. Joel is. He can preserve the meaningful parts of selector names on the erlang side as he wishes. Personally I think 'With' and 'and' are pretty meaningless parts of an imaginary meaningless method name, which is why it would be silly with a 'doStuffWith:and:'(Foo, Bar) function. It's very different if we have things like drawCircle:at: and drawRectangle:at:. Then we have information. From mfeathers@REDACTED Sun Aug 12 04:45:13 2007 From: mfeathers@REDACTED (Michael Feathers) Date: Sat, 11 Aug 2007 22:45:13 -0400 Subject: [erlang-questions] Mocking processes for testing In-Reply-To: References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> Message-ID: <46BE7439.7060702@mindspring.com> Hi. New to the language and just reading Joe Armstrong's book. I was just wondering.. is there any facility in the language to allow you to create mock processes, so that outgoing process calls can be intercepted under test? Michael From juneaftn@REDACTED Sun Aug 12 06:37:37 2007 From: juneaftn@REDACTED (June Kim) Date: Sun, 12 Aug 2007 13:37:37 +0900 Subject: [erlang-questions] Mocking processes for testing In-Reply-To: <46BE7439.7060702@mindspring.com> References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> <46BE7439.7060702@mindspring.com> Message-ID: <6f80c1520708112137n5c249714i15cfd63d7cd9fb94@mail.gmail.com> Hi, Michael, Glad to see you here. I've tested processes behaviors in Erlang with a lot of ease. It's really easy. All you have to do is pass around pid instead of global reference, just like DIP in OOP. Suppose process A should wait for msg1 from process C and then once it receives, it should emit msg2 to process B. You want to test the behavior of process A. You first spawn a mock process MockB which just waits for msg2 and then it sends you "test passed" back(I mean back to the testing process). Now, you spawn process A with the pid of MockB. You also need to spawn a stub process MockC(along with the pid of process A) which just sends msg1 to process A. You can easily build a mock framework, discovering and refactoring the repeating patterns. If you want more detail, I'll work on a concrete example code. June 2007/8/12, Michael Feathers : > Hi. New to the language and just reading Joe Armstrong's book. > > I was just wondering.. is there any facility in the language to allow > you to create mock processes, so that outgoing process calls can be > intercepted under test? > > Michael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ahmed.nawras@REDACTED Sun Aug 12 09:42:56 2007 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Sun, 12 Aug 2007 11:42:56 +0400 Subject: [erlang-questions] Erlang with BDB In-Reply-To: <781dd98c0708101213t11090c60t71147cfe20754a2d@mail.gmail.com> References: <781dd98c0708091448s3b71360bk72a6f0e039349fd3@mail.gmail.com> <781dd98c0708101213t11090c60t71147cfe20754a2d@mail.gmail.com> Message-ID: Thanks a lot for the useful information. I'll give this a try and let you know if I had a problem. Best regards, Ahmed Al-Issaei On 8/10/07, Chris Newcombe wrote: > > > Sending this again as I apparently hit 'reply' instead of 'reply all'. > > Chris > > > On 8/9/07, Chris Newcombe wrote: > > > > > > >> Has any one here used BDB with Erlang before? > > >> Can anyone share his experience with Erlang & BDB? > > > > Yes. In my opinion and experience, BDB is an excellent match for > > Erlang. For instance, BDB is implemented as a C library and it has such > > high code-quality that it is relatively low risk to use it directly from > > inside the Erlang VM as a port-driver (shared library). This gives you a > > very high performance, concurrent, local-disk transactional store for > > arbitrary Erlang data. > > > > Also, BDB's replication technology is a very interesting option for > > adding fault-tolerance and scalability to many types of system. > > > > I recently spent considerable time enhancing Scott Lystig Fritchie's > > EDTK project to improve support for BDB, and add support for BDB-HA. You > > can find it here: > > > > http://www.snookles.com/erlang/edtk/ > > > > Important: BDB a 'sharp tool' that can be painful if you mis-use it. I > > spent a lot of time making the interface between Erlang and BDB as seemless, > > natural, and safe as possible (while retaining high performance). But if > > you abuse the BDB API ( i.e. violate the documented pre-conditions on a > > given function, by calling them in the wrong order) then you can still cause > > any amount of havoc. Please read the following file careful before use. > > > > http://www.snookles.com/erlang/edtk/edtk-1.5.1.README-cnewcom > > > > I hope this helps, > > > > Chris > > > > > > On 8/9/07, Ahmed Ali < ahmed.nawras@REDACTED> wrote: > > > > > Hi All, > > > > > > I'd like to use an external BerkeleyDB (BDB) with Erlang. Mnesia is > > > good for me but requirements are to use BDB or MySQL. I searched in the > > > internet and found that MySQL has more support for Erlang than BDB but I > > > want to use BDB. Has any one here used BDB with Erlang before? Can anyone > > > share his experience with Erlang & BDB? Any information is appreciated. > > > Thanks. > > > > > > Best regards, > > > > > > Ahmed Al-Issaei > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sun Aug 12 11:02:15 2007 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 12 Aug 2007 11:02:15 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: Message-ID: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> This looks like Joe's "bang-bang" notation. Joe made a small change to the parser to make this possible. He first wrote about it in http://www.sics.se/~joe/nerl.html, I think. BR, Ulf W 2007/8/12, Joel Reymont : > Folks, > > Suppose I wanted !! to send a synchronous message via a function > call. How would I write a parse transform to do it? > > I would like x !! y to be transformed into mod:func(x, y). Is this > possible? > > Thanks in advance, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dot@REDACTED Sun Aug 12 12:49:13 2007 From: dot@REDACTED (Tony Finch) Date: Sun, 12 Aug 2007 11:49:13 +0100 Subject: [erlang-questions] Erlang is 47th, Java firtst! In-Reply-To: <46BC7B50.8060603@cheapnet.it> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <46BC211D.1090406@erlang-consulting.com> <46BC2960.6000705@erlang-consulting.com> <70660262-7B04-4866-907C-B407869CDDAD@gmail.com> <46BC438C.3080309@cheapnet.it> <46BC7B50.8060603@cheapnet.it> Message-ID: On Fri, 10 Aug 2007, Jilani Khaldi wrote: > http://www.tiobe.com/tpci.htm > Erlang is 47th, but Java is first!!! Marketing has done a miracle. The TIOBE ranking is based on how many people say "Erlang programming". Unfortunately this means that Joe's book won't help the ranking. Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From ulf@REDACTED Sun Aug 12 13:44:27 2007 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 12 Aug 2007 13:44:27 +0200 Subject: [erlang-questions] What modules belong to an application? In-Reply-To: <532C0ADC-D70E-4CD4-BF7B-2437409638AC@gmail.com> References: <595CD750-618F-4B00-81C9-DAE95AAFB59A@gmail.com> <532C0ADC-D70E-4CD4-BF7B-2437409638AC@gmail.com> Message-ID: <8209f740708120444w639780bfw86180164031ec1be@mail.gmail.com> ... or even application:get_key(App, modules). BR, Ulf W 2007/8/10, Joel Reymont : > Further research reveals that application:get_all_key(app) does the > trick. > > On Aug 10, 2007, at 1:17 PM, Joel Reymont wrote: > > > What is the easiest way to determine the modules belonging to a > > particular application? > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Sun Aug 12 14:06:50 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 12 Aug 2007 13:06:50 +0100 Subject: [erlang-questions] Obj-C bridge In-Reply-To: References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> Message-ID: <6E510B1A-492D-4F03-846F-1DF32353432D@gmail.com> On Aug 12, 2007, at 2:09 AM, Christian S wrote: > Objective-C looks like this: > > [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz]; I'm in favor of modifying the parser to add the !! notation (aliased to !) and then doing A = object !! [{dostuffWith, foo}, {and, bar}], B = A !! [moreStuff], C = B !! [{lastStuffUsing, baz}] What do you think? I also think that I would rather add the Obj-C runtime functions as Erlang BIFs than to use the FFI. I definitely want the bridge to run inside the Erlang VM so I'm still don't know how to best combine the Erlang runtime with that of Obj-C. Cocoa wants its own run loop which could be a problem. Joel -- http://wagerlabs.com From xapwing@REDACTED Sun Aug 12 14:32:37 2007 From: xapwing@REDACTED (Arie van Wingerden) Date: Sun, 12 Aug 2007 14:32:37 +0200 Subject: [erlang-questions] .erlang file in Windows Message-ID: <5949aaa30708120532n3a55b351tae3b116dab9fc78c@mail.gmail.com> Hi, reading page 47 in Joe Armstrong's new book, I tried to create a .erlang file, which (as I read earlier) should reside in the bin directory (which is stated otherwise in the book). However, Windows XP OS won't accept a file named ".erlang" (dot in position 1). Any ideas? -- Met vriendelijke groet / with kind regards, Arie van Wingerden "God likes your code if it's beautiful." -- Joe Armstrong -- Joe Armstrong Donate free food at http://www.voedselhulp.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Sun Aug 12 14:48:41 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 12 Aug 2007 16:48:41 +0400 Subject: [erlang-questions] .erlang file in Windows In-Reply-To: <5949aaa30708120532n3a55b351tae3b116dab9fc78c@mail.gmail.com> References: <5949aaa30708120532n3a55b351tae3b116dab9fc78c@mail.gmail.com> Message-ID: <337538cb0708120548k6dd2269ehd82af60dae4a66@mail.gmail.com> I suppose you are using Windows Explorer :) There are better file managing utils - e.g. I create such a file in FAR with no problem. Best regards, Kirill. On 8/12/07, Arie van Wingerden wrote: > > Hi, > > reading page 47 in Joe Armstrong's new book, I tried to create a .erlang > file, which (as I read earlier) should reside in the bin directory (which is > stated otherwise in the book). > > However, Windows XP OS won't accept a file named ".erlang" (dot in > position 1). > > Any ideas? > > -- > Met vriendelijke groet / with kind regards, > Arie van Wingerden > > "God likes your code if it's beautiful." -- Joe Armstrong > -- Joe Armstrong > > Donate free food at http://www.voedselhulp.nl > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From finked@REDACTED Sun Aug 12 15:10:23 2007 From: finked@REDACTED (Douglas Finke) Date: Sun, 12 Aug 2007 13:10:23 +0000 Subject: [erlang-questions] .erlang file in Windows Message-ID: You can create the directory from the command line. Start | Run then type cmd and press enter. md .erlang You can then view it in the Explorer. Doug blog: Development In a Blink Date: Sun, 12 Aug 2007 14:32:37 +0200From: xapwing@REDACTED: erlang-questions@REDACTED: [erlang-questions] .erlang file in WindowsHi,reading page 47 in Joe Armstrong's new book, I tried to create a .erlang file, which (as I read earlier) should reside in the bin directory (which is stated otherwise in the book).However, Windows XP OS won't accept a file named ".erlang" (dot in position 1). Any ideas?-- Met vriendelijke groet / with kind regards, Arie van Wingerden"God likes your code if it's beautiful." -- Joe Armstrong -- Joe ArmstrongDonate free food at http://www.voedselhulp.nl _________________________________________________________________ Recharge--play some free games. Win cool prizes too! http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Sun Aug 12 15:55:48 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 12 Aug 2007 15:55:48 +0200 Subject: [erlang-questions] Obj-C bridge In-Reply-To: <6E510B1A-492D-4F03-846F-1DF32353432D@gmail.com> References: <812BA44D-EBD3-4F9A-BF77-D197CF1BFCBC@gmail.com> <6E510B1A-492D-4F03-846F-1DF32353432D@gmail.com> Message-ID: 2007/8/12, Joel Reymont : > On Aug 12, 2007, at 2:09 AM, Christian S wrote: > > Objective-C looks like this: > > [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz]; > > I'm in favor of modifying the parser to add the !! notation (aliased > to !) and then doing Are you going to make this objc-bridge open source? Because modifying the scanner and parser to make the syntax parsable will make it difficult to begin using the code, it needing special compilation methods, which might be more of a nuisance than the benefit of the syntax itself. > A = object !! [{dostuffWith, foo}, {and, bar}], > B = A !! [moreStuff], > C = B !! [{lastStuffUsing, baz}] > > What do you think? It displays its sequential order very clearly, but dont you think it is a bit verbose? The reason I used do_stuff(Foo, Bar) for constructing something like {'doStuffWith:and:', Foo, Bar} is that the more intelligent editors can perform tab completion and pop up documentation for functions. Dialyzer will perhaps be more practical too, and guards on the do_stuff arguments can perform sanity checks. But the quick hack can still spell out a selector name directly in the code (shell!) and refactor it later. Another idea, similar in verbosity to your bang-bang approach. A = {Object, 'doStuffWith:and:', Foo, Bar}, B = {A, 'moreStuff'}, C = {B, 'lastStuffUsing:', Baz}, objc:eval(C). %% Or objc:eval(Port, C) where Port is one of several separated objc ports, or just %% something to hang preregistered shortcut atom names on for frequently used objects. You would also get a way to get a bunch of methods happen atomically. Now that we make such a big deal of concurrency in erlang. :) The best approach is probably to write some code in erlang for the various syntax suggestions, get a feel for how they're to work with and how well they read. Then implement the one you like best. > I also think that I would rather add the Obj-C runtime functions as > Erlang BIFs than to use the FFI. I definitely want the bridge to run > inside the Erlang VM so I'm still don't know how to best combine the > Erlang runtime with that of Obj-C. Cocoa wants its own run loop which > could be a problem. Conventional wisdom is to do this later, if at all, and start out with an external port process since it is easier and find out if it would be a good idea with closer interaction. Myself, I tend to always underestimate the speed of computers with a factor of 100. Memo to self: I need to look into how one gives linked in drivers threads of their own and how to communicate with the erlang runtime. From qrilka@REDACTED Sun Aug 12 16:09:40 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 12 Aug 2007 18:09:40 +0400 Subject: [erlang-questions] .erlang file in Windows In-Reply-To: References: Message-ID: <337538cb0708120709u1ed798f4tff4c26ba2ef35896@mail.gmail.com> .erlang is not a directory! A file can be created from command line using e.g. copy nul .erlang Regards, Kirill. On 8/12/07, Douglas Finke wrote: > > You can create the directory from the command line. > > Start | Run then type cmd and press enter. > > md .erlang > > You can then view it in the Explorer. > > Doug > > blog: Development In a Blink > > > > ------------------------------ > Date: Sun, 12 Aug 2007 14:32:37 +0200 > From: xapwing@REDACTED > To: erlang-questions@REDACTED > Subject: [erlang-questions] .erlang file in Windows > > Hi, > > reading page 47 in Joe Armstrong's new book, I tried to create a .erlang > file, which (as I read earlier) should reside in the bin directory (which is > stated otherwise in the book). > > However, Windows XP OS won't accept a file named ".erlang" (dot in > position 1). > > Any ideas? > > -- > Met vriendelijke groet / with kind regards, > Arie van Wingerden > > "God likes your code if it's beautiful." -- Joe Armstrong > -- Joe Armstrong > > Donate free food at http://www.voedselhulp.nl > > > ------------------------------ > Recharge--play some free games. Win cool prizes too! Play It! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Sun Aug 12 16:20:36 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 12 Aug 2007 18:20:36 +0400 Subject: [erlang-questions] Changing environment variables for an application started from boot script Message-ID: <337538cb0708120720y545f802ex10f5d9279f0dd26c@mail.gmail.com> Hello everyone! I've created an application and a boot script to start it. But now it looks like I can not use .app-file to change the variables I need to change. Why is it so? At the moment it looks like I need to rebuilt the boot script every time anything is changed. And what if need the system to run 24x7? Or maybe I miss some other way around? Best regards, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sean.hinde@REDACTED Sun Aug 12 16:38:26 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Sun, 12 Aug 2007 15:38:26 +0100 Subject: [erlang-questions] Changing environment variables for an application started from boot script In-Reply-To: <337538cb0708120720y545f802ex10f5d9279f0dd26c@mail.gmail.com> References: <337538cb0708120720y545f802ex10f5d9279f0dd26c@mail.gmail.com> Message-ID: <062EDA64-A37A-488A-97B1-8BE905B5130A@gmail.com> Hi Kiril, You are right, the variables in the .app file are basically intended for startup. It is possible to change them (with application:set_env/3), but see the warnings in the doc. One alternative and quite nice way to deal with the config issue is to make an mnesia table for all the config items, and use mnesia:subscribe to notify users of the config about changes. Sean On 12 Aug 2007, at 15:20, Kirill Zaborski wrote: > Hello everyone! > I've created an application and a boot script to start it. But now > it looks like I can not use .app-file to change the variables I > need to change. Why is it so? > At the moment it looks like I need to rebuilt the boot script every > time anything is changed. And what if need the system to run 24x7? > Or maybe I miss some other way around? > > Best regards, > Kirill. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From xapwing@REDACTED Sun Aug 12 19:09:47 2007 From: xapwing@REDACTED (Arie van Wingerden) Date: Sun, 12 Aug 2007 19:09:47 +0200 Subject: [erlang-questions] .erlang file in Windows In-Reply-To: <337538cb0708120709u1ed798f4tff4c26ba2ef35896@mail.gmail.com> References: <337538cb0708120709u1ed798f4tff4c26ba2ef35896@mail.gmail.com> Message-ID: <5949aaa30708121009td8e20b9nd464dba0d7838e05@mail.gmail.com> Hi all, thanks for the answer. I was not aware that Explorer cheated on me :-( Arie 2007/8/12, Kirill Zaborski : > > .erlang is not a directory! > A file can be created from command line using e.g. > copy nul .erlang > > Regards, > Kirill. > > On 8/12/07, Douglas Finke wrote: > > > You can create the directory from the command line. > > > > Start | Run then type cmd and press enter. > > > > md .erlang > > > > You can then view it in the Explorer. > > > > Doug > > > > blog: Development In a Blink > > > > > > > > ------------------------------ > > Date: Sun, 12 Aug 2007 14:32:37 +0200 > > From: xapwing@REDACTED > > To: erlang-questions@REDACTED > > Subject: [erlang-questions] .erlang file in Windows > > > > Hi, > > > > reading page 47 in Joe Armstrong's new book, I tried to create a .erlang > > file, which (as I read earlier) should reside in the bin directory (which is > > stated otherwise in the book). > > > > However, Windows XP OS won't accept a file named ".erlang" (dot in > > position 1). > > > > Any ideas? > > > > -- > > Met vriendelijke groet / with kind regards, > > Arie van Wingerden > > > > "God likes your code if it's beautiful." -- Joe Armstrong > > -- Joe Armstrong > > > > Donate free food at http://www.voedselhulp.nl > > > > > > ------------------------------ > > Recharge--play some free games. Win cool prizes too! Play It! > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Mon Aug 13 00:04:11 2007 From: james.hague@REDACTED (James Hague) Date: Sun, 12 Aug 2007 17:04:11 -0500 Subject: [erlang-questions] VM & BEAM Specs : idea for improving the lists support In-Reply-To: <46B5AFE5.40706@mail.ru> References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> Message-ID: On 8/5/07, Denys Rtveliashvili wrote: > The problems I see with the current implementation are: > - The computational complexity required to do certain list operations is > O(n), not O(1) > - The linked list is not CPU cache - friendly. It can be dispersed in > the memory, reducing the cache - hits and thus killing the performance. > - Each of the list items is a quite big object. It takes 64bits if I am > not mistaken. So, if you'd like to store a list of, say, 16bit > characters / ordinary Unicode strings it takes 4 times more memory. Are these problems based on analysis of an existing application or are they just gut feelings about what's fast and what's slow? James From ulf@REDACTED Mon Aug 13 00:25:15 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 13 Aug 2007 00:25:15 +0200 Subject: [erlang-questions] Changing environment variables for an application started from boot script In-Reply-To: <337538cb0708120720y545f802ex10f5d9279f0dd26c@mail.gmail.com> References: <337538cb0708120720y545f802ex10f5d9279f0dd26c@mail.gmail.com> Message-ID: <8209f740708121525i5a223a98o554b3c1fe4d8bce7@mail.gmail.com> You can override the variables in the .app file either by adding them to the command line, or by using a system configuration file (.config). The .config file (often called sys.config) is identified from the command line with the -sys /sys flag. http://www.erlang.org/doc/design_principles/applications.html Chapter 7.8, Configuring an Application BR, Ulf W 2007/8/12, Kirill Zaborski : > Hello everyone! > I've created an application and a boot script to start it. But now it looks > like I can not use .app-file to change the variables I need to change. Why > is it so? > At the moment it looks like I need to rebuilt the boot script every time > anything is changed. And what if need the system to run 24x7? > Or maybe I miss some other way around? > > Best regards, > Kirill. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From benbutlercole@REDACTED Mon Aug 13 00:36:59 2007 From: benbutlercole@REDACTED (Ben Butler-Cole) Date: Sun, 12 Aug 2007 15:36:59 -0700 (PDT) Subject: [erlang-questions] Mocking processes for testing Message-ID: <276006.95029.qm@web30802.mail.mud.yahoo.com> Michael I have written a test library with facilities for creating mocks and stubs. I just wrote it for my own use and it needs some work before it's publishable, but I would be happy to share what I have with you. It allows the creating of mock processes (which expect messages to be sent to them) and stub ones (which silently accept any message). Either type can be created as an anonymous or as a registered process. Code that uses the library looks like this: should_feed_marmosets_at_break_of_day() -> stub(cat), M = mock({expect, {food, weevil}}), Keeper = keeper:new([M]), Keeper ! wake_up. should_kick_cat_at_break_of_day() -> mock(cat, {expect, kick}), Keeper = keeper:new([]), Keeper ! wake_up. Where the keeper's code contains something like this: loop(Marmosets) -> receive wake_up -> cat ! kick, lists:foreach(fun(M) -> M ! weevil end, Marmosets), loop(Marmosets) % ... end. The cat is modeled as a registered process just to show what is possible. It is also possible to create expectations on existing mocks (by sending them messages) when dependencies are more complicated. It's not currently integrated with EUnit (or any other proper testing framework), but probably should be. Let me know if you are interested. If several people would like to use it I'll publish it somewhere. Ben From hendy@REDACTED Mon Aug 13 05:50:45 2007 From: hendy@REDACTED (Hendy Irawan) Date: Mon, 13 Aug 2007 10:50:45 +0700 Subject: [erlang-questions] Erlang/OTP In-Reply-To: References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> Message-ID: <46BFD515.6010700@rainbowpurple.com> Hi, I'm very new to Erlang and I want to get to jump on it including OTP quickly... There are many resources on Erlang but I haven't seen many about OTP. I want to ask a few questions, I hope you don't mind: * Is there free resources about OTP? * Is it free? * How does it compare to Jungerl libs? * Does the "Programming Erlang" (pragmatic) book include OTP in its discussion? * Where is the official homepage for OTP itself? * Where can I find OTP documentation? Thank you very much. -- Hendy Irawan www.hendyirawan.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Aug 13 07:44:25 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 13 Aug 2007 07:44:25 +0200 Subject: [erlang-questions] Erlang/OTP In-Reply-To: <46BFD515.6010700@rainbowpurple.com> References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> <46BFD515.6010700@rainbowpurple.com> Message-ID: <8209f740708122244wcab5decmcabccf80a0a2553@mail.gmail.com> 2007/8/13, Hendy Irawan : > > Is there free resources about OTP? > Is it free? OTP is as free as Erlang, as they are bundled together. The Erlang documentation also covers OTP. > How does it compare to Jungerl libs? OTP is a commercial set of libraries that have been proven in the field in a wide range of products since ca 1998. There are courses available on OTP, and the Erlang/OTP team takes responsibility for its quality. The jungerl libs are just unmoderated contributions with no guarantees whatsoever. > Does the "Programming Erlang" (pragmatic) book include OTP in its > discussion? Yes, especially chapters 16-18. > Where is the official homepage for OTP itself? http://www.erlang.org > Where can I find OTP documentation? http://www.erlang.org/doc.html BR, Ulf W From ahmed.nawras@REDACTED Mon Aug 13 08:40:59 2007 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Mon, 13 Aug 2007 10:40:59 +0400 Subject: [erlang-questions] Load testing in parallel Message-ID: Hi all, I've been trying to load test a function in my code. The way I'm doing it is to generate lists of the data I want to process, start a process for each list and calculate runtime for each process. The function that I implemented will call a WebService operation in a different host for each data. I have the code below for this test. what I do is basically run load_test(10, 1000) to generate 10 lists, each with 1000 data in it. The problem is that WebService call is done successfully but I don't get any output for the statistics. When I run the code sequentially (i.e. instead of spawn the call to run_process, I call run_process directly) I get the output with no issues. Is there something that I missed in the code below? I appreciate your help. Best regards, Ahmed Al-Issaei run_process(Num, Fun, List, _Pid) -> statistics(wall_clock), io:format("load testing process~n"), lists:map(Fun, List), {_, Time2} = statistics(wall_clock), U2 = Time2 / 1000, io:format("Num (~s) done: total time = ~p~n",[Num, U2]). start(_N, _Op, [], _Pid) -> true; start(Num, Op, Final, Pid) -> [Head | Rest] = Final, spawn(?MODULE, run_process, [Num, Op, Head, Pid]), start(Num-1, Op, Rest, Pid). load_test(Threads, Size) -> List = generate_lists(Threads, Size, []), Op = fun(X) -> call_ws_create(X) end, start(Threads, Op, List, self()). -------------- next part -------------- An HTML attachment was scrubbed... URL: From dae@REDACTED Sat Aug 11 18:00:23 2007 From: dae@REDACTED (dae@REDACTED) Date: Sat, 11 Aug 2007 09:00:23 -0700 Subject: [erlang-questions] gs:read Message-ID: <46BDDD17.1090703@copper.net> Newbie question: I am looking at the docs for gs and am trying to modify ex9 (copied below from /lib/gs-1.5.7/doc/html/gs_chapter8.html). I want the window to stay open after sending a name tuple to the console, so another name tuple can be sent. I don't want the window to close unless I click the cancel button (or the top-right X button). I've tried adding loop(Pid) at the end of the two receive clauses which call Text=gs:read(entry,text), but get strange results. (this on XP, using werl). Can someone show me how to do it? Thanks. ---------- from the docs: -module(ex9). -copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). -vsn('$Revision: /main/release/2 $ '). -export([start/0,init/1]). start() -> spawn(ex9, init, [self()]), receive {entry_reply, Reply} -> Reply end. init(Pid) -> S = gs:start(), Win = gs:create(window,S,[{title,"Entry Demo"}, {width,150},{height,100}]), gs:create(label,Win,[{label,{text,"What's your name?"}}, {width,150}]), gs:create(entry,entry,Win,[{x,10},{y,30},{width,130}, {keypress,true}]), gs:create(button,ok,Win,[{width,45},{y,60},{x,10}, {label,{text,"Ok"}}]), gs:create(button,cancel,Win,[{width,60},{y,60},{x,80}, {label,{text,"Cancel"}}]), gs:config(Win,{map,true}), loop(Pid). loop(Pid) -> receive {gs,entry,keypress,_,['Return'|_]} -> Text=gs:read(entry,text), Pid ! {entry_reply,{name,Text}}; {gs,entry,keypress,_,_} -> % all other keypresses loop(Pid); {gs,ok,click,_,_} -> Text=gs:read(entry,text), Pid ! {entry_reply,{name,Text}}; {gs,cancel,click,_,_} -> Pid ! {entry_reply,cancel}; X -> io:format("Got X=~w~n",[X]), loop(Pid) end. From vances@REDACTED Mon Aug 13 06:13:48 2007 From: vances@REDACTED (Vance Shipley) Date: Mon, 13 Aug 2007 00:13:48 -0400 Subject: [erlang-questions] Erlang/OTP In-Reply-To: <46BFD515.6010700@rainbowpurple.com> References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> <46BFD515.6010700@rainbowpurple.com> Message-ID: <20070813041319.GA2530@little-black-book.motivity.ca> On Mon, Aug 13, 2007 at 10:50:45AM +0700, Hendy Irawan wrote: } * Is there free resources about OTP? } * Is it free? } * Where is the official homepage for OTP itself? } * Where can I find OTP documentation? Erlang is a programming language. OTP is an implementation of an erlang virtual machine and a collection of libraries which implement a framework for building fault tolerant, distributed applications. So what you would think of as Erlang, the software package which you download at www.erlang.org (i.e. otp_src_R11B-5), is in fact Erlang/OTP. } * How does it compare to Jungerl libs? Jungerl contains another, sometimes partially overlapping, collection of libraries, but not a virtual machine. } * Does the "Programming Erlang" (pragmatic) book include OTP in its } discussion? Indeed it does. -Vance From saleyn@REDACTED Mon Aug 13 13:56:59 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 13 Aug 2007 06:56:59 -0500 Subject: [erlang-questions] Load testing in parallel In-Reply-To: References: Message-ID: <46C0470B.8080401@gmail.com> You have several problems with this code: 1. Since you don't provide implementation of generate_lists/3, I assume it returns a flat list. In this case in the start function you call: spawn(?MODULE, run_process, [Num, Op, Head, Pid]), if here Head is not a list, whereas run_process/4 expects a list as the third argument, lists:map/2 function would crashes the process silently. You can fix it by changing that line to: spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), 2. Also you use the following call to obtain time: {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). Wallclock_Time_Since_Last_Call is time in milliseconds, so unless evaluated function takes more than a millisecond you'd get a 0. Moreover, unfortunately Wallclock_Time_Since_Last_Call is a *globally shared* counter, so any process that calls statistics would cause a reset of this value. So in a concurrent system where many processes use this function you'll likely always get a zero. use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) to measure time. Serge Ahmed Ali wrote: > Hi all, > > I've been trying to load test a function in my code. The way I'm doing it is > to generate lists of the data I want to process, start a process for each > list and calculate runtime for each process. The function that I implemented > will call a WebService operation in a different host for each data. > > I have the code below for this test. what I do is basically run > load_test(10, 1000) to generate 10 lists, each with 1000 data in it. > > The problem is that WebService call is done successfully but I don't get any > output for the statistics. When I run the code sequentially (i.e. instead of > spawn the call to run_process, I call run_process directly) I get the output > with no issues. Is there something that I missed in the code below? I > appreciate your help. > > Best regards, > > Ahmed Al-Issaei > > run_process(Num, Fun, List, _Pid) -> > statistics(wall_clock), > io:format("load testing process~n"), > lists:map(Fun, List), > {_, Time2} = statistics(wall_clock), > U2 = Time2 / 1000, > io:format("Num (~s) done: total time = ~p~n",[Num, U2]). > > start(_N, _Op, [], _Pid) -> > true; > start(Num, Op, Final, Pid) -> > [Head | Rest] = Final, > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > start(Num-1, Op, Rest, Pid). > > load_test(Threads, Size) -> > List = generate_lists(Threads, Size, []), > Op = fun(X) -> call_ws_create(X) end, > start(Threads, Op, List, self()). > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dmitriid@REDACTED Mon Aug 13 12:59:02 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Mon, 13 Aug 2007 13:59:02 +0300 Subject: [erlang-questions] .erlang file in Windows In-Reply-To: <5949aaa30708121009td8e20b9nd464dba0d7838e05@mail.gmail.com> References: <337538cb0708120709u1ed798f4tff4c26ba2ef35896@mail.gmail.com> <5949aaa30708121009td8e20b9nd464dba0d7838e05@mail.gmail.com> Message-ID: <46C03976.5090906@gmail.com> Arie van Wingerden wrote: > Hi all, > > thanks for the answer. I was not aware that Explorer cheated on me :-( > > Arie you can also create any file and ten do a "ren filename.extension .erlang" in the cmd shell. this works, too From dmitriid@REDACTED Mon Aug 13 14:54:24 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Mon, 13 Aug 2007 15:54:24 +0300 Subject: [erlang-questions] About Planet Erlang Message-ID: <46C05480.206@gmail.com> I didn't find any way to send feedback to Planet Erlang, so I'll post to the erlang list. We're all here after all :) The new site is fantastic. I can see it from the RSS feed. However, when you visit the site, the situation is very different. All you see on the site is the 9-day old "Planet Erlang updated" news whereas the "upcoming news" section lists news as fresh as "4 hours ago". Same goes for the RSS links. While my old rss link got updated to the "upcoming news" RSS link, any newcomer will hardly see any of the wonderful new posts/news/links that get hurdled into the "unpublished" section. I realise that the moderator might be just a tad too busy to approve/publish all news :) However, might it be better to just let all the incoming news be published by default? From joelr1@REDACTED Mon Aug 13 15:40:50 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 13 Aug 2007 14:40:50 +0100 Subject: [erlang-questions] Boot files and diskless nodes Message-ID: Do diskless nodes fetch their bootfile over the network? The state that the start script gets fetched from the boot server but don't explain what the start script is. What is the start script then? Thanks, Joel -- http://wagerlabs.com From jay@REDACTED Mon Aug 13 16:19:22 2007 From: jay@REDACTED (Jay Nelson) Date: Mon, 13 Aug 2007 07:19:22 -0700 Subject: [erlang-questions] Potential EEP for binary comprehension addition Message-ID: <1A00AE79-8615-4FEB-A490-17BF2728F734@duomark.com> Binary comprehensions nicely parallel list comprehensions and add the ability to create a list or binary by visiting subsequences of a binary and transform and/or filter them. Binaries have a positional feature that can be leveraged in a way that list positions do not offer: it is highly efficient to index or extract a subsequence from a binary. Positional information can also be useful for things like indexing an external file. I haven't been able to come up with a good syntax -- the only thing I can think of is magic variables ala Perl -- but it would be nice to be able to reference positional information during the comprehension. ##PA is the absolute position in a binary that matches. ##PR is the relative position in a binary that matches. Binary = <<"abcd abcd abcd">>, Positions = [ ##PA || X:8 <<- Binary, X == $a ], Positions = [ 0, 5, 10 ], Offsets = [ ##PR l| X:8 <<-Binary, X == $a ]. Offsets = [ 0, 5, 5 ]. ##PA is useful for absolute offsets to a bit stream or a file read as binary or text. ##PR is useful when clipping out sub-binaries after filtering, or for re-encoding the binary in slices with run-lengths preceding each slice. Any suggestions on syntax or comments on the features are welcome. jay From francesco@REDACTED Mon Aug 13 17:28:48 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Mon, 13 Aug 2007 16:28:48 +0100 Subject: [erlang-questions] Erlang/OTP In-Reply-To: <46BFD515.6010700@rainbowpurple.com> References: <46B46D0D.9010302@mail.ru> <46B5AFE5.40706@mail.ru> <46BFD515.6010700@rainbowpurple.com> Message-ID: <46C078B0.4030400@erlang-consulting.com> On top of the sites suggested by Ulf and Vance, another place to look for Erlang/OTP resources is trapexit. It has a large collection of resources, including HowTos, many on OTP, its behaviors and libraries, as well the Erlang Cook Book. The link is http://www.trapexit.org Regards, Francesco -- http://www.erlang-consulting.com Hendy Irawan wrote: > Hi, > > I'm very new to Erlang and I want to get to jump on it including OTP > quickly... > > There are many resources on Erlang but I haven't seen many about OTP. > > I want to ask a few questions, I hope you don't mind: > > * Is there free resources about OTP? > * Is it free? > * How does it compare to Jungerl libs? > * Does the "Programming Erlang" (pragmatic) book include OTP in > its discussion? > * Where is the official homepage for OTP itself? > * Where can I find OTP documentation? > > Thank you very much. > -- > Hendy Irawan > www.hendyirawan.com > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From christophe.romain@REDACTED Mon Aug 13 18:13:49 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 13 Aug 2007 18:13:49 +0200 Subject: [erlang-questions] About Planet Erlang In-Reply-To: <46C05480.206@gmail.com> References: <46C05480.206@gmail.com> Message-ID: <64C6FA4D-6AA1-4393-B8C3-D7F5D1E5B02A@process-one.net> > However, when you visit the site, the situation is very different. Yes, news have to be voted by readers to be on main page. > I realise that the moderator might be just a tad too busy to > approve/publish all news :) However, might it be better to just > let all > the incoming news be published by default? No, that is not the way it should work. If you read article from "Upcomming news" (available by rss feed as well) and think it should be on main page, just vote for it ! most voted articles will be published on main page. From bob@REDACTED Mon Aug 13 18:46:04 2007 From: bob@REDACTED (Bob Ippolito) Date: Mon, 13 Aug 2007 09:46:04 -0700 Subject: [erlang-questions] About Planet Erlang In-Reply-To: <64C6FA4D-6AA1-4393-B8C3-D7F5D1E5B02A@process-one.net> References: <46C05480.206@gmail.com> <64C6FA4D-6AA1-4393-B8C3-D7F5D1E5B02A@process-one.net> Message-ID: <6a36e7290708130946t4f351bd0n73c52471fbd3847e@mail.gmail.com> On 8/13/07, Christophe Romain wrote: > > However, when you visit the site, the situation is very different. > > Yes, news have to be voted by readers to be on main page. > > > I realise that the moderator might be just a tad too busy to > > approve/publish all news :) However, might it be better to just > > let all > > the incoming news be published by default? > > No, that is not the way it should work. > If you read article from "Upcomming news" (available by rss feed as > well) and think it should be on main page, just vote for it ! > most voted articles will be published on main page. Maybe the threshold is too high? 2 or 3 would probably work better than 5, at least on weekend news. -bob From dmitriid@REDACTED Tue Aug 14 09:03:14 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 14 Aug 2007 10:03:14 +0300 Subject: [erlang-questions] About Planet Erlang In-Reply-To: <6a36e7290708130946t4f351bd0n73c52471fbd3847e@mail.gmail.com> References: <46C05480.206@gmail.com> <64C6FA4D-6AA1-4393-B8C3-D7F5D1E5B02A@process-one.net> <6a36e7290708130946t4f351bd0n73c52471fbd3847e@mail.gmail.com> Message-ID: <46C153B2.8020602@gmail.com> >> No, that is not the way it should work. >> If you read article from "Upcomming news" (available by rss feed as >> well) and think it should be on main page, just vote for it ! >> most voted articles will be published on main page. >> > > Maybe the threshold is too high? 2 or 3 would probably work better > than 5, at least on weekend news. > > Indeed -------------- next part -------------- An HTML attachment was scrubbed... URL: From monch1962@REDACTED Tue Aug 14 09:57:55 2007 From: monch1962@REDACTED (David Mitchell) Date: Tue, 14 Aug 2007 17:57:55 +1000 Subject: [erlang-questions] Load testing in parallel In-Reply-To: <46C0470B.8080401@gmail.com> References: <46C0470B.8080401@gmail.com> Message-ID: Great tip Serge! Like many others, I'm new to Erlang - I've read through the "Programming Erlang" book, "Thinking in Erlang" and various PDFs at the main Erlang site. I've written a few trivial bits of code, identified and sorted out a bunch of problems I've created, and now I'm moving into using Erlang for larger projects. However, I've never come across info about now() and timer.diff() before; like Ahmed, I've been using statistics(wall_clock) for profiling purposes. Where is that type of info documented? Is it only in the various library APIs (and thus I'll have to work through each of these to get a handle on this type of info), or is there some "best practices"-type documentation I haven't yet stumbled on? I don't mind putting in the time to do my research, but I suspect I'm not yet across all the "good" sources of info. Thanks in advance Dave M. On 13/08/07, Serge Aleynikov wrote: > You have several problems with this code: > > 1. Since you don't provide implementation of generate_lists/3, I assume > it returns a flat list. In this case in the start function you call: > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > if here Head is not a list, whereas run_process/4 expects a list > as the third argument, lists:map/2 function would > crashes the process silently. You can fix it by changing that line > to: > spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), > > > 2. Also you use the following call to obtain time: > > {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). > > Wallclock_Time_Since_Last_Call is time in milliseconds, so unless > evaluated function takes more than a millisecond you'd get a 0. > > Moreover, unfortunately Wallclock_Time_Since_Last_Call is a *globally > shared* counter, so any process that calls statistics would cause a > reset of this value. So in a concurrent system where many processes > use this function you'll likely always get a zero. > > use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) > to measure time. > > Serge > > > > Ahmed Ali wrote: > > Hi all, > > > > I've been trying to load test a function in my code. The way I'm doing it is > > to generate lists of the data I want to process, start a process for each > > list and calculate runtime for each process. The function that I implemented > > will call a WebService operation in a different host for each data. > > > > I have the code below for this test. what I do is basically run > > load_test(10, 1000) to generate 10 lists, each with 1000 data in it. > > > > The problem is that WebService call is done successfully but I don't get any > > output for the statistics. When I run the code sequentially (i.e. instead of > > spawn the call to run_process, I call run_process directly) I get the output > > with no issues. Is there something that I missed in the code below? I > > appreciate your help. > > > > Best regards, > > > > Ahmed Al-Issaei > > > > run_process(Num, Fun, List, _Pid) -> > > statistics(wall_clock), > > io:format("load testing process~n"), > > lists:map(Fun, List), > > {_, Time2} = statistics(wall_clock), > > U2 = Time2 / 1000, > > io:format("Num (~s) done: total time = ~p~n",[Num, U2]). > > > > start(_N, _Op, [], _Pid) -> > > true; > > start(Num, Op, Final, Pid) -> > > [Head | Rest] = Final, > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > start(Num-1, Op, Rest, Pid). > > > > load_test(Threads, Size) -> > > List = generate_lists(Threads, Size, []), > > Op = fun(X) -> call_ws_create(X) end, > > start(Threads, Op, List, self()). > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ahmed.nawras@REDACTED Tue Aug 14 11:10:18 2007 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Tue, 14 Aug 2007 13:10:18 +0400 Subject: [erlang-questions] Load testing in parallel In-Reply-To: References: <46C0470B.8080401@gmail.com> Message-ID: Hi All, Thanks for the info. It was really useful for me. Serge, Your assumption is true about the list, it is flat list. Also, there's no issue what so ever with spawn call, because it is working correctly. It's just the time that wouldn't output. timer:now_diff/2 is very useful and it is exactly what I've been looking for. I discovered that i should change the last line in run_process/4 to: io:format("Num ~p done: total time = ~p~n",[Num, U2]). (i.e. ~p instead of ~s) :) Best regards, Ahmed Al-Issaei On 8/14/07, David Mitchell wrote: > > Great tip Serge! > > Like many others, I'm new to Erlang - I've read through the > "Programming Erlang" book, "Thinking in Erlang" and various PDFs at > the main Erlang site. I've written a few trivial bits of code, > identified and sorted out a bunch of problems I've created, and now > I'm moving into using Erlang for larger projects. However, I've never > come across info about now() and timer.diff() before; like Ahmed, I've > been using statistics(wall_clock) for profiling purposes. > > Where is that type of info documented? Is it only in the various > library APIs (and thus I'll have to work through each of these to get > a handle on this type of info), or is there some "best practices"-type > documentation I haven't yet stumbled on? I don't mind putting in the > time to do my research, but I suspect I'm not yet across all the > "good" sources of info. > > Thanks in advance > > Dave M. > > On 13/08/07, Serge Aleynikov wrote: > > You have several problems with this code: > > > > 1. Since you don't provide implementation of generate_lists/3, I assume > > it returns a flat list. In this case in the start function you > call: > > > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > > > if here Head is not a list, whereas run_process/4 expects a list > > as the third argument, lists:map/2 function would > > crashes the process silently. You can fix it by changing that line > > to: > > spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), > > > > > > 2. Also you use the following call to obtain time: > > > > {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). > > > > Wallclock_Time_Since_Last_Call is time in milliseconds, so unless > > evaluated function takes more than a millisecond you'd get a 0. > > > > Moreover, unfortunately Wallclock_Time_Since_Last_Call is a > *globally > > shared* counter, so any process that calls statistics would cause a > > reset of this value. So in a concurrent system where many processes > > use this function you'll likely always get a zero. > > > > use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) > > to measure time. > > > > Serge > > > > > > > > Ahmed Ali wrote: > > > Hi all, > > > > > > I've been trying to load test a function in my code. The way I'm doing > it is > > > to generate lists of the data I want to process, start a process for > each > > > list and calculate runtime for each process. The function that I > implemented > > > will call a WebService operation in a different host for each data. > > > > > > I have the code below for this test. what I do is basically run > > > load_test(10, 1000) to generate 10 lists, each with 1000 data in it. > > > > > > The problem is that WebService call is done successfully but I don't > get any > > > output for the statistics. When I run the code sequentially (i.e. > instead of > > > spawn the call to run_process, I call run_process directly) I get the > output > > > with no issues. Is there something that I missed in the code below? I > > > appreciate your help. > > > > > > Best regards, > > > > > > Ahmed Al-Issaei > > > > > > run_process(Num, Fun, List, _Pid) -> > > > statistics(wall_clock), > > > io:format("load testing process~n"), > > > lists:map(Fun, List), > > > {_, Time2} = statistics(wall_clock), > > > U2 = Time2 / 1000, > > > io:format("Num (~s) done: total time = ~p~n",[Num, U2]). > > > > > > start(_N, _Op, [], _Pid) -> > > > true; > > > start(Num, Op, Final, Pid) -> > > > [Head | Rest] = Final, > > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > > start(Num-1, Op, Rest, Pid). > > > > > > load_test(Threads, Size) -> > > > List = generate_lists(Threads, Size, []), > > > Op = fun(X) -> call_ws_create(X) end, > > > start(Threads, Op, List, self()). > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue Aug 14 11:57:27 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 14 Aug 2007 11:57:27 +0200 Subject: [erlang-questions] Load testing in parallel In-Reply-To: References: <46C0470B.8080401@gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F9223155026521C3@esealmw115.eemea.ericsson.se> I think there could be a chapter in the efficiency guide about simple benchmarking. There is a chapter, but it feels a bit complicated. Personally, I am fond of timer:tc(M, F, A). It's a very convenient way to get a rough picture of the cost of different operations. It's not very useful for very cheap functions. Perhaps one could add a timer:tc(N, M, F, A), which calls apply(M, F, A) N times, and reports how long it took? -module(timer1). -export([tc/4]). tc(N, M, F, A) when N > 0 -> Pid = spawn_opt(fun() -> exit(call_acc(N, M, F, A, erlang:now(), [])) end, [{min_heap_size, 10000}]), MRef = erlang:monitor(process, Pid), receive {'DOWN', MRef, process, _, Result} -> Result end. call_acc(N, M, F, A, St, Acc) when N > 0 -> call_acc(N-1, M, F, A, St, [catch apply(M, F, A)|Acc]); call_acc(0, _, _, _, Start, Acc) -> Stop = erlang:now(), {timer:now_diff(Stop, Start), lists:reverse(Acc)}. Example: 2> timer:tc(lists,reverse,[[1,2,3,4,5,6,7,8,9,10]]). {6,[10,9,8,7,6,5,4,3,2,1]} 3> timer1:tc(10, lists,reverse, [lists:seq(1,10)]). {12, [[10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1]]} 4> timer1:tc(100, lists,reverse, [lists:seq(1,10)]). {90, [[10,9,8,7,6,5,4,3,2,1], ... 5> timer1:tc(1000, lists,reverse, [lists:seq(1,10)]). {2121, [[10,9,8,7,6,5,4,3,2,1], [10,9,8,7,6,5,4,3,2,1], ... 6> {_, Term} = timer1:tc(1000, lists,reverse,...). ... 7> erts_debug:flat_size(Term) 22000 Showing that the result is quite different depending on how many iterations we measure on: #iter time/iter 1 6 10 3 100 0.9 1000 2.1 The accumulated value over 1000 iterations is larger than the heap size of the process, which means that GC cost is included in the last measurement. The included module turns off accumulation by default, and adds a tc/5, with the option whether or not to accumulate. In the case of no accumulation, the last result is returned. It's not perfect by any means, but I find it useful for quick measurements in the erlang shell. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > David Mitchell > Sent: den 14 augusti 2007 09:58 > To: Erlang > Subject: Re: [erlang-questions] Load testing in parallel > > Great tip Serge! > > Like many others, I'm new to Erlang - I've read through the > "Programming Erlang" book, "Thinking in Erlang" and various > PDFs at the main Erlang site. I've written a few trivial > bits of code, identified and sorted out a bunch of problems > I've created, and now I'm moving into using Erlang for larger > projects. However, I've never come across info about now() > and timer.diff() before; like Ahmed, I've been using > statistics(wall_clock) for profiling purposes. > > Where is that type of info documented? Is it only in the > various library APIs (and thus I'll have to work through each > of these to get a handle on this type of info), or is there > some "best practices"-type documentation I haven't yet > stumbled on? I don't mind putting in the time to do my > research, but I suspect I'm not yet across all the "good" > sources of info. > > Thanks in advance > > Dave M. > > On 13/08/07, Serge Aleynikov wrote: > > You have several problems with this code: > > > > 1. Since you don't provide implementation of > generate_lists/3, I assume > > it returns a flat list. In this case in the start > function you call: > > > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > > > if here Head is not a list, whereas run_process/4 expects a list > > as the third argument, lists:map/2 function would > > crashes the process silently. You can fix it by > changing that line > > to: > > spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), > > > > > > 2. Also you use the following call to obtain time: > > > > {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). > > > > Wallclock_Time_Since_Last_Call is time in milliseconds, > so unless > > evaluated function takes more than a millisecond you'd get a 0. > > > > Moreover, unfortunately Wallclock_Time_Since_Last_Call > is a *globally > > shared* counter, so any process that calls statistics > would cause a > > reset of this value. So in a concurrent system where > many processes > > use this function you'll likely always get a zero. > > > > use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) > > to measure time. > > > > Serge > > > > > > > > Ahmed Ali wrote: > > > Hi all, > > > > > > I've been trying to load test a function in my code. The way I'm > > > doing it is to generate lists of the data I want to > process, start a > > > process for each list and calculate runtime for each process. The > > > function that I implemented will call a WebService > operation in a different host for each data. > > > > > > I have the code below for this test. what I do is basically run > > > load_test(10, 1000) to generate 10 lists, each with 1000 > data in it. > > > > > > The problem is that WebService call is done successfully > but I don't > > > get any output for the statistics. When I run the code > sequentially > > > (i.e. instead of spawn the call to run_process, I call > run_process > > > directly) I get the output with no issues. Is there > something that I > > > missed in the code below? I appreciate your help. > > > > > > Best regards, > > > > > > Ahmed Al-Issaei > > > > > > run_process(Num, Fun, List, _Pid) -> > > > statistics(wall_clock), > > > io:format("load testing process~n"), > > > lists:map(Fun, List), > > > {_, Time2} = statistics(wall_clock), > > > U2 = Time2 / 1000, > > > io:format("Num (~s) done: total time = ~p~n",[Num, U2]). > > > > > > start(_N, _Op, [], _Pid) -> > > > true; > > > start(Num, Op, Final, Pid) -> > > > [Head | Rest] = Final, > > > spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > > > start(Num-1, Op, Rest, Pid). > > > > > > load_test(Threads, Size) -> > > > List = generate_lists(Threads, Size, []), > > > Op = fun(X) -> call_ws_create(X) end, > > > start(Threads, Op, List, self()). > > > > > > > > > > > > > -------------------------------------------------------------------- > > > ---- > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- A non-text attachment was scrubbed... Name: timer1.erl Type: application/octet-stream Size: 936 bytes Desc: timer1.erl URL: From saleyn@REDACTED Tue Aug 14 13:12:47 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Tue, 14 Aug 2007 06:12:47 -0500 Subject: [erlang-questions] Game of Erlang life [was: Load testing in parallel] In-Reply-To: References: <46C0470B.8080401@gmail.com> Message-ID: <46C18E2F.8040806@gmail.com> So far the best resource of OTP documentation is the on-line reference: http://www.erlang.org/doc. Sometimes this documentation may seem odd or vague for newcomers, yet the more you learn Erlang/OTP the more you understand and appreciate the format, depth and value of the content. Once you mastered first "Programming Erlang" chapters (ch.1-15, excluding OTP ones) I suggest that you start by studying on-line module documentation under "Basic Applications": stdlib and kernel. They expose a wealth of functions, many of which you'll find used in all projects. Despite the fact that it may seem like a lot of information, if you approach this studying methodically and patiently, you'll be able to filter content on the module level first (i.e. gaining high-level understanding of what each module does) and then in those modules that seem to trigger more of your interest (like kernel/erlang, stdlib/io, stdlib/ets, etc.) study documented functions. Don't worry about OTP (aside from stdlib and kernel applications) as much in the beginning - when you feel you have a good grasp on basic functions available in the two apps above, read the Design Principles guide [1] to understand OTP behaviors - which is the "meat" part of the framework that gives you the power of increasing your coding productivity by implying practical and reliable abstractions. At this point, go back to "Programming Erlang" and study the OTP-related chapters (ch.16 onward) that give you application examples of how to use behaviors. This will conclude your "first circle of Erlang life" and give you enough knowledge to move on to exploiting the power of Erlang/OTP in your projects. The "second circle of Erlang life" will begin when your curiosity will drive you to understanding that Erlang is *open source* and you'll start exploring the sources of OTP applications included in distribution. That is when you'll actually begin seeing that on-line documentation is rather good. When you are comfortable with OTP code you may find bugs and post them to the erlang-bugs@REDACTED list, and also make some contributions. The "third circle of Erlang life" will begin when you discover that Erlang's performance sucks at number-crunching applications (which are not the domain of problems Erlang was designed for), and begin writing ports and drivers to overcome these bottlenecks. Additionally As a conclusion of this circle you'll be quite fascinated at how much thought was put in preventing mis-behaving user code crash the Erlang emulator. The "forth circle of Erlang life" will begin when your curiosity drives you to studying sources of the Erlang emulator. Here you'll learn how I/O multiplexing, garbage collection, bytecode execution, etc. is done, and answer some of more advanced questions you might have accumulated about features of the run-time system. By this time others will find that you are "... more object oriented in thinking than most of his C++ guys" [2]. The "next circle of Erlang life" will begin when you manage to get a job that will let your evolution as an Erlang programmer use acquired knowledge during day-time. Since not many companies know the hidden powers of Erlang, this will largely depend on your abilities to show the strength of Erlang/OTP development to your manager, find suitable projects, and generate spin to share this knowledge and apply it in your organization. Regards, Serge [1] http://www.erlang.org/doc/design_principles/part_frame.html [2] http://www.erlang.org/pipermail/erlang-questions/2007-August/028392.html David Mitchell wrote: > Great tip Serge! > > Like many others, I'm new to Erlang - I've read through the > "Programming Erlang" book, "Thinking in Erlang" and various PDFs at > the main Erlang site. I've written a few trivial bits of code, > identified and sorted out a bunch of problems I've created, and now > I'm moving into using Erlang for larger projects. However, I've never > come across info about now() and timer.diff() before; like Ahmed, I've > been using statistics(wall_clock) for profiling purposes. > > Where is that type of info documented? Is it only in the various > library APIs (and thus I'll have to work through each of these to get > a handle on this type of info), or is there some "best practices"-type > documentation I haven't yet stumbled on? I don't mind putting in the > time to do my research, but I suspect I'm not yet across all the > "good" sources of info. > > Thanks in advance > > Dave M. > > On 13/08/07, Serge Aleynikov wrote: >> You have several problems with this code: >> >> 1. Since you don't provide implementation of generate_lists/3, I assume >> it returns a flat list. In this case in the start function you call: >> >> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), >> >> if here Head is not a list, whereas run_process/4 expects a list >> as the third argument, lists:map/2 function would >> crashes the process silently. You can fix it by changing that line >> to: >> spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), >> >> >> 2. Also you use the following call to obtain time: >> >> {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). >> >> Wallclock_Time_Since_Last_Call is time in milliseconds, so unless >> evaluated function takes more than a millisecond you'd get a 0. >> >> Moreover, unfortunately Wallclock_Time_Since_Last_Call is a *globally >> shared* counter, so any process that calls statistics would cause a >> reset of this value. So in a concurrent system where many processes >> use this function you'll likely always get a zero. >> >> use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) >> to measure time. >> >> Serge >> >> >> >> Ahmed Ali wrote: >>> Hi all, >>> >>> I've been trying to load test a function in my code. The way I'm doing it is >>> to generate lists of the data I want to process, start a process for each >>> list and calculate runtime for each process. The function that I implemented >>> will call a WebService operation in a different host for each data. >>> >>> I have the code below for this test. what I do is basically run >>> load_test(10, 1000) to generate 10 lists, each with 1000 data in it. >>> >>> The problem is that WebService call is done successfully but I don't get any >>> output for the statistics. When I run the code sequentially (i.e. instead of >>> spawn the call to run_process, I call run_process directly) I get the output >>> with no issues. Is there something that I missed in the code below? I >>> appreciate your help. >>> >>> Best regards, >>> >>> Ahmed Al-Issaei >>> >>> run_process(Num, Fun, List, _Pid) -> >>> statistics(wall_clock), >>> io:format("load testing process~n"), >>> lists:map(Fun, List), >>> {_, Time2} = statistics(wall_clock), >>> U2 = Time2 / 1000, >>> io:format("Num (~s) done: total time = ~p~n",[Num, U2]). >>> >>> start(_N, _Op, [], _Pid) -> >>> true; >>> start(Num, Op, Final, Pid) -> >>> [Head | Rest] = Final, >>> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), >>> start(Num-1, Op, Rest, Pid). >>> >>> load_test(Threads, Size) -> >>> List = generate_lists(Threads, Size, []), >>> Op = fun(X) -> call_ws_create(X) end, >>> start(Threads, Op, List, self()). From ahmed.nawras@REDACTED Tue Aug 14 14:33:25 2007 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Tue, 14 Aug 2007 16:33:25 +0400 Subject: [erlang-questions] Game of Erlang life [was: Load testing in parallel] In-Reply-To: <46C18E2F.8040806@gmail.com> References: <46C0470B.8080401@gmail.com> <46C18E2F.8040806@gmail.com> Message-ID: Hi Serge, Actually, I'm not sure if the last 3 "circles" are seperate at all. It seems to me that "number crunching" circle could be in the first part when learning Erlang. Same for the 4th one. Are you referring to implementation of the last 2 circles when you divide it to different stages? Best regards, Ahmed Al-Issaei On 8/14/07, Serge Aleynikov wrote: > > So far the best resource of OTP documentation is the on-line reference: > http://www.erlang.org/doc. > > Sometimes this documentation may seem odd or vague for newcomers, yet > the more you learn Erlang/OTP the more you understand and appreciate the > format, depth and value of the content. > > Once you mastered first "Programming Erlang" chapters (ch.1-15, > excluding OTP ones) I suggest that you start by studying on-line module > documentation under "Basic Applications": stdlib and kernel. They > expose a wealth of functions, many of which you'll find used in all > projects. Despite the fact that it may seem like a lot of information, > if you approach this studying methodically and patiently, you'll be able > to filter content on the module level first (i.e. gaining high-level > understanding of what each module does) and then in those modules that > seem to trigger more of your interest (like kernel/erlang, stdlib/io, > stdlib/ets, etc.) study documented functions. > > Don't worry about OTP (aside from stdlib and kernel applications) as > much in the beginning - when you feel you have a good grasp on basic > functions available in the two apps above, read the Design Principles > guide [1] to understand OTP behaviors - which is the "meat" part of the > framework that gives you the power of increasing your coding > productivity by implying practical and reliable abstractions. > > At this point, go back to "Programming Erlang" and study the OTP-related > chapters (ch.16 onward) that give you application examples of how to use > behaviors. This will conclude your "first circle of Erlang life" and > give you enough knowledge to move on to exploiting the power of > Erlang/OTP in your projects. > > The "second circle of Erlang life" will begin when your curiosity will > drive you to understanding that Erlang is *open source* and you'll start > exploring the sources of OTP applications included in distribution. > That is when you'll actually begin seeing that on-line documentation is > rather good. When you are comfortable with OTP code you may find bugs > and post them to the erlang-bugs@REDACTED list, and also make some > contributions. > > The "third circle of Erlang life" will begin when you discover that > Erlang's performance sucks at number-crunching applications (which are > not the domain of problems Erlang was designed for), and begin writing > ports and drivers to overcome these bottlenecks. Additionally As a > conclusion of this circle you'll be quite fascinated at how much thought > was put in preventing mis-behaving user code crash the Erlang emulator. > > The "forth circle of Erlang life" will begin when your curiosity drives > you to studying sources of the Erlang emulator. Here you'll learn how > I/O multiplexing, garbage collection, bytecode execution, etc. is done, > and answer some of more advanced questions you might have accumulated > about features of the run-time system. > > By this time others will find that you are "... more object oriented in > thinking than most of his C++ guys" [2]. The "next circle of Erlang > life" will begin when you manage to get a job that will let your > evolution as an Erlang programmer use acquired knowledge during > day-time. Since not many companies know the hidden powers of Erlang, > this will largely depend on your abilities to show the strength of > Erlang/OTP development to your manager, find suitable projects, and > generate spin to share this knowledge and apply it in your organization. > > Regards, > > Serge > > > [1] http://www.erlang.org/doc/design_principles/part_frame.html > [2] > http://www.erlang.org/pipermail/erlang-questions/2007-August/028392.html > > > David Mitchell wrote: > > Great tip Serge! > > > > Like many others, I'm new to Erlang - I've read through the > > "Programming Erlang" book, "Thinking in Erlang" and various PDFs at > > the main Erlang site. I've written a few trivial bits of code, > > identified and sorted out a bunch of problems I've created, and now > > I'm moving into using Erlang for larger projects. However, I've never > > come across info about now() and timer.diff() before; like Ahmed, I've > > been using statistics(wall_clock) for profiling purposes. > > > > Where is that type of info documented? Is it only in the various > > library APIs (and thus I'll have to work through each of these to get > > a handle on this type of info), or is there some "best practices"-type > > documentation I haven't yet stumbled on? I don't mind putting in the > > time to do my research, but I suspect I'm not yet across all the > > "good" sources of info. > > > > Thanks in advance > > > > Dave M. > > > > On 13/08/07, Serge Aleynikov wrote: > >> You have several problems with this code: > >> > >> 1. Since you don't provide implementation of generate_lists/3, I assume > >> it returns a flat list. In this case in the start function you > call: > >> > >> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > >> > >> if here Head is not a list, whereas run_process/4 expects a list > >> as the third argument, lists:map/2 function would > >> crashes the process silently. You can fix it by changing that line > >> to: > >> spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), > >> > >> > >> 2. Also you use the following call to obtain time: > >> > >> {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). > >> > >> Wallclock_Time_Since_Last_Call is time in milliseconds, so unless > >> evaluated function takes more than a millisecond you'd get a 0. > >> > >> Moreover, unfortunately Wallclock_Time_Since_Last_Call is a > *globally > >> shared* counter, so any process that calls statistics would cause a > >> reset of this value. So in a concurrent system where many > processes > >> use this function you'll likely always get a zero. > >> > >> use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) > >> to measure time. > >> > >> Serge > >> > >> > >> > >> Ahmed Ali wrote: > >>> Hi all, > >>> > >>> I've been trying to load test a function in my code. The way I'm doing > it is > >>> to generate lists of the data I want to process, start a process for > each > >>> list and calculate runtime for each process. The function that I > implemented > >>> will call a WebService operation in a different host for each data. > >>> > >>> I have the code below for this test. what I do is basically run > >>> load_test(10, 1000) to generate 10 lists, each with 1000 data in it. > >>> > >>> The problem is that WebService call is done successfully but I don't > get any > >>> output for the statistics. When I run the code sequentially (i.e. > instead of > >>> spawn the call to run_process, I call run_process directly) I get the > output > >>> with no issues. Is there something that I missed in the code below? I > >>> appreciate your help. > >>> > >>> Best regards, > >>> > >>> Ahmed Al-Issaei > >>> > >>> run_process(Num, Fun, List, _Pid) -> > >>> statistics(wall_clock), > >>> io:format("load testing process~n"), > >>> lists:map(Fun, List), > >>> {_, Time2} = statistics(wall_clock), > >>> U2 = Time2 / 1000, > >>> io:format("Num (~s) done: total time = ~p~n",[Num, U2]). > >>> > >>> start(_N, _Op, [], _Pid) -> > >>> true; > >>> start(Num, Op, Final, Pid) -> > >>> [Head | Rest] = Final, > >>> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), > >>> start(Num-1, Op, Rest, Pid). > >>> > >>> load_test(Threads, Size) -> > >>> List = generate_lists(Threads, Size, []), > >>> Op = fun(X) -> call_ws_create(X) end, > >>> start(Threads, Op, List, self()). > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dking@REDACTED Tue Aug 14 17:43:54 2007 From: dking@REDACTED (David King) Date: Tue, 14 Aug 2007 08:43:54 -0700 Subject: [erlang-questions] mnemosyne reference Message-ID: <1D3851BA-CAA5-4307-9D86-30A91918B790@ketralnis.com> Are there are good mnemosyne/QLC cheat-cheats around? How about a reference that says, "To do this in SQL, do this in Mnemosyne..."? The examples in the mnemosyne and qlc manpages are good, but they don't show how to form very complicated queries. I'm trying to translate a few SQL queries, most of which are about half a page long. Is the paradigm so different that writing a reference like that would be non-sequitur? From opendev@REDACTED Tue Aug 14 18:00:57 2007 From: opendev@REDACTED (Joern) Date: Tue, 14 Aug 2007 18:00:57 +0200 Subject: [erlang-questions] Configuration management below the application layer? Message-ID: <9e009ad0708140900j758a92d3q3bbb3fa502b285a2@mail.gmail.com> Dear list, I am aware of the application-wide configuration mechanisms provided by the OTP. Now I am interested in the configuration of individual, named (registered) processes. My initial idea was like this: - Provide a gen_server which maintains the configuration data. It's API would allow the re-reading of configuration options, provides named processes with the configuration data relevant to them and applies defaults where not overridden (via proplists) - All configurable modules must maintain an arbitrary { state, ... } record which has an arbitrary { config, ... } record in it. - All configurable modules must accept a system message { configuration_changed, { config, ... } }. Depending wheater the configuration change requires a restart of that component or not { stop, configuration_changed ... } or { no_reply, ... } is returned. Now to my problem: behaviours functions are class-functions, so I have no sensible way (except cascading behaviours for gen_*) of getting an appropriate handle_info(...) into the configurable module. Is there some way to add "instance" inheritance to behaviours? Yariv Sadans smerl seems to "extend" on function name and arity instead of patterns. Or is there some obvious way to handle configuration management for processes I am not aware of? Thanks again, Joern -- From kenneth.lundin@REDACTED Tue Aug 14 18:11:53 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 14 Aug 2007 18:11:53 +0200 Subject: [erlang-questions] mnemosyne reference In-Reply-To: <1D3851BA-CAA5-4307-9D86-30A91918B790@ketralnis.com> References: <1D3851BA-CAA5-4307-9D86-30A91918B790@ketralnis.com> Message-ID: Hi, I think you should forget Mnemosyne, we will discontinue support and delivery of Mnemosyne before end of the year. QLC is the supported alternative. QLC does not support all types of complicated queries that can be expressed in SQL. For example QLC today only support join of 2 tables. Support for join of 3 and more tables + more optimizations planned. /Kenneth (Erlang/OTP team at Ericsson) On 8/14/07, David King wrote: > Are there are good mnemosyne/QLC cheat-cheats around? How about a > reference that says, "To do this in SQL, do this in Mnemosyne..."? > > The examples in the mnemosyne and qlc manpages are good, but they > don't show how to form very complicated queries. I'm trying to > translate a few SQL queries, most of which are about half a page > long. Is the paradigm so different that writing a reference like that > would be non-sequitur? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dustin@REDACTED Tue Aug 14 23:44:52 2007 From: dustin@REDACTED (Dustin Sallings) Date: Tue, 14 Aug 2007 14:44:52 -0700 Subject: [erlang-questions] slow message processing in cluster Message-ID: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> Hi *, I've got a cluster of five nodes across two machines and I'm finding my message queues are getting really full on my remote nodes. I'm pushing some rather large data around. This application consists of a process that reads a file and translates them into http requests (many are posts with binary contents), a process to issue the requests, and a process to handle the responses. I'm using http:request (async) to issue my requests from a process whose job is to time and track requests and send the responses back to the ``master'' process for dispatch. The problem I'm experiencing is in this process. The source code is available here: http://hg.west.spy.net/hg/erlang/httpload/file/fc80675fc138/src/ http_requestor.erl When this process is running on a remote node, the message queue grows fairly rapidly, but it's fine on the local node. I assumed this might be because of the response, so I pushed that out into yet another process (locally queue the outbound message so I can quickly get back to my input queue), but it had no effect. This is what ni() in an interactive session shows me: <5253.14588.0> net_kernel:spawn_func/6 8024355 23848914 7332 http_requestor gen:wait_resp_mon/3 35 <5253.14589.0> erlang:apply/2 2584 156940 0 http_response_sender http_requestor:response_sender_lo 1 I named the processes for clarity (note that this is showing the version I altered to separate local vs. remote node sending -- that detail seemed to not matter). Examining the message queue, I see good mix of request and response messages. I am observing responses coming back from every node, even though the queues are always bigger each time I look. Any clues as to how I might get stuff moving along a bit more smoothly? -- Dustin Sallings -------------- next part -------------- An HTML attachment was scrubbed... URL: From dloutrein.lists@REDACTED Wed Aug 15 00:52:40 2007 From: dloutrein.lists@REDACTED (denis) Date: Tue, 14 Aug 2007 18:52:40 -0400 Subject: [erlang-questions] Extending error_logger Message-ID: <006a01c7dec5$d310b6c0$b029030a@mtl.ubisoft.org> Hi all, In my server, which is an OTP application using supervisor, gen_servers, ., I use error_logger to log my information. I would like to modify error_logger to add one kind of message: debug, link error, debug, info. Is there a clean way to add it to error_logger ? I dug the source, but not find an easy way. For now, the only solution I found is to implement my own logger implementing all I need, and trap the events sent to error_logger by OTP framework. If I'm not mistaken, I can do it by writing my logger as event handler and register it with error_logger: add_report_handler. Am I one the good track ? Maybe there is a simpler method to do it ? Note that I also want to store logs as text file. I think that write a new error handler should do the job, like log_mf_h. Thanks Denis From bob@REDACTED Wed Aug 15 01:39:30 2007 From: bob@REDACTED (Bob Ippolito) Date: Tue, 14 Aug 2007 16:39:30 -0700 Subject: [erlang-questions] slow message processing in cluster In-Reply-To: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> References: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> Message-ID: <6a36e7290708141639y7fe74dav3e73ea22d4d07a13@mail.gmail.com> You might want to take a look at the options in the http module. The client has some pretty low concurrency by default (e.g. max 2 connections per host, look at max_sessions). -bob On 8/14/07, Dustin Sallings wrote: > > > Hi *, > > I've got a cluster of five nodes across two machines and I'm finding my > message queues are getting really full on my remote nodes. > > I'm pushing some rather large data around. This application consists of a > process that reads a file and translates them into http requests (many are > posts with binary contents), a process to issue the requests, and a process > to handle the responses. > > I'm using http:request (async) to issue my requests from a process whose > job is to time and track requests and send the responses back to the > ``master'' process for dispatch. > > The problem I'm experiencing is in this process. The source code is > available here: > > > http://hg.west.spy.net/hg/erlang/httpload/file/fc80675fc138/src/http_requestor.erl > > When this process is running on a remote node, the message queue grows > fairly rapidly, but it's fine on the local node. I assumed this might be > because of the response, so I pushed that out into yet another process > (locally queue the outbound message so I can quickly get back to my input > queue), but it had no effect. > > This is what ni() in an interactive session shows me: > > > <5253.14588.0> net_kernel:spawn_func/6 8024355 23848914 > 7332 > http_requestor gen:wait_resp_mon/3 35 > > <5253.14589.0> erlang:apply/2 2584 156940 > 0 > http_response_sender http_requestor:response_sender_lo > 1 > I named the processes for clarity (note that this is showing the version I > altered to separate local vs. remote node sending -- that detail seemed to > not matter). > > > Examining the message queue, I see good mix of request and response > messages. I am observing responses coming back from every node, even though > the queues are always bigger each time I look. > > Any clues as to how I might get stuff moving along a bit more smoothly? > > > -- > Dustin Sallings > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dustin@REDACTED Wed Aug 15 02:03:49 2007 From: dustin@REDACTED (Dustin Sallings) Date: Tue, 14 Aug 2007 17:03:49 -0700 Subject: [erlang-questions] slow message processing in cluster In-Reply-To: <6a36e7290708141639y7fe74dav3e73ea22d4d07a13@mail.gmail.com> References: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> <6a36e7290708141639y7fe74dav3e73ea22d4d07a13@mail.gmail.com> Message-ID: <7F4E6809-1A3B-444B-A3DD-84F0D814C0BB@spy.net> On Aug 14, 2007, at 16:39 , Bob Ippolito wrote: > You might want to take a look at the options in the http module. The > client has some pretty low concurrency by default (e.g. max 2 > connections per host, look at max_sessions). I adjusted both of those and didn't find anything terribly interesting. I was a little afraid it might be the http client, but I don't have much visibility into how that works. My goal is to send a large number of http requests over a short amount of time. Is there any appropriate tuning to achieve this or at least detect if it's the cause of my problems? Thanks. -- Dustin Sallings From dustin@REDACTED Wed Aug 15 03:19:57 2007 From: dustin@REDACTED (Dustin Sallings) Date: Tue, 14 Aug 2007 18:19:57 -0700 Subject: [erlang-questions] slow message processing in cluster In-Reply-To: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> References: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> Message-ID: <3CBC930C-89EE-4EA9-B917-B562CFFB09BB@spy.net> On Aug 14, 2007, at 14:44 , Dustin Sallings wrote: > Any clues as to how I might get stuff moving along a bit more > smoothly? It had been starting up fine, but would always hang after it'd been running for a few minutes. It's currently been running for about an hour flawlessly. The difference between this run and previous runs is that I was using a hostname for the requests and now I'm using the IP address. Apparently it was hanging in the resolver. -- Dustin Sallings -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Wed Aug 15 09:26:07 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 15 Aug 2007 09:26:07 +0200 Subject: [erlang-questions] rpc from erlang to java Message-ID: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> Hi all, I'm not sure how many people are interacting with Java from Erlang, but I am (for ErlIDE) and I just implemented a nice feature (if I may say so myself) that might of interest: the ability to call Java code from Erlang. The reason I needed this is that I want to move as much erlide core functionality from Java code to Erlang code, but doing it without rpcs would have meant writing an awful lot of wrapper classes around the Eclipse API. So what I can do now (work is still in progress) is for example {ok, Map} = jrpc:call("java.util.HashMap", "HashMap", []), jrpc:call(Map, "put", "theKey", {some, kind, of value}), The conversion layer converts between Erlang terms and Java objects, almost seamlessly (atoms aren't easy to translate, for example) and uses reflection to resolve and invoke the proper methods. Type translation is trying to be clever, for example strings are represented by native types, likewise integers. Lists correspond to java.util.Lists and tuples to arrays. Objects can also be sent back and forth, by storing them in a map and converting to unique references. Beside 'call's, there is support for 'cast's and 'event's. The latter are async messages to which one can subscribe for notification on the Java side. The functionality is similar to what the corba interface provides, but it's at the same time simpler (no idl descriptions are needed) and more naive, and more powerful (since objects can be sent). I am working on a tool to generate erlang stubs that would make the above example look something like {ok, Map} = java_util_HashMap:'HashMap'(), java_util_HashMap:put(Map, "theKey", value), Of course, this isn't a general solution, and it is very slow to use as in the example above. One would still want to write special interface classes that would do much more work per call. There are also issues still to be resolved (like memory management and concurrency issues), but I thought that someone might be interested and find it useful. The code is part of Erlide but I tried to keep it generic, so it can be extracted to a standalone library, if needed. best regards, Vlad From mbj@REDACTED Wed Aug 15 09:46:29 2007 From: mbj@REDACTED (Martin Bjorklund) Date: Wed, 15 Aug 2007 09:46:29 +0200 (CEST) Subject: [erlang-questions] Extending error_logger In-Reply-To: <006a01c7dec5$d310b6c0$b029030a@mtl.ubisoft.org> References: <006a01c7dec5$d310b6c0$b029030a@mtl.ubisoft.org> Message-ID: <20070815.094629.159254541.mbj@tail-f.com> "denis" wrote: > Hi all, > > In my server, which is an OTP application using supervisor, gen_servers, ., > I use error_logger to log my information. > I would like to modify error_logger to add one kind of message: debug, link > error, debug, info. > Is there a clean way to add it to error_logger ? I dug the source, but not > find an easy way. > For now, the only solution I found is to implement my own logger > implementing all I need, and trap the events sent to error_logger by OTP > framework. > If I'm not mistaken, I can do it by writing my logger as event handler and > register it with error_logger: add_report_handler. > Am I one the good track ? Maybe there is a simpler method to do it ? You can use error_logger:error_report/1,2 for this, and make sure your handler formats these reports. > Note that I also want to store logs as text file. I think that write a new > error handler should do the job, like log_mf_h. IMO, the log_mf_h/rb approach in OTP was a mistake. The last 10 years or so we have always used text based error logs in all our projects. I think the standard log_mf_h should be replaced with disk_log_h which is in Jungerl. Anyway, since OTP R10B-9, you can use the disk_log_h and logger modules in jungerl w/o having to patch OTP. So, go to jungerl and grab the files lib/msc/src/disk_log_h.erl and logger.erl. (I just checked in my updated versions of these modules) Then, create the following module: -module(aa). -export([start_errlog/0, test/0]). start_errlog() -> Opts = [{name, logger}, {file, "./elog"}, {type, wrap}, {format, external}, {force_size, true}, {size, {1024*1024, 5}}], % 5 files gen_event:add_sup_handler( error_logger, {disk_log_h, logger}, disk_log_h:init(fun logger:form_no_progress/1, Opts)). test() -> error_logger:error_msg("testing ~p\n", [self()]). Start erlang: erl -pa jungerl/lib/msc/ebin/ -boot start_sasl 1> aa:start_errlog(). ok 2> exit(whereis(overload), foo). true 3> aa:test(). ok You should have some nicely formatted errors in elog.1. You can of course you halt logs and everything else supported by disk_log. Disclaimer: I haven't tested with R11. /martin From saleyn@REDACTED Wed Aug 15 13:08:30 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 15 Aug 2007 06:08:30 -0500 Subject: [erlang-questions] Extending error_logger In-Reply-To: <20070815.094629.159254541.mbj@tail-f.com> References: <006a01c7dec5$d310b6c0$b029030a@mtl.ubisoft.org> <20070815.094629.159254541.mbj@tail-f.com> Message-ID: <46C2DEAE.3060704@gmail.com> Another alternative is the LAMA application in jungerl that offers logging messages to syslog and provides debug / info / warning / error / critical report types formatted in the same way as standard SASL reports. It swaps default error_logger handler with its own. Serge Martin Bjorklund wrote: > "denis" wrote: >> Hi all, >> >> In my server, which is an OTP application using supervisor, gen_servers, ., >> I use error_logger to log my information. >> I would like to modify error_logger to add one kind of message: debug, link >> error, debug, info. >> Is there a clean way to add it to error_logger ? I dug the source, but not >> find an easy way. >> For now, the only solution I found is to implement my own logger >> implementing all I need, and trap the events sent to error_logger by OTP >> framework. >> If I'm not mistaken, I can do it by writing my logger as event handler and >> register it with error_logger: add_report_handler. >> Am I one the good track ? Maybe there is a simpler method to do it ? > > You can use error_logger:error_report/1,2 for this, and make sure your > handler formats these reports. > >> Note that I also want to store logs as text file. I think that write a new >> error handler should do the job, like log_mf_h. > > IMO, the log_mf_h/rb approach in OTP was a mistake. The last 10 years > or so we have always used text based error logs in all our projects. > I think the standard log_mf_h should be replaced with disk_log_h which > is in Jungerl. > > Anyway, since OTP R10B-9, you can use the disk_log_h and logger > modules in jungerl w/o having to patch OTP. So, go to jungerl and > grab the files lib/msc/src/disk_log_h.erl and logger.erl. (I just > checked in my updated versions of these modules) Then, create the > following module: > > -module(aa). > -export([start_errlog/0, test/0]). > > start_errlog() -> > Opts = [{name, logger}, > {file, "./elog"}, > {type, wrap}, > {format, external}, > {force_size, true}, > {size, {1024*1024, 5}}], % 5 files > gen_event:add_sup_handler( > error_logger, > {disk_log_h, logger}, > disk_log_h:init(fun logger:form_no_progress/1, Opts)). > > test() -> > error_logger:error_msg("testing ~p\n", [self()]). > > > Start erlang: > > erl -pa jungerl/lib/msc/ebin/ -boot start_sasl > > 1> aa:start_errlog(). > ok > 2> exit(whereis(overload), foo). > true > 3> aa:test(). > ok > > You should have some nicely formatted errors in elog.1. You can of > course you halt logs and everything else supported by disk_log. > > > Disclaimer: I haven't tested with R11. > > > > /martin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From saleyn@REDACTED Wed Aug 15 13:18:26 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 15 Aug 2007 06:18:26 -0500 Subject: [erlang-questions] Game of Erlang life [was: Load testing in parallel] In-Reply-To: References: <46C0470B.8080401@gmail.com> <46C18E2F.8040806@gmail.com> Message-ID: <46C2E102.2030906@gmail.com> As far as the implementation of the game is concerned - why use multi-dimensional arrays? Follow Joe's idea of Concurrency Oriented Programming and treat live cells as processes that are linked to neighbors. Then they can exchange messages, mate, and when a process would die all neighboring ones would know about it. This is a bit different approach then using a shared array with a single flow of control, and I am sure it'll be fun. Regards, Serge Chad Wilson wrote: > You tricked me, Serge. When I saw the subject "Game of Erlang Life", > I thought I was about to read someone's Erlang version of the old > computer simulation called "Game of Life". > > I have programmed the Game of Life is several other languages, making > used of arrays each time, but Erlang is presenting me with a different > challenge, since it doesn't have multi-dimensional arrays. > > -w > From saleyn@REDACTED Wed Aug 15 13:30:55 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 15 Aug 2007 06:30:55 -0500 Subject: [erlang-questions] Game of Erlang life [was: Load testing in parallel] In-Reply-To: References: <46C0470B.8080401@gmail.com> <46C18E2F.8040806@gmail.com> Message-ID: <46C2E3EF.4010306@gmail.com> Of course your own "circles" can be different from what was described - each developer has his own degree of interest, pace and learning curve. If you are approaching Erlang from "number crunching" crunching perspective from the very beginning it might be a disappointment to see 10x performance drop compared to C/C++/Pascal family. But in doing so, you may be missing the point - Erlang is a domain-specific language. Despite the fact that it's a general-purpose language - there are parts of it that really excel - namely its approach to concurrency, declarative style and robustness through OTP. As Scott mentioned in one of the recent emails - you really begin appreciating this robustness when your programs work reliably and your pager is quiet. Serge Ahmed Ali wrote: > Hi Serge, > > Actually, I'm not sure if the last 3 "circles" are seperate at all. It seems > to me that "number crunching" circle could be in the first part when > learning Erlang. Same for the 4th one. Are you referring to implementation > of the last 2 circles when you divide it to different stages? > > Best regards, > > Ahmed Al-Issaei > > On 8/14/07, Serge Aleynikov wrote: >> So far the best resource of OTP documentation is the on-line reference: >> http://www.erlang.org/doc. >> >> Sometimes this documentation may seem odd or vague for newcomers, yet >> the more you learn Erlang/OTP the more you understand and appreciate the >> format, depth and value of the content. >> >> Once you mastered first "Programming Erlang" chapters (ch.1-15, >> excluding OTP ones) I suggest that you start by studying on-line module >> documentation under "Basic Applications": stdlib and kernel. They >> expose a wealth of functions, many of which you'll find used in all >> projects. Despite the fact that it may seem like a lot of information, >> if you approach this studying methodically and patiently, you'll be able >> to filter content on the module level first (i.e. gaining high-level >> understanding of what each module does) and then in those modules that >> seem to trigger more of your interest (like kernel/erlang, stdlib/io, >> stdlib/ets, etc.) study documented functions. >> >> Don't worry about OTP (aside from stdlib and kernel applications) as >> much in the beginning - when you feel you have a good grasp on basic >> functions available in the two apps above, read the Design Principles >> guide [1] to understand OTP behaviors - which is the "meat" part of the >> framework that gives you the power of increasing your coding >> productivity by implying practical and reliable abstractions. >> >> At this point, go back to "Programming Erlang" and study the OTP-related >> chapters (ch.16 onward) that give you application examples of how to use >> behaviors. This will conclude your "first circle of Erlang life" and >> give you enough knowledge to move on to exploiting the power of >> Erlang/OTP in your projects. >> >> The "second circle of Erlang life" will begin when your curiosity will >> drive you to understanding that Erlang is *open source* and you'll start >> exploring the sources of OTP applications included in distribution. >> That is when you'll actually begin seeing that on-line documentation is >> rather good. When you are comfortable with OTP code you may find bugs >> and post them to the erlang-bugs@REDACTED list, and also make some >> contributions. >> >> The "third circle of Erlang life" will begin when you discover that >> Erlang's performance sucks at number-crunching applications (which are >> not the domain of problems Erlang was designed for), and begin writing >> ports and drivers to overcome these bottlenecks. Additionally As a >> conclusion of this circle you'll be quite fascinated at how much thought >> was put in preventing mis-behaving user code crash the Erlang emulator. >> >> The "forth circle of Erlang life" will begin when your curiosity drives >> you to studying sources of the Erlang emulator. Here you'll learn how >> I/O multiplexing, garbage collection, bytecode execution, etc. is done, >> and answer some of more advanced questions you might have accumulated >> about features of the run-time system. >> >> By this time others will find that you are "... more object oriented in >> thinking than most of his C++ guys" [2]. The "next circle of Erlang >> life" will begin when you manage to get a job that will let your >> evolution as an Erlang programmer use acquired knowledge during >> day-time. Since not many companies know the hidden powers of Erlang, >> this will largely depend on your abilities to show the strength of >> Erlang/OTP development to your manager, find suitable projects, and >> generate spin to share this knowledge and apply it in your organization. >> >> Regards, >> >> Serge >> >> >> [1] http://www.erlang.org/doc/design_principles/part_frame.html >> [2] >> http://www.erlang.org/pipermail/erlang-questions/2007-August/028392.html >> >> >> David Mitchell wrote: >>> Great tip Serge! >>> >>> Like many others, I'm new to Erlang - I've read through the >>> "Programming Erlang" book, "Thinking in Erlang" and various PDFs at >>> the main Erlang site. I've written a few trivial bits of code, >>> identified and sorted out a bunch of problems I've created, and now >>> I'm moving into using Erlang for larger projects. However, I've never >>> come across info about now() and timer.diff() before; like Ahmed, I've >>> been using statistics(wall_clock) for profiling purposes. >>> >>> Where is that type of info documented? Is it only in the various >>> library APIs (and thus I'll have to work through each of these to get >>> a handle on this type of info), or is there some "best practices"-type >>> documentation I haven't yet stumbled on? I don't mind putting in the >>> time to do my research, but I suspect I'm not yet across all the >>> "good" sources of info. >>> >>> Thanks in advance >>> >>> Dave M. >>> >>> On 13/08/07, Serge Aleynikov wrote: >>>> You have several problems with this code: >>>> >>>> 1. Since you don't provide implementation of generate_lists/3, I assume >>>> it returns a flat list. In this case in the start function you >> call: >>>> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), >>>> >>>> if here Head is not a list, whereas run_process/4 expects a list >>>> as the third argument, lists:map/2 function would >>>> crashes the process silently. You can fix it by changing that line >>>> to: >>>> spawn(?MODULE, run_process, [Num, Op, [Head], Pid]), >>>> >>>> >>>> 2. Also you use the following call to obtain time: >>>> >>>> {_, Wallclock_Time_Since_Last_Call} = statistics(wall_clock). >>>> >>>> Wallclock_Time_Since_Last_Call is time in milliseconds, so unless >>>> evaluated function takes more than a millisecond you'd get a 0. >>>> >>>> Moreover, unfortunately Wallclock_Time_Since_Last_Call is a >> *globally >>>> shared* counter, so any process that calls statistics would cause a >>>> reset of this value. So in a concurrent system where many >> processes >>>> use this function you'll likely always get a zero. >>>> >>>> use T1 = now(), ..., T2 = now(), ... timer:now_diff(T2, T1) >>>> to measure time. >>>> >>>> Serge >>>> >>>> >>>> >>>> Ahmed Ali wrote: >>>>> Hi all, >>>>> >>>>> I've been trying to load test a function in my code. The way I'm doing >> it is >>>>> to generate lists of the data I want to process, start a process for >> each >>>>> list and calculate runtime for each process. The function that I >> implemented >>>>> will call a WebService operation in a different host for each data. >>>>> >>>>> I have the code below for this test. what I do is basically run >>>>> load_test(10, 1000) to generate 10 lists, each with 1000 data in it. >>>>> >>>>> The problem is that WebService call is done successfully but I don't >> get any >>>>> output for the statistics. When I run the code sequentially (i.e. >> instead of >>>>> spawn the call to run_process, I call run_process directly) I get the >> output >>>>> with no issues. Is there something that I missed in the code below? I >>>>> appreciate your help. >>>>> >>>>> Best regards, >>>>> >>>>> Ahmed Al-Issaei >>>>> >>>>> run_process(Num, Fun, List, _Pid) -> >>>>> statistics(wall_clock), >>>>> io:format("load testing process~n"), >>>>> lists:map(Fun, List), >>>>> {_, Time2} = statistics(wall_clock), >>>>> U2 = Time2 / 1000, >>>>> io:format("Num (~s) done: total time = ~p~n",[Num, U2]). >>>>> >>>>> start(_N, _Op, [], _Pid) -> >>>>> true; >>>>> start(Num, Op, Final, Pid) -> >>>>> [Head | Rest] = Final, >>>>> spawn(?MODULE, run_process, [Num, Op, Head, Pid]), >>>>> start(Num-1, Op, Rest, Pid). >>>>> >>>>> load_test(Threads, Size) -> >>>>> List = generate_lists(Threads, Size, []), >>>>> Op = fun(X) -> call_ws_create(X) end, >>>>> start(Threads, Op, List, self()). >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From erlang@REDACTED Wed Aug 15 14:50:49 2007 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 15 Aug 2007 14:50:49 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> Message-ID: <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> yes indeed very easy !! needs a one line addition to erl_parse.yrl Find erl_parse.yrl (in stdlib/src) Look for a line like this: expr_100 -> expr_150 '!' expr_100 : mkop('$1', '$2', '$3'). Then add the following expr_100 -> expr_150 '!' '!' expr_100: {call, line('$1'),{atom, line('$1'), rpc},['$1', '$4']}. This turns all calls A !! B into rpc(A, B) Build a new parser > erlc erl_parse.yrl > erlc erl_parse.erl test with (for example) -module(bang). -compile(export_all). test1() -> a !! b. rpc(A, B) -> {hello, A, B}. $erl > c(bang). > bang:test1() {hello, a,b} This way you can redefine !! as you please by using an appropriate -import(xyz, [rpc/2]) in your code *remember* !! is addictive - so don't forget to remove !! from programs you distribute, since you need a non-standard parser to parse the sources. (I guess we need a -use_parser(Mod) annotation in the code :-) Question (to Joel) can't the entire Obj c interface be made dynamic using obj_sendMsg??? The call [obj with:i str:@"abc"] can be built dynamically using something like int i; NSString s; i = 1234; s = @"hello" obj_sendMsg(obj, NSSelectorFromString(@"with:str:", &i, s) and the type signature can be found introspectively - I think this is how Fscript does it Cheers /Joe On 8/12/07, Ulf Wiger wrote: > This looks like Joe's "bang-bang" notation. > Joe made a small change to the parser to make this possible. > He first wrote about it in http://www.sics.se/~joe/nerl.html, > I think. > > BR, > Ulf W > > 2007/8/12, Joel Reymont : > > Folks, > > > > Suppose I wanted !! to send a synchronous message via a function > > call. How would I write a parse transform to do it? > > > > I would like x !! y to be transformed into mod:func(x, y). Is this > > possible? > > > > Thanks in advance, Joel > > > > -- > > http://wagerlabs.com > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Aug 15 14:57:44 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 15 Aug 2007 13:57:44 +0100 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> Message-ID: <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> On Aug 15, 2007, at 1:50 PM, Joe Armstrong wrote: > Question (to Joel) can't the entire Obj c interface be made dynamic > using > obj_sendMsg??? Sure. What is the question, though? The reason I asked for !! is to have shorten the code that would otherwise need to be written. In absence of !! I would need to add a receive loop after each obj ! .... -- http://wagerlabs.com From zac@REDACTED Wed Aug 15 15:03:41 2007 From: zac@REDACTED (Zac Brown) Date: Wed, 15 Aug 2007 09:03:41 -0400 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> Message-ID: <46C2F9AD.40407@zacbrown.org> I'm quite interested in this project as I work with some computational models that are written in Java. I'd like to write a distribution system for the cluster I have here in Erlang since msg passing in Erlang is much nicer than trying to fight with Java's RMI. I'll be keeping tabs on this :). Zac Vlad Dumitrescu wrote: > Hi all, > > I'm not sure how many people are interacting with Java from Erlang, > but I am (for ErlIDE) and I just implemented a nice feature (if I may > say so myself) that might of interest: the ability to call Java code > from Erlang. > > The reason I needed this is that I want to move as much erlide core > functionality from Java code to Erlang code, but doing it without rpcs > would have meant writing an awful lot of wrapper classes around the > Eclipse API. > > So what I can do now (work is still in progress) is for example > {ok, Map} = jrpc:call("java.util.HashMap", "HashMap", []), > jrpc:call(Map, "put", "theKey", {some, kind, of value}), > > The conversion layer converts between Erlang terms and Java objects, > almost seamlessly (atoms aren't easy to translate, for example) and > uses reflection to resolve and invoke the proper methods. Type > translation is trying to be clever, for example strings are > represented by native types, likewise integers. Lists correspond to > java.util.Lists and tuples to arrays. > > Objects can also be sent back and forth, by storing them in a map and > converting to unique references. > > Beside 'call's, there is support for 'cast's and 'event's. The latter > are async messages to which one can subscribe for notification on the > Java side. > > The functionality is similar to what the corba interface provides, but > it's at the same time simpler (no idl descriptions are needed) and > more naive, and more powerful (since objects can be sent). I am > working on a tool to generate erlang stubs that would make the above > example look something like > {ok, Map} = java_util_HashMap:'HashMap'(), > java_util_HashMap:put(Map, "theKey", value), > > Of course, this isn't a general solution, and it is very slow to use > as in the example above. One would still want to write special > interface classes that would do much more work per call. > > There are also issues still to be resolved (like memory management and > concurrency issues), but I thought that someone might be interested > and find it useful. The code is part of Erlide but I tried to keep it > generic, so it can be extracted to a standalone library, if needed. > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pmuellr@REDACTED Wed Aug 15 17:46:04 2007 From: pmuellr@REDACTED (Patrick Mueller) Date: Wed, 15 Aug 2007 11:46:04 -0400 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> Message-ID: Vlad Dumitrescu wrote: > Hi all, > > I'm not sure how many people are interacting with Java from Erlang, > but I am (for ErlIDE) and I just implemented a nice feature (if I may > say so myself) that might of interest: the ability to call Java code > from Erlang. I'm curious if this built on Jinterface? http://www.erlang.org/doc/apps/jinterface/index.html -- Patrick Mueller http://muellerware.org From sgolovan@REDACTED Wed Aug 15 19:05:55 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Wed, 15 Aug 2007 21:05:55 +0400 Subject: [erlang-questions] SCTP with lksctp 2.6.22-1.0.7 Message-ID: Hi! Appears that SCTP support in Erlang/OTP cant be compiled with newest lksctp (version 2.6.22-1.0.7). lksctp authors just replaced all 'adaption' substrings in lksctp API by 'adaptation'. As far as I can see, the current snapshot of R12B-0 builds only with older lksctp. Are there plans to port Erlang to a newer lksctp version? Thanks! -- Sergei Golovan From vladdu55@REDACTED Wed Aug 15 18:42:18 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 15 Aug 2007 16:42:18 +0000 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> Message-ID: <95be1d3b0708150942u46d7e316gb286cc742f41712e@mail.gmail.com> On 8/15/07, Patrick Mueller wrote: > Vlad Dumitrescu wrote: > > I'm not sure how many people are interacting with Java from Erlang, > > but I am (for ErlIDE) and I just implemented a nice feature (if I may > > say so myself) that might of interest: the ability to call Java code > > from Erlang. > > I'm curious if this built on Jinterface? Yes, of course it is. The version of jinterface that is included with erlide is slightly altered, but nothing significant (mostly adaptation to Java 5 and a few small fixes). best regards, Vlad From husfloen@REDACTED Wed Aug 15 20:23:04 2007 From: husfloen@REDACTED (Patrik Husfloen) Date: Wed, 15 Aug 2007 20:23:04 +0200 Subject: [erlang-questions] Reading large (1GB+) XML files. Message-ID: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> I've been trying to learn erlang for a while, and I recently found what I thought to be an easy starter project. I currently have a simple application that reads data from a couple of Xml files using SAX, and inserts it using a rpc over http. I'm not sure about the terminology here, I've been stuck in OO land for so long that everything looks like an object, but here's what I'm thinking: One thread reading the xmls and piecing together the data, and then handing off each record to a pool of workers that issue the http requests, or, maybe the xml-reading part could just spawn a new thread for each record it reads, and ensure that only X are running at the most? The http request was easy enough to get working, but I'm having trouble with reading the xml, I used xmerl_scan:file to parse the file, but that loads the file into memory before starting to process. I took a look at Erlsom, and it's SAX reader examples, but that read the entire file into a binary before passing it off to the Xml reader. Thanks, Patrik From kevin@REDACTED Wed Aug 15 21:19:10 2007 From: kevin@REDACTED (Kevin A. Smith) Date: Wed, 15 Aug 2007 15:19:10 -0400 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> Message-ID: I'd also be interested to hear how experienced Erlangers handle this. I'm trying to do some heavy SAX parsing as well and it'd be nice to not have to load the entire file into memory at once. --Kevin On Aug 15, 2007, at 2:23 PM, Patrik Husfloen wrote: > I've been trying to learn erlang for a while, and I recently found > what I thought to be an easy starter project. I currently have a > simple application that reads data from a couple of Xml files using > SAX, and inserts it using a rpc over http. > > I'm not sure about the terminology here, I've been stuck in OO land > for so long that everything looks like an object, but here's what I'm > thinking: One thread reading the xmls and piecing together the data, > and then handing off each record to a pool of workers that issue the > http requests, or, maybe the xml-reading part could just spawn a new > thread for each record it reads, and ensure that only X are running at > the most? > > The http request was easy enough to get working, but I'm having > trouble with reading the xml, I used xmerl_scan:file to parse the > file, but that loads the file into memory before starting to process. > > I took a look at Erlsom, and it's SAX reader examples, but that read > the entire file into a binary before passing it off to the Xml reader. > > > Thanks, > > Patrik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Wed Aug 15 21:22:57 2007 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 15 Aug 2007 21:22:57 +0200 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> Message-ID: <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> Interesting - I've been writing some new XML libraries and handling infinite streams (Well very large) is one of the problems I've been thinking about I'll poke around tomorrow and send you some code that might help /Joe Armstrong On 8/15/07, Patrik Husfloen wrote: > I've been trying to learn erlang for a while, and I recently found > what I thought to be an easy starter project. I currently have a > simple application that reads data from a couple of Xml files using > SAX, and inserts it using a rpc over http. > > I'm not sure about the terminology here, I've been stuck in OO land > for so long that everything looks like an object, but here's what I'm > thinking: One thread reading the xmls and piecing together the data, > and then handing off each record to a pool of workers that issue the > http requests, or, maybe the xml-reading part could just spawn a new > thread for each record it reads, and ensure that only X are running at > the most? > > The http request was easy enough to get working, but I'm having > trouble with reading the xml, I used xmerl_scan:file to parse the > file, but that loads the file into memory before starting to process. > > I took a look at Erlsom, and it's SAX reader examples, but that read > the entire file into a binary before passing it off to the Xml reader. > > > Thanks, > > Patrik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dustin@REDACTED Wed Aug 15 22:15:39 2007 From: dustin@REDACTED (Dustin Sallings) Date: Wed, 15 Aug 2007 13:15:39 -0700 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> Message-ID: <03CB6816-770C-484E-8338-306B1078A40A@spy.net> On Aug 15, 2007, at 11:23 , Patrik Husfloen wrote: > I'm not sure about the terminology here, I've been stuck in OO land > for so long that everything looks like an object, but here's what I'm > thinking: One thread reading the xmls and piecing together the data, > and then handing off each record to a pool of workers that issue the > http requests, or, maybe the xml-reading part could just spawn a new > thread for each record it reads, and ensure that only X are running at > the most? This sounds very similar to the design of my load replay tool. I've got a tool that reads a pcap file and writes out a binary file that I suppose is conceptually similar to XML. The playback tool reads that file and issues HTTP requests with the same types of payload (some contents rewritten for validity on playback) with the same timings (to whatever scale is desirable) and logs the results. It works like this: 1) There's an overseer process that starts all of the other processes and facilitates communication among them. 2) One process is responsible for reading the file, sleeping as appropriate, and sending records up to the overseer. 3) Another process is responsible for performing HTTP requests. It receives the messages from the overseer, issues an async http request against inets, and adds the result to a dict with a timer. When a response comes back from inets, it looks up the request and sends the timing, request, and results back up. 4) The logging process figures out what the request meant, on behalf of what user it was sent, and some other stuff and logs it. On startup, I find all available nodes and run one of the requestor processes (#3) on each node. The overseer has a queue of these processes and pops the next available requestor off the front, sends it a request, and adds it to the back of the queue again. If you want to control how many concurrent requests you're executing, you can issue the requests synchronously and use a process queue like I've got there. -- Dustin Sallings From dot@REDACTED Wed Aug 15 23:48:18 2007 From: dot@REDACTED (Tony Finch) Date: Wed, 15 Aug 2007 22:48:18 +0100 Subject: [erlang-questions] sub-byte endianness in bit syntax Message-ID: I can't find anything in the documentation that describes the order in which the bits of a byte are used up by a sequence of sub-byte segments in the bit syntax. For big-endian data, like the standard IP header example, it makes sense to fill in bytes most significant end first, whereas for little endian data you should fill them least significant end first. These conflict if you append big and little endian bit strings - which would be mad, but I can't spot anything that says this causes an error. Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From rvirding@REDACTED Thu Aug 16 00:24:43 2007 From: rvirding@REDACTED (Robert Virding) Date: Thu, 16 Aug 2007 00:24:43 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> Message-ID: <3dbc6d1c0708151524k5be9e4fcx7c8ac315c9b7d3ed@mail.gmail.com> There is one small problem with this fix, as you have not modified the tokeniser it will allow you to write things like: test1() -> A ! ! B. test2() -> A ! ! B. Which does look a little strange. :-) Robert On 15/08/07, Joe Armstrong wrote: > > yes indeed very easy !! needs a one line addition to erl_parse.yrl > > > Find erl_parse.yrl (in stdlib/src) > > Look for a line like this: > > expr_100 -> expr_150 '!' expr_100 : mkop('$1', '$2', '$3'). > > Then add the following > > expr_100 -> expr_150 '!' '!' expr_100: {call, line('$1'),{atom, > line('$1'), rpc},['$1', '$4']}. > > This turns all calls A !! B into rpc(A, B) > > Build a new parser > > > erlc erl_parse.yrl > > erlc erl_parse.erl > > test with (for example) > > -module(bang). > > -compile(export_all). > > test1() -> > a !! b. > > rpc(A, B) -> > {hello, A, B}. > > $erl > > c(bang). > > bang:test1() > {hello, a,b} > > This way you can redefine !! as you please by using an appropriate > -import(xyz, [rpc/2]) in your code > > *remember* !! is addictive - so don't forget to remove !! from programs > you > distribute, since you need a non-standard parser to parse the sources. > > (I guess we need a -use_parser(Mod) annotation in the code :-) > > Question (to Joel) can't the entire Obj c interface be made dynamic using > obj_sendMsg??? > > The call [obj with:i str:@"abc"] > > can be built dynamically using something like > > int i; > NSString s; > i = 1234; > s = @"hello" > obj_sendMsg(obj, NSSelectorFromString(@"with:str:", &i, s) > > and the type signature can be found introspectively - I think this is > how Fscript does it > > Cheers > > /Joe > > > > > > On 8/12/07, Ulf Wiger wrote: > > This looks like Joe's "bang-bang" notation. > > Joe made a small change to the parser to make this possible. > > He first wrote about it in http://www.sics.se/~joe/nerl.html, > > I think. > > > > BR, > > Ulf W > > > > 2007/8/12, Joel Reymont : > > > Folks, > > > > > > Suppose I wanted !! to send a synchronous message via a function > > > call. How would I write a parse transform to do it? > > > > > > I would like x !! y to be transformed into mod:func(x, y). Is this > > > possible? > > > > > > Thanks in advance, Joel > > > > > > -- > > > http://wagerlabs.com > > > > > > > > > > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Aug 16 02:27:51 2007 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 16 Aug 2007 01:27:51 +0100 Subject: [erlang-questions] Erlang VM in Haskell Message-ID: <5F9DE878-839C-4BB6-B721-2BCB33D647E0@gmail.com> Folks, I thought hard about my next fun project and decided to write an Erlang VM in Haskell. I hope to be able to learn about the Erlang internals and have a readable and correct VM implementation. The darcs repository for HEM (Haskell Erlang Machine) is at http:// darcs.haskell.org/hem. A much improved HAW implementation will follow much later. I'll be posting about my progress on my blog below. Thanks, Joel -- http://wagerlabs.com From bob@REDACTED Thu Aug 16 02:57:56 2007 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Aug 2007 17:57:56 -0700 Subject: [erlang-questions] sub-byte endianness in bit syntax In-Reply-To: References: Message-ID: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> It takes a few seconds to figure this out yourself: 1> <> = <<2#10100000>>, {A, B}. {2,2} On 8/15/07, Tony Finch wrote: > I can't find anything in the documentation that describes the order in > which the bits of a byte are used up by a sequence of sub-byte segments in > the bit syntax. For big-endian data, like the standard IP header example, > it makes sense to fill in bytes most significant end first, whereas for > little endian data you should fill them least significant end first. These > conflict if you append big and little endian bit strings - which would be > mad, but I can't spot anything that says this causes an error. > > Tony. > -- > f.a.n.finch http://dotat.at/ > IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR > MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From brianm@REDACTED Wed Aug 15 21:47:30 2007 From: brianm@REDACTED (Brian McCallister) Date: Wed, 15 Aug 2007 12:47:30 -0700 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <8209f740708111454x77c9fa29y962fe7ab62376871@mail.gmail.com> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> <54852223-6BCD-4B01-8C08-9D21B3B782A8@chriswongstudio.com> <8209f740708111454x77c9fa29y962fe7ab62376871@mail.gmail.com> Message-ID: <0E2E0766-2127-433C-B15A-4CC9C0554315@skife.org> On Aug 11, 2007, at 2:54 PM, Ulf Wiger wrote: > If you want just 1000 CPUs, why not connect 32 nodes, each using > 32 cores? Then you don't even have to resort to trickery. ;-) If, say, you are writing a management agent to run on tens or hundreds of thousands of machines so you want the distribution and process monitoring more than processing power... Being able to use Erlang's default distribution model is a major benefit. You cannot really do a flat topology, but, frankly, Erlang is kinda beautiful for this kind of thing. Speaking of global (not quotes) -- do you know the mutex algorithm it uses for global locks? Is it possible to use global for a subset of nodes (based on number you are willing to tolerate failing or the number of monitored child nodes a single can support (ie, 50 servers coordinating 1000 children each gives you 50k in a very shallow tree)? -Brian From lcoquelle@REDACTED Thu Aug 16 03:49:20 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Thu, 16 Aug 2007 09:49:20 +0800 Subject: [erlang-questions] edoc macro Message-ID: Hi, I was trying to implement a "user defined macro" in edoc to automatically generate an html formating of image inclusion (some 'div' tags for alignment, caption etc). I successfully defined a static macro with option like {def, [{mymacro, "macro output"}]}. But I didn't succeed in using a function with something like {def,[{dynmacro, fun mymod:myfun/3}]}. I had a quick look at edoc code, and it seems there is a macro checking that ensure the macro body is a string. Is there any way to define a macro as a function in the same way it is done internally in edoc? Not related remark: has author's firstname a typo in proplists documentation (or have proplists and edoc been written by different authors)? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanobjc@REDACTED Thu Aug 16 04:07:02 2007 From: ryanobjc@REDACTED (Ryan Rawson) Date: Wed, 15 Aug 2007 19:07:02 -0700 Subject: [erlang-questions] "Erlang, the next Java" In-Reply-To: <0E2E0766-2127-433C-B15A-4CC9C0554315@skife.org> References: <414336.73225.qm@web38802.mail.mud.yahoo.com> <9C22DE8C-366E-4D86-9C0F-7AFB946E99B6@chriswongstudio.com> <54852223-6BCD-4B01-8C08-9D21B3B782A8@chriswongstudio.com> <8209f740708111454x77c9fa29y962fe7ab62376871@mail.gmail.com> <0E2E0766-2127-433C-B15A-4CC9C0554315@skife.org> Message-ID: The problem is that 32 CPU systems are expensive. You could afford more CPU time if you did a cluster of 2 or 4 proc boxes. In fact, it is the dominant strategy to create large computing centers. If I had to do it, I would write my own custom distribution protocol in pure erlang. -ryan Sent from my iPhone On Aug 15, 2007, at 12:47 PM, Brian McCallister wrote: > On Aug 11, 2007, at 2:54 PM, Ulf Wiger wrote: > >> If you want just 1000 CPUs, why not connect 32 nodes, each using >> 32 cores? Then you don't even have to resort to trickery. ;-) > > If, say, you are writing a management agent to run on tens or > hundreds of thousands of machines so you want the distribution and > process monitoring more than processing power... > > Being able to use Erlang's default distribution model is a major > benefit. You cannot really do a flat topology, but, frankly, Erlang > is kinda beautiful for this kind of thing. > > Speaking of global (not quotes) -- do you know the mutex algorithm it > uses for global locks? Is it possible to use global for a subset of > nodes (based on number you are willing to tolerate failing or the > number of monitored child nodes a single can support (ie, 50 servers > coordinating 1000 children each gives you 50k in a very shallow tree)? > > -Brian > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Thu Aug 16 07:22:01 2007 From: ok@REDACTED (ok) Date: Thu, 16 Aug 2007 17:22:01 +1200 Subject: [erlang-questions] Alpha-beta in Erlang? In-Reply-To: <6a36e7290708141639y7fe74dav3e73ea22d4d07a13@mail.gmail.com> References: <39F279E5-3DA9-48DE-92D9-AC449DD4C129@spy.net> <6a36e7290708141639y7fe74dav3e73ea22d4d07a13@mail.gmail.com> Message-ID: <2D595029-F350-44CB-88A3-F69CCD6E8468@cs.otago.ac.nz> I'm co-supervising a student project where in this semester the student is to compare a message passing version of alpha-beta (platform: MPI, game: Othello) and a distributed shared memory version (platform: VODCA). I thought it would be fun to show him an Erlang concurrent alpha-beta. I am aware of Othello-1.0, but that doesn't use multiple processes in the game tree search, and what's more doesn't actually seem to work any more. Does anyone have a concurrent alpha-beta in Erlang? (This has to be easier than the ~15000 lines of code on top of PVM that we're currently staring at in horror.) From vladdu55@REDACTED Thu Aug 16 08:42:39 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 16 Aug 2007 08:42:39 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <3dbc6d1c0708151524k5be9e4fcx7c8ac315c9b7d3ed@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <3dbc6d1c0708151524k5be9e4fcx7c8ac315c9b7d3ed@mail.gmail.com> Message-ID: <95be1d3b0708152342m5a1cf037icaf04fe2b642bcee@mail.gmail.com> On 8/16/07, Robert Virding wrote: > test1() -> > A ! ! B. > test2() -> > A ! > > ! B. > > Which does look a little strange. :-) Not as strange as A ! %% hi, this is a comment ! B. :-) /Vlad From dmitriid@REDACTED Thu Aug 16 08:48:19 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Thu, 16 Aug 2007 09:48:19 +0300 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> Message-ID: <46C3F333.6090501@gmail.com> Patrik Husfloen wrote: > I've been trying to learn erlang for a while, and I recently found > what I thought to be an easy starter project. I currently have a > simple application that reads data from a couple of Xml files using > SAX, and inserts it using a rpc over http. > > I guess that for large files you could do better with http://www.codeproject.com/cpp/HTML_XML_Scanner.asp " It is fast. We managed to reach a speed of scanning nearly 40 MB of XML per second (depends on the hardware you have, of course). " And bind that to Erlang... Mmmmmm... :) From kenneth.lundin@REDACTED Thu Aug 16 09:25:08 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 16 Aug 2007 09:25:08 +0200 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> Message-ID: Hi, There is already support handling infinite streams in the xmerl application. You should use the xmerl_eventp module and the functions there. The documentation is here: http://www.erlang.org/doc/man/xmerl_eventp.html We are using it ourselves , it works ok, but I admit that the documentation is a bit sparse. /Kenneth (Erlang/OTP team at Ericsson) On 8/15/07, Joe Armstrong wrote: > Interesting - I've been writing some new XML libraries and handling > infinite streams (Well very large) is one of the problems I've been > thinking about > > I'll poke around tomorrow and send you some code that might help > > /Joe Armstrong > > On 8/15/07, Patrik Husfloen wrote: > > I've been trying to learn erlang for a while, and I recently found > > what I thought to be an easy starter project. I currently have a > > simple application that reads data from a couple of Xml files using > > SAX, and inserts it using a rpc over http. > > > > I'm not sure about the terminology here, I've been stuck in OO land > > for so long that everything looks like an object, but here's what I'm > > thinking: One thread reading the xmls and piecing together the data, > > and then handing off each record to a pool of workers that issue the > > http requests, or, maybe the xml-reading part could just spawn a new > > thread for each record it reads, and ensure that only X are running at > > the most? > > > > The http request was easy enough to get working, but I'm having > > trouble with reading the xml, I used xmerl_scan:file to parse the > > file, but that loads the file into memory before starting to process. > > > > I took a look at Erlsom, and it's SAX reader examples, but that read > > the entire file into a binary before passing it off to the Xml reader. > > > > > > Thanks, > > > > Patrik > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From heinrich@REDACTED Thu Aug 16 09:51:17 2007 From: heinrich@REDACTED (Heinrich Venter) Date: Thu, 16 Aug 2007 09:51:17 +0200 Subject: [erlang-questions] crypto and RSA Message-ID: <000601c7dfda$3d0a0580$b71e1080$@com> Just wondering what the status is of extending crypto to expose more of the OpenSSL functionality. Specifically some of the RSA stuff. There was a thread earlier "[erlang-questions] SSL certificate question" that pointed at a patch for crypto. Any chance of this making it into a future release? -]-[ From kenneth.lundin@REDACTED Thu Aug 16 10:03:11 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 16 Aug 2007 10:03:11 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> Message-ID: Sorry, I don't understand why you would ask for a !! operator at all. If you want to translate A !! B to myspecialrpc(A,B) why not just use the functioncall directly. I can not see that the !! offers any advantage more than it perhaps saves you a number of characters per call. It would on the other hand be a big disadvantage having code that can't be handled by the standard Erlang compiler at least if the source is to be distributed. Joe introduced the bang bang '!!' operator when he developed his ex11 application and we did not like it better at that time either. I think Joe removed the use of !! from ex11 because of the many complaints about the source not beeing compilable by the standard compiler. So in fact the unnecessary (for the ex11 problem) introduction of the !! operator proved to be a disadvantage for the popularity of ex11.It was not easy enough to test it. I am in favour of a VERY VERY RESTRICTIVE approach when it comes to introduction of non standard language constructs by modifying the parser or by use of parse transforms since it will result in source code that is hard to understand and use if you don't have the full knowledge of the language additions and modifications. Parse transforms can be motivated if used with care and not spread out in many modules which then are distributed as source. If there are language improvements or extensions that are of general interest please write an Erlang Enhancement Proposal (EEP) about it and we will consider that. The !! operator as described by Joe is however something that we have no plans to introduce in the standard language since we think it has so many problems and questionmarks and does not offer anything but syntactic sugar. A !! B instead of rpc(A,B) . Example of problem is that a synchronous rpc can fail in various ways, for example if the server does not respond at all. For how long shall the client wait? If we want a timeout , how should that be specified with that syntax etc. etc.? /Kenneth (Erlang/OTP team at Ericsson) On 8/15/07, Joel Reymont wrote: > > On Aug 15, 2007, at 1:50 PM, Joe Armstrong wrote: > > > Question (to Joel) can't the entire Obj c interface be made dynamic > > using > > obj_sendMsg??? > > Sure. What is the question, though? > > The reason I asked for !! is to have shorten the code that would > otherwise need to be written. In absence of !! I would need to add a > receive loop after each obj ! .... > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Thu Aug 16 10:06:16 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 16 Aug 2007 10:06:16 +0200 Subject: [erlang-questions] edoc macro In-Reply-To: References: Message-ID: <46C40578.8020408@it.uu.se> Ludovic Coquelle wrote: > Hi, > I was trying to implement a "user defined macro" in edoc to > automatically generate an html formating of image inclusion (some 'div' > tags for alignment, caption etc). > I successfully defined a static macro with option like {def, [{mymacro, > "macro output"}]}. But I didn't succeed in using a function with > something like {def,[{dynmacro, fun mymod:myfun/3}]}. I had a quick look > at edoc code, and it seems there is a macro checking that ensure the > macro body is a string. > Is there any way to define a macro as a function in the same way it is > done internally in edoc? I think that was my intention, but it is possible that I didn't check that it actually worked. I'll have a look at it. Thanks for the report. > Not related remark: has author's firstname a typo in proplists > documentation (or have proplists and edoc been written by different > authors)? Nope, both by me. /Richard From erlang@REDACTED Thu Aug 16 10:17:40 2007 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 16 Aug 2007 10:17:40 +0200 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> Message-ID: <9b08084c0708160117mcb29aa9k698cb050b33be3cf@mail.gmail.com> After thought - I *won't* be sending you any code :-( My XML stuff is in the middle of a big re-write - I'll do this first. I'm trying to make several inter-related XML processing things. I don't believe the one-tool-suits-all approach for manipulating XML. Parsing XML raises a number of tricky design issues. What do we want to do with the XML? --- do we have to handle infinite (or at least very large) inputs. Is all the input available at the time of parsing, or does it arrive in fragmented chunks from a stream. If the data is streamed do we want to handle the chunks as they come in a re-entrant parser, or do we want to wait until all the chunks have come and then do the parsing? In this case we'll have to pre-scan the data so that we know when to do the parsing. Given that we've got a tokenizer can we write a parser that works with lists of tokens, or with streams, or do we have to write a number of different parsers to handle the different cases? Do we want to write a validating parser, or a non-validating parser? Should it be re-entrant or not? Do we want to handle simple ASCII character sets or many different character sets and is the code very different in the two cases? Do we want to *exactly reconstruct* the input or should the parse tree represent the logically equivalent of the input. For example, do we want to pass tag attributes in the same order as they appear in the input. Do we want to exactly retain white space and tabs in places where they are not semantically important? These are difficult design questions and it is difficult to write the libraries in such a way that all of these things can be done. If we write a very general set of routines they will probably not be very fast for a specific purpose. If we write fast specialised routines, they will not be very general. A lot of XML processing can be done at a token level alone - there is no need to even have a well-formed document - here parsing and validating would be a waste of time. Then we have to decide on performance - a set of routines that work correctly of GByte files will also work on small files - but if we were only processing small files then a more efficient algorithms would be possible. Do we have to write two sets of routines (for large and small files) and can they share common code? Anyway - I'm trying to make a toolkit that can allow you to manipulate a document either as a stream of tokens, or as a well-formed or as a validated document. Another question I have is: What do you want to do with an infinite document? (here infinite means "too big to keep the parse tree in memory in an efficient manner") Do you want to: a) - produce another infinite document b) - extract a sub-set according to some filter rules If it's a) are the things in the output document in the same order as the things in the input document? - I guess both a and b would be candidates for some kinds of higher order functions that work on xml parse trees Lot's to think about /Joe On 8/15/07, Joe Armstrong wrote: > Interesting - I've been writing some new XML libraries and handling > infinite streams (Well very large) is one of the problems I've been > thinking about > > I'll poke around tomorrow and send you some code that might help > > /Joe Armstrong > > On 8/15/07, Patrik Husfloen wrote: > > I've been trying to learn erlang for a while, and I recently found > > what I thought to be an easy starter project. I currently have a > > simple application that reads data from a couple of Xml files using > > SAX, and inserts it using a rpc over http. > > > > I'm not sure about the terminology here, I've been stuck in OO land > > for so long that everything looks like an object, but here's what I'm > > thinking: One thread reading the xmls and piecing together the data, > > and then handing off each record to a pool of workers that issue the > > http requests, or, maybe the xml-reading part could just spawn a new > > thread for each record it reads, and ensure that only X are running at > > the most? > > > > The http request was easy enough to get working, but I'm having > > trouble with reading the xml, I used xmerl_scan:file to parse the > > file, but that loads the file into memory before starting to process. > > > > I took a look at Erlsom, and it's SAX reader examples, but that read > > the entire file into a binary before passing it off to the Xml reader. > > > > > > Thanks, > > > > Patrik > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From erlang@REDACTED Thu Aug 16 10:52:12 2007 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 16 Aug 2007 10:52:12 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> Message-ID: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> On 8/16/07, Kenneth Lundin wrote: > Sorry, I don't understand why you would ask for a !! operator at all. > > If you want to translate A !! B to myspecialrpc(A,B) why not just use > the functioncall directly. I can not see that the !! offers any advantage > more than it perhaps saves you a number of characters per call. For things that are used a lot infix syntax is nice A + B is nicer than plus(A, B) I use rpc's a lot There is a second and more important reason. Since we can *hide* rpcs through function abstraction, we cannot easily see which function calls are "real function calls" and which are (disguised) rpcs. suppse we write interface routines someFunc(A, B) -> gen_server:call(abc, {glurk, A, B}) or someOtherFunc(Pid, A) -> rpc(Pid, {glonk, A}) And export them from a module. The user *cannot see* that someFunc(A, B) results in an rpc If you write abc !! {glurk, A, B} or Pid !! {glonk, A] then this is apparent. rpc's are places in the code that need to be starred at hard - they introduce bottlenecks and are extremely inefficient when the occur over a processor boundary If the code says {node(), abc} !! message We *know* that this will be extremely inefficient. If we *hide* this in a function call we can't see this fact. if we write abc !! Q We know that we have to avoid a potential bottleneck in the registered process abc If we hide this in a function abstraction abc:foo(...) we cannot see at a glance that this is a potential dangerous operation. We also don't need to write interface functions. This programming style *exposes* the protocol between the client/server which is also a good thing - many time the appropriate functional abstractions do not exist and we have to write new interface routines to no good purpose. Knowing the underlying protocol and using the two operators ! and !! makes life much nicer. Finally, on syntax, to my mind Pid ! A Pid !! B have a beautiful symetry - Pid ! A says send A to Pid Pid !! B says send B to Pid and wait for a reply > It would on the other hand be a big disadvantage having code that > can't be handled > by the standard Erlang compiler at least if the source is to be distributed. > > Joe introduced the bang bang '!!' operator when he developed his ex11 > application > and we did not like it better at that time either. > I think Joe removed the use of !! from ex11 because of the many complaints about > the source not beeing compilable by the standard compiler. So in fact > the unnecessary (for the ex11 problem) introduction of the !! operator > proved to be a > disadvantage for the popularity of ex11.It was not easy enough to test it. I reissued it with rpc instead of !! and this had no effect on the popularity. The code with rpc was far less beautiful than the code with !! > > I am in favour of a VERY VERY RESTRICTIVE approach when it comes to > introduction of non standard language constructs by modifying the > parser or by use of parse transforms since it will result in source > code > that is hard to understand and use if you don't have the full > knowledge of the language additions and modifications. Parse > transforms can be motivated if used with care and not spread out in > many modules which then are distributed as source. > I agree - that's why I added a warning in my post > If there are language improvements or extensions that are of general interest > please write an Erlang Enhancement Proposal (EEP) about it and we will > consider that. > > The !! operator as described by Joe is however something that we have > no plans to introduce in the standard language since we think it has > so many problems and questionmarks I don't think so. (Actually we dont use ? any more so we could say A ? B instead of A !! B this might be even better - it saves one character and the ? clearly indicates the intent) > and does not offer anything but syntactic sugar. A !! B instead of rpc(A,B) . > Example of problem is that a synchronous rpc can fail in various ways, > for example > if the server does not respond at all. For how long shall the client > wait? If we want a timeout , how should that be specified with that > syntax etc. etc.? Easy. A !! B is defined to expand to rpc(A, B) in the local module - *nothing else* suppose we have two modules a and b -module(a) -import(lib1, [rpc/2]). f() -> abc !! def. -module(b) -import(lib2, [rpc/2]). f() -> abc !! def. In a !! means lib1:rpc - in b it means lib2:rpc So we can customise the meaning to whatever we want. We could also add a local definition - giving the timeout value etc. what you want. I can only think of one reason not to add !! (or ?) If people use !! in some new version of erlang and distribute their code it will not compile with old versions of Erlang. *worse* old versions of erlang will give a bad error message. We *need* to add a erlang version number to the modules. -module(foo). -needs_erlang_version(5). This should have been added years ago. Old versions of the compiler will ignore this. New versions 5,6,7 .. whatever will recognise this. So in the future when a version 5 compiler finds code like this -module(foo) -needs_erlang_version(7). It can say *politely* please update your compiler to at least version 7 What I propose is: Add code to recognise a version number ASAP assume that no version number in the code means version 1. Let this version propagate to all sites in the world (say one year) *then bump the version number* Then we can add !! in version 2 with no problems. Alternativly - add "live upgrade" to the system. Erlang system could (should?) check back with the mothership every month for a new version. /Joe > > > /Kenneth (Erlang/OTP team at Ericsson) > > On 8/15/07, Joel Reymont wrote: > > > > On Aug 15, 2007, at 1:50 PM, Joe Armstrong wrote: > > > > > Question (to Joel) can't the entire Obj c interface be made dynamic > > > using > > > obj_sendMsg??? > > > > Sure. What is the question, though? > > > > The reason I asked for !! is to have shorten the code that would > > otherwise need to be written. In absence of !! I would need to add a > > receive loop after each obj ! .... > > > > -- > > http://wagerlabs.com > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From richardc@REDACTED Thu Aug 16 11:07:11 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 16 Aug 2007 11:07:11 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> Message-ID: <46C413BF.3020301@it.uu.se> Kenneth Lundin wrote: > The !! operator as described by Joe is however something that we have > no plans to introduce in the standard language since we think it has > so many problems and questionmarks and does not offer anything but > syntactic sugar. A !! B instead of rpc(A,B) . Example of problem is > that a synchronous rpc can fail in various ways, for example if the > server does not respond at all. For how long shall the client wait? > If we want a timeout , how should that be specified with that syntax > etc. etc.? Hear, hear! The !! syntax looks alluringly simple, but it is far from clear what the details of its semantics ought to be. There are many possible variations of RPC, in particular with respect to what it guarantees in the presence of failure. Furthermore, it would be necessary to standardize the format of messages, and that is another area where that which is sufficient for some applications, e.g. {ok, Value}, would be too brittle for other applications that might want to include a special tag or a unique reference in requests, to be part of the replies, e.g. {reply, From, MsgID, Value}. I'm not saying that it's impossible to come up with a straightforward behaviour that matches what most people need most of the time, but it really needs to be worked out properly before a new operator is dedicated to it. Meanwhile, stick to plain old function calls, please. To end this on a more positive note, I'd like to encourage everyone on this list to keep thinking about how Erlang process communication could be made even simpler and more streamlined. Plain asynchronous message passing (with selective receive) is a powerful yet simple building block but it is still rather primitive, and often, Erlang programmers (myself included) will neglect to think too far about what might happen if messages are lost, timeouts occur, or messages arrive in an unexpected order. We tend to go back and fix those bugs when they bite us, but it would be better if we were using communication constructs that came with certain guarantees to begin with; like the difference between goto- programming and structured language constructs like while/for/case. /Richard From vladdu55@REDACTED Thu Aug 16 11:46:30 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 16 Aug 2007 11:46:30 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> Message-ID: <95be1d3b0708160246jb300636k817cd771a0292369@mail.gmail.com> Hi, On 8/16/07, Joe Armstrong wrote: > Since we can *hide* rpcs through function abstraction, we cannot easily see > which function calls are "real function calls" and which are (disguised) rpcs. > [snip] > If you write > > abc !! {glurk, A, B} > or > Pid !! {glonk, A] > > then this is apparent. Well, this isn't quite true. Since !! would expand to calling rpc/2, it all depends on what this function does -- it would do a rpc only by convention. > > if the server does not respond at all. For how long shall the client > > wait? If we want a timeout , how should that be specified with that > > syntax etc. etc.? > > Easy. > A !! B is defined to expand to rpc(A, B) in the local module - *nothing else* > > -module(a) > -import(lib1, [rpc/2]). > > f() -> > abc !! def. > > So we can customise the meaning to whatever we want. We could also add > a local definition - giving the timeout value etc. what you want. That would mean that you can't have two !! calls from the same module that use different options, wouldn't it? That said, I too think this kind of notation would help streamline not only the code, but also the coder's thoughts. However, I think it should be more than just a simple sugar coating on a local call to rpc/2. [No, sorry, I don't have an answer to the follow up question, it's just my feeling] best regards, Vlad From prabhuram.k@REDACTED Thu Aug 16 12:06:55 2007 From: prabhuram.k@REDACTED (Prabhuram K) Date: Thu, 16 Aug 2007 15:36:55 +0530 Subject: [erlang-questions] Problems in a list Message-ID: <3052a6dc0708160306wa508c52g646e41bb2a3b1c8a@mail.gmail.com> Hello all, I am a newbie to erlang. I have a value of this format "\"srs1\",\"srs2\"". If I do a list_to_atom on this I get '"srs1","srs2"', that is within single quote. So if I store it as [SrsNameList] it is stored as ['"srs1","srs2"']. I don't need the single quote, it should just be ["srs1","srs2"]. How do I do that ? Thanks in advance, --Prabhu -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Thu Aug 16 12:48:21 2007 From: chsu79@REDACTED (Christian S) Date: Thu, 16 Aug 2007 12:48:21 +0200 Subject: [erlang-questions] Problems in a list In-Reply-To: <3052a6dc0708160306wa508c52g646e41bb2a3b1c8a@mail.gmail.com> References: <3052a6dc0708160306wa508c52g646e41bb2a3b1c8a@mail.gmail.com> Message-ID: Do you want to parse erlang terms? Quick solution: {ok, Tokens, _} = erl_scan:string("[\"abc\", \"def\"]."). {ok, Parse} = erl_parse:parse_term(Tokens). Parse = ["abc","def"]. However, there might be reasons to not use this method to parse data, if you dont trust the data you parse, a malicious user could fill up your atom tables with nonsense atom names. If that is not an issue you just need to take your String and lists:flatten([$[, String, $], $.]) to get the string you pass erl_scan:string/1 If it is an issue, implement your own parser. 2007/8/16, Prabhuram K : > Hello all, > I am a newbie to erlang. > I have a value of this format "\"srs1\",\"srs2\"". If I do a list_to_atom on > this I get '"srs1","srs2"', that is within single quote. So if I store it as > [SrsNameList] it is stored as ['"srs1","srs2"']. I don't need the single > quote, it should just be ["srs1","srs2"]. How do I do that ? > > > Thanks in advance, > > --Prabhu > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From olopierpa@REDACTED Thu Aug 16 13:27:08 2007 From: olopierpa@REDACTED (Pierpaolo Bernardi) Date: Thu, 16 Aug 2007 13:27:08 +0200 Subject: [erlang-questions] Problems in a list In-Reply-To: <3052a6dc0708160306wa508c52g646e41bb2a3b1c8a@mail.gmail.com> References: <3052a6dc0708160306wa508c52g646e41bb2a3b1c8a@mail.gmail.com> Message-ID: <7352e43a0708160427i4a6a1a81xc3c9baa308029ac@mail.gmail.com> On 8/16/07, Prabhuram K wrote: > Hello all, > I am a newbie to erlang. > I have a value of this format "\"srs1\",\"srs2\"". If I do a list_to_atom on > this I get '"srs1","srs2"', that is within single quote. So if I store it as > [SrsNameList] it is stored as ['"srs1","srs2"']. I don't need the single > quote, it should just be ["srs1","srs2"]. How do I do that ? There are no single quotes in the atom name. The single quotes you see are part of the syntax of atoms. Look at this: 23> list_to_atom("A"). 'A' 24> list_to_atom("a"). a Note that atoms once created are never deleted and that only a limited number of them can be created. So it's not a good idea to apply list_to_atom to random lists. P. From goryachev@REDACTED Thu Aug 16 14:38:14 2007 From: goryachev@REDACTED (Igor Goryachev) Date: Thu, 16 Aug 2007 16:38:14 +0400 Subject: [erlang-questions] http-client fails when gets response w/o headers Message-ID: <87lkcbhcy1.fsf@yandex-team.ru> Hello. It seems there is yet another bug found in http-client while it gets response from http-server with omitted headers (?): 23> http:request("http://shingler:7070/check?aaa=bbb"). {error,session_remotly_closed} 24> =ERROR REPORT==== 16-Aug-2007::16:15:56 === ** Generic server <0.871.0> terminating ** Last message in was {tcp_closed,#Port<0.696>} ** When Server state == {state,{request, #Ref<0.0.0.16664>, <0.31.0>, 0, http, {"shingler",7070}, "/check", "?aaa=bbb", get, {http_request_h, undefined, "keep-alive", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, "shingler", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, [], undefined, undefined, undefined, undefined, "0", undefined, undefined, undefined, undefined, undefined, undefined, []}, {[],[]}, {http_options, infinity, true, [], undefined, false}, "http://shingler:7070/check?aaa=bbb", [], none, []}, {tcp_session, {{"shingler",7070},<0.871.0>}, false, http, #Port<0.696>, 1}, undefined, undefined, undefined, {httpc_response, parse_reason_phrase, [<<>>, "TSET\n\nKO", nolimit, [200,"HTTP/1.1"]]}, {[],[]}, new, [], nolimit, nolimit, {options, {undefined,[]}, 0, 2, 2, disabled, enabled, false}, {timers,[],undefined}} ** Reason for termination == ** session_remotly_closed -- Igor Goryachev Yandex development team. From vances@REDACTED Thu Aug 16 15:38:22 2007 From: vances@REDACTED (Vance Shipley) Date: Thu, 16 Aug 2007 09:38:22 -0400 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> Message-ID: <20070816133822.GA46135@frogman.motivity.ca> On Thu, Aug 16, 2007 at 10:03:11AM +0200, Kenneth Lundin wrote: } Sorry, I don't understand why you would ask for a !! operator at all. Because it's so elegant, it makes for beautiful code. :) ... however I'm sure you're right. -Vance [Good code is prose.] From chsu79@REDACTED Thu Aug 16 16:09:18 2007 From: chsu79@REDACTED (Christian S) Date: Thu, 16 Aug 2007 16:09:18 +0200 Subject: [erlang-questions] Upgrading tcp connection to ssl (tls) Message-ID: It seems like the ssl module doesnt support taking over a tcp connection and bootstrapping ssl/tls on it? I recall having seen this issue on the list once, but i cant find anything when searching for it. Is there any work on the ssl module, or undocumented features for this? ejabberd use their own tls driver to communicate with openssl which seem to have support for promoting tcp to tls. i guess this is time tested code that works well, another idea i had was to just connect back to a ssl port on the same machine and relay the tcp traffic there? or doesnt this work? i have very little knowledge about the protocol in ssl/tls From toby@REDACTED Thu Aug 16 16:34:06 2007 From: toby@REDACTED (Toby Thain) Date: Thu, 16 Aug 2007 11:34:06 -0300 Subject: [erlang-questions] Upgrading tcp connection to ssl (tls) In-Reply-To: References: Message-ID: On 16-Aug-07, at 11:09 AM, Christian S wrote: > It seems like the ssl module doesnt support taking over a tcp > connection and bootstrapping ssl/tls on it? > > I recall having seen this issue on the list once, but i cant find > anything when searching for it. > > Is there any work on the ssl module, or undocumented features for > this? > > ejabberd use their own tls driver to communicate with openssl which > seem to have support for promoting tcp to tls. i guess this is time > tested code that works well, > > another idea i had was to just connect back to a ssl port on the same > machine and relay the tcp traffic there? or doesnt this work? i have > very little knowledge about the protocol in ssl/tls Does this help at all? http://telegraphics.com.au/svn/essltest/trunk/essltest.erl --Toby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From chsu79@REDACTED Thu Aug 16 16:46:51 2007 From: chsu79@REDACTED (Christian S) Date: Thu, 16 Aug 2007 16:46:51 +0200 Subject: [erlang-questions] Upgrading tcp connection to ssl (tls) In-Reply-To: References: Message-ID: No, I guess I am being vague. I have an established gen_tcp connection, after negotiation the client says it want to proceed talking in an encrypted tls channel over this tcp connection. I would need something like {ok, SSLSock} = ssl:initiate_tls(TCPSocket, Opts). 2007/8/16, Toby Thain : > > On 16-Aug-07, at 11:09 AM, Christian S wrote: > > > It seems like the ssl module doesnt support taking over a tcp > > connection and bootstrapping ssl/tls on it? > > > > I recall having seen this issue on the list once, but i cant find > > anything when searching for it. > > > > Is there any work on the ssl module, or undocumented features for > > this? > > > > ejabberd use their own tls driver to communicate with openssl which > > seem to have support for promoting tcp to tls. i guess this is time > > tested code that works well, > > > > another idea i had was to just connect back to a ssl port on the same > > machine and relay the tcp traffic there? or doesnt this work? i have > > very little knowledge about the protocol in ssl/tls > > Does this help at all? > http://telegraphics.com.au/svn/essltest/trunk/essltest.erl > > --Toby > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > From jakob@REDACTED Thu Aug 16 17:11:10 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Thu, 16 Aug 2007 17:11:10 +0200 Subject: [erlang-questions] crypto and RSA In-Reply-To: <000601c7dfda$3d0a0580$b71e1080$@com> References: <000601c7dfda$3d0a0580$b71e1080$@com> Message-ID: <46C4690E.9020209@erix.ericsson.se> The functionality from OpenSSL that the patch exposed was already available in the ssl-module (although not documented). We will expose more of the ciphers from the crypto-library from OpenSSL, but things that are easily done in erlang will not be exposed. /Jakob Heinrich Venter wrote: > Just wondering what the status is of extending crypto to expose more of the > OpenSSL functionality. Specifically some of the RSA stuff. > There was a thread earlier "[erlang-questions] SSL certificate question" > that pointed at a patch for crypto. > Any chance of this making it into a future release? > > -]-[ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From jakob@REDACTED Thu Aug 16 17:36:42 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Thu, 16 Aug 2007 17:36:42 +0200 Subject: [erlang-questions] Upgrading tcp connection to ssl (tls) In-Reply-To: References: Message-ID: <46C46F0A.800@erix.ericsson.se> It's not in the current implementation of ssl, due to a lot of reasons. There is a newer implementation in the works that will make it possible to do ssl-encryption on an already established socket connection, but it's one or two otp-releases in the future. /Jakob Christian S wrote: > No, I guess I am being vague. > > I have an established gen_tcp connection, after negotiation the client > says it want to proceed talking in an encrypted tls channel over this > tcp connection. > > I would need something like {ok, SSLSock} = ssl:initiate_tls(TCPSocket, Opts). > > 2007/8/16, Toby Thain : > >> On 16-Aug-07, at 11:09 AM, Christian S wrote: >> >> >>> It seems like the ssl module doesnt support taking over a tcp >>> connection and bootstrapping ssl/tls on it? >>> >>> I recall having seen this issue on the list once, but i cant find >>> anything when searching for it. >>> >>> Is there any work on the ssl module, or undocumented features for >>> this? >>> >>> ejabberd use their own tls driver to communicate with openssl which >>> seem to have support for promoting tcp to tls. i guess this is time >>> tested code that works well, >>> >>> another idea i had was to just connect back to a ssl port on the same >>> machine and relay the tcp traffic there? or doesnt this work? i have >>> very little knowledge about the protocol in ssl/tls >>> >> Does this help at all? >> http://telegraphics.com.au/svn/essltest/trunk/essltest.erl >> >> --Toby >> >> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Thu Aug 16 18:10:21 2007 From: dmercer@REDACTED (David Mercer) Date: Thu, 16 Aug 2007 11:10:21 -0500 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com><9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com><4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> Message-ID: <003801c7e01f$f2b366c0$891ea8c0@SSI.CORP> On 8/16/07, Joe Armstrong wrote: > For things that are used a lot infix syntax is nice > > A + B is nicer than plus(A, B) The problem with infix is formatting. How do you format in your editor a long list of infix-separated expressions? A + B + C + D Loses the fact that A has an equivalent rank to B, C, D. If later, you decide to reorder your expressions, A cannot be freely reordered like the other lines because it lacks the infix operator. Of course you can move the infix operator to the end (this is what is usually done when the infix operator is a comma), but then expression D loses its free movement ability. Keeping with infix, we could put the operator on its own line: A + B + C + D Or A + B + C + D Which enables you to move A around so long as you take its following operator along with it and so long as it is not going at the end. What I am getting at is that prefix operator make it much easier to format your code. I'm not a Lisp programmer, but that is one of the first things I noticed about Lisp, which I like. This is much easier to rearrange: + A B C D Even on a single line: + A B C D Is easier to rearrange than its infix counterpart: A + B + C + D Since A cannot easily be moved to the end. One would have to move the "A + " to the end, and then move the " + " between the "D" and "A". > A + B is nicer than plus(A, B) I would argue that you have simply exchanged one infix operator (plus) for a another (comma) and added in a prefix ("plus(") and postfix (closing paren) to boot, so, yes, you are right, one infix operator is better than an infix operator that also requires a prefix and postfix. Erlang is by no means the only language to have this problem. Indeed, I think any non-Lisp language has this problem. However, in some languages the problem is not quite so severe. Erlang's syntax, however, is as bad as SQL's in terms of formatting, in my opinion: I never know exactly how to format my Erlang consistently. Example 1: Take a simple function definition: f(...) -> ... . Seems simple enough. If the body is long, we can format it like so: f(...) -> ... , ... , ... . Now let's add in a guard: f(...) when ... -> ... , ... , ... . How about a complicated guard: f(...) when ..., ..., ...; ..., ..., ...; ..., ..., ...; -> ... , ... , ... . Now the body of our function has to be indented another level to show that it is subordinate to the infix operator "->". But if we later decide to change the function to eliminate the guard, we have to modify our indentation, too. Example 2: Multiple clauses in a function. They are separated by the infix semicolon operator, but terminated by a postfix period. This arrangement results in the ordering problems that was described earlier with our A + B + C + D example: we cannot freely rearrange the order of the clauses without making structural changes to our code. Note that this would not be a problem if the semicolon were a postfix clause terminator, but since it is infix, it is. If it were postfix, then this would be valid, and we wouldn't have the clause reordering problem: f(...) -> ...; f(...) -> ...; f(...) -> ...; f(...) -> ...; . % Postfix function terminator Therefore, I would argue for infix operator reduction rather than expansion. > For things that are used a lot infix syntax is nice I don't find infix operators nice at all. I realize we are stuck, by and large, with Erlang's infix-heavy syntax, however, so I'll go along with it. Cheers, David From husfloen@REDACTED Thu Aug 16 19:25:52 2007 From: husfloen@REDACTED (Patrik Husfloen) Date: Thu, 16 Aug 2007 19:25:52 +0200 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <9b08084c0708160117mcb29aa9k698cb050b33be3cf@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> <9b08084c0708160117mcb29aa9k698cb050b33be3cf@mail.gmail.com> Message-ID: <4bcbf07d0708161025s69a13067v2236777348583d7@mail.gmail.com> Well, I think I have a decent idea on where to go from here, I'll report back this weekend with results. Thanks everyone, Patrik On 8/16/07, Joe Armstrong wrote: > After thought - I *won't* be sending you any code :-( > > My XML stuff is in the middle of a big re-write - I'll do this first. > > I'm trying to make several inter-related XML processing things. I > don't believe the > one-tool-suits-all approach for manipulating XML. > > > Parsing XML raises a number of tricky design issues. What > do we want to do with the XML? --- do we have to handle > infinite (or at least very large) inputs. Is all the input > available at the time of parsing, or does it arrive in > fragmented chunks from a stream. If the data is streamed do we > want to handle the chunks as they come in a re-entrant parser, > or do we want to wait until all the chunks have come and then > do the parsing? In this case we'll have to pre-scan the data so > that we know when to do the parsing. > > > Given that we've got a tokenizer can we write a parser that > works with lists of tokens, or with streams, or do we have to > write a number of different parsers to handle the different > cases? > > Do we want to write a validating parser, or a non-validating parser? > Should it be re-entrant or not? > > Do we want to handle simple ASCII character sets or many different > character sets > and is the code very different in the two cases? > > Do we want to *exactly reconstruct* the input or > should the parse tree represent the logically equivalent of the > input. For example, do we want to pass tag attributes in the > same order as they appear in the input. Do we want to exactly > retain white space and tabs in places where they are not > semantically important? > > These are difficult design questions and it is difficult to > write the libraries in such a way that all of these things can be > done. If we write a very general set of routines they will > probably not be very fast for a specific purpose. If we write fast > specialised routines, they will not be very general. > > A lot of XML processing can be done at a token level alone - there is no > need to even have a well-formed document - here parsing and validating would > be a waste of time. > > Then we have to decide on performance - a set of routines that work correctly > of GByte files will also work on small files - but if we were only processing > small files then a more efficient algorithms would be possible. Do we have to > write two sets of routines (for large and small files) and can they > share common code? > > Anyway - I'm trying to make a toolkit that can allow you to manipulate > a document > either as a stream of tokens, or as a well-formed or as a validated document. > > Another question I have is: > > What do you want to do with an infinite document? > > (here infinite means "too big to keep the parse tree in memory in > an efficient manner") > > Do you want to: > > a) - produce another infinite document > b) - extract a sub-set according to some filter rules > > If it's a) are the things in the output document in the same order > as the things > in the input document? - I guess both a and b would be candidates > for some kinds of > higher order functions that work on xml parse trees > > Lot's to think about > > /Joe > > > > On 8/15/07, Joe Armstrong wrote: > > Interesting - I've been writing some new XML libraries and handling > > infinite streams (Well very large) is one of the problems I've been > > thinking about > > > > I'll poke around tomorrow and send you some code that might help > > > > /Joe Armstrong > > > > On 8/15/07, Patrik Husfloen wrote: > > > I've been trying to learn erlang for a while, and I recently found > > > what I thought to be an easy starter project. I currently have a > > > simple application that reads data from a couple of Xml files using > > > SAX, and inserts it using a rpc over http. > > > > > > I'm not sure about the terminology here, I've been stuck in OO land > > > for so long that everything looks like an object, but here's what I'm > > > thinking: One thread reading the xmls and piecing together the data, > > > and then handing off each record to a pool of workers that issue the > > > http requests, or, maybe the xml-reading part could just spawn a new > > > thread for each record it reads, and ensure that only X are running at > > > the most? > > > > > > The http request was easy enough to get working, but I'm having > > > trouble with reading the xml, I used xmerl_scan:file to parse the > > > file, but that loads the file into memory before starting to process. > > > > > > I took a look at Erlsom, and it's SAX reader examples, but that read > > > the entire file into a binary before passing it off to the Xml reader. > > > > > > > > > Thanks, > > > > > > Patrik > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > From dot@REDACTED Thu Aug 16 19:54:03 2007 From: dot@REDACTED (Tony Finch) Date: Thu, 16 Aug 2007 18:54:03 +0100 Subject: [erlang-questions] sub-byte endianness in bit syntax In-Reply-To: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> References: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> Message-ID: On Wed, 15 Aug 2007, Bob Ippolito wrote: > It takes a few seconds to figure this out yourself: > > 1> <> = <<2#10100000>>, {A, B}. > {2,2} It would be nice if this were documented. How do you tell Erlang to fill bytes little-end first? Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From opendev@REDACTED Thu Aug 16 21:16:33 2007 From: opendev@REDACTED (Joern) Date: Thu, 16 Aug 2007 21:16:33 +0200 Subject: [erlang-questions] Configuration management below the application layer? In-Reply-To: References: <9e009ad0708140900j758a92d3q3bbb3fa502b285a2@mail.gmail.com> Message-ID: <9e009ad0708161216l56f17cb4p6c686bed666157bc@mail.gmail.com> Hi Daniel, On 8/15/07, Daniel Goertzen wrote: > So the main difference with mine is that there are no requirements on the > client processes, and the reaction-to-configuration-change > policy is embodied in the client processes rather than the config server... > it works well for me, put perhaps your needs are different? My needs are probably not that different - except that in my case some kind of plain text configuration file is a requirement. Of course I could easily adopt your excellent suggestion, write this data on demand into an mnesia table to which the interested processes subscribe. The problem I saw with such an approach is that I would have need a considerable amount of infrastructure for unit tests. That's why I initially opted for an approach which embedded the config data into a behaviours state. On the other hand one could probably combine both approaches by handling the configuration in mnesia AND keeping the current config in the behaviours state - the actual mnesia event subscription could be a fun() in the state or the (then abstract) module. This would allow one to simply mock out the wait for mnesia / initial pull of the configuration and the subscription to changes from the mnesia database. > Getting back to your approach... instead of extending each configurable > module with a pile of handle_info clauses, you could implement a > supervisor-like module to receive the configuration messages and restart the > actual configurable module based on that. One config-supervisor process per > configurable process. That's another quite good idea. Currently I just { stop, ... } with reason configuration_changed my persistent processes and let their respective supervisor restart them. But the whole discussion makes me wonder nevertheless - is the configuration of processes such a unique problem? Best regards, Joern -- From erlangx@REDACTED Thu Aug 16 21:46:30 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Thu, 16 Aug 2007 12:46:30 -0700 Subject: [erlang-questions] sub-byte endianness in bit syntax In-Reply-To: References: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> Message-ID: <20070816194630.GH6446@delora.autosys.us> On Thu, Aug 16, 2007 at 06:54:03PM +0100, Tony Finch wrote: > On Wed, 15 Aug 2007, Bob Ippolito wrote: > > > It takes a few seconds to figure this out yourself: > > > > 1> <> = <<2#10100000>>, {A, B}. > > {2,2} > > It would be nice if this were documented. > > How do you tell Erlang to fill bytes little-end first? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ documentation, programming examples, section 4.3 " The TypeSpecifierList is a list of type specifiers separated by hyphens. Type The type can be integer, float, or binary. Signedness The signedness specification can be either signed or unsigned. Note that signedness only matters for matching. Endianness The endianness specification can be either big, little, or native. Native-endian means that the endian will be resolved at load time to be either big-endian or little-endian, depending on what is "native" for the CPU that the Erlang machine is run on. Unit The unit size is given as unit:IntegerLiteral. The allowed range is 1-256. It will be multiplied by the Size specifier to give the effective size of the segment. Example: X:4/little-signed-integer-unit:8 This element has a total size of 4*8 = 32 bits, and it contains a signed integer in little-endian order. " ~Michael > > Tony. > -- > f.a.n.finch http://dotat.at/ > IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR > MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,46c48f8773321070549924! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From dustin@REDACTED Thu Aug 16 22:30:05 2007 From: dustin@REDACTED (Dustin Sallings) Date: Thu, 16 Aug 2007 13:30:05 -0700 Subject: [erlang-questions] poor performance on Linux? Message-ID: I have two machines I've been trying my software on: My old macbook pro (2GHz Core Duo) Ubuntu server with 8 2.33GHz Xeon cores. On my mac: Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] [kernel-poll:false] On the ubuntu server: Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false] The exact problem I'm seeing is that when I run my software (which heavily exercises inets http client), any work that's sent to a node on the linux box is performed considerably more slowly than work on my mac. Isolating the components as I can into separate processes and using the synchronous form of http:request, I see this on the nodes I have running: My mac: httpc_manager <5291.60.0> httpc_manager:init/1 1136283 0 Each linux node: httpc_manager <5253.44.0> httpc_manager:init/1 9530010 9217 httpc_manager <5294.44.0> httpc_manager:init/1 9360826 9850 httpc_manager <5292.44.0> httpc_manager:init/1 9635531 9773 httpc_manager <5293.44.0> httpc_manager:init/1 9611592 9544 Looking further into one of those processes: <5253.44.0> httpc_manager:init/1 2629425 7236635 1102 httpc_manager proc_lib:sync_wait/2 29 I've got similar performance issues regardless of the number of nodes I run on the linux box. The load is distributed evenly across all nodes. Is there any reason my Linux machine should perform significantly more poorly than my mac in this application? -- Dustin Sallings -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Thu Aug 16 22:30:17 2007 From: dmercer@REDACTED (David Mercer) Date: Thu, 16 Aug 2007 15:30:17 -0500 Subject: [erlang-questions] sub-byte endianness in bit syntax In-Reply-To: <20070816194630.GH6446@delora.autosys.us> References: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> <20070816194630.GH6446@delora.autosys.us> Message-ID: <003f01c7e044$42a86a80$891ea8c0@SSI.CORP> At Thursday, August 16, 2007 14:47, Michael McDaniel wrote: > On Thu, Aug 16, 2007 at 06:54:03PM +0100, Tony Finch wrote: > > How do you tell Erlang to fill bytes little-end first? > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > documentation, programming examples, section 4.3 . . . I think what Tony is asking about is little-endian *bit* order as opposed to byte order. I think Erlang's endianness is at the byte level, not bit level. Therefore, << 2#11110000:8/little >> = << 2#11110000:8/big >> regardless of the endianness, since it is only one byte, and the bits within a byte are filled in big-endian order always. Once we go over a byte boundary, however, endianness does matter: << 2#11110000:16/little >> = << 2#11110000:16/big >> will not match. This request may be related to EEP #4 (http://www.erlang.org/eeps/eep-0004.html), since it seems to be related to bit streams as opposed to byte streams. From bernied@REDACTED Fri Aug 17 02:59:32 2007 From: bernied@REDACTED (Bernhard Damberger) Date: Thu, 16 Aug 2007 17:59:32 -0700 (PDT) Subject: [erlang-questions] {erlang, aws} = erlawys. Message-ID: <12192024.post@talk.nabble.com> I thought I would let people know that I did a first pass at implementing the Amazon Web Services (AWS) APIs in erlang. It implements the ec2 and fps APIs. You can check it out at http://code.google.com/p/erlawys/. If you have any questions or comments let me know. -- View this message in context: http://www.nabble.com/%7Berlang%2C-aws%7D-%3D-erlawys.-tf4282971.html#a12192024 Sent from the Erlang Questions mailing list archive at Nabble.com. From bernied@REDACTED Fri Aug 17 03:38:41 2007 From: bernied@REDACTED (Bernhard Damberger) Date: Thu, 16 Aug 2007 18:38:41 -0700 Subject: [erlang-questions] {erlang, aws} = erlawys. Message-ID: I thought I would let people know that I did a first pass at implementing the Amazon Web Services (AWS) APIs in erlang. It implements the ec2 and fps APIs. You can check it out at http://code.google.com/p/erlawys/. If you have any questions or comments let me know. _bernhard From lcoquelle@REDACTED Fri Aug 17 07:32:50 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Fri, 17 Aug 2007 13:32:50 +0800 Subject: [erlang-questions] Mnesia in an OTP application Message-ID: Hi, What is the common (or easy) way to integrate Mnesia in an OTP application? I mean, my app rely on Mnesia. Thus, when my app start, it check that mnesia is running and start it if necessary. If my app started mnesia, I would like to stop mnesia when I stop my app ... but I cannot call mnesia:stop/0 while I am in myapp:stop/0 (it hangs, probably there is single application manager... or something like that). How do you guys solved this problem for your app? Is it a real case or is it a bad idea to start mnesia from another app? Is there a mnesia supervisor I could use to put mnesia inside my app supervision tree? Could I see Mnesia as a "included application"? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From 0x6e6562@REDACTED Fri Aug 17 08:31:24 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Fri, 17 Aug 2007 07:31:24 +0100 Subject: [erlang-questions] Reading large (1GB+) XML files. In-Reply-To: <9b08084c0708160117mcb29aa9k698cb050b33be3cf@mail.gmail.com> References: <4bcbf07d0708151123j726c2b7ck1061d9cdb2160415@mail.gmail.com> <9b08084c0708151222y71ce538rb34f710ced1e1597@mail.gmail.com> <9b08084c0708160117mcb29aa9k698cb050b33be3cf@mail.gmail.com> Message-ID: <269388e30708162331u13c96db9keeb523014e9d05a1@mail.gmail.com> On 8/16/07, Joe Armstrong wrote: > Another question I have is: > > What do you want to do with an infinite document? > > (here infinite means "too big to keep the parse tree in memory in > an efficient manner") If I understand you correctly, you are asking about real world scenarios where one would want to parse massive XML files in a streaming fashion? If so, one example use case is a payments system that I'm working on that accepts instructions in an ISO 20022 XML file which can contain in excess of 100000 items in a single file (but there is no hard limit). Each item might be on average 4k, but could be up to 10k (this is the size of the uncompressed ASCII XML encoding). Then if you have to process multiple input files concurrently, you can't materialize the whole thing into memory. So the approach is to parse and materialze in a streaming fashion and send the resulting data objects off to a downstream process system. Anyway, apologies if I misunderstood you and this comment is irrelevant to this conversation. HTH, Ben From heinrich@REDACTED Fri Aug 17 09:23:27 2007 From: heinrich@REDACTED (Heinrich Venter) Date: Fri, 17 Aug 2007 09:23:27 +0200 Subject: [erlang-questions] crypto and RSA In-Reply-To: <290b3ba10708160802g458d9bb4m92f764362db65ed7@mail.gmail.com> References: <000601c7dfda$3d0a0580$b71e1080$@com> <290b3ba10708160740y1f4e11a0n39175e8338d6e6af@mail.gmail.com> <000301c7e014$348e57a0$9dab06e0$@com> <290b3ba10708160802g458d9bb4m92f764362db65ed7@mail.gmail.com> Message-ID: <003401c7e09f$85523e50$8ff6baf0$@com> Yes, I mean RSA_private_encrypt specifically. This is used to encrypt a 3DES key that is sent along with the 3DES encrypted data. I don't have a command line, but the examples in the OpenSSL docs with regards to rsautl has all the functionality that is required. I looked at the functions exposed in crypto_drv.c again and it is only the RSA signature functions that is exported at present. Unfortunately due to time constraints it has been decided to do the XML encryption in a Java module using third party tools instead (Weblogic soap client libraries) One piece of functionality that I missed is the ability to easily get the required key parameters out of certifficates. The emphasis here is on easily, because all the parts (except the ASN.1 key parameter speciffics eg. RSAPublicKey.asn) are already there. -]-[ From jerith@REDACTED Fri Aug 17 11:12:14 2007 From: jerith@REDACTED (Jeremy Thurgood) Date: Fri, 17 Aug 2007 11:12:14 +0200 Subject: [erlang-questions] {erlang, aws} = erlawys. In-Reply-To: References: Message-ID: <46C5666E.6070806@jerith.za.net> Bernhard Damberger wrote: > I thought I would let people know that I did a first pass at > implementing the Amazon Web Services (AWS) APIs in erlang. It > implements the ec2 and fps APIs. > > You can check it out at http://code.google.com/p/erlawys/. > > If you have any questions or comments let me know. I've got the start of an SQS client that might be a useful addition. I'll poke around in the code over the weekend and see how tricky the conversion will be. It would be pretty cool to end up with an Erlang equivalent to boto (http://code.google.com/p/boto/) eventually. --J From jerith@REDACTED Fri Aug 17 12:54:44 2007 From: jerith@REDACTED (Jeremy Thurgood) Date: Fri, 17 Aug 2007 12:54:44 +0200 Subject: [erlang-questions] {erlang, aws} = erlawys. In-Reply-To: References: Message-ID: <46C57E74.5090909@jerith.za.net> Bernhard Damberger wrote: > I thought I would let people know that I did a first pass at > implementing the Amazon Web Services (AWS) APIs in erlang. It > implements the ec2 and fps APIs. > > You can check it out at http://code.google.com/p/erlawys/. > > If you have any questions or comments let me know. Firstly, you should avoid using -import(), since it makes it a bit more difficult to figure out what module your functions live in. It looks like your auth failures are due to improperly URL-encoding the parameters. This is especially important with the signature, as base64-encoded strings may contain a number of illegal characters. Here's the URL-encoding code I use in my (incomplete) sqs library: hexify_char(Char) -> Must_escape = lists:member(Char, " <>#{}|^[]+`;/?&:@=%\"~\\"), if Must_escape; Char < 31; Char > 177 -> io_lib:format("%~2.16.0B", [Char]); true -> Char end. url_encode(String) -> lists:flatten(lists:map(fun(C) -> hexify_char(C) end, String)). HTH, --J From jesper.louis.andersen@REDACTED Fri Aug 17 13:13:30 2007 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 17 Aug 2007 13:13:30 +0200 Subject: [erlang-questions] Question on ETS/DETS and log_mf_h Message-ID: <56a0a2840708170413k3962cb5aoffaf7c2f289ca701@mail.gmail.com> Hi Erlang users I am liking my erlang programming very much this far. I like the simplicity of the language and how the OTP part allows me to construct concurrent programs. However, I have run into some dilemmas, which I think is due to me using the primitives in a non-intended way. Hence, let me get some views on the problems I have: *** log_mf_h *** I like log_mf_h together with the sasl applications rb module a lot: Let your program run and let it gather problem reports in a binary round-robin circular database. Then, at a much later time, use the rb module to look into the problem reports. The main part of log_mf_h (OTP R11B-5) is: Bin = term_to_binary(tag_event(Event)), Size = size(Bin), NewState = if % .... rotate logs if necessary end, [Hi,Lo] = put_int16(Size), file:write(NewState#state.cur_fd, [Hi, Lo, Bin]), {ok, NewState#state{curB = NewState#state.curB + Size + 2}}; That is: We tag our problem report Event and convert it into a binary, take its size and store the report in the file as <>. My problem: I have some processes which are start_link'ed with a lot of state and when they run, they accumulate quite some state. Far more than the 64k we can store in the 16-bit size field. Thus, when rb tries to read the terms from a PROGRESS or CRASH report things go very wrong indeed. The PROGRESS report problem is mostly to the big state-transfer on the start_link. Is it a bad idiom to shove that much data to a starting process or should I seek to transfer it with a message just after process start (And of course handling the serialization issues neatly). The CRASH problem report is more problematic since I'd like to have the full state for debugging. I *could* alter log_mf_h to store 4 bytes of size. 4GB seems to be a reasonable upper limit for quite some time. Also, I ponder if it wouldn't be an advantage to trade CPU cycles for Disk I/O and make it use term_to_binary(tag_event(Event), [compressed]), at least as an option. I could also just throw log_mf_h away and then use standard logging to file via SASL, but it really defeats the purpose of log_mf_h. Is there any tool I am missing which can do the same as log_mf_h without the size problem? What nags me is that the size has not been bumped a long time ago. This makes me think I am using Erlang wrong or I am using log_mf_h wrong. The process uses some nice data structures, dict and gb_trees (The latter to get a simple way to traverse the keys in order) which ensures a pretty fast O(lg n) lookup time. This leads me to question #2: *** ETS *** For some other process exposing the same problem, I found it more beneficial to shove its data into an ETS table, but what is a tuple() described in the ets man-page type-wise? Of course it is a tuple {e1, e2, e3, ..., eN}, but are there any limits on the elements eK (0 <= K <= N) ? Can I just store arbitrary Erlang terms like gb_trees and dicts as the eK elements and can I do lookups on them? Any limitations on keys? It would give a possible workaround where I can store most of the state inside an ETS table. Though: * I will probably serialize access to the ETS table. Goodbye parallelism on that part of the code. I don't think it will matter, but it doesn't really please me. * I speculate that ETS tables are much faster than Erlang-based data structures. Am I right? Other options are also welcome. Thanks In Advance. J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Fri Aug 17 15:04:29 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 17 Aug 2007 08:04:29 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> Message-ID: <46C59CDD.3020200@gmail.com> Samuel, Thanks for your input. I reviewed your modifications and have to say that there are several problems with this approach. 1. Not doing asynchronous accept and relying on a separate process to accept connections may be *dangerous* if not handled properly as it introduces race conditions that could potentially block the server permanently. Here's an important quote from ACE book "C++ Network Programming Vol.1": "When an acceptor socket is passed to select(), it's marked as "active" when a connection is received. Many servers use this event to indicate that it's OK to call accept() without blocking. Unfortunately, there's a race condition that stems from the asynchronous behavior of TCP/IP In particular, after select() indicates an acceptor socket is active (but before accept() is called) a client can close its connection, whereupon accept() can block and potentially hang the entire application process. To avoid this problem, acceptor sockets should always be set into non-blocking mode when used with select()." This applies to your changes indirectly. Under the hood of the network driver, it still does the asynchronous accept, so the paragraph above doesn't apply at the driver level. However, there may be a failure between these two lines in the init/1: {ok, Ref} = create_acceptor(Listen_socket), {ok, #state{listener = Listen_socket, acceptor = Ref, module = Module}}; due to various reasons and despite the fact that it was linked, the {'EXIT', Pid, Reason} message is presently not handled (trap_exit though is turned on), so the process will be locked forever. The same can happen if the acceptor process dies anywhere in the middle of the F() function: F = fun() -> {ok, Socket} = gen_tcp:accept(Listener), gen_tcp:controlling_process(Socket, Self), gen_server:call(Self, {accept, Socket}) end, As mentioned above, this can likely be fixed by proper handling of the {'EXIT', Pid, Reason} and respawning acceptor when it happens. This, however presents another challenge - what if the system runs out of file descriptors - your listener process will be in an unhappy more of constantly respawning acceptors that will die because of this line: {ok, Socket} = gen_tcp:accept(Listener) So you would need to monitor how many accept failures you got in the last several seconds and do some intelligent recovery. This would complicate code by quite a bit. 2. This new process is not OTP compliant - no supervisors know about it and it doesn't process debug and system messages as per "6.2 Special Processes" of Design Principles. This means that you may have problems when you upgrade your system dynamically. Partly these are some of the reasons I put together this tutorial to show how to avoid such problems all together. :-) I hope you will find this feedback useful. Regards, Serge Samuel Tesla wrote: > Serge, > > I really got a lot from your guide on building TCP servers. I really > appreciate the work you put into it. I think I've got an improvement that > you may want to consider putting up on the website. > > I wanted to read documentation for prim_inet:async_accept/2 so I could > figure out what that -1 was for, and couldn't find any documentation. So, I > Googled and discovered that there is no documentation on purpose ( > http://www.trapexit.org/forum/viewtopic.php?p=29157). Basically, it's not a > guaranteed API between versions, whereas gen_tcp is. So, I set out to see > if I could use gen_tcp:accept/1 instead of prim_inet:async_accept/2, and I > was successful. > > I copied your source off the website and then made modifications. I only > had to change the listener and the FSM modules, and I've attached the > altered source files. The gist of what I did was spawn a linked process > which does the accept, and then sends a call back to the main listener > process. The whole sequence until the control has to be synchronous until > the FSM gets into WAIT_FOR_DATA or the socket will disconnect and you'll > start getting posix errors. > > There were a few other things I cleaned up or changed: > * You don't need to copy socket options, as accept/1 does that. > * You don't need to call gen_tcp:close/1 in terminate/2 as the listening > socket will close when its controlling process exits. > * I set {packet, 0} as I was testing with a raw telnet session. > > I hope you find this helpful! > > -- Samuel > -------------- next part -------------- A non-text attachment was scrubbed... Name: tcp_listener.erl Type: application/octet-stream Size: 5729 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: tcp_echo_fsm.erl Type: application/octet-stream Size: 6086 bytes Desc: not available URL: From jesper.louis.andersen@REDACTED Fri Aug 17 13:20:00 2007 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 17 Aug 2007 13:20:00 +0200 Subject: [erlang-questions] {erlang, aws} = erlawys. In-Reply-To: <46C57E74.5090909@jerith.za.net> References: <46C57E74.5090909@jerith.za.net> Message-ID: <56a0a2840708170420y1416b1c1mbe3e0776ec1915c3@mail.gmail.com> On 8/17/07, Jeremy Thurgood wrote:It looks like your auth failures are [hexify code] Let me give my hexify version as well. I don't know which is most correct or fastest. I am mostly concerned about the correctness. According to RFC1738, you may actually encode everything, even unreserved characters, but there are parsers which fails if you try that. What characters are unreserved is given in RFC3986: rfc_3986_unreserved_characters() -> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~". rfc_3986_unreserved_characters_set() -> sets:from_list(rfc_3986_unreserved_characters()). %%-------------------------------------------------------------------- %% Function: build_uri_encoded_form_rfc1738(List) -> String %% Description: Convert the list into RFC1738 encoding (URL-encoding). %%-------------------------------------------------------------------- build_uri_encoded_form_rfc1738(List) -> Unreserved = rfc_3986_unreserved_characters_set(), lists:flatten(lists:map( fun (E) -> case sets:is_element(E, Unreserved) of true -> E; false -> lists:concat( ["%", io_lib:format("~2.16.0B", [E])]) end end, List)). -------------- next part -------------- An HTML attachment was scrubbed... URL: From S.J.Thompson@REDACTED Fri Aug 17 15:02:54 2007 From: S.J.Thompson@REDACTED (S.J.Thompson) Date: Fri, 17 Aug 2007 14:02:54 +0100 (BST) Subject: [erlang-questions] Erlang Workshop '07: registration now open Message-ID: We are pleased to announce that registration for the Erlang Workshop '07, ICFP, and other workshops, is now open at http://www.erlang.se/workshop/2007/ The programme for the workshop itself can be found at http://www.erlang.se/workshop/2007/ and the main conference website at http://www.informatik.uni-bonn.de/~ralf/icfp07.html also has details of support available to students. We look forward to seeing you in Freiburg in October. Lars-Ake Fredlund Simon Thompson From twa@REDACTED Fri Aug 17 21:35:20 2007 From: twa@REDACTED (Tom Ayerst) Date: Fri, 17 Aug 2007 20:35:20 +0100 Subject: [erlang-questions] Cannot get the hang of single assignment Message-ID: <46C5F878.4000004@post.com> Hi, I think I am missing something obvious here. I was reading Jim Menard's account of writing a boids flocking simulator and wanted to have a go. Giving each Boid its own process was obvious but, I am very new to erlang and was then stumped. How should I track the state (position and vector) of each Boid? All help appreciated. Tom From dmercer@REDACTED Fri Aug 17 21:44:36 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 17 Aug 2007 14:44:36 -0500 Subject: [erlang-questions] Cannot get the hang of single assignment In-Reply-To: <46C5F878.4000004@post.com> References: <46C5F878.4000004@post.com> Message-ID: <008101c7e107$0b3baf30$891ea8c0@SSI.CORP> On Friday, August 17, 2007, Tom Ayerst wrote: > How should I track the state (position and vector) of each Boid? The short answer is that your boid is in a loop: implement that loop as a tail-recursive function, passing the state from the previous iteration in as arguments to the next. Something like: boid_loop(State) -> . . . New_state = ... boid_loop(New_state). Does this help? Cheers, David From dmercer@REDACTED Fri Aug 17 21:46:57 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 17 Aug 2007 14:46:57 -0500 Subject: [erlang-questions] Variable Name Capitalization References: <46C5F878.4000004@post.com> Message-ID: <008201c7e107$5f43ad80$891ea8c0@SSI.CORP> For those of you who don't like to RunYourWordsTogether, how do you capitalize your multi-word variable names? Do you capitalize all of the words or just the first one. That is, Long_Variable_Name or Long_variable_name? Cheers, David From dustin@REDACTED Fri Aug 17 22:04:15 2007 From: dustin@REDACTED (Dustin Sallings) Date: Fri, 17 Aug 2007 13:04:15 -0700 Subject: [erlang-questions] Cannot get the hang of single assignment In-Reply-To: <46C5F878.4000004@post.com> References: <46C5F878.4000004@post.com> Message-ID: <63351253-D660-4C72-9373-357040926311@spy.net> On Aug 17, 2007, at 12:35 , Tom Ayerst wrote: > I think I am missing something obvious here. I was reading Jim > Menard's > account of writing a boids flocking simulator and wanted to have a go. > Giving each Boid its own process was obvious but, I am very new to > erlang and was then stumped. > > How should I track the state (position and vector) of each Boid? The general way you do this in a functional language is by passing the parameters in to a tail-recursive function. I have no idea what a Boid is, but it seems to have a position and a vector, and I'm assuming does something to change these. I imagine your process's main loop would look something like this: loop(Position, Vector) -> {NewPosition, NewVector} = compute_new_position_and_vector (Position, Vector), loop(NewPosition, NewVector). -- Dustin Sallings From samuel.tesla@REDACTED Fri Aug 17 22:04:36 2007 From: samuel.tesla@REDACTED (Samuel Tesla) Date: Fri, 17 Aug 2007 15:04:36 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46C59CDD.3020200@gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> Message-ID: <4bd555f70708171304w23f3d4d2r3b7fc986c12cfb19@mail.gmail.com> I suppose the question really becomes, then, how can you write a TCP server using the documented APIs of Erlang/OTP that you can reasonably expect to remain the same between releases? The APIs in prim_inet aren't intended to be used. They can change between releases and that will cause problems with the original code you posted as well. Whereas a solution that uses the functions exported from gen_tcp can be expected to survive upgrades to the OTP environment. I'm currently looking at ejabberd to see how they do things, as they manage a jabber server with only gen_tcp. -- Samuel On 8/17/07, Serge Aleynikov wrote: > > Samuel, > > Thanks for your input. I reviewed your modifications and have to say > that there are several problems with this approach. > > 1. Not doing asynchronous accept and relying on a separate process to > accept connections may be *dangerous* if not handled properly as it > introduces race conditions that could potentially block the server > permanently. > > Here's an important quote from ACE book "C++ Network Programming Vol.1": > > "When an acceptor socket is passed to select(), it's marked as "active" > when a connection is received. Many servers use this event to indicate > that it's OK to call accept() without blocking. Unfortunately, there's a > race condition that stems from the asynchronous behavior of TCP/IP In > particular, after select() indicates an acceptor socket is active (but > before accept() is called) a client can close its connection, whereupon > accept() can block and potentially hang the entire application process. > To avoid this problem, acceptor sockets should always be set into > non-blocking mode when used with select()." > > This applies to your changes indirectly. Under the hood of the network > driver, it still does the asynchronous accept, so the paragraph above > doesn't apply at the driver level. However, there may be a failure > between these two lines in the init/1: > > {ok, Ref} = create_acceptor(Listen_socket), > {ok, #state{listener = Listen_socket, > acceptor = Ref, > module = Module}}; > > due to various reasons and despite the fact that it was linked, the > {'EXIT', Pid, Reason} message is presently not handled (trap_exit though > is turned on), so the process will be locked forever. > > The same can happen if the acceptor process dies anywhere in the middle > of the F() function: > > F = fun() -> > {ok, Socket} = gen_tcp:accept(Listener), > gen_tcp:controlling_process(Socket, Self), > gen_server:call(Self, {accept, Socket}) > end, > > As mentioned above, this can likely be fixed by proper handling of the > {'EXIT', Pid, Reason} and respawning acceptor when it happens. This, > however presents another challenge - what if the system runs out of file > descriptors - your listener process will be in an unhappy more of > constantly respawning acceptors that will die because of this line: > > {ok, Socket} = gen_tcp:accept(Listener) > > So you would need to monitor how many accept failures you got in the > last several seconds and do some intelligent recovery. This would > complicate code by quite a bit. > > 2. This new process is not OTP compliant - no supervisors know about it > and it doesn't process debug and system messages as per "6.2 Special > Processes" of Design Principles. This means that you may have problems > when you upgrade your system dynamically. > > Partly these are some of the reasons I put together this tutorial to > show how to avoid such problems all together. :-) > > I hope you will find this feedback useful. > > Regards, > > Serge > > > Samuel Tesla wrote: > > Serge, > > > > I really got a lot from your guide on building TCP servers. I really > > appreciate the work you put into it. I think I've got an improvement > that > > you may want to consider putting up on the website. > > > > I wanted to read documentation for prim_inet:async_accept/2 so I could > > figure out what that -1 was for, and couldn't find any > documentation. So, I > > Googled and discovered that there is no documentation on purpose ( > > http://www.trapexit.org/forum/viewtopic.php?p=29157). Basically, it's > not a > > guaranteed API between versions, whereas gen_tcp is. So, I set out to > see > > if I could use gen_tcp:accept/1 instead of prim_inet:async_accept/2, and > I > > was successful. > > > > I copied your source off the website and then made modifications. I > only > > had to change the listener and the FSM modules, and I've attached the > > altered source files. The gist of what I did was spawn a linked process > > which does the accept, and then sends a call back to the main listener > > process. The whole sequence until the control has to be synchronous > until > > the FSM gets into WAIT_FOR_DATA or the socket will disconnect and you'll > > start getting posix errors. > > > > There were a few other things I cleaned up or changed: > > * You don't need to copy socket options, as accept/1 does that. > > * You don't need to call gen_tcp:close/1 in terminate/2 as the > listening > > socket will close when its controlling process exits. > > * I set {packet, 0} as I was testing with a raw telnet session. > > > > I hope you find this helpful! > > > > -- Samuel > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Sat Aug 18 04:27:20 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 17 Aug 2007 21:27:20 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <4bd555f70708171304w23f3d4d2r3b7fc986c12cfb19@mail.gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <4bd555f70708171304w23f3d4d2r3b7fc986c12cfb19@mail.gmail.com> Message-ID: <46C65908.3030302@gmail.com> I can only comment that it would be really useful if the OTP team exposed the async_accept function to the gen_tcp module. Serge Samuel Tesla wrote: > I suppose the question really becomes, then, how can you write a TCP server > using the documented APIs of Erlang/OTP that you can reasonably expect to > remain the same between releases? > > The APIs in prim_inet aren't intended to be used. They can change between > releases and that will cause problems with the original code you posted as > well. Whereas a solution that uses the functions exported from gen_tcp can > be expected to survive upgrades to the OTP environment. > > I'm currently looking at ejabberd to see how they do things, as they manage > a jabber server with only gen_tcp. > > -- Samuel > > On 8/17/07, Serge Aleynikov wrote: >> Samuel, >> >> Thanks for your input. I reviewed your modifications and have to say >> that there are several problems with this approach. >> >> 1. Not doing asynchronous accept and relying on a separate process to >> accept connections may be *dangerous* if not handled properly as it >> introduces race conditions that could potentially block the server >> permanently. >> >> Here's an important quote from ACE book "C++ Network Programming Vol.1": >> >> "When an acceptor socket is passed to select(), it's marked as "active" >> when a connection is received. Many servers use this event to indicate >> that it's OK to call accept() without blocking. Unfortunately, there's a >> race condition that stems from the asynchronous behavior of TCP/IP In >> particular, after select() indicates an acceptor socket is active (but >> before accept() is called) a client can close its connection, whereupon >> accept() can block and potentially hang the entire application process. >> To avoid this problem, acceptor sockets should always be set into >> non-blocking mode when used with select()." >> >> This applies to your changes indirectly. Under the hood of the network >> driver, it still does the asynchronous accept, so the paragraph above >> doesn't apply at the driver level. However, there may be a failure >> between these two lines in the init/1: >> >> {ok, Ref} = create_acceptor(Listen_socket), >> {ok, #state{listener = Listen_socket, >> acceptor = Ref, >> module = Module}}; >> >> due to various reasons and despite the fact that it was linked, the >> {'EXIT', Pid, Reason} message is presently not handled (trap_exit though >> is turned on), so the process will be locked forever. >> >> The same can happen if the acceptor process dies anywhere in the middle >> of the F() function: >> >> F = fun() -> >> {ok, Socket} = gen_tcp:accept(Listener), >> gen_tcp:controlling_process(Socket, Self), >> gen_server:call(Self, {accept, Socket}) >> end, >> >> As mentioned above, this can likely be fixed by proper handling of the >> {'EXIT', Pid, Reason} and respawning acceptor when it happens. This, >> however presents another challenge - what if the system runs out of file >> descriptors - your listener process will be in an unhappy more of >> constantly respawning acceptors that will die because of this line: >> >> {ok, Socket} = gen_tcp:accept(Listener) >> >> So you would need to monitor how many accept failures you got in the >> last several seconds and do some intelligent recovery. This would >> complicate code by quite a bit. >> >> 2. This new process is not OTP compliant - no supervisors know about it >> and it doesn't process debug and system messages as per "6.2 Special >> Processes" of Design Principles. This means that you may have problems >> when you upgrade your system dynamically. >> >> Partly these are some of the reasons I put together this tutorial to >> show how to avoid such problems all together. :-) >> >> I hope you will find this feedback useful. >> >> Regards, >> >> Serge >> >> >> Samuel Tesla wrote: >>> Serge, >>> >>> I really got a lot from your guide on building TCP servers. I really >>> appreciate the work you put into it. I think I've got an improvement >> that >>> you may want to consider putting up on the website. >>> >>> I wanted to read documentation for prim_inet:async_accept/2 so I could >>> figure out what that -1 was for, and couldn't find any >> documentation. So, I >>> Googled and discovered that there is no documentation on purpose ( >>> http://www.trapexit.org/forum/viewtopic.php?p=29157). Basically, it's >> not a >>> guaranteed API between versions, whereas gen_tcp is. So, I set out to >> see >>> if I could use gen_tcp:accept/1 instead of prim_inet:async_accept/2, and >> I >>> was successful. >>> >>> I copied your source off the website and then made modifications. I >> only >>> had to change the listener and the FSM modules, and I've attached the >>> altered source files. The gist of what I did was spawn a linked process >>> which does the accept, and then sends a call back to the main listener >>> process. The whole sequence until the control has to be synchronous >> until >>> the FSM gets into WAIT_FOR_DATA or the socket will disconnect and you'll >>> start getting posix errors. >>> >>> There were a few other things I cleaned up or changed: >>> * You don't need to copy socket options, as accept/1 does that. >>> * You don't need to call gen_tcp:close/1 in terminate/2 as the >> listening >>> socket will close when its controlling process exits. >>> * I set {packet, 0} as I was testing with a raw telnet session. >>> >>> I hope you find this helpful! >>> >>> -- Samuel >>> >> >> > From als@REDACTED Sat Aug 18 11:27:46 2007 From: als@REDACTED (Anthony Shipman) Date: Sat, 18 Aug 2007 19:27:46 +1000 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46C65908.3030302@gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <4bd555f70708171304w23f3d4d2r3b7fc986c12cfb19@mail.gmail.com> <46C65908.3030302@gmail.com> Message-ID: <200708181927.46860.als@iinet.net.au> On Saturday 18 August 2007 12:27, Serge Aleynikov wrote: > I can only comment that it would be really useful if the OTP team > exposed the async_accept function to the gen_tcp module. > > Serge > > Samuel Tesla wrote: > > I suppose the question really becomes, then, how can you write a TCP > > server using the documented APIs of Erlang/OTP that you can reasonably > > expect to remain the same between releases? > > > > The APIs in prim_inet aren't intended to be used. They can change > > between releases and that will cause problems with the original code you > > posted as well. Whereas a solution that uses the functions exported from > > gen_tcp can be expected to survive upgrades to the OTP environment. Please ensure that any changes are reflected in the SSL functions as well. A server that does http and https shouldn't have to have two different design paradigms. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From rvirding@REDACTED Sat Aug 18 12:05:47 2007 From: rvirding@REDACTED (Robert Virding) Date: Sat, 18 Aug 2007 12:05:47 +0200 Subject: [erlang-questions] Variable Name Capitalization In-Reply-To: <008201c7e107$5f43ad80$891ea8c0@SSI.CORP> References: <46C5F878.4000004@post.com> <008201c7e107$5f43ad80$891ea8c0@SSI.CORP> Message-ID: <3dbc6d1c0708180305j16d5c795g449a45e6abc89e82@mail.gmail.com> I use different standards for atoms and variables: In atoms I use_underscore to_separate_words because this is much easier to to read and there is nu UC letter at the beginning anyway. For variables I use capitalisation ToSeparateWords as there already IS an UC letter at the beginning. BUT I very seldom use long variable names that are more than one word. I find it much better, and more readable, to document what the variable is for and use a short name. This also makes it easier to see which are atoms and which are variables. I don't know if there is an accepted "standard". Robert On 17/08/07, David Mercer wrote: > > For those of you who don't like to RunYourWordsTogether, how do you > capitalize your multi-word variable names? Do you capitalize all of the > words or just the first one. That is, Long_Variable_Name or > Long_variable_name? > > Cheers, > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 0x6e6562@REDACTED Sat Aug 18 14:36:50 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Sat, 18 Aug 2007 13:36:50 +0100 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> Message-ID: <269388e30708180536p64883665h9e62973bd4f24e32@mail.gmail.com> Vlad, On 8/15/07, Vlad Dumitrescu wrote: > I'm not sure how many people are interacting with Java from Erlang, > but I am (for ErlIDE) and I just implemented a nice feature (if I may > say so myself) that might of interest: the ability to call Java code I'm using Hessian to achieve binary data binding between Erlang and Java, see http://cotton.sourceforge.net/hg/cotton/file/88f45901c41f/src/integration_test.erl for an example. In this example I using http as a transport between the Erlang client and Java server, but Hessian is not tied to a particular transport mechanism, it just handles binary encoding and decoding to a language neutral data format protocol. > The conversion layer converts between Erlang terms and Java objects, > almost seamlessly (atoms aren't easy to translate, for example) and > uses reflection to resolve and invoke the proper methods. Type > translation is trying to be clever, for example strings are > represented by native types, likewise integers. Lists correspond to > java.util.Lists and tuples to arrays. This example http://cotton.sourceforge.net/hg/cotton/file/88f45901c41f/src/hessian_test.erl shows how the type mapping works. The main assumption is that in order to serialize an Erlang record (which is just a tuple with no runtime type information), a serializable record type should have a field called fqn (abbreviation of fully qualified name) so that it can be deserialized in more strongly typed languages like Java. HTH, Ben From dot@REDACTED Thu Aug 16 20:08:35 2007 From: dot@REDACTED (Tony Finch) Date: Thu, 16 Aug 2007 19:08:35 +0100 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46C413BF.3020301@it.uu.se> References: <8209f740708120202t7f5ff19bx9dac1f05a85533f3@mail.gmail.com> <9b08084c0708150550u61db8c51gaee16c6cf5b36c39@mail.gmail.com> <4ED5D26B-E686-42FF-AE38-1DBF26D19D03@gmail.com> <46C413BF.3020301@it.uu.se> Message-ID: On Thu, 16 Aug 2007, Richard Carlsson wrote: > > To end this on a more positive note, I'd like to encourage everyone on > this list to keep thinking about how Erlang process communication could > be made even simpler and more streamlined. I quite like E's promise-passing RPC. It's sort of intermediate between Erlang's async one-way messages and a synchronous RPC. The immediate result of an RPC is a promise, and you can send messages to it on the assumption that it will resolve into an object that can handle the messages (in Erlang that would be a pid). For anything else you have to wait for the promise to resolve or be broken; I think it would be reasonable for the promise to provide standard ways of doing so while handling errors and timeouts. See erights.org for more. Their promises asynchronously morph into the value they resolve to, which makes me worry - I prefer the idea of promises that are more visibly proxies that must be unwrapped when they are ready. Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From vladdu55@REDACTED Sun Aug 19 12:58:27 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 19 Aug 2007 10:58:27 +0000 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <269388e30708180536p64883665h9e62973bd4f24e32@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> <269388e30708180536p64883665h9e62973bd4f24e32@mail.gmail.com> Message-ID: <95be1d3b0708190358g16577771qbcca2438f3f417cf@mail.gmail.com> Hi, On 8/18/07, Ben Hood <0x6e6562@REDACTED> wrote: > I'm using Hessian to achieve binary data binding between Erlang and > Java, see http://cotton.sourceforge.net/hg/cotton/file/88f45901c41f/src/integration_test.erl > for an example. In this example I using http as a transport between > the Erlang client and Java server, but Hessian is not tied to a > particular transport mechanism, it just handles binary encoding and > decoding to a language neutral data format protocol. This looks very interesting. Do you have any link to documentation regarding configuration on the Java side when not using HessianServlet? I couldn't find any when doing a quick browse at their site. BTW, I suppose you are aware that your hessian:encode_reply/1 is incomplete, it only accepts integers. best regards, Vlad From saleyn@REDACTED Sun Aug 19 15:39:09 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 19 Aug 2007 08:39:09 -0500 Subject: [erlang-questions] release_handler and documentation of supervisor's child spec Message-ID: <46C847FD.4050007@gmail.com> To: OTP maintainers of the 'supervisor' documentation and SASL's release handler. 1. The documentation of child specification of a supervisor states: {Id, StartFunc, Restart, Shutdown, Type, Modules} ... Modules = [Module] | dynamic Module = atom() Modules should be a list with one element [Module], where Module is the name of the callback module, if the child process is a supervisor, gen_server or gen_fsm. If the child process is a gen_event, Modules should be dynamic. Modules is used by the release handler during code replacement to determine which processes are using a certain module. As a rule of thumb Modules should be a list with one element [Module], where Module is the callback module, if the child process is a supervisor, gen_server or gen_fsm. If the child process is an event manager (gen_event) with a dynamic set of callback modules, Modules should be dynamic. See OTP Design Principles for more information about release handling. What neither reference mentions is the fact that if the child process is *not* a supervisor, gen_server, gen_fsm, nor gen_event, what the requirements are for the process when the Modules parameter is set to 'dynamic'. An example could be a module implemented using proc_lib. Unless implemented correctly release_handler won't be able to upgrade it properly. It looks like the requirement is that the supervised process must implement get_modules/0 function that should return a list of modules (with at least one item) it executes as a call_back or process module. 2. The release_handler_1:get_procs/2 does the following call: get_procs([{Name, Pid, worker, dynamic} | T], Sup) when pid(Pid) -> Mods = get_dynamic_mods(Name), ... Shouldn't this instead be the following? Mods = get_dynamic_mods(Pid), ... The current implementation mandates that the registered name of a dynamic process must match the supervisor's chiled specification ID (which is a name that is used to identify the child specification internally by the supervisor). This mandate is somewhat odd for custom processes implemented using proc_lib. To illustrate this point, I had the following code in the LAMA application on jungerl: init([AlarmOptions, SyslogOpts]) -> SafeSupervisor = {lama_safe_sup, {supervisor, start_link, [{local, lama_sup_safe}, ?MODULE, {safe, AlarmOptions, SyslogOpts}]}, permanent, infinity, supervisor, [?MODULE]}, %% Reboot node if lama_logger or lama_alarmer or lama_snmp_trapper crashes! {ok, {_SupFlags = {one_for_one, 0, 1}, [SafeSupervisor]}}; init({safe, AlarmOptions, SyslogOpts}) -> SyslogH = {lama_syslog_sup, {lama_guard, start_link, [lama_guard_syslog, lama_syslog_h, SyslogOpts]}, permanent, 2000, worker, dynamic}, AlarmH = {lama_alarm_sup, {lama_guard, start_link, [lama_guard_alarm, lama_alarm_h, AlarmOptions]}, permanent, 2000, worker, dynamic}, {ok, {_SupFlags = {one_for_one, 4, 3600}, [SyslogH, AlarmH]}}. The lama_guard:start_link/1 is implemented like this: start_link(GuardName, HandlerModule, Options) -> Self = self(), proc_lib:start_link(?MODULE, init, [GuardName, HandlerModule, Options, Self], infinity). init(GuardName, HandlerModule, Options, Parent) -> case catch erlang:register(GuardName, self()) of true -> .... We see here that the registered name of the lama_guard process is determined dynamically by the GuardName parameter as the same module is reused for two implementations. This presents a problem with 'lama_syslog_sup' and 'lama_alarm_sup' child specification IDs above if we don't give the same name to the supervisor's child spec as the name registered by the spawned processes 'lama_guard_syslog' and 'lama_guard_alarm'. So we have to rewrite the spec as: SyslogH = {lama_guard_syslog, ^^^^^^^^^^^^^^^^^ {lama_guard, start_link, [lama_guard_syslog, lama_syslog_h, SyslogOpts]}, ^^^^^^^^^^^^^^^^^ permanent, 2000, worker, dynamic}, AlarmH = {lama_guard_alarm, ^^^^^^^^^^^^^^^^ {lama_guard, start_link, [lama_guard_alarm, lama_alarm_h, AlarmOptions]}, ^^^^^^^^^^^^^^^^ permanent, 2000, worker, dynamic}, Since ID in the supervisor's child specification is documented as "used to identify the child specification internally by the supervisor", it shouldn't have any implications on the choice of registered names of supervised processes. I don't know all the implications of changing Mods = get_dynamic_mods(Name), to Mods = get_dynamic_mods(Pid), in the release_handler_1:get_procs/2, but it looks like the right thing to do in addition to documenting get_modules/0 requirement. Regards, Serge From 0x6e6562@REDACTED Sun Aug 19 18:15:02 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Sun, 19 Aug 2007 17:15:02 +0100 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <95be1d3b0708190358g16577771qbcca2438f3f417cf@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> <269388e30708180536p64883665h9e62973bd4f24e32@mail.gmail.com> <95be1d3b0708190358g16577771qbcca2438f3f417cf@mail.gmail.com> Message-ID: <269388e30708190915p39b26104r47503118dbe4605c@mail.gmail.com> > This looks very interesting. Do you have any link to documentation > regarding configuration on the Java side when not using > HessianServlet? I couldn't find any when doing a quick browse at their > site. The decoding/encoding from/to a stream is implemented in the HessianOutput / HessianInput classes. I don't think there is any online documentation of this, but it's fairly straight forward to read the API docs of these 2 classes. > BTW, I suppose you are aware that your hessian:encode_reply/1 is > incomplete, it only accepts integers. Yes, the cotton lib is still incomplete because I have been concentrating first on the parts that I require for some downstream projects. The hessian_test module is supposed to be a protocol compatibility test and tests for all facets of the protocol still need to be added. If you are interested in using any of it at all I can re-prioritize some of the work on this. HTH, Ben From frej.drejhammar@REDACTED Sun Aug 19 20:38:38 2007 From: frej.drejhammar@REDACTED (Frej Drejhammar) Date: Sun, 19 Aug 2007 20:38:38 +0200 Subject: [erlang-questions] Patch to inets for correct handling of HTTP's Conditional GET Message-ID: Hi, The http client in inets for R11B-5 does not handle conditional get correctly. Doing a http:request/4 with the "If-None-Match" and "If-Modified-Since" headers set such that the server gives a 304 "Not Modified" reply, the httpc_handler still expects to receive a body. This eventually leads to a timeout. The attached bug.erl demonstrates the problem by retrieving the slashdot rss-feed. The included patch seems to fix the problem, although I'm not completely sure about its correctness when pipelining is used. Regards, Frej Drejhammar --- otp_src_R11B-5/lib/inets/src/http_client/httpc_handler.erl 2007-06-11 12:25:27.000000000 +0200 +++ otp_src_R11B-5.orig/lib/inets/src/http_client/httpc_handler.erl 2007-08-19 18:09:16.000000000 +0200 @@ -489,6 +489,9 @@ {NewBody, NewRequest}= stream(Body, State#state.request, Code), handle_response(State#state{body = NewBody, request = NewRequest}). +handle_http_body(<<>>, State = #state{status_line = {_,304, _}}) -> + handle_response(State#state{body = <<>>}); + handle_http_body(<<>>, State = #state{request = #request{method = head}}) -> handle_response(State#state{body = <<>>}); -------------- next part -------------- A non-text attachment was scrubbed... Name: bug.erl Type: application/octet-stream Size: 1138 bytes Desc: not available URL: From ingela@REDACTED Mon Aug 20 11:21:35 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 20 Aug 2007 11:21:35 +0200 Subject: [erlang-questions] Patch to inets for correct handling of HTTP's Conditional GET In-Reply-To: References: Message-ID: <46C95D1F.90007@erix.ericsson.se> Hello, thank you for the patch it will be included in the next release. It should be fine for the pipelining as the server should not send a body together with 304 code. So the client will after the 304 code, expect the answer to the next request in the pipeline. Regards Ingela -OTP team Frej Drejhammar wrote: > Hi, > > The http client in inets for R11B-5 does not handle conditional get > correctly. Doing a http:request/4 with the "If-None-Match" and > "If-Modified-Since" headers set such that the server gives a 304 "Not > Modified" reply, the httpc_handler still expects to receive a > body. This eventually leads to a timeout. The attached bug.erl > demonstrates the problem by retrieving the slashdot rss-feed. > > The included patch seems to fix the problem, although I'm not > completely sure about its correctness when pipelining is used. > > Regards, > > Frej Drejhammar > > --- otp_src_R11B-5/lib/inets/src/http_client/httpc_handler.erl 2007-06-11 12:25:27.000000000 +0200 > +++ otp_src_R11B-5.orig/lib/inets/src/http_client/httpc_handler.erl 2007-08-19 18:09:16.000000000 +0200 > @@ -489,6 +489,9 @@ > {NewBody, NewRequest}= stream(Body, State#state.request, Code), > handle_response(State#state{body = NewBody, request = NewRequest}). > > +handle_http_body(<<>>, State = #state{status_line = {_,304, _}}) -> > + handle_response(State#state{body = <<>>}); > + > handle_http_body(<<>>, State = #state{request = #request{method = head}}) -> > handle_response(State#state{body = <<>>}); > > From raimo+erlang-questions@REDACTED Mon Aug 20 12:24:52 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 20 Aug 2007 12:24:52 +0200 Subject: [erlang-questions] SCTP with lksctp 2.6.22-1.0.7 In-Reply-To: References: Message-ID: <20070820102452.GB11758@erix.ericsson.se> Yes, in general there are plans to follow the development. Could you give me some pointers on how to be compatible with old versions too. We can not find the latest version on all our supported platforms, eg. Solaris 10 On Wed, Aug 15, 2007 at 09:05:55PM +0400, Sergei Golovan wrote: > Hi! > > Appears that SCTP support in Erlang/OTP cant be compiled with newest > lksctp (version 2.6.22-1.0.7). > > lksctp authors just replaced all 'adaption' substrings in lksctp API > by 'adaptation'. > > As far as I can see, the current snapshot of R12B-0 builds only with > older lksctp. > > Are there plans to port Erlang to a newer lksctp version? > > Thanks! > -- > Sergei Golovan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Mon Aug 20 14:44:17 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 20 Aug 2007 14:44:17 +0200 Subject: [erlang-questions] Tilera 64-core chip Message-ID: <50EF7C1F8DC43749AC0018FB9574D996171B73@esealmw115.eemea.ericsson.se> Does anyone have experience with Tilera? http://www.tilera.com/index.php For example their PCI Express card with a 64-core* chip and 6-12 gigabit Ethernet ports, all running at ca 35W, sounds like a pretty good match for SMP Erlang... (: * Each core running at 600-900 MHz BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Mon Aug 20 16:15:47 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 20 Aug 2007 07:15:47 -0700 (PDT) Subject: [erlang-questions] Tilera 64-core chip In-Reply-To: <50EF7C1F8DC43749AC0018FB9574D996171B73@esealmw115.eemea.ericsson.se> Message-ID: <354772.36532.qm@web38804.mail.mud.yahoo.com> --- "Ulf Wiger (TN/EAB)" wrote: > > Does anyone have experience with Tilera? > > http://www.tilera.com/index.php > > For example their PCI Express card with a 64-core* > chip > and 6-12 gigabit Ethernet ports, all running at ca > 35W, > sounds like a pretty good match for SMP Erlang... (: It does seem to run Linux (in some sense, "supports" is a flexible word) so it can't be too exotic. That's good. I wonder what ISA the cores implement? MIPS? PPC? It also seems interesting to consider this: 1. 5MB onchip cache => 78 KB per core (at a guess that's 16+64 KB locally per core in split caches of some sort). 2. What memory bandwidth does the chip support? (E.g., how many pins?) And what will 64 SMP Erlang cores require? Best, Thomas ____________________________________________________________________________________ Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz From mikpe@REDACTED Mon Aug 20 16:40:40 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 20 Aug 2007 16:40:40 +0200 (MEST) Subject: [erlang-questions] Tilera 64-core chip Message-ID: <200708201440.l7KEeeON001371@harpo.it.uu.se> On Mon, 20 Aug 2007 07:15:47 -0700 (PDT), Thomas Lindgren wrote: > > Does anyone have experience with Tilera? > > > > http://www.tilera.com/index.php > > > > For example their PCI Express card with a 64-core* > > chip > > and 6-12 gigabit Ethernet ports, all running at ca > > 35W, > > sounds like a pretty good match for SMP Erlang... (: > > It does seem to run Linux (in some sense, "supports" > is a flexible word) so it can't be too exotic. That's > good. I wonder what ISA the cores implement? MIPS? > PPC? I had to look around quite a bit in their rather superficial documentation before I found something useful, but their compiler is based on SGI's MIPSpro, so the ISA is probably MIPS. From joelr1@REDACTED Mon Aug 20 19:41:59 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 20 Aug 2007 18:41:59 +0100 Subject: [erlang-questions] Does CEAN modify init.erl? Message-ID: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> Folks, Does CEAN modify init.erl? It looks to me from the following error that cean:version is being called from init:start_it. =PROGRESS REPORT==== 20-Aug-2007::13:33:24 === application: sync started_at: 'i-a58864cc@REDACTED' {"init terminating in do_boot",{undef,[{cean,version,[]}, {init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () I'm starting the diskless node using CEAN and "loader inet -mode embedded", as well as a custom boot file that does not include CEAN since it's not an app. Thanks, Joel -- http://wagerlabs.com From joelr1@REDACTED Mon Aug 20 20:05:21 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 20 Aug 2007 19:05:21 +0100 Subject: [erlang-questions] Does CEAN modify init.erl? In-Reply-To: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> References: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> Message-ID: <0FAA1A2E-4455-417B-9431-D9EF0CAF67CF@gmail.com> Please disregard my question! start.sh is the culprit: $BINDIR/$cmd ${1+"$@"} -s cean version -- http://wagerlabs.com From dmercer@REDACTED Tue Aug 21 00:46:43 2007 From: dmercer@REDACTED (David Mercer) Date: Mon, 20 Aug 2007 17:46:43 -0500 Subject: [erlang-questions] Name For This Pattern? Message-ID: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> OK, so I want to generate a sequence based on some mathematical formula. For instance, [1, 2, 3, 4, 5, .] or [1, 2, 4, 8, 16, .]. Since these are infinite, I cannot implement them as lists. Instead, I implement them as a function: 2> % [1, 2, 3, 4, 5, ...] 2> F0a = FF(fun(X) -> X + 1 end, 1). #Fun 3> {_, F1a} = F0a(). {1,#Fun} 4> {_, F2a} = F1a(). {2,#Fun} 5> {_, F3a} = F2a(). {3,#Fun} 6> {_, F4a} = F3a(). {4,#Fun} 7> {_, F5a} = F4a(). {5,#Fun} 12> % [1, 2, 4, 8, 16, ...] 12> F0b = FF(fun(X) -> 2 * X end, 1). #Fun 13> {_, F1b} = F0b(). {1,#Fun} 14> {_, F2b} = F1b(). {2,#Fun} 15> {_, F3b} = F2b(). {4,#Fun} 16> {_, F4b} = F3b(). {8,#Fun} 17> {_, F5b} = F4b(). {16,#Fun} I am sure many of you have done this before, and I haven't discovered anything new, but I wanted to figure it out for myself, so I did. The function I came up with was: FF = fun(F, X0) -> G = fun(F, X0, G) -> { X0, fun() -> G(F, F(X0), G) end } end, fun() -> G(F, X0, G) end end. 1. Is this the way you'd have done this? 2. Is there a name for this pattern? I was calling it a continuation in my mind, because the second element of the output 2-tuple is a continuation function to give the next value, but I thought maybe there is a more specific name for this use of continuations. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From lcoquelle@REDACTED Tue Aug 21 02:45:16 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Tue, 21 Aug 2007 08:45:16 +0800 Subject: [erlang-questions] Name For This Pattern? In-Reply-To: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> References: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> Message-ID: I think it can be called "lazy-list" because it behave like a list. However it is often called "stream" because the internal structure may really differ from a list (like in your example). There is a section in SICP about streams (http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5). For other erlang related code, there is an implementation in user contribution of trapexit, and I wrote a very simple one too http://khigia.wordpress.com/2007/05/07/44/ (the end contains few links which could interest you). Hope this help. On 8/21/07, David Mercer wrote: > > OK, so I want to generate a sequence based on some mathematical formula. > For instance, [1, 2, 3, 4, 5, ?] or [1, 2, 4, 8, 16, ?]. Since these are > infinite, I cannot implement them as lists. Instead, I implement them as a > function: > > > > 2> % *[1, 2, 3, 4, 5, ...]* > > 2> F0a = FF(fun(X) -> *X + 1* end, 1). > > #Fun > > 3> {_, F1a} = F0a(). > > {*1*,#Fun} > > 4> {_, F2a} = F1a(). > > {*2*,#Fun} > > 5> {_, F3a} = F2a(). > > {*3*,#Fun} > > 6> {_, F4a} = F3a(). > > {*4*,#Fun} > > 7> {_, F5a} = F4a(). > > {*5*,#Fun} > > 12> % *[1, 2, 4, 8, 16, ...]* > > 12> F0b = FF(fun(X) -> *2 * X* end, 1). > > #Fun > > 13> {_, F1b} = F0b(). > > {*1*,#Fun} > > 14> {_, F2b} = F1b(). > > {*2*,#Fun} > > 15> {_, F3b} = F2b(). > > {*4*,#Fun} > > 16> {_, F4b} = F3b(). > > {*8*,#Fun} > > 17> {_, F5b} = F4b(). > > {*16*,#Fun} > > > > I am sure many of you have done this before, and I haven't discovered > anything new, but I wanted to figure it out for myself, so I did. The > function I came up with was: > > > > FF = fun(F, X0) -> > > G = fun(F, X0, G) -> > > { X0, fun() -> G(F, F(X0), G) end } > > end, > > fun() -> G(F, X0, G) end > > end. > > > > 1. Is this the way you'd have done this? > > > > 2. Is there a name for this pattern? I was calling it a > continuation in my mind, because the second element of the output 2-tuple is > a continuation function to give the next value, but I thought maybe there is > a more specific name for this use of continuations. > > > > Cheers, > > > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pwa@REDACTED Tue Aug 21 02:51:59 2007 From: pwa@REDACTED (Peter Wang) Date: Tue, 21 Aug 2007 10:51:59 +1000 Subject: [erlang-questions] Name For This Pattern? In-Reply-To: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> References: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> Message-ID: <20070821005157.GA3130@missioncriticalit.com> On 2007-08-20, David Mercer wrote: > > 2. Is there a name for this pattern? I was calling it a continuation > in my mind, because the second element of the output 2-tuple is a > continuation function to give the next value, but I thought maybe there is a > more specific name for this use of continuations. In Scheme (at least) they are called streams. e.g. http://srfi.schemers.org/srfi-40/srfi-40.html Peter From ingela@REDACTED Tue Aug 21 07:43:20 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 21 Aug 2007 07:43:20 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 3, Issue 47 In-Reply-To: References: Message-ID: <46CA7B78.2000605@erix.ericsson.se> > Yes, I mean RSA_private_encrypt specifically. This is used to encrypt a > 3DES key that is sent along with the 3DES encrypted data. > I don't have a command line, but the examples in the OpenSSL docs with > regards to rsautl has all the functionality that is required. > I looked at the functions exposed in crypto_drv.c again and it is only the > RSA signature functions that is exported at present. > Unfortunately due to time constraints it has been decided to do the XML > encryption in a Java module using third party tools instead (Weblogic soap > client libraries) > One piece of functionality that I missed is the ability to easily get the > required key parameters out of certifficates. The emphasis here is on > easily, because all the parts (except the ASN.1 key parameter speciffics eg. >RSAPublicKey.asn) are already there. Have you looked at the ssl_pkix API module? It might be what you want. Regards Ingela - OTP team From dustin@REDACTED Tue Aug 21 07:43:38 2007 From: dustin@REDACTED (Dustin Sallings) Date: Mon, 20 Aug 2007 22:43:38 -0700 Subject: [erlang-questions] questions about dict Message-ID: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> There are a couple of things about dict I'm working around in some of my programs and was wondering if there's a better way or something. 1) There doesn't seem to be a way to get the length of a dict directly, although it seems to be directly stored (I'm using fold right now to calculate it). 2) I can't seem to make a guard for a dict because the record format is unavailable to me at compile time (I'm working around this by matching tuple and hard-coding a tuple pattern for identifying a dict). Is there a better way to do either of these? -- Dustin Sallings From bjorn@REDACTED Tue Aug 21 08:09:48 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 21 Aug 2007 08:09:48 +0200 Subject: [erlang-questions] questions about dict In-Reply-To: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> Message-ID: Dustin Sallings writes: > There are a couple of things about dict I'm working around in some > of my programs and was wondering if there's a better way or something. > > 1) There doesn't seem to be a way to get the length of a dict > directly, although it seems to be directly stored (I'm using fold > right now to calculate it). Use orddict:size/1. It seems to be undocumented for no good reason. We will update the documentation in R12B. > 2) I can't seem to make a guard for a dict because the record > format is unavailable to me at compile time (I'm working around this > by matching tuple and hard-coding a tuple pattern for identifying a > dict). That is intentional (and even mentioned in the documentation). There is no portable way to test for a dict in a guard. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dustin@REDACTED Tue Aug 21 09:12:28 2007 From: dustin@REDACTED (Dustin Sallings) Date: Tue, 21 Aug 2007 00:12:28 -0700 Subject: [erlang-questions] questions about dict In-Reply-To: References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> Message-ID: <481EBA55-D6ED-4EA2-A0BB-53CDBD4BD272@spy.net> On Aug 20, 2007, at 23:09, Bjorn Gustavsson wrote: >> 1) There doesn't seem to be a way to get the length of a dict >> directly, although it seems to be directly stored (I'm using fold >> right now to calculate it). > > Use orddict:size/1. > > It seems to be undocumented for no good reason. We will update the > documentation in R12B. Ah, I see this exists in dict as well. Thanks. It seemed to be an obvious missing thing. >> 2) I can't seem to make a guard for a dict because the record >> format is unavailable to me at compile time (I'm working around this >> by matching tuple and hard-coding a tuple pattern for identifying a >> dict). > > That is intentional (and even mentioned in the documentation). > > There is no portable way to test for a dict in a guard. Where is this documented? I looked around for a while and couldn't find anything either way. There's clearly a gap in my understanding of guards, records, or dicts. -- Dustin Sallings From bjorn@REDACTED Tue Aug 21 09:27:49 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 21 Aug 2007 09:27:49 +0200 Subject: [erlang-questions] questions about dict In-Reply-To: <481EBA55-D6ED-4EA2-A0BB-53CDBD4BD272@spy.net> References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> <481EBA55-D6ED-4EA2-A0BB-53CDBD4BD272@spy.net> Message-ID: Dustin Sallings writes: > > >> 2) I can't seem to make a guard for a dict because the record > >> format is unavailable to me at compile time (I'm working around this > >> by matching tuple and hard-coding a tuple pattern for identifying a > >> dict). > > > > That is intentional (and even mentioned in the documentation). > > > > There is no portable way to test for a dict in a guard. > > Where is this documented? I looked around for a while and > couldn't find anything either way. There's clearly a gap in my > understanding of guards, records, or dicts. It may be a little subtle, but the documentation for dict says: "Dict implements a Key - Value dictionary. The representation of a dictionary is not defined." That means that only the dict module knows about how a dictionary is represented, and that you should only use the functions in the dict module to access a dictionary. If you use knowledge gained from looking at the source of dict to write a guard test any, your code could in principle stop to work in a future release of OTP if we change the representation. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dmitriid@REDACTED Tue Aug 21 10:21:39 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 21 Aug 2007 11:21:39 +0300 Subject: [erlang-questions] Simple binary question Message-ID: <46CAA093.5060109@gmail.com> Suppose I have a binary: 00 00 31 00 00 This 16#31 is actually "1" in ascii. However, if I do a <<_Pad:2/binary, Number/integer, _Rest/binary>> or <<_Pad:2/binary, Number:1/binary, _Rest/binary>> I get 16#31. If I do a binaty_to_list/1 or integer_to_list/1 I still get 16#31. How do I get "1", if it's at all possible? Thank you From per.gustafsson@REDACTED Tue Aug 21 10:51:58 2007 From: per.gustafsson@REDACTED (Per Gustafsson) Date: Tue, 21 Aug 2007 10:51:58 +0200 Subject: [erlang-questions] Simple binary question In-Reply-To: <46CAA093.5060109@gmail.com> References: <46CAA093.5060109@gmail.com> Message-ID: <46CAA7AE.4070906@it.uu.se> Dmitrii 'Mamut' Dimandt wrote: > Suppose I have a binary: > > 00 00 31 00 00 > > This 16#31 is actually "1" in ascii. > > However, if I do a <<_Pad:2/binary, Number/integer, _Rest/binary>> or > <<_Pad:2/binary, Number:1/binary, _Rest/binary>> I get 16#31. > > If I do a binaty_to_list/1 or integer_to_list/1 I still get 16#31. > > How do I get "1", if it's at all possible? > > Thank you > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions You'll have to do list_to_integer(binary_to_list(Number)). Per From richardc@REDACTED Tue Aug 21 11:07:51 2007 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 21 Aug 2007 11:07:51 +0200 Subject: [erlang-questions] questions about dict In-Reply-To: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> Message-ID: <46CAAB67.5050400@it.uu.se> Dustin Sallings wrote: > 2) I can't seem to make a guard for a dict because the record > format is unavailable to me at compile time (I'm working around this > by matching tuple and hard-coding a tuple pattern for identifying a > dict). Why do you need that test? Do you have some X that migh be a dict and might be something else? In that case, I'd say that it's better, both style wise and for practical reasons, to wrap your data in tagged tuples so that you can distinguish between them easily, regardless of their actual representation. If, on the other hand, X should never be anything but a dict, then you don't really need the test. /Richard From raimo+erlang-questions@REDACTED Tue Aug 21 11:09:26 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 21 Aug 2007 11:09:26 +0200 Subject: [erlang-questions] : questions about dict In-Reply-To: References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> <481EBA55-D6ED-4EA2-A0BB-53CDBD4BD272@spy.net> Message-ID: <20070821090926.GD18251@erix.ericsson.se> On Tue, Aug 21, 2007 at 09:27:49AM +0200, Bjorn Gustavsson wrote: > Dustin Sallings writes: > > > > > >> 2) I can't seem to make a guard for a dict because the record > > >> format is unavailable to me at compile time (I'm working around this > > >> by matching tuple and hard-coding a tuple pattern for identifying a > > >> dict). > > > > > > That is intentional (and even mentioned in the documentation). > > > > > > There is no portable way to test for a dict in a guard. > > > > Where is this documented? I looked around for a while and > > couldn't find anything either way. There's clearly a gap in my > > understanding of guards, records, or dicts. > > It may be a little subtle, but the documentation for dict says: > > "Dict implements a Key - Value dictionary. The representation of a dictionary is not defined." > > That means that only the dict module knows about how a dictionary is represented, > and that you should only use the functions in the dict module to access a dictionary. > > If you use knowledge gained from looking at the source of dict to write a guard > test any, your code could in principle stop to work in a future release of OTP if > we change the representation. > So, you are supposed to maintain that knowledge yourself. You could e.g wrap all dictionaries in a {dict,UnknownRepresentatio} tuple, or just know from the context that they are dictionaries. > /Bjorn > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From joelr1@REDACTED Tue Aug 21 11:28:57 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 21 Aug 2007 10:28:57 +0100 Subject: [erlang-questions] Trouble connecting to Erlang in a virtual hosting setup Message-ID: <73FB469F-275F-4DA0-A6BC-AB0BF00BB98B@gmail.com> I host with Joyent on one of their Sparc Accelerators. My container has a dedicated IP address and I point both wagerlabs.com and topdog.cc to it. Internally, though, the name of the box is z13261AA.textdrive.com. I cannot connect to this node with net_adm:ping/1 using the internal box name since the Erlang ports are blocked. The challenge code in dist_util grabs the internal box name and fails in list_to_existing_atom when I cannot connect to my node using my domain names or the IP address. It also fails with no_node if I pre- create the xxx@REDACTED atom since the host portion of the node name won't match that returned by the Erlang node at Joyent. Is there a workaround for this? Thanks, Joel -- http://wagerlabs.com From jason@REDACTED Tue Aug 21 11:49:44 2007 From: jason@REDACTED (Jason A. Hoffman) Date: Tue, 21 Aug 2007 02:49:44 -0700 Subject: [erlang-questions] Trouble connecting to Erlang in a virtual hosting setup In-Reply-To: <73FB469F-275F-4DA0-A6BC-AB0BF00BB98B@gmail.com> References: <73FB469F-275F-4DA0-A6BC-AB0BF00BB98B@gmail.com> Message-ID: <3C6147CE-4184-4662-AF0B-C21B54C3AC5D@joyent.com> On Aug 21, 2007, at 2:28 AM, Joel Reymont wrote: > I host with Joyent on one of their Sparc Accelerators. My container > has a dedicated IP address and I point both wagerlabs.com and > topdog.cc to it. Internally, though, the name of the box is > z13261AA.textdrive.com. > > I cannot connect to this node with net_adm:ping/1 using the internal > box name since the Erlang ports are blocked. > > The challenge code in dist_util grabs the internal box name and fails > in list_to_existing_atom when I cannot connect to my node using my > domain names or the IP address. It also fails with no_node if I pre- > create the xxx@REDACTED atom since the host portion of > the node name won't match that returned by the Erlang node at Joyent. > > Is there a workaround for this? > > Thanks, Joel > It doesn't have to be called "z13261AA.textdrive.com". You can change the hostname with hostname something.com and permanently by editing /etc/nodename - Jason From raimo+erlang-questions@REDACTED Tue Aug 21 11:57:29 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 21 Aug 2007 11:57:29 +0200 Subject: [erlang-questions] Simple binary question In-Reply-To: <46CAA093.5060109@gmail.com> References: <46CAA093.5060109@gmail.com> Message-ID: <20070821095729.GB21041@erix.ericsson.se> You have got "1". Erlang does not have strings, but a list of integers can be regarded as a string. The shell pretty-prints a list of integers that corresponds to printable ascii characters as a string: > [16#31]. "1" > 16#31 = 49 = $1. 49 Where $1 is the integer corresponding to the ascii value for the character `1'. > [16#31] = [49] = [$1]. "1" On Tue, Aug 21, 2007 at 11:21:39AM +0300, Dmitrii 'Mamut' Dimandt wrote: > Suppose I have a binary: > > 00 00 31 00 00 > > This 16#31 is actually "1" in ascii. > > However, if I do a <<_Pad:2/binary, Number/integer, _Rest/binary>> or > <<_Pad:2/binary, Number:1/binary, _Rest/binary>> I get 16#31. > > If I do a binaty_to_list/1 or integer_to_list/1 I still get 16#31. > > How do I get "1", if it's at all possible? > > Thank you > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ingela@REDACTED Tue Aug 21 12:03:34 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 21 Aug 2007 12:03:34 +0200 Subject: [erlang-questions] crypto and RSA In-Reply-To: <46CA7B78.2000605@erix.ericsson.se> References: <46CA7B78.2000605@erix.ericsson.se> Message-ID: <46CAB876.1080005@erix.ericsson.se> Hooops, forgot to change the subject, so just in case here is my answer with the correct subject. [...] > >> One piece of functionality that I missed is the ability to easily get >> the >> required key parameters out of certifficates. The emphasis here is on >> easily, because all the parts (except the ASN.1 key parameter >> speciffics eg. >> RSAPublicKey.asn) are already there. Have you looked at the ssl_pkix API module? It might be what you want. Regards Ingela - OTP team From joelr1@REDACTED Tue Aug 21 11:52:09 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 21 Aug 2007 10:52:09 +0100 Subject: [erlang-questions] Unexpected behaviour from operating system high resolution timer Message-ID: <3E5B8496-2F9D-4FC7-AF77-7ABCD0A34A03@gmail.com> This is running on Amazon EC2 (Xen). What does it mean? Crash dump was written to: erl_crash.dump Unexpected behaviour from operating system high resolution timer/usr/ local/cean/start.sh: line 85: 2235 Aborted $BINDIR/ $cmd ${1+"$@"} -s cean version Thanks, Joel -- http://wagerlabs.com From dmitriid@REDACTED Tue Aug 21 12:58:15 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 21 Aug 2007 13:58:15 +0300 Subject: [erlang-questions] Simple binary question In-Reply-To: <46CAA7AE.4070906@it.uu.se> References: <46CAA093.5060109@gmail.com> <46CAA7AE.4070906@it.uu.se> Message-ID: <46CAC547.9090908@gmail.com> Per Gustafsson wrote: > Dmitrii 'Mamut' Dimandt wrote: >> Suppose I have a binary: >> >> 00 00 31 00 00 >> >> This 16#31 is actually "1" in ascii. >> >> However, if I do a <<_Pad:2/binary, Number/integer, _Rest/binary>> or >> <<_Pad:2/binary, Number:1/binary, _Rest/binary>> I get 16#31. >> >> If I do a binaty_to_list/1 or integer_to_list/1 I still get 16#31. >> >> How do I get "1", if it's at all possible? >> >> Thank you >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > You'll have to do list_to_integer(binary_to_list(Number)). > > Per > Thank you, it worked! :) From raimo+erlang-questions@REDACTED Tue Aug 21 14:11:46 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 21 Aug 2007 14:11:46 +0200 Subject: [erlang-questions] : Trouble connecting to Erlang in a virtual hosting setup In-Reply-To: <3C6147CE-4184-4662-AF0B-C21B54C3AC5D@joyent.com> References: <73FB469F-275F-4DA0-A6BC-AB0BF00BB98B@gmail.com> <3C6147CE-4184-4662-AF0B-C21B54C3AC5D@joyent.com> Message-ID: <20070821121146.GA22880@erix.ericsson.se> If you can find a name that is routable from both sides. E.g in /etc/hosts on z13261AA.textdrive.com define wagerlabs.com and topdog.cc to be alternative names for the machine. Then start the Erlang node with -name name@REDACTED An Erlang node must have one hostname, so if you need to contact topdog.cc you probably need to start another node. There are kernel variables to control which ports the Erlang distribution protocol should listen to. If you have a firewall you will need to use these to know which port range (plus EPMD) to open. On Tue, Aug 21, 2007 at 02:49:44AM -0700, Jason A. Hoffman wrote: > On Aug 21, 2007, at 2:28 AM, Joel Reymont wrote: > > > I host with Joyent on one of their Sparc Accelerators. My container > > has a dedicated IP address and I point both wagerlabs.com and > > topdog.cc to it. Internally, though, the name of the box is > > z13261AA.textdrive.com. > > > > I cannot connect to this node with net_adm:ping/1 using the internal > > box name since the Erlang ports are blocked. > > > > The challenge code in dist_util grabs the internal box name and fails > > in list_to_existing_atom when I cannot connect to my node using my > > domain names or the IP address. It also fails with no_node if I pre- > > create the xxx@REDACTED atom since the host portion of > > the node name won't match that returned by the Erlang node at Joyent. > > > > Is there a workaround for this? > > > > Thanks, Joel > > > > It doesn't have to be called "z13261AA.textdrive.com". > > You can change the hostname with > > hostname something.com > > and permanently by editing /etc/nodename > > - Jason > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From erlang@REDACTED Tue Aug 21 14:56:32 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 21 Aug 2007 14:56:32 +0200 Subject: [erlang-questions] Name For This Pattern? In-Reply-To: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> References: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> Message-ID: <9b08084c0708210556q58de0c7t20403585f0bbd954@mail.gmail.com> Another *completly different* way to represent them is as processes Pid = spawn(fun() -> loop(0) end). creates a counter process where loop(N) -> receive {From, next} -> From ! N, loop(N+1) end. You need an access fucntion to hide the call to the counter bump(Pid) -> .Puid ! {self(), next}, receive {Pud, Val} -> On 8/21/07, David Mercer wrote: > > > > > OK, so I want to generate a sequence based on some mathematical formula. > For instance, [1, 2, 3, 4, 5, ?] or [1, 2, 4, 8, 16, ?]. Since these are > infinite, I cannot implement them as lists. Instead, I implement them as a > function: > > > > 2> % [1, 2, 3, 4, 5, ...] > > 2> F0a = FF(fun(X) -> X + 1 end, 1). > > #Fun > > 3> {_, F1a} = F0a(). > > {1,#Fun} > > 4> {_, F2a} = F1a(). > > {2,#Fun} > > 5> {_, F3a} = F2a(). > > {3,#Fun} > > 6> {_, F4a} = F3a(). > > {4,#Fun} > > 7> {_, F5a} = F4a(). > > {5,#Fun} > > 12> % [1, 2, 4, 8, 16, ...] > > 12> F0b = FF(fun(X) -> 2 * X end, 1). > > #Fun > > 13> {_, F1b} = F0b(). > > {1,#Fun} > > 14> {_, F2b} = F1b(). > > {2,#Fun} > > 15> {_, F3b} = F2b(). > > {4,#Fun} > > 16> {_, F4b} = F3b(). > > {8,#Fun} > > 17> {_, F5b} = F4b(). > > {16,#Fun} > > > > I am sure many of you have done this before, and I haven't discovered > anything new, but I wanted to figure it out for myself, so I did. The > function I came up with was: > > > > FF = fun(F, X0) -> > > G = fun(F, X0, G) -> > > { X0, fun() -> G(F, F(X0), G) end } > > end, > > fun() -> G(F, X0, G) end > > end. > > > > 1. Is this the way you'd have done this? > > > > 2. Is there a name for this pattern? I was calling it a continuation > in my mind, because the second element of the output 2-tuple is a > continuation function to give the next value, but I thought maybe there is a > more specific name for this use of continuations. > > > > Cheers, > > > > David > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Tue Aug 21 15:04:25 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 21 Aug 2007 15:04:25 +0200 Subject: [erlang-questions] Name For This Pattern? In-Reply-To: <9b08084c0708210556q58de0c7t20403585f0bbd954@mail.gmail.com> References: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> <9b08084c0708210556q58de0c7t20403585f0bbd954@mail.gmail.com> Message-ID: <9b08084c0708210604k5c803f1al906e51e4504d849@mail.gmail.com> My last mail got truncated ....(don't type emacs commands in gmail :-) On 8/21/07, Joe Armstrong wrote: Another *completely different* way to represent lazy lists is as processes You send a next message to the process and it delivers the next integer. Create like this: Pid = spawn(fun() -> loop(0) end). where loop(N) -> receive {From, next} -> From ! {self(), N}, loop(N+1) end. You need an access function to hide the call to the counter process bump(Pid) -> .Pid ! {self(), next}, receive {Pid, Val} -> Val end. Then you get new values each time you call bump(Pid) Sometimes this method is better than using a fun, depends on what you're trying to do creating little networks of processes is equivalent to doing function compositions /Joe > On 8/21/07, David Mercer wrote: > > > > > > > > > > OK, so I want to generate a sequence based on some mathematical formula. > > For instance, [1, 2, 3, 4, 5, ?] or [1, 2, 4, 8, 16, ?]. Since these are > > infinite, I cannot implement them as lists. Instead, I implement them as a > > function: > > > > > > > > 2> % [1, 2, 3, 4, 5, ...] > > > > 2> F0a = FF(fun(X) -> X + 1 end, 1). > > > > #Fun > > > > 3> {_, F1a} = F0a(). > > > > {1,#Fun} > > > > 4> {_, F2a} = F1a(). > > > > {2,#Fun} > > > > 5> {_, F3a} = F2a(). > > > > {3,#Fun} > > > > 6> {_, F4a} = F3a(). > > > > {4,#Fun} > > > > 7> {_, F5a} = F4a(). > > > > {5,#Fun} > > > > 12> % [1, 2, 4, 8, 16, ...] > > > > 12> F0b = FF(fun(X) -> 2 * X end, 1). > > > > #Fun > > > > 13> {_, F1b} = F0b(). > > > > {1,#Fun} > > > > 14> {_, F2b} = F1b(). > > > > {2,#Fun} > > > > 15> {_, F3b} = F2b(). > > > > {4,#Fun} > > > > 16> {_, F4b} = F3b(). > > > > {8,#Fun} > > > > 17> {_, F5b} = F4b(). > > > > {16,#Fun} > > > > > > > > I am sure many of you have done this before, and I haven't discovered > > anything new, but I wanted to figure it out for myself, so I did. The > > function I came up with was: > > > > > > > > FF = fun(F, X0) -> > > > > G = fun(F, X0, G) -> > > > > { X0, fun() -> G(F, F(X0), G) end } > > > > end, > > > > fun() -> G(F, X0, G) end > > > > end. > > > > > > > > 1. Is this the way you'd have done this? > > > > > > > > 2. Is there a name for this pattern? I was calling it a continuation > > in my mind, because the second element of the output 2-tuple is a > > continuation function to give the next value, but I thought maybe there is a > > more specific name for this use of continuations. > > > > > > > > Cheers, > > > > > > > > David > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From Daniel.Berger@REDACTED Tue Aug 21 16:09:26 2007 From: Daniel.Berger@REDACTED (Berger, Daniel) Date: Tue, 21 Aug 2007 09:09:26 -0500 Subject: [erlang-questions] Building Erlang with the Sun Studio compiler Message-ID: <7524A45A1A5B264FA4809E2156496CFBE72D8C@ITOMAE2KM01.AD.QINTRA.COM> Hi, I tried to build Erlang on my Solaris 10/Sparc box with the Sun Studio Compiler 12, but it appears that you must build using Erlang using gcc/gmake. I think I've seen a Solaris package out there, but I'd rather build from source, since packages can take a while to catch up with the latest release, and may not be configured with the options I want. Are there GNU extensions that Erlang absolutely has to have? If not, is there any chance we can alter the appropriate files so that it will build using other toolchains? Or, is there a way to build with Sun's compiler that I've missed? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From rsaccon@REDACTED Tue Aug 21 16:31:42 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Tue, 21 Aug 2007 11:31:42 -0300 Subject: [erlang-questions] Unexpected behaviour from operating system high resolution timer In-Reply-To: <3E5B8496-2F9D-4FC7-AF77-7ABCD0A34A03@gmail.com> References: <3E5B8496-2F9D-4FC7-AF77-7ABCD0A34A03@gmail.com> Message-ID: I have seen this before, at Amazon EC2, with an Ubuntu feisty image, when starting cean erlang at OS boot via traditional inittab. As first aid, I managed to prevent this error by putting in a sleep for 30 seconds iat my start script. But there must be a better solution, it probably works when using upstart instead of inittab, I haven't tried that yet. regards -- Roberto Saccon - http://rsaccon.com From Chris.Curtis@REDACTED Tue Aug 21 16:42:14 2007 From: Chris.Curtis@REDACTED (Chris Curtis) Date: Tue, 21 Aug 2007 10:42:14 -0400 Subject: [erlang-questions] Building Erlang with the Sun Studio compiler In-Reply-To: <7524A45A1A5B264FA4809E2156496CFBE72D8C@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFBE72D8C@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <36E4692623C5974BA6661C0B18EE8EDF7FFA51@MAILSERV.hcrest.com> > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > bounces@REDACTED] On Behalf Of Berger, Daniel > Sent: Tuesday, August 21, 2007 10:09 AM > To: erlang-questions@REDACTED > Subject: [erlang-questions] Building Erlang with the Sun Studio compiler > > Hi, > > I tried to build Erlang on my Solaris 10/Sparc box with the Sun Studio > Compiler 12, but it appears that you must build using Erlang using > gcc/gmake. I think I've seen a Solaris package out there, but I'd rather > build from source, since packages can take a while to catch up with the > latest release, and may not be configured with the options I want. > > Are there GNU extensions that Erlang absolutely has to have? If not, is > there any chance we can alter the appropriate files so that it will > build using other toolchains? > > Or, is there a way to build with Sun's compiler that I've missed? > > Regards, I haven't personally tried it (no SPARC here), but you might want to check out GCCFSS... it's a GCC front end integrated with the Sun Studio SPARC backend, so you get GCC build compatibility with what looks like a big performance boost. It's at http://cooltools.sunsource.net/gcc/. --chris From dmercer@REDACTED Tue Aug 21 16:55:54 2007 From: dmercer@REDACTED (David Mercer) Date: Tue, 21 Aug 2007 09:55:54 -0500 Subject: [erlang-questions] Name For This Pattern? In-Reply-To: References: <003b01c7e37b$fbb3dde0$891ea8c0@SSI.CORP> Message-ID: <004d01c7e403$60bd6c10$891ea8c0@SSI.CORP> On Monday, August 20, 2007 at 19:45, Ludovic Coquelle wrote: There is a section in SICP about streams ( http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5). Neat-o. I gave away my copy of that book 19 years ago when I finished with the course. I don't remember a thing about that book other than that it was about Scheme. To me, the course was learn-Scheme-to-get-an-A, but I always thought the professors were trying to get at something more profound, I just didn't care. Get my A and get out of there. Now that I'm older, I bet a reread of the text would probably be more meaningful. Thanks for the link. For other erlang related code, there is an implementation in user contribution of trapexit, and I wrote a very simple one too http://khigia.wordpress.com/2007/05/07/44/ (the end contains few links which could interest you). That's a pretty good link, too. For the lazy among you, I think the Trapexit link being referred to is http://forum.trapexit.org/viewtopic.php?t=6591. On Tuesday, August 21, 2007 at 08:04, Joe Armstrong wrote: Another *completely different* way to represent lazy lists is as processes That's the way I probably would do it in real life Erlang. (So if you stumble across this thread and thought to copy my way, consider Joe's first.) I was going for more the brain-bending exercise of doing this functionally. The catch with a process is that it does not get automatically garbage collected: would have to kill it manually. Thanks. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dustin@REDACTED Tue Aug 21 18:25:35 2007 From: dustin@REDACTED (Dustin Sallings) Date: Tue, 21 Aug 2007 09:25:35 -0700 Subject: [erlang-questions] questions about dict In-Reply-To: <46CAAB67.5050400@it.uu.se> References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> <46CAAB67.5050400@it.uu.se> Message-ID: On Aug 21, 2007, at 2:07 , Richard Carlsson wrote: > Why do you need that test? Do you have some X that migh be a dict and > might be something else? In that case, I'd say that it's better, both > style wise and for practical reasons, to wrap your data in tagged > tuples so that you can distinguish between them easily, regardless > of their actual representation. I have some code that reads a custom binary format[0] into erlang terms for a load test tool I've written. The code that wrote the custom binary format was python and was very straightforward to write in python and read in erlang. I ran into problems when I tried to write erlang terms back into the binary format because it isn't obvious when I've encountered a dict. I suppose {badrecord,dict} is probably the best option. [0] The format basically consists of dicts, tuples, and lists of dicts, tuples, lists, strings, floats, and numbers. -- Dustin Sallings From Daniel.Berger@REDACTED Tue Aug 21 19:01:06 2007 From: Daniel.Berger@REDACTED (Berger, Daniel) Date: Tue, 21 Aug 2007 12:01:06 -0500 Subject: [erlang-questions] Building Erlang with the Sun Studio compiler In-Reply-To: <36E4692623C5974BA6661C0B18EE8EDF7FFA51@MAILSERV.hcrest.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFBE72D8D@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: Chris Curtis [mailto:Chris.Curtis@REDACTED] > Sent: Tuesday, August 21, 2007 8:42 AM > To: Berger, Daniel; erlang-questions@REDACTED > Subject: RE: [erlang-questions] Building Erlang with the Sun > Studio compiler > > > > > -----Original Message----- > > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > > bounces@REDACTED] On Behalf Of Berger, Daniel > > Sent: Tuesday, August 21, 2007 10:09 AM > > To: erlang-questions@REDACTED > > Subject: [erlang-questions] Building Erlang with the Sun Studio > compiler > > > > Hi, > > > > I tried to build Erlang on my Solaris 10/Sparc box with the > Sun Studio > > Compiler 12, but it appears that you must build using Erlang using > > gcc/gmake. I think I've seen a Solaris package out there, but I'd > rather > > build from source, since packages can take a while to catch up with > the > > latest release, and may not be configured with the options I want. > > > > Are there GNU extensions that Erlang absolutely has to have? If not, > is > > there any chance we can alter the appropriate files so that it will > > build using other toolchains? > > > > Or, is there a way to build with Sun's compiler that I've missed? > > > > Regards, > > I haven't personally tried it (no SPARC here), but you might > want to check out GCCFSS... it's a GCC front end integrated > with the Sun Studio SPARC backend, so you get GCC build > compatibility with what looks like a big performance boost. > It's at http://cooltools.sunsource.net/gcc/. > > --chris Thanks Chris, that definitely looks interesting. However, I still think removing the GNU specific dependencies is a better long term solution. People are going to want to build from source with their own compilers on other platforms as well, e.g. MS VC++, Borland, the HP-UX compiler, etc. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From erlang@REDACTED Tue Aug 21 20:05:09 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 21 Aug 2007 20:05:09 +0200 Subject: [erlang-questions] questions about dict In-Reply-To: References: <19DF2CD6-74B9-4871-B111-9082F7FD23C2@spy.net> <481EBA55-D6ED-4EA2-A0BB-53CDBD4BD272@spy.net> Message-ID: <9b08084c0708211105h27ce414hbc74bc1a843464da@mail.gmail.com> You could put the dictionary in a record and test for the record :-) Define dict.hrl --- dict.hrl --- -record(dict,{val}). --- my_dict.erl --- -module(my_dict). -record(dict, {val}). -export([new/0, store/3, find/2]). new() -> #dict{val=dict:new()}. store(Key, Val, Dict) -> #dict{val=dict:store(Key, Val, Dict#dict.val)}. find(Key, Dict) -> dict:find(Key, Dict#dict.val). Use can use my_dict.erl just as you would use dict --- test1.erl --- -module(test1). -compile(export_all). -include("dict.hrl"). test() -> D = my_dict:new(), D1 = my_dict:store(name,joe,D), foo(D1). foo(X) when is_record(X, dict) -> %% This is how to fake a guard my_dict:find(name, X). etc ... If you *really* want to fake it up as a guard The more "erlangy" way is to add a wrapper and use pattern matching: foo({dict, X}) -> ... the tuple {dict, X} is used *everywhere* in the code to signal the fact that X is an instance of a dictionary - then you just pattern match on {dict, X} /Joe Armstrong On 21 Aug 2007 09:27:49 +0200, Bjorn Gustavsson wrote: > Dustin Sallings writes: > > > > > >> 2) I can't seem to make a guard for a dict because the record > > >> format is unavailable to me at compile time (I'm working around this > > >> by matching tuple and hard-coding a tuple pattern for identifying a > > >> dict). > > > > > > That is intentional (and even mentioned in the documentation). > > > > > > There is no portable way to test for a dict in a guard. > > > > Where is this documented? I looked around for a while and > > couldn't find anything either way. There's clearly a gap in my > > understanding of guards, records, or dicts. > > It may be a little subtle, but the documentation for dict says: > > "Dict implements a Key - Value dictionary. The representation of a dictionary is not defined." > > That means that only the dict module knows about how a dictionary is represented, > and that you should only use the functions in the dict module to access a dictionary. > > If you use knowledge gained from looking at the source of dict to write a guard > test any, your code could in principle stop to work in a future release of OTP if > we change the representation. > > /Bjorn > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From shimoco@REDACTED Tue Aug 21 22:14:53 2007 From: shimoco@REDACTED (Shimon Cohen) Date: Tue, 21 Aug 2007 23:14:53 +0300 Subject: [erlang-questions] Lists Comprehentions vs. Accumulators Message-ID: <92e13fb30708211314h6c10f28frdec38ccb0f42b265@mail.gmail.com> Hi My question concerning section 3.12 in Joe's "Programming Erlang": Why odd_and_evens should be less space efficient than odd_and_evens_acc ? I guess it must be somthing with tail-recursion, but can't see why List Comprehetions can't be implemented tail-recursive or even as a plain loop. Thanks, Shimon Cohen. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Tue Aug 21 22:55:48 2007 From: dmercer@REDACTED (David Mercer) Date: Tue, 21 Aug 2007 15:55:48 -0500 Subject: [erlang-questions] Lists Comprehentions vs. Accumulators In-Reply-To: <92e13fb30708211314h6c10f28frdec38ccb0f42b265@mail.gmail.com> References: <92e13fb30708211314h6c10f28frdec38ccb0f42b265@mail.gmail.com> Message-ID: <006f01c7e435$a7824300$891ea8c0@SSI.CORP> My guess is that it has to do with the fact that the list comprehension version, odds_and_evens/1 allocates memory for the lists L, Odds, and Evens simultaneously, whereas the accumulator version, odds_and_evens_acc/1 only has to allocate enough memory for Odds, Evens, and only the suffix of L that has not yet been processed. Just a guess. Cheers, David _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Shimon Cohen Sent: Tuesday, August 21, 2007 15:15 To: erlang-questions@REDACTED Subject: [erlang-questions] Lists Comprehentions vs. Accumulators Hi My question concerning section 3.12 in Joe's "Programming Erlang": Why odd_and_evens should be less space efficient than odd_and_evens_acc ? I guess it must be somthing with tail-recursion, but can't see why List Comprehetions can't be implemented tail-recursive or even as a plain loop. Thanks, Shimon Cohen. -------------- next part -------------- An HTML attachment was scrubbed... URL: From christophe.romain@REDACTED Tue Aug 21 23:11:20 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Tue, 21 Aug 2007 23:11:20 +0200 Subject: [erlang-questions] Does CEAN modify init.erl? In-Reply-To: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> References: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> Message-ID: Hi yes i just saw that -s cean:version which is old code this bug as been corrected and will be uploaded in next revision (planed for 1st week of september) by now, you can just edit start.sh and set $BINDIR/$cmd ${1+"$@"} without -s cean version regards. From joelr1@REDACTED Tue Aug 21 23:50:59 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 21 Aug 2007 22:50:59 +0100 Subject: [erlang-questions] Does CEAN modify init.erl? In-Reply-To: References: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> Message-ID: Yep, did that! Please note that start.sh also sets PROGNAME to cean for no particular reason. This interferes with launching of slave nodes since there's no binary or script by the name of "cean". Why not the following? PROGNAME=`echo $0 | sed 's/.*\///'` On Aug 21, 2007, at 10:11 PM, Christophe Romain wrote: > by now, you can just edit start.sh and set $BINDIR/$cmd ${1+"$@"} > without -s cean version -- http://wagerlabs.com From christophe.romain@REDACTED Wed Aug 22 00:10:30 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Wed, 22 Aug 2007 00:10:30 +0200 Subject: [erlang-questions] Does CEAN modify init.erl? In-Reply-To: References: <22BB6FBE-00BC-40D0-9656-524E353927D3@gmail.com> Message-ID: > PROGNAME=`echo $0 | sed 's/.*\///'` well, this matches 1.5.4 start_erl from Embedded Systems User's Guide so i'm OK for that patch. just been applyed :) From dot@REDACTED Wed Aug 22 02:51:18 2007 From: dot@REDACTED (Tony Finch) Date: Wed, 22 Aug 2007 01:51:18 +0100 Subject: [erlang-questions] sub-byte endianness in bit syntax In-Reply-To: <003f01c7e044$42a86a80$891ea8c0@SSI.CORP> References: <6a36e7290708151757u1a3c3f89l30dcfbec3635d509@mail.gmail.com> <20070816194630.GH6446@delora.autosys.us> <003f01c7e044$42a86a80$891ea8c0@SSI.CORP> Message-ID: On Thu, 16 Aug 2007, David Mercer wrote: > > I think what Tony is asking about is little-endian *bit* order as opposed to > byte order. I think Erlang's endianness is at the byte level, not bit level. Exactly. This is relevant to interoperability with C, which on little-endian machines usually packs bit-fields into bytes little end first. So I don't think there's a neat way to describe a structure like the following in Erlang. struct { int a:4; int b:8; int c:12; } s; Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From thomas.arts@REDACTED Wed Aug 22 08:27:52 2007 From: thomas.arts@REDACTED (Thomas Arts) Date: Wed, 22 Aug 2007 08:27:52 +0200 Subject: [erlang-questions] Helping universities with Erlang project Message-ID: <46CBD768.1010909@ituniv.se> To all Erlang enthusiast We have run Erlang projects for IT University students for 5 years now. This year we have a problem though... insufficiently many qualified supervisors! Everyone with Erlang knowledge has started working in industry. In order to get more students educated, we would appreciate some help. If you are situated in G?teborg and would like to meet one or two student groups once a week (say 2 hours) to help them with Erlang questions and project in general, then please contact me. Of course, we do pay for your effort, but far less than consultancy rates. This is an excellent opportunity for companies to get in touch with future employees :0). Students really appreciate the help they get from experienced people from industry. This touch of reality is what motivates them. In the project students develop a multi-user game in Erlang. However, if you have a project yourself that you prefer, then we can arrange that they help you instead. Thomas Arts IT University of G?teborg tel 031 772 6031 email: thomas.arts@REDACTED We educate 60 students per year in Erlang and OTP. The education is build around projects of 2400 hours, which four students work on together (typically lasting around 15 weeks). The projects have a realistic industrial setting to stimulate the pedagogics of "problem based learning". From thomas.arts@REDACTED Wed Aug 22 08:29:04 2007 From: thomas.arts@REDACTED (Thomas Arts) Date: Wed, 22 Aug 2007 08:29:04 +0200 Subject: [erlang-questions] Error in erl_tidy (syntax tools) any fix? Message-ID: <46CBD7B0.7000203@ituniv.se> Erlang R11B, erl 5.5.4 under Windows Vista syntax-tools-1.5.3 Save the following program: %%--------------------------------------------------------- -module(test7705). -export([header/0]). header() -> Bin = <<"test7705">>, <<(size(Bin)), Bin/binary>>. %%--------------------------------------------------------- Erlang (BEAM) emulator version 5.5.4 [async-threads:0] Eshell V5.5.4 (abort with ^G) 1> c("test7705.erl"). {ok,test7705} 2> test7705:header(). <<"\btest7705">> 3> erl_tidy:file("test7705.erl"). ok 4> c("test7705.erl"). ./test7705.erl:6: syntax error before: '(' ./test7705.erl:3: function header/0 undefined error 5> The reason for failure is that the parentheses around size(...) are omitted in pretty printing: -module(test7705). -export([header/0]). header() -> Bin = <<"test7705">>, <>. The cause of this is in erl_prettypr.erl around line 624. However, it is not obvious how to fix the code in the right way. Any suggestions? Thanks Thomas From Erik.Stenman@REDACTED Wed Aug 22 08:49:00 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 22 Aug 2007 08:49:00 +0200 Subject: [erlang-questions] Error in erl_tidy (syntax tools) any fix? In-Reply-To: <46CBD7B0.7000203@ituniv.se> References: <46CBD7B0.7000203@ituniv.se> Message-ID: <46CBDC5C.9030409@Kreditor.se> Jag fick den bifogade patchen av Richard. Den l?ser nog problemet, och kommer med i n?sta version av erl_tidy. /Erik Stenman Thomas Arts wrote: > Erlang R11B, erl 5.5.4 under Windows Vista > syntax-tools-1.5.3 > > Save the following program: > %%--------------------------------------------------------- > -module(test7705). > > -export([header/0]). > > header() -> > Bin = <<"test7705">>, <<(size(Bin)), Bin/binary>>. > > %%--------------------------------------------------------- > > Erlang (BEAM) emulator version 5.5.4 [async-threads:0] > > Eshell V5.5.4 (abort with ^G) > 1> c("test7705.erl"). > {ok,test7705} > 2> test7705:header(). > <<"\btest7705">> > 3> erl_tidy:file("test7705.erl"). > ok > 4> c("test7705.erl"). > ./test7705.erl:6: syntax error before: '(' > ./test7705.erl:3: function header/0 undefined > error > 5> > > The reason for failure is that the parentheses around size(...) are > omitted in pretty printing: > -module(test7705). > > -export([header/0]). > > header() -> > Bin = <<"test7705">>, <>. > > > The cause of this is in erl_prettypr.erl around line 624. However, it is > not obvious how to fix the code in the right way. Any suggestions? > > Thanks > Thomas > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: diff URL: From Erik.Stenman@REDACTED Wed Aug 22 08:54:59 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 22 Aug 2007 08:54:59 +0200 Subject: [erlang-questions] Error in erl_tidy (syntax tools) any fix? In-Reply-To: <46CBDC5C.9030409@Kreditor.se> References: <46CBD7B0.7000203@ituniv.se> <46CBDC5C.9030409@Kreditor.se> Message-ID: <46CBDDC3.8040004@Kreditor.se> Sorry for writing in Swedish to erlang-question, I didn't really mean to send it to the list. I wrote that I had received a patch from Richard which might solve the problem. But on second thought I think the patch only solves the problem when the type is given as binary, as in: <<(foo(X))/binary>> So I guess Richard needs to take a deeper look at the whole handling of expressions inside binaries in syntax_tools. /Erik Stenman Erik Stenman wrote: > Jag fick den bifogade patchen av Richard. > Den l?ser nog problemet, och kommer med i n?sta version av erl_tidy. > > /Erik Stenman > > Thomas Arts wrote: >> Erlang R11B, erl 5.5.4 under Windows Vista >> syntax-tools-1.5.3 >> >> Save the following program: >> %%--------------------------------------------------------- >> -module(test7705). >> >> -export([header/0]). >> >> header() -> >> Bin = <<"test7705">>, <<(size(Bin)), Bin/binary>>. >> >> %%--------------------------------------------------------- >> >> Erlang (BEAM) emulator version 5.5.4 [async-threads:0] >> >> Eshell V5.5.4 (abort with ^G) >> 1> c("test7705.erl"). >> {ok,test7705} >> 2> test7705:header(). >> <<"\btest7705">> >> 3> erl_tidy:file("test7705.erl"). >> ok >> 4> c("test7705.erl"). >> ./test7705.erl:6: syntax error before: '(' >> ./test7705.erl:3: function header/0 undefined >> error >> 5> >> >> The reason for failure is that the parentheses around size(...) are >> omitted in pretty printing: >> -module(test7705). >> >> -export([header/0]). >> >> header() -> >> Bin = <<"test7705">>, <>. >> >> >> The cause of this is in erl_prettypr.erl around line 624. However, it >> is not obvious how to fix the code in the right way. Any suggestions? >> >> Thanks >> Thomas >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > ------------------------------------------------------------------------ > > Index: lib/syntax_tools/src/erl_prettypr.erl > =================================================================== > RCS file: /hipe/otp/lib/syntax_tools/src/erl_prettypr.erl,v > retrieving revision 1.56 > diff -u -r1.56 erl_prettypr.erl > --- lib/syntax_tools/src/erl_prettypr.erl 28 Mar 2007 09:59:01 -0000 1.56 > +++ lib/syntax_tools/src/erl_prettypr.erl 13 Aug 2007 20:03:28 -0000 > @@ -640,7 +640,7 @@ > beside(par(Es), floating(text(">>")))); > > binary_field -> > - Ctxt1 = reset_prec(Ctxt), > + Ctxt1 = set_prec(Ctxt, max_prec()), > D1 = lay(erl_syntax:binary_field_body(Node), Ctxt1), > D2 = case erl_syntax:binary_field_types(Node) of > [] -> From richardc@REDACTED Wed Aug 22 09:42:14 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 22 Aug 2007 09:42:14 +0200 Subject: [erlang-questions] Error in erl_tidy (syntax tools) any fix? In-Reply-To: <46CBDDC3.8040004@Kreditor.se> References: <46CBD7B0.7000203@ituniv.se> <46CBDC5C.9030409@Kreditor.se> <46CBDDC3.8040004@Kreditor.se> Message-ID: <46CBE8D6.6040407@it.uu.se> Erik Stenman wrote: > I wrote that I had received a patch from Richard which might > solve the problem. But on second thought I think the patch > only solves the problem when the type is given as binary, > as in: > <<(foo(X))/binary>> > > So I guess Richard needs to take a deeper look at the whole > handling of expressions inside binaries in syntax_tools. I'll have to figure out what the proper precedences should be. At first glance, it seems a bit strange that <> does not parse, while <<(size(Bin)), ...>> does. /Richard From chandrashekhar.mullaparthi@REDACTED Wed Aug 22 09:55:36 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 22 Aug 2007 08:55:36 +0100 Subject: [erlang-questions] Suggestions Message-ID: Hi, I have a couple of suggestions to make to the OTP team. * Can a command which shows only processes with non-zero message queues be added (similar to c:i() but shows only processes which have non-zero message queues). Will be very helpful when a node is going wrong and eating up all available CPU. I know it can be done using a combination of c:processes() and then checking the message queue length of each process using erlang:process_info but in a high load situation, fetching the list of processes and walking the process list is time and resource consuming and might make things worse. * Along with the various metadata stored in a beam file such as the compiler version used, can the MD5 checksum of the source file be stored in the beam file? It helps sometimes in figuring out which version of a particular source file was used to produce a beam file. Info in the -vsn attribute in the module can be misleading because sometimes local modifications would've been done without the version number being updated. I guess the checksum has to be calculated without any preprocessing of the module. (Sean will probably ask me to check-in the source code before using the resulting beam file, but there still are times when this will be useful :-) * It would nice for erlang:process_info/1 to support as input, a list of attributes instead of just one. Sometimes, I don't want to call erlang:process_info/0 as the process might have a large message queue and it just makes things worse. Instead I want multiple items of info. If a try to query in a loop, sometimes the process would've died half way through. cheers Chandru From chandrashekhar.mullaparthi@REDACTED Wed Aug 22 10:23:33 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 22 Aug 2007 09:23:33 +0100 Subject: [erlang-questions] Patch to inets for correct handling of HTTP's Conditional GET In-Reply-To: References: Message-ID: On 19/08/07, Frej Drejhammar wrote: > Hi, > > The http client in inets for R11B-5 does not handle conditional get > correctly. Doing a http:request/4 with the "If-None-Match" and > "If-Modified-Since" headers set such that the server gives a 304 "Not > Modified" reply, the httpc_handler still expects to receive a > body. This eventually leads to a timeout. The attached bug.erl > demonstrates the problem by retrieving the slashdot rss-feed. To any users of ibrowse, I've tested this scenario and it works properly with the current version of ibrowse in sourceforge. cheers Chandru From tomas.pihl@REDACTED Wed Aug 22 10:41:35 2007 From: tomas.pihl@REDACTED (Tomas Pihl) Date: Wed, 22 Aug 2007 10:41:35 +0200 Subject: [erlang-questions] Stupid mistakes (Re: Suggestions) In-Reply-To: References: Message-ID: <20070822084135.GN17404@seasc0391.rnd.as.sw.ericsson.se> * Chandru [2007-08-22 08:55:36 +0100]: > Hi, > > I have a couple of suggestions to make to the OTP team. > > * Can a command which shows only processes with non-zero message > queues be added (similar to c:i() but shows only processes which have > non-zero message queues). Will be very helpful when a node is going > wrong and eating up all available CPU. I know it can be done using a > combination of c:processes() and then checking the message queue > length of each process using erlang:process_info but in a high load > situation, fetching the list of processes and walking the process list > is time and resource consuming and might make things worse. Ohhh, you have my wote on this one! Me and a collegue was called out to a customer site who had a bunch of AXD 301's running live traffic. One site had problems with high load and we suspected this was due to some process was queueing up messages. At 1am, our list comprehension-fu wasn't really showing its glory. We actually managed to kill the site trying to get a list of the processes with non-zero messages due to even higher load from a list comprehension which was not so CPU friendly. Things around us lit up like a christmas tree. Red leds all over the place. At this time my collegue asked the techies the customer had there: "Do you have a bathroom around here?" and off he went. With the techies looking at me asking how things are progressing, all I could say was "Hrm, tricky problem but we really had to reboot the thing. It'll be sorted in a minute or so" /topi From bjorn@REDACTED Wed Aug 22 11:01:29 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 22 Aug 2007 11:01:29 +0200 Subject: [erlang-questions] Suggestions In-Reply-To: References: Message-ID: Chandru writes: > Hi, > > I have a couple of suggestions to make to the OTP team. > > * Can a command which shows only processes with non-zero message > queues be added (similar to c:i() but shows only processes which have > non-zero message queues). Will be very helpful when a node is going > wrong and eating up all available CPU. I know it can be done using a > combination of c:processes() and then checking the message queue > length of each process using erlang:process_info but in a high load > situation, fetching the list of processes and walking the process list > is time and resource consuming and might make things worse. We will probably implement it in a future release. I can't promise that it will be in R12B. We would like to implement some general (or at least semi-general) way to pass some sort of filter specification to processes(). Otherwise we will end up implementing a lot of special-purposes BIFs > * Along with the various metadata stored in a beam file such as the > compiler version used, can the MD5 checksum of the source file be > stored in the beam file? It helps sometimes in figuring out which > version of a particular source file was used to produce a beam file. > Info in the -vsn attribute in the module can be misleading because > sometimes local modifications would've been done without the version > number being updated. I guess the checksum has to be calculated > without any preprocessing of the module. (Sean will probably ask me to > check-in the source code before using the resulting beam file, but > there still are times when this will be useful :-) If you don't set the -vsn attribute in your source code, the compiler will automatically set it to the MD5 for the module. Also, beam_lib:md5/1 will calculate the MD5 for a .beam file. > * It would nice for erlang:process_info/1 to support as input, a list > of attributes instead of just one. Sometimes, I don't want to call > erlang:process_info/0 as the process might have a large message queue > and it just makes things worse. Instead I want multiple items of info. > If a try to query in a loop, sometimes the process would've died half > way through. We will probably implement that in R12B. > cheers > Chandru > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From chandrashekhar.mullaparthi@REDACTED Wed Aug 22 11:10:02 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 22 Aug 2007 10:10:02 +0100 Subject: [erlang-questions] Suggestions In-Reply-To: References: Message-ID: On 22 Aug 2007 11:01:29 +0200, Bjorn Gustavsson wrote: > Chandru writes: > > > Hi, > > > > I have a couple of suggestions to make to the OTP team. > > > > * Can a command which shows only processes with non-zero message > > queues be added (similar to c:i() but shows only processes which have > > non-zero message queues). Will be very helpful when a node is going > > wrong and eating up all available CPU. I know it can be done using a > > combination of c:processes() and then checking the message queue > > length of each process using erlang:process_info but in a high load > > situation, fetching the list of processes and walking the process list > > is time and resource consuming and might make things worse. > > We will probably implement it in a future release. I can't promise > that it will be in R12B. We would like to implement some general (or at > least semi-general) way to pass some sort of filter specification to > processes(). Otherwise we will end up implementing a lot of > special-purposes BIFs This would be perfect. Anyone who supports erlang based applications will be very grateful! > > * Along with the various metadata stored in a beam file such as the > > compiler version used, can the MD5 checksum of the source file be > > stored in the beam file? It helps sometimes in figuring out which > > version of a particular source file was used to produce a beam file. > > Info in the -vsn attribute in the module can be misleading because > > sometimes local modifications would've been done without the version > > number being updated. I guess the checksum has to be calculated > > without any preprocessing of the module. (Sean will probably ask me to > > check-in the source code before using the resulting beam file, but > > there still are times when this will be useful :-) > > If you don't set the -vsn attribute in your source code, the compiler > will automatically set it to the MD5 for the module. > Ah! I see. Is it possible to have the md5 as well in case the -vsn is specified? > > * It would nice for erlang:process_info/1 to support as input, a list > > of attributes instead of just one. Sometimes, I don't want to call > > erlang:process_info/0 as the process might have a large message queue > > and it just makes things worse. Instead I want multiple items of info. > > If a try to query in a loop, sometimes the process would've died half > > way through. > > We will probably implement that in R12B. > Thank you very much. Much appreciated. Chandru From bjorn@REDACTED Wed Aug 22 11:17:17 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 22 Aug 2007 11:17:17 +0200 Subject: [erlang-questions] Suggestions In-Reply-To: References: Message-ID: Chandru writes: > > > > If you don't set the -vsn attribute in your source code, the compiler > > will automatically set it to the MD5 for the module. > > > > Ah! I see. Is it possible to have the md5 as well in case the -vsn is specified? No. I suppose we could invent a new attribute that is always set, for instance -md5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From saleyn@REDACTED Wed Aug 22 15:04:27 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 22 Aug 2007 08:04:27 -0500 Subject: [erlang-questions] Suggestions In-Reply-To: References: Message-ID: <46CC345B.1010409@gmail.com> Since you are in this wonderful mood of accepting requests, I thought it wouldn't hurt to ask you adding string:join/2: http://www.erlang.org/pipermail/erlang-questions/2004-June/012588.html http://www.erlang.org/pipermail/erlang-questions/2006-December/024435.html Serge Bjorn Gustavsson wrote: > Chandru writes: > >> Hi, >> >> I have a couple of suggestions to make to the OTP team. >> >> * Can a command which shows only processes with non-zero message >> queues be added (similar to c:i() but shows only processes which have >> non-zero message queues). Will be very helpful when a node is going >> wrong and eating up all available CPU. I know it can be done using a >> combination of c:processes() and then checking the message queue >> length of each process using erlang:process_info but in a high load >> situation, fetching the list of processes and walking the process list >> is time and resource consuming and might make things worse. > > We will probably implement it in a future release. I can't promise > that it will be in R12B. We would like to implement some general (or at > least semi-general) way to pass some sort of filter specification to > processes(). Otherwise we will end up implementing a lot of > special-purposes BIFs > >> * Along with the various metadata stored in a beam file such as the >> compiler version used, can the MD5 checksum of the source file be >> stored in the beam file? It helps sometimes in figuring out which >> version of a particular source file was used to produce a beam file. >> Info in the -vsn attribute in the module can be misleading because >> sometimes local modifications would've been done without the version >> number being updated. I guess the checksum has to be calculated >> without any preprocessing of the module. (Sean will probably ask me to >> check-in the source code before using the resulting beam file, but >> there still are times when this will be useful :-) > > If you don't set the -vsn attribute in your source code, the compiler > will automatically set it to the MD5 for the module. > > Also, beam_lib:md5/1 will calculate the MD5 for a .beam file. > >> * It would nice for erlang:process_info/1 to support as input, a list >> of attributes instead of just one. Sometimes, I don't want to call >> erlang:process_info/0 as the process might have a large message queue >> and it just makes things worse. Instead I want multiple items of info. >> If a try to query in a loop, sometimes the process would've died half >> way through. > > We will probably implement that in R12B. > >> cheers >> Chandru >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions From kevin@REDACTED Wed Aug 22 14:26:01 2007 From: kevin@REDACTED (Kevin A. Smith) Date: Wed, 22 Aug 2007 08:26:01 -0400 Subject: [erlang-questions] Using Soap Message-ID: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> I have a need to write both a Soap client and server in Erlang. Being relatively new to Erlang and really new to Soap I have two questions: 1) How mature are the Soap libs? Any problems or gotchas I should be aware of? 2) Are there any Erlang tutorials or FAQs for the Soap libs? --Kevin From casper2000a@REDACTED Wed Aug 22 14:44:54 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Wed, 22 Aug 2007 18:14:54 +0530 Subject: [erlang-questions] Bit reversing In-Reply-To: <465C37D7.7070502@ericsson.com> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se><46541826.30804@it.uu.se> <465C37D7.7070502@ericsson.com> Message-ID: <006c01c7e4ba$3d7646c0$b862d440$@com> Hi, Is there a straight forward and efficient method to reverse the bits in a whole binary? For eg. <> After reversing, <> Thanks, - Eranga From joseerlang@REDACTED Wed Aug 22 14:49:48 2007 From: joseerlang@REDACTED (Jose (Developer Erlang)) Date: Wed, 22 Aug 2007 14:49:48 +0200 Subject: [erlang-questions] Using Soap In-Reply-To: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> References: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> Message-ID: <46CC30EC.3010100@gmail.com> Kevin A. Smith escribi?: > I have a need to write both a Soap client and server in Erlang. Being > relatively new to Erlang and really new to Soap I have two questions: > > 1) How mature are the Soap libs? Any problems or gotchas I should be > aware of? > Erlsom project is a good introduction, but it isn't a mature project. Xmerl is another lib. > 2) Are there any Erlang tutorials or FAQs for the Soap libs? > You should visit http://yaws.hyber.org/soap_intro.yaws Good Luck, Kevin Jose A. Garc?a Computer Science Department University of A Corunna > --Kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From dmitriid@REDACTED Wed Aug 22 15:41:32 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Wed, 22 Aug 2007 16:41:32 +0300 Subject: [erlang-questions] Using Soap In-Reply-To: <46CC30EC.3010100@gmail.com> References: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> <46CC30EC.3010100@gmail.com> Message-ID: <46CC3D0C.5070406@gmail.com> Jose (Developer Erlang) wrote: > Kevin A. Smith escribi?: > >> I have a need to write both a Soap client and server in Erlang. Being >> relatively new to Erlang and really new to Soap I have two questions: >> >> 1) How mature are the Soap libs? Any problems or gotchas I should be >> aware of? >> >> > Erlsom project is a good introduction, but it isn't a mature project. > Xmerl is another lib. > >> 2) Are there any Erlang tutorials or FAQs for the Soap libs? >> >> > You should visit http://yaws.hyber.org/soap_intro.yaws > There's also erlsoap, see http://forum.trapexit.org/viewtopic.php?p=21614 -------------- next part -------------- An HTML attachment was scrubbed... URL: From w.a.de.jong@REDACTED Wed Aug 22 18:33:24 2007 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Wed, 22 Aug 2007 18:33:24 +0200 Subject: [erlang-questions] Using Soap In-Reply-To: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> References: <6480E625-32B2-48A8-BF94-74A92CC2EB3A@hypotheticalabs.com> Message-ID: <407d9ef80708220933q445d3443o5fae524b6962fd00@mail.gmail.com> On 8/22/07, Kevin A. Smith wrote: > > I have a need to write both a Soap client and server in Erlang. Being > relatively new to Erlang and really new to Soap I have two questions: > > 1) How mature are the Soap libs? Any problems or gotchas I should be > aware of? The are 2 soap libs that I am aware of: yaws_soap_lib and erlsoap. Both use Erlsom to parse the XML. I would like to think that Erlsom is fairly mature, but the soap implementations are both limited in scope and they could use some work. Still, depending on your needs, you may find them quite useful. Yaws_soap_lib uses yaws as the HTTP server; erlsoap uses inets. Both include functions to build a client and a server (I haven't tried the erlsoap client). Both support soap over HTTP only. Both support the 'document' binding style only Both support the 'literal' encoding style only. (Fortunately, SOAP over HTTP using document binding and literal encoding seems to be the preferred flavour of SOAP nowadays.) Yaws_soap_lib will accept a WSDL file as its configuration. Erlsoap will accept the XSD only (so you have to extract this from the WSDL). Erlsoap has no proper support for soap faults (this may not be an issue, because you may not require it. In any case it should be easy to fix this). There may be more limitations that I am not aware of... It would be interesting to know what your experiences are. Regards, Willem > 2) Are there any Erlang tutorials or FAQs for the Soap libs? > > --Kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Wed Aug 22 19:23:15 2007 From: chsu79@REDACTED (Christian S) Date: Wed, 22 Aug 2007 19:23:15 +0200 Subject: [erlang-questions] Suggestions In-Reply-To: <46CC345B.1010409@gmail.com> References: <46CC345B.1010409@gmail.com> Message-ID: Another good name is "intersperse", it also makes it sound more suitable for 'lists'. 2007/8/22, Serge Aleynikov : > Since you are in this wonderful mood of accepting requests, I thought it > wouldn't hurt to ask you adding string:join/2: > > http://www.erlang.org/pipermail/erlang-questions/2004-June/012588.html > http://www.erlang.org/pipermail/erlang-questions/2006-December/024435.html From kevin@REDACTED Wed Aug 22 20:00:17 2007 From: kevin@REDACTED (Kevin Kleinfelter) Date: Wed, 22 Aug 2007 14:00:17 -0400 Subject: [erlang-questions] Accessing COM/OLE/ActiveX Message-ID: <46CC79B1.2050004@kleinfelter.com> When Comet was removed from the Erlang distribution, what took its place? i.e. Now that Comet is gone, how does a program access a COM object on the Windows platform? TIA From shimoco@REDACTED Wed Aug 22 22:12:13 2007 From: shimoco@REDACTED (Shimon Cohen) Date: Wed, 22 Aug 2007 23:12:13 +0300 Subject: [erlang-questions] Bit reversing In-Reply-To: <006c01c7e4ba$3d7646c0$b862d440$@com> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> <46541826.30804@it.uu.se> <465C37D7.7070502@ericsson.com> <006c01c7e4ba$3d7646c0$b862d440$@com> Message-ID: <92e13fb30708221312u350b6495y9344c6f441c3ad78@mail.gmail.com> Hi As reading just now Chap. 5 in "Programming Erlang", I can't ressist the chalange. Although not very staright forward... reverse_binary(B) -> list_to_binary(lists:reverse([reverse_byte(X) || X <- binary_to_list(B)])). reverse_byte(B) -> <> = <>, <>. Shimon. On 8/22/07, Eranga Udesh wrote: > > Hi, > > Is there a straight forward and efficient method to reverse the bits in a > whole binary? For eg. > > <> > After reversing, > <> > > Thanks, > - Eranga > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shimoco@REDACTED Wed Aug 22 22:26:14 2007 From: shimoco@REDACTED (Shimon Cohen) Date: Wed, 22 Aug 2007 23:26:14 +0300 Subject: [erlang-questions] Shell printing mode Message-ID: <92e13fb30708221326o56d66cebmaf1ca3e20047e61c@mail.gmail.com> Hi Is there a way to force the shell to always print numbers in lists and binaries, even if content contains only printable characters ? Thanks, Shimon. -------------- next part -------------- An HTML attachment was scrubbed... URL: From twa@REDACTED Wed Aug 22 22:26:21 2007 From: twa@REDACTED (Tom Ayerst) Date: Wed, 22 Aug 2007 21:26:21 +0100 Subject: [erlang-questions] [SPAM] Re: Cannot get the hang of single assignment In-Reply-To: <008101c7e107$0b3baf30$891ea8c0@SSI.CORP> References: <46C5F878.4000004@post.com> <008101c7e107$0b3baf30$891ea8c0@SSI.CORP> Message-ID: <46CC9BED.8060501@post.com> Hi, Thanks for the pointers. I eventually worked this out. The example code I came up with is here: http://notwaving.net/wordpress/2007/08/20/a-basic-mutable-state-in-an-erlang-process/ Now, another question. Is this a useful idiom in Erlang or is it the bastard offspring of an OO programmer trying to bring his baggage into the Functional/Actor world. Cheers tom David Mercer wrote: > On Friday, August 17, 2007, Tom Ayerst wrote: > >> How should I track the state (position and vector) of each Boid? >> > > The short answer is that your boid is in a loop: implement that loop as a > tail-recursive function, passing the state from the previous iteration in as > arguments to the next. Something like: > > boid_loop(State) -> > . . . > New_state = ... > boid_loop(New_state). > > Does this help? > > Cheers, > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From 0x6e6562@REDACTED Wed Aug 22 23:52:52 2007 From: 0x6e6562@REDACTED (Ben Hood) Date: Wed, 22 Aug 2007 22:52:52 +0100 Subject: [erlang-questions] rpc from erlang to java In-Reply-To: <95be1d3b0708220428v6090d12te6b5682d613562b@mail.gmail.com> References: <95be1d3b0708150026r66a1b006t40e54d199cc7c2b0@mail.gmail.com> <269388e30708180536p64883665h9e62973bd4f24e32@mail.gmail.com> <95be1d3b0708190358g16577771qbcca2438f3f417cf@mail.gmail.com> <269388e30708190915p39b26104r47503118dbe4605c@mail.gmail.com> <95be1d3b0708220428v6090d12te6b5682d613562b@mail.gmail.com> Message-ID: <269388e30708221452u9e7908fyb25f25d4a5d5710b@mail.gmail.com> Vlad, > I've looked at this and for what I use it for I don't really see any > advantage of using the Hessian serialization over the builtin > jinterface/Erlang one. That's fair enough, because Hessian is aimed at being interpreted by many languages but in your case you only have 2 languages, so you don't gain from this abstraction. Furthermore, it is also designed to be a wire format, which isn't necessarily relevant in your case. Just wanted to give you a further option. Cheers, Ben From klacke@REDACTED Thu Aug 23 00:15:00 2007 From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=) Date: Thu, 23 Aug 2007 00:15:00 +0200 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46C59CDD.3020200@gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> Message-ID: <46CCB564.7000004@hyber.org> Serge Aleynikov wrote: > > {ok, Socket} = gen_tcp:accept(Listener) > > So you would need to monitor how many accept failures you got in the > last several seconds and do some intelligent recovery. This would > complicate code by quite a bit. Checking the errors that can occur for accept, the only ones that apply are: [EMFILE] The per-process descriptor table is full. [ENFILE] The system file table is full. In either of these cases, there is really nothing good that can be done. I've just changed the default behavior of yaws to terminate the entire yaws application when accept actually fails. When running the standalone server, the entire node will die and be restarted by heart. This is a bit like trying to do something clever when malloc() fails - pondering on the issue for a couple of years eventually the only sane thing to do is exit(1), same thing with accept() here. I think there are quite a few erlang/server apps that log the accept() error an retry - which is very bad if the error is e{n,m}file. /klacke From dustin@REDACTED Thu Aug 23 01:37:02 2007 From: dustin@REDACTED (Dustin Sallings) Date: Wed, 22 Aug 2007 16:37:02 -0700 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46CCB564.7000004@hyber.org> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <46CCB564.7000004@hyber.org> Message-ID: On Aug 22, 2007, at 15:15 , Claes Wikstr?m wrote: > I think there are quite a few erlang/server apps that log the > accept() error an retry - which is very bad if the error is e{n,m} > file. I had an app recently that was doing just that, and I don't see what's bad about it. My log file is already open on a node, another node gets emfile or enfile (I was getting both) and sends it back to the logging node which tells me that's why a particular request failed. I suppose I'm not actually doing a *retry*, but I'm proceeding which means I'm going to try to make a new connection pretty much immediately afterwards. My app recovered after both of those errors. -- Dustin Sallings From samuel.tesla@REDACTED Thu Aug 23 01:54:03 2007 From: samuel.tesla@REDACTED (Samuel Tesla) Date: Wed, 22 Aug 2007 18:54:03 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46CCB564.7000004@hyber.org> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <46CCB564.7000004@hyber.org> Message-ID: <4bd555f70708221654o6bcf7ba1yba80f6f3e7d0225c@mail.gmail.com> On 8/22/07, Claes Wikstr?m wrote: > > This is a bit like trying to do something clever when malloc() > fails - pondering on the issue for a couple of years eventually > the only sane thing to do is exit(1), same thing with accept() here. > That's pretty much the conclusion I came to. In the application I'm writing (that got me going down this road in the first place) I'm just bailing on that process. But, I should probably exit the whole app. But, beyond that, some simple exit handling makes the blocking sub-process work great for making a parallel TCP server. -- Samuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From bernied@REDACTED Thu Aug 23 03:14:24 2007 From: bernied@REDACTED (Bernhard Damberger) Date: Wed, 22 Aug 2007 18:14:24 -0700 (PDT) Subject: [erlang-questions] Deployment of erlang apps. Message-ID: <12285908.post@talk.nabble.com> What is the recommended way to deploy an erlang application? Is it better to dump everything into one erlterpreter, or to split the application into several different processes (assuming on one machine)? For example I was running saw Yaws, erljabberd and some custom code, should I split into three separate processes or dump them into one? What do people recommend? _bernhard -- View this message in context: http://www.nabble.com/Deployment-of-erlang-apps.-tf4314904.html#a12285908 Sent from the Erlang Questions mailing list archive at Nabble.com. From saleyn@REDACTED Thu Aug 23 05:14:58 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 22 Aug 2007 22:14:58 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46CCB564.7000004@hyber.org> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <46CCB564.7000004@hyber.org> Message-ID: <46CCFBB2.1060501@gmail.com> Despite the fact that aborting the application is also what's implemented in the tutorial, this may seem questionable to be "the only" reasonable recovery action as for some servers EMFILE can be a temporary condition. Suppose there was a spike of short-lived client connections when the server might have hit the limit of file descriptors. As some client connections disconnect, the server's gen_tcp:accept/1 call may recover automatically. I could speculate that in selected cases it may be more expensive to failover/recover state of some applications in a node then to attempt several retries in a timely manner. Serge Claes Wikstr?m wrote: > Serge Aleynikov wrote: > >> >> {ok, Socket} = gen_tcp:accept(Listener) >> >> So you would need to monitor how many accept failures you got in the >> last several seconds and do some intelligent recovery. This would >> complicate code by quite a bit. > > > Checking the errors that can occur for accept, the only ones > that apply are: > > [EMFILE] The per-process descriptor table is full. > > [ENFILE] The system file table is full. > > > In either of these cases, there is really nothing good that can > be done. I've just changed the default behavior of yaws to > terminate the entire yaws application when accept actually fails. > > When running the standalone server, the entire node will die and > be restarted by heart. > > This is a bit like trying to do something clever when malloc() > fails - pondering on the issue for a couple of years eventually > the only sane thing to do is exit(1), same thing with accept() here. > > I think there are quite a few erlang/server apps that log the > accept() error an retry - which is very bad if the error is e{n,m}file. > > > /klacke From casper2000a@REDACTED Thu Aug 23 04:16:29 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Thu, 23 Aug 2007 07:46:29 +0530 Subject: [erlang-questions] Bit reversing In-Reply-To: <92e13fb30708221312u350b6495y9344c6f441c3ad78@mail.gmail.com> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> <46541826.30804@it.uu.se> <465C37D7.7070502@ericsson.com> <006c01c7e4ba$3d7646c0$b862d440$@com> <92e13fb30708221312u350b6495y9344c6f441c3ad78@mail.gmail.com> Message-ID: <002e01c7e52b$a010f9d0$e032ed70$@com> Hi, Thanks for the code snippet. However what I wanted to find out is whether there?s a BIF or Function which can do this without the need of binary/bit segmentation, list creation, list reversing and recreation the reversed binary. The complexity of this method is too high write a method that is heavily used. A little improvement I can suggest to your code is in reverse_byte/1 function, we can do a byte decode in little/big endian and repack is in opposite endian. So, anything available like that? Also is it possible to segment a binary starting from tail? Eg. with bitlevel_binaries and binary_comprehension compiler flags [ X || <> <= <<1,2,3,4,5,6>>] ---> Results ---> [0,64,64,48,32,20] Ie. It segments the binary starting from the beginning. In bit representation, 00000001 00000010 00000011 00000100 00000101 00000110 ---> Results ---> 0000000 1000000 1000000 0110000 0100000 0010100 000110 How do I make it to give result, [32,32,24,16,10,6] In bit representation, 00000001 00000010 00000011 00000100 00000101 00000110 ---> Results ---> 000000 0100000 0100000 0011000 0010000 0001010 0000110 Thanks, - Eranga From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Shimon Cohen Sent: Thursday, August 23, 2007 1:42 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] Bit reversing Hi As reading just now Chap. 5 in "Programming Erlang", I can't ressist the chalange. Although not very staright forward... reverse_binary(B) -> ??? list_to_binary(lists:reverse([reverse_byte(X) || X <- binary_to_list(B)])). reverse_byte(B) -> ??? <> = <>, ??? <>. Shimon. On 8/22/07, Eranga Udesh wrote: Hi, Is there a straight forward and efficient method to reverse the bits in a whole binary? For eg. <> After reversing, <> Thanks, - Eranga _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From matthew@REDACTED Mon Aug 20 23:45:44 2007 From: matthew@REDACTED (Matthew Sackman) Date: Mon, 20 Aug 2007 22:45:44 +0100 Subject: [erlang-questions] Tilera 64-core chip In-Reply-To: <200708201440.l7KEeeON001371@harpo.it.uu.se> References: <200708201440.l7KEeeON001371@harpo.it.uu.se> Message-ID: <20070820214544.GF13839@wellquite.org> On Mon, Aug 20, 2007 at 04:40:40PM +0200, Mikael Pettersson wrote: > On Mon, 20 Aug 2007 07:15:47 -0700 (PDT), Thomas Lindgren wrote: > > > Does anyone have experience with Tilera? > > > http://www.tilera.com/index.php > > It does seem to run Linux (in some sense, "supports" > > is a flexible word) so it can't be too exotic. That's > > good. I wonder what ISA the cores implement? MIPS? > > PPC? > > I had to look around quite a bit in their rather > superficial documentation before I found something > useful, but their compiler is based on SGI's MIPSpro, > so the ISA is probably MIPS. Turned up on El Reg today: http://www.theregister.co.uk/2007/08/20/tilera_tile64_chip/ Matthew -- Matthew Sackman http://www.wellquite.org/ From ingela@REDACTED Thu Aug 23 11:18:33 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Thu, 23 Aug 2007 11:18:33 +0200 Subject: [erlang-questions] Patch to inets for correct handling of HTTP's Conditional In-Reply-To: References: Message-ID: <46CD50E9.3010707@erix.ericsson.se> > On 19/08/07, Frej Drejhammar wrote: > >> Hi, >> >> The http client in inets for R11B-5 does not handle conditional get >> correctly. Doing a http:request/4 with the "If-None-Match" and >> "If-Modified-Since" headers set such that the server gives a 304 "Not >> Modified" reply, the httpc_handler still expects to receive a >> body. This eventually leads to a timeout. The attached bug.erl >> demonstrates the problem by retrieving the slashdot rss-feed. >> > > To any users of ibrowse, I've tested this scenario and it works > properly with the current version of ibrowse in sourceforge. > Wonderful :) It would surprise me immensely if ibrowse was bug compatible with inets or vice versa ;) Regards Ingela From kenneth.lundin@REDACTED Thu Aug 23 11:40:45 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 23 Aug 2007 11:40:45 +0200 Subject: [erlang-questions] Building Erlang with the Sun Studio compiler In-Reply-To: <7524A45A1A5B264FA4809E2156496CFBE72D8D@ITOMAE2KM01.AD.QINTRA.COM> References: <36E4692623C5974BA6661C0B18EE8EDF7FFA51@MAILSERV.hcrest.com> <7524A45A1A5B264FA4809E2156496CFBE72D8D@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: > However, I still think removing the GNU specific dependencies is a > better long term solution. People are going to want to build from source > with their own compilers on other platforms as well, e.g. MS VC++, > Borland, the HP-UX compiler, etc. It should be possible to build Erlang with other compilers than GCC but we are not testing that actively because we have choosen GCC as our standard compiler. There are many reasons for choosing GCC as the standard compiler: - It's free - Available on all relevant platforms - We use the GCC specific feature called "first class labels" which means that you can assign a label to a variable say A and the use the goto A statement to jump to the label location. By using this feature we achieve 20% better performance then by using an ordinary switch construct. In fact it is only one file (beam_emu.c) that uses this feature and that is where the main loop of the virtual machine is implemented. On Windows for example we build Erlang with MS VC++ except for the file mentioned above which we build with gcc. On all other platforms we use GCC. As said earlier it should be possible to build Erlang with Suns compilers , there are macros which replaces the goto Variable constructs with a switch statement for other compilers than GCC. The configure step should take care of this if no GCC compiler is found on the system. For Sun SOlaris Sparc we have earlier tried a combination of GCC for beam_emu.c and Sparcworks for all the rest. This showed a performance improvement with 5-10% compared with using GCC for all files. /Regards Kenneth (Erlang/OTP team at Ericsson) > > Regards, > > Dan > > > This communication is the property of Qwest and may contain confidential or > privileged information. Unauthorized use of this communication is strictly > prohibited and may be unlawful. If you have received this communication > in error, please immediately notify the sender by reply e-mail and destroy > all copies of the communication and any attachments. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dbt@REDACTED Thu Aug 23 15:58:26 2007 From: dbt@REDACTED (David Terrell) Date: Thu, 23 Aug 2007 08:58:26 -0500 Subject: [erlang-questions] erl -make exit status Message-ID: <20070823135826.GB31070@sphinx.chicagopeoplez.org> % erlc -o ebin src/*.erl src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" % echo $? 1 % cat Emakefile {'src/*', [debug_info, {outdir, "ebin"}]}. % erl -make Recompile: src/my_test src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" % echo %? 0 This is making it hard to use emake in my continuous integration system... any suggestions? Is emake considered production ready? -- David Terrell dbt@REDACTED ((meatspace)) http://meat.net/ From thomasl_erlang@REDACTED Thu Aug 23 15:40:07 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 23 Aug 2007 06:40:07 -0700 (PDT) Subject: [erlang-questions] Tilera 64-core chip In-Reply-To: <20070820214544.GF13839@wellquite.org> Message-ID: <71385.53197.qm@web38808.mail.mud.yahoo.com> --- Matthew Sackman wrote: > On Mon, Aug 20, 2007 at 04:40:40PM +0200, Mikael > Pettersson wrote: > > On Mon, 20 Aug 2007 07:15:47 -0700 (PDT), Thomas > Lindgren wrote: > > > > Does anyone have experience with Tilera? > > > > http://www.tilera.com/index.php > > > It does seem to run Linux (in some sense, > "supports" > > > is a flexible word) so it can't be too exotic. > That's > > > good. I wonder what ISA the cores implement? > MIPS? > > > PPC? > > > > I had to look around quite a bit in their rather > > superficial documentation before I found something > > useful, but their compiler is based on SGI's > MIPSpro, > > so the ISA is probably MIPS. > > Turned up on El Reg today: > http://www.theregister.co.uk/2007/08/20/tilera_tile64_chip/ > Anant Agarwal is the CTO ... in that case, this likely is a continuation of the RAW project at MIT. http://www.cag.lcs.mit.edu/raw/ Best, Thomas ____________________________________________________________________________________ Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. http://autos.yahoo.com/carfinder/ From roger.larsson@REDACTED Thu Aug 23 16:48:02 2007 From: roger.larsson@REDACTED (Roger Larsson) Date: Thu, 23 Aug 2007 16:48:02 +0200 Subject: [erlang-questions] Tilera 64-core chip - full Linux on each core! In-Reply-To: <20070820214544.GF13839@wellquite.org> References: <200708201440.l7KEeeON001371@harpo.it.uu.se> <20070820214544.GF13839@wellquite.org> Message-ID: <200708231648.02322.roger.larsson@norran.net> On Monday 20 August 2007 23:45, Matthew Sackman wrote: > Turned up on El Reg today: > http://www.theregister.co.uk/2007/08/20/tilera_tile64_chip/ > > Matthew And on Video/Imaging DesignLine http://www.videsignline.com/showArticle.jhtml?articleID=201801262 "Tilera's approach is straightforward. Its individual cores are full-fledged general-purpose processors, each capable of running a symmetric multiprocessing version of Linux. Each core also has an embedded switch for linking to any of the other cores on the die connected on a mesh network." "Tilera's approach is unique in part because each of its cores has the interrupt and cache structures needed to support a full operating system..." Sounds very interesting to try this chip out in interpreted mode. And interpretion might prove better suited to cache limited architectures anyway. /RogerL From kenneth.lundin@REDACTED Thu Aug 23 17:11:08 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 23 Aug 2007 17:11:08 +0200 Subject: [erlang-questions] erl -make exit status In-Reply-To: <20070823135826.GB31070@sphinx.chicagopeoplez.org> References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> Message-ID: Hi, What is your real problem? Is it the fact that "erl -make" doesn't return an exit code to the shell? Or is it the "can't find include lib" thing? The make module in tools is not meant to be a heavy duty build tool. It is rather a convenient way of making for example all Erlang modules in one directory (mostly invoked from the Erlang shell). For real building of products we recommend the use of UNIX make or similar invoking erlc for each Erlang module. You must specify -I IncludeDir for erlc or {i,IncludeDir} in the Emakefile in order to find the include files for eunit. /Regards Kenneth On 8/23/07, David Terrell wrote: > % erlc -o ebin src/*.erl > src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" > % echo $? > 1 > > % cat Emakefile > {'src/*', [debug_info, {outdir, "ebin"}]}. > % erl -make > Recompile: src/my_test > src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" > % echo %? > 0 > > This is making it hard to use emake in my continuous integration > system... any suggestions? Is emake considered production ready? > > -- > David Terrell > dbt@REDACTED > ((meatspace)) http://meat.net/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From michael.campbell@REDACTED Thu Aug 23 18:30:50 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Thu, 23 Aug 2007 12:30:50 -0400 Subject: [erlang-questions] erl -make exit status In-Reply-To: References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> Message-ID: <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> On 8/23/07, Kenneth Lundin wrote: > Hi, > > What is your real problem? > Is it the fact that "erl -make" doesn't return an exit code to the shell? > Or is it the "can't find include lib" thing? I can't answer your question to the OP there, but it seems a bit much to call a usable return code a qualification of a "heavy duty" build tool, no? As it is, you can't even script the thing reliably. From grpack@REDACTED Thu Aug 23 18:44:17 2007 From: grpack@REDACTED (Gabriel Pack) Date: Thu, 23 Aug 2007 09:44:17 -0700 Subject: [erlang-questions] spawn_monitor documentation wrong Message-ID: <174431D3-847A-40A5-8AE0-3D70033AC01C@mac.com> Is the man page for erlang:spawn_monitor/1 out of date? I'm running R11B-5. I had to find out the hard way that it doesn't behave like spawn_link/ 1 as claimed. Rather than returning a PID, it returns {PID, _}. When trapping exits, you have to receive {'DOWN', _, _, _, _} as opposed to {'EXIT', _, _}. I've been coding in Erlang for all of a couple weeks now. So let me know if I'm missing something. From ulf.wiger@REDACTED Thu Aug 23 19:29:00 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 23 Aug 2007 19:29:00 +0200 Subject: [erlang-questions] erl -make exit status In-Reply-To: <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> Message-ID: <50EF7C1F8DC43749AC0018FB9574D99621B684@esealmw115.eemea.ericsson.se> Michael Campbell wrote: > > On 8/23/07, Kenneth Lundin wrote: > > Hi, > > > > What is your real problem? > > Is it the fact that "erl -make" doesn't return an exit code > to the shell? > > Or is it the "can't find include lib" thing? > > I can't answer your question to the OP there, but it seems a > bit much to call a usable return code a qualification of a > "heavy duty" build tool, no? As it is, you can't even script > the thing reliably. > But to be fair, Kenneth only said that erl -make isn't _meant_ to be a heavy duty build tool. He never suggested that it would be one if it could only return a proper return code. BR, Ulf W From ulf.wiger@REDACTED Thu Aug 23 19:32:19 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 23 Aug 2007 19:32:19 +0200 Subject: [erlang-questions] spawn_monitor documentation wrong In-Reply-To: <174431D3-847A-40A5-8AE0-3D70033AC01C@mac.com> References: <174431D3-847A-40A5-8AE0-3D70033AC01C@mac.com> Message-ID: <50EF7C1F8DC43749AC0018FB9574D99621B686@esealmw115.eemea.ericsson.se> > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Gabriel Pack > Sent: den 23 augusti 2007 18:44 > To: erlang-questions@REDACTED > Subject: [erlang-questions] spawn_monitor documentation wrong > > Is the man page for erlang:spawn_monitor/1 out of date? I'm > running R11B-5. > > I had to find out the hard way that it doesn't behave like spawn_link/ > 1 as claimed. Rather than returning a PID, it returns {PID, > _}. When trapping exits, you have to receive {'DOWN', _, _, > _, _} as opposed to {'EXIT', _, _}. > > I've been coding in Erlang for all of a couple weeks now. So > let me know if I'm missing something. The doc doesn't claim that spawn_monitor/1 works like spawn_link/1. It says that it works like spawn/1, with the exception that it also creates a monitor. >From http://www.erlang.org/doc/man/erlang.html "erlang:spawn_monitor(Fun) -> {pid(),reference()} Types: Fun = fun() Returns the pid of a new process started by the application of Fun to the empty list [] and reference for a monitor created to the new process. Otherwise works like spawn/3. " BR, Ulf W From oscar@REDACTED Thu Aug 23 19:35:54 2007 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 23 Aug 2007 18:35:54 +0100 Subject: [erlang-questions] Deployment of erlang apps. In-Reply-To: <12285908.post@talk.nabble.com> References: <12285908.post@talk.nabble.com> Message-ID: <46CDC57A.60004@erlang-consulting.com> Hi, For the ease of deployment in case of starting, stopping, monitoring, distribution etc. it is probably best to keep them as in one interpeter. You can for instance run it as a target system, which can be very convenient, both for distribution and for start/stop/monitoring. If you want to benefit from several processors / cores, you can use the SMP support added to recent Erlang distributions. If it's *one* application (not Erlang application, but from a user/administrator perspective) I'd keep it as one OS process. Bernhard Damberger wrote: > What is the recommended way to deploy an erlang application? Is it better to > dump everything into one erlterpreter, or to split the application into > several different processes (assuming on one machine)? > > For example I was running saw Yaws, erljabberd and some custom code, should > I split into three separate processes or dump them into one? > > What do people recommend? > > _bernhard Best Regards -- Oscar Hellstr?m, oscar@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From anders.nygren@REDACTED Thu Aug 23 19:57:45 2007 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 23 Aug 2007 12:57:45 -0500 Subject: [erlang-questions] crypto:start() fails on SPARC Solaris 9 Message-ID: Hi I am having a problem with R11B-4 on Solaris 9 SPARC. bash-2.05$ uname -a SunOS testing 5.9 Generic_118558-25 sun4u sparc SUNW,Ultra-5_10 When I try to start crypto I get Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> crypto:start(). sh: crypto_drv: not found sh: crypto_drv: not found =ERROR REPORT==== 23-Aug-2007::12:47:44 === ** Generic server crypto_server terminating ** Last message in was {'EXIT',#Port<0.98>,normal} ** When Server state == {#Port<0.98>,[]} ** Reason for termination == ** {port_died,normal} Does anyone have any ideas what could be wrong? /Anders From erlangx@REDACTED Thu Aug 23 22:02:01 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Thu, 23 Aug 2007 13:02:01 -0700 Subject: [erlang-questions] crypto:start() fails on SPARC Solaris 9 In-Reply-To: References: Message-ID: <20070823200200.GL23220@delora.autosys.us> though the thread is regarding Linux, mssrs google returns the following as the first link: https://launchpad.net/ubuntu/+source/erlang/+bug/68163 when provided with search string: erlang crypto:start Some of the information looks pertinent to any *nix flavor. ~Michael On Thu, Aug 23, 2007 at 12:57:45PM -0500, Anders Nygren wrote: > Hi > I am having a problem with R11B-4 on Solaris 9 SPARC. > > bash-2.05$ uname -a > SunOS testing 5.9 Generic_118558-25 sun4u sparc SUNW,Ultra-5_10 > > When I try to start crypto I get > > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] > [kernel-poll:false] > Eshell V5.5.4 (abort with ^G) > 1> crypto:start(). > sh: crypto_drv: not found > sh: crypto_drv: not found > > =ERROR REPORT==== 23-Aug-2007::12:47:44 === > ** Generic server crypto_server terminating > ** Last message in was {'EXIT',#Port<0.98>,normal} > ** When Server state == {#Port<0.98>,[]} > ** Reason for termination == > ** {port_died,normal} > > > Does anyone have any ideas what could be wrong? > > /Anders > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,46cdcab973321477453396! > > From kenneth.lundin@REDACTED Thu Aug 23 23:00:41 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 23 Aug 2007 23:00:41 +0200 Subject: [erlang-questions] erl -make exit status In-Reply-To: <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> Message-ID: Hi, On 8/23/07, Michael Campbell wrote: > On 8/23/07, Kenneth Lundin wrote: > > Hi, > > > > What is your real problem? > > Is it the fact that "erl -make" doesn't return an exit code to the shell? > > Or is it the "can't find include lib" thing? > > I can't answer your question to the OP there, but it seems a bit much > to call a usable return code a qualification of a "heavy duty" build > tool, no? As it is, you can't even script the thing reliably. > It seems that you misunderstood what I wrote in my earlier post. Maybe it gets clearer if I say like this: I think that erl -make should return a usable return code (to the Unix or similar shell), we will look at that. But fixing this still does not make the "make" module suitable for heavy duty building, there is far to many functions missing for that. The make module has been around for + 10 years now with only minor enhancements during that time. So obviously we have not got many or any complaints about "erl -make" and the lack of useful return code. T his indicates that the invokation via "erl -make" is very rarely used. The dominating use is make:all() from the Erlang shell. /Kenneth > From klacke@REDACTED Thu Aug 23 23:32:26 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Thu, 23 Aug 2007 23:32:26 +0200 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46CCFBB2.1060501@gmail.com> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <46CCB564.7000004@hyber.org> <46CCFBB2.1060501@gmail.com> Message-ID: <46CDFCEA.4000408@hyber.org> Serge Aleynikov wrote: > Despite the fact that aborting the application is also what's > implemented in the tutorial, this may seem questionable to be "the only" > reasonable recovery action as for some servers EMFILE can be a temporary > condition. Suppose there was a spike of short-lived client connections > when the server might have hit the limit of file descriptors. As some > client connections disconnect, the server's gen_tcp:accept/1 call may > recover automatically. I could speculate that in selected cases it may > be more expensive to failover/recover state of some applications in a > node then to attempt several retries in a timely manner. > Agreed, the hitch is how to - programatically - differentiate the cases "temporary condition" and "permanently fucked". For most websites the "permanently fucked" is more probable than "temporary condition". My laptop mac: [klacke@REDACTED]~ > ulimit -n 10240 When was the last time you had 10240 simultaneous HTTP connections. My shoddy sites sure dont get that :-) Anyway, that was just a case for the probability - In general I agree with you. Maybe try to redo the accept() .. say 10 times and then bail out Hmmmm... /klacke From klacke@REDACTED Thu Aug 23 23:53:40 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Thu, 23 Aug 2007 23:53:40 +0200 Subject: [erlang-questions] View patterns In-Reply-To: <59101FF2-CF4F-4B4B-9C51-C1DBAB1B03C5@cs.otago.ac.nz> References: <200707251056.34272.als@iinet.net.au> <59101FF2-CF4F-4B4B-9C51-C1DBAB1B03C5@cs.otago.ac.nz> Message-ID: <46CE01E4.2020501@hyber.org> > One of the things which is about to be added to GHC is view patterns. > The idea is that if E is an expression and P is a pattern, then > (E -> P) > is a pattern. This pattern matches a value V if and only if > P = (E)(V). > what a thoroughly disgusting idea - it makes the LOC count shrink at the expense of unreadability. /klacke From anders.nygren@REDACTED Fri Aug 24 01:29:08 2007 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 23 Aug 2007 18:29:08 -0500 Subject: [erlang-questions] crypto:start() fails on SPARC Solaris 9 In-Reply-To: <20070823200200.GL23220@delora.autosys.us> References: <20070823200200.GL23220@delora.autosys.us> Message-ID: On 8/23/07, Michael McDaniel wrote: > though the thread is regarding Linux, mssrs google returns the > following as the first link: > > https://launchpad.net/ubuntu/+source/erlang/+bug/68163 > > > when provided with search string: > > erlang crypto:start > > > Some of the information looks pertinent to any *nix flavor. > It was indeed a compiler problem. I upgraded to gcc 3.4.6 and it is now working. /Anders From michael.campbell@REDACTED Fri Aug 24 01:44:42 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Thu, 23 Aug 2007 19:44:42 -0400 Subject: [erlang-questions] Spanking new neophyte seeks guidance Message-ID: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> Hello everyone, I was wondering if someone might point me in the right direction. I'm a professional developer and have a pretty solid, albeit imperative background for the last 20 or so years. I have long wanted to get my head around functional programming, and have picked up Erlang recently; as in about a week ago. I don't quite know /why/, but for some reason this language has really excited me. Haven't felt this way about a language in a long time (year and language left as an exercise for the reader). I'm reading Joe's "Programming Erlang" book, and am slowly picking up the syntax, and TRYING to get the idioms. I hope that will come with use and practice. Ok, so, I'm reading that book, trapexit, any blogs I can find, looking at code samples, etc. What I was wondering is if there were any canonical types of exercises, or tutorials with exercises, etc. that will help me along this journey? And lastly, I'll inevitably have really, really basic questions I'm sure. Is this the place for those, or if not, where? Thanks, Michael From parlar@REDACTED Fri Aug 24 03:05:54 2007 From: parlar@REDACTED (Jay Parlar) Date: Thu, 23 Aug 2007 21:05:54 -0400 Subject: [erlang-questions] Spanking new neophyte seeks guidance In-Reply-To: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> References: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> Message-ID: On 8/23/07, Michael Campbell wrote: > Hello everyone, > > I was wondering if someone might point me in the right direction. I'm > a professional developer and have a pretty solid, albeit imperative > background for the last 20 or so years. I have long wanted to get my > head around functional programming, and have picked up Erlang > recently; as in about a week ago. > > I don't quite know /why/, but for some reason this language has really > excited me. Haven't felt this way about a language in a long time > (year and language left as an exercise for the reader). > > I'm reading Joe's "Programming Erlang" book, and am slowly picking up > the syntax, and TRYING to get the idioms. I hope that will come with > use and practice. Ok, so, I'm reading that book, trapexit, any blogs > I can find, looking at code samples, etc. What I was wondering is if > there were any canonical types of exercises, or tutorials with > exercises, etc. that will help me along this journey? > > And lastly, I'll inevitably have really, really basic questions I'm > sure. Is this the place for those, or if not, where? I'm in the exact same situation. Long time Python developer, excited by all the recent Erlang talk in the Python community, learning from the book. If you haven't found them yet, there's a lot of stuff on erlang.org under "Examples". Haven't had time to go through them yet (still working through the book), but it looks like there's some decent stuff there. Jay P. From michael.campbell@REDACTED Fri Aug 24 03:24:50 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Thu, 23 Aug 2007 21:24:50 -0400 Subject: [erlang-questions] erl -make exit status In-Reply-To: References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> <811f2f1c0708230930p4b11de13i8aa05ef201f4a336@mail.gmail.com> Message-ID: <811f2f1c0708231824x403b6da6x4a3f554570ba5876@mail.gmail.com> > It seems that you misunderstood what I wrote in my earlier post. Very likely. > But fixing this still does not make the "make" module suitable for > heavy duty building, there is far to many functions missing for that. Yup, fair enough. Thanks! From KONGA@REDACTED Fri Aug 24 06:08:33 2007 From: KONGA@REDACTED (Anthony Kong) Date: Fri, 24 Aug 2007 14:08:33 +1000 Subject: [erlang-questions] Spanking new neophyte seeks guidance In-Reply-To: References: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> Message-ID: <46CEE65E.664A.00DD.0@stgeorge.com.au> I am in more or less situation as you. I am a Java programmer by trade, and python programmer by hobby :-) This is just an idea: I have subscribed to the RSS feed from planet trapexit and from time to time I find some fun little thing people do with erlang e.g. write binary search in erlang. I think 'reinventing some wheels' (i.e. getting your hand dirty) is the best way to learn. I have set up a blog for this purpose http://erlang-python-java.blogspot.com/. Hopefully when I get around to finish something worth goes public in the blog, I can solicit some feedback from the community. Cheers, Anthony >>> "Jay Parlar" 24/08/2007 11:05 am >>> On 8/23/07, Michael Campbell wrote: > Hello everyone, > > I was wondering if someone might point me in the right direction. I'm > a professional developer and have a pretty solid, albeit imperative > background for the last 20 or so years. I have long wanted to get my > head around functional programming, and have picked up Erlang > recently; as in about a week ago. > > I don't quite know /why/, but for some reason this language has really > excited me. Haven't felt this way about a language in a long time > (year and language left as an exercise for the reader). > > I'm reading Joe's "Programming Erlang" book, and am slowly picking up > the syntax, and TRYING to get the idioms. I hope that will come with > use and practice. Ok, so, I'm reading that book, trapexit, any blogs > I can find, looking at code samples, etc. What I was wondering is if > there were any canonical types of exercises, or tutorials with > exercises, etc. that will help me along this journey? > > And lastly, I'll inevitably have really, really basic questions I'm > sure. Is this the place for those, or if not, where? I'm in the exact same situation. Long time Python developer, excited by all the recent Erlang talk in the Python community, learning from the book. If you haven't found them yet, there's a lot of stuff on erlang.org under "Examples". Haven't had time to go through them yet (still working through the book), but it looks like there's some decent stuff there. Jay P. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions ********************************************************************** ***** IMPORTANT INFORMATION ***** This document should be read only by those persons to whom it is addressed and its content is not intended for use by any other persons. If you have received this message in error, please notify us immediately. Please also destroy and delete the message from your computer. Any unauthorised form of reproduction of this message is strictly prohibited. St.George Bank Limited AFSL 240997, Advance Asset Management Limited AFSL 240902, St.George Life Limited AFSL 240900, ASGARD Capital Management Limited AFSL 240695 and Securitor Financial Group Limited AFSL 240687 is not liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt. ********************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From doug.mansell@REDACTED Fri Aug 24 08:53:39 2007 From: doug.mansell@REDACTED (doug mansell) Date: Fri, 24 Aug 2007 08:53:39 +0200 Subject: [erlang-questions] Spanking new neophyte seeks guidance In-Reply-To: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> References: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> Message-ID: Hi Michael, I had a similar feeling with Erlang when I started looking at it a couple of years ago. I read a lot but my learning accelerated when I took a problem domain I was familiar with (DICOM decoding) and reimplemented my C++ library in Erlang. It was slow at first translating the imperative things, but then you get the hang of it. Some of the patterns and solutions I came up with in Erlang then informed my third gen C# library. Unexpected! I write in a functional style as much as I can these days. That was a library, now I'm building a system with Mnesia and Orber and learning about otp and applications and releases and all those good things. Lots of fun. :) Enjoy. On 8/24/07, Michael Campbell wrote: > Hello everyone, > > I was wondering if someone might point me in the right direction. I'm > a professional developer and have a pretty solid, albeit imperative > background for the last 20 or so years. I have long wanted to get my > head around functional programming, and have picked up Erlang > recently; as in about a week ago. > > I don't quite know /why/, but for some reason this language has really > excited me. Haven't felt this way about a language in a long time > (year and language left as an exercise for the reader). > > I'm reading Joe's "Programming Erlang" book, and am slowly picking up > the syntax, and TRYING to get the idioms. I hope that will come with > use and practice. Ok, so, I'm reading that book, trapexit, any blogs > I can find, looking at code samples, etc. What I was wondering is if > there were any canonical types of exercises, or tutorials with > exercises, etc. that will help me along this journey? > > And lastly, I'll inevitably have really, really basic questions I'm > sure. Is this the place for those, or if not, where? > > Thanks, > > Michael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From raimo+erlang-questions@REDACTED Fri Aug 24 09:24:05 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 24 Aug 2007 09:24:05 +0200 Subject: [erlang-questions] Spanking new neophyte seeks guidance In-Reply-To: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> References: <811f2f1c0708231644r5a86a994raf4d49cbffc297ae@mail.gmail.com> Message-ID: <20070824072405.GA10823@erix.ericsson.se> On Thu, Aug 23, 2007 at 07:44:42PM -0400, Michael Campbell wrote: > Hello everyone, > : > And lastly, I'll inevitably have really, really basic questions I'm > sure. Is this the place for those, or if not, where? > This (erlang-questions@REDACTED) is not a bad place for a few odd really, really basic questions. Neither is the forums at trapexit. > Thanks, > > Michael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From mats.cronqvist@REDACTED Fri Aug 24 09:40:49 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 24 Aug 2007 09:40:49 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> Message-ID: <46CE8B81.9020006@ericsson.com> On 2007-08-16 10:52, Joe Armstrong wrote: > [...] > (Actually we dont use ? any more so we could say A ? B instead of A !! B > this might be even better - it saves one character and the ? clearly > indicates the intent) if only... but as far as i know '?' is munched by the preprocessor. also, i think that if anything '?' should be used instead of 'receive' (the way God, or at least Tony Hoare, intended). mats From jakob@REDACTED Fri Aug 24 09:48:33 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Fri, 24 Aug 2007 09:48:33 +0200 Subject: [erlang-questions] Accessing COM/OLE/ActiveX In-Reply-To: <46CC79B1.2050004@kleinfelter.com> References: <46CC79B1.2050004@kleinfelter.com> Message-ID: <46CE8D51.7050602@erix.ericsson.se> Nothing took it's place... However, you can still get Comet from an older relase, Erlang/OTP 5.1 (R8B) is the last one, and recompile it with a newer erlang release. (Note that the driver interface has changed a bit.) /Jakob Kevin Kleinfelter wrote: > When Comet was removed from the Erlang distribution, what took its > place? i.e. Now that Comet is gone, how does a program access a COM > object on the Windows platform? > > TIA > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From lcoquelle@REDACTED Fri Aug 24 10:02:41 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Fri, 24 Aug 2007 16:02:41 +0800 Subject: [erlang-questions] edoc: grouping functions Message-ID: Hi, Is there any way using edoc to create a group of function (like functions retrieving info, functions updating data, callback of behaviour ...) ? Also, is there an easy way to change the order in the function index? From mats.cronqvist@REDACTED Fri Aug 24 10:34:10 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 24 Aug 2007 10:34:10 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46C413BF.3020301@it.uu.se> References: <46C413BF.3020301@it.uu.se> Message-ID: <46CE9802.4010505@ericsson.com> On 2007-08-16 11:07, Richard Carlsson wrote: > I'd like to encourage everyone on > this list to keep thinking about how Erlang process communication could > be made even simpler and more streamlined. Plain asynchronous message > passing (with selective receive) is a powerful yet simple building block > but it is still rather primitive, and often, Erlang programmers (myself > included) will neglect to think too far about what might happen if > messages are lost, timeouts occur, or messages arrive in an unexpected > order. We tend to go back and fix those bugs when they bite us, but it > would be better if we were using communication constructs that came with > certain guarantees to begin with; like the difference between goto- > programming and structured language constructs like while/for/case. i read somewhere that "an idiom indicates a missing feature." (or maybe i just made it up?) in any case, i tend to use this idiom a lot, and i think it does indeed indicate a missing language feature. safe_send(Pid,Msg) -> Ref = erlang:monitor(process,Pid), Pid ! {Ref,self(),Msg}, receive {'DOWN',Ref,_,_,R} -> exit({no_receiver,R,Pid}); {Ref,Ans} -> erlang:demonitor(Ref), receive {_,Ref,_,_,_} -> ok after 0 -> ok end, Ans end. the caller of safe_send/2 will receive either an answer from Pid, or an exit(*). i'm not proposing safe_send/2 to become part of OTP (i haven't even compiled this particular version). my point is just that there is a need for a version of '!' that guarantees that the message was delivered. mats (*) of course, the code running in Pid must look something like this; receive {Ref,Pid,Msg} -> Pid ! {Ref,handle(Msg)} end From saleyn@REDACTED Fri Aug 24 14:58:13 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 24 Aug 2007 07:58:13 -0500 Subject: [erlang-questions] Building a Non-blocking TCP server using OTP principles In-Reply-To: <46CDFCEA.4000408@hyber.org> References: <4bd555f70708162059g4e8449dcsa21820b0fd2a284a@mail.gmail.com> <46C59CDD.3020200@gmail.com> <46CCB564.7000004@hyber.org> <46CCFBB2.1060501@gmail.com> <46CDFCEA.4000408@hyber.org> Message-ID: <46CED5E5.1070309@gmail.com> Claes Wikstrom wrote: > Maybe try to redo the accept() .. say 10 times and then bail out > Hmmmm... Or, perhaps, stop accepting new connections if the number of active connections is close or equal to the known limit. Why would newly accepted client connections be favored over the existing good ones that may be processing data? If the situation doesn't heal in some period of time - kill some client connections that haven't shown recent activity. I agree that recovery can be tricky if one's goal is to keep the service alive, but this is beyond the subject of this thread. ;-) Serge From joelr1@REDACTED Fri Aug 24 13:57:38 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 24 Aug 2007 12:57:38 +0100 Subject: [erlang-questions] Reading a term from a string Message-ID: <5521C09B-C40C-4567-94F5-7791A0204F7D@gmail.com> How do you read, say, a list of tuples from a string? Thanks, Joel -- http://wagerlabs.com From dmercer@REDACTED Fri Aug 24 17:05:52 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 24 Aug 2007 10:05:52 -0500 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46CE9802.4010505@ericsson.com> References: <46C413BF.3020301@it.uu.se> <46CE9802.4010505@ericsson.com> Message-ID: <012101c7e660$43f2c120$891ea8c0@SSI.CORP> On Friday, August 24, 2007 at 03:34 Mats Cronqvist wrote: > in any case, i tend to use this idiom a lot, and i think it does > indeed indicate a missing language feature. > > safe_send(Pid,Msg) -> > Ref = erlang:monitor(process,Pid), > Pid ! {Ref,self(),Msg}, > receive > {'DOWN',Ref,_,_,R} -> > exit({no_receiver,R,Pid}); > {Ref,Ans} -> > erlang:demonitor(Ref), > receive {_,Ref,_,_,_} -> ok after 0 -> ok end, > Ans > end. I like your use of Ref to identify which message is the reply to your request. I was using make_ref/0 before for this, but your way is better. Your demonitor-receive instructions can be condensed into one line: erlang:demonitor(Ref, [flush]) Cheers, David From dmercer@REDACTED Fri Aug 24 17:15:53 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 24 Aug 2007 10:15:53 -0500 Subject: [erlang-questions] Error vs. Exit Message-ID: <012201c7e661$aa571b40$891ea8c0@SSI.CORP> How do you decide whether to use erlang:error/1, erlang:error/2, and exit/1? I can't quite grok the distinction between "when you really want to terminate the current process" and "something rather nasty has happened that callers are not really expected to handle." Please advise. Thank-you. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcaoyuan@REDACTED Fri Aug 24 17:33:06 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Fri, 24 Aug 2007 23:33:06 +0800 Subject: [erlang-questions] Reading a term from a string In-Reply-To: <5521C09B-C40C-4567-94F5-7791A0204F7D@gmail.com> References: <5521C09B-C40C-4567-94F5-7791A0204F7D@gmail.com> Message-ID: Did you mean: > TupleListStr = "[{a, b, c}, {d, e}]". "[{a, b, c}, {d, e}]" > {ok, TermTokens, _EndLine} = erl_scan:string(TupleListStr ++ "."). {ok,[{'[',1}, {'{',1}, {atom,1,a}, {',',1}, {atom,1,b}, {',',1}, {atom,1,c}, {'}',1}, {',',1}, {'{',1}, {atom,1,d}, {',',1}, {atom,1,e}, {'}',1}, {']',1}, {dot,1}], 1} > {ok, Exprs} = erl_parse:parse_exprs(TermTokens). {ok,[{cons,1, {tuple,1,[{atom,1,a},{atom,1,b},{atom,1,c}]}, {cons,1,{tuple,1,[{atom,1,d},{atom,1,e}]},{nil,1}}}]} > {value, TupleList, _NewBindings} = erl_eval:exprs(Exprs, []). {value,[{a,b,c},{d,e}],[]} > TupleList. [{a,b,c},{d,e}] On 8/24/07, Joel Reymont wrote: > How do you read, say, a list of tuples from a string? > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- - Caoyuan From dave@REDACTED Fri Aug 24 17:42:23 2007 From: dave@REDACTED (David Johnson) Date: Fri, 24 Aug 2007 16:42:23 +0100 Subject: [erlang-questions] Mathematical Library Message-ID: <46CEFC5F.3040207@g4dpz.me.uk> Hi, Is there a math library for Erlang I.e trig, log etc Regards Dave Johnson From joelr1@REDACTED Fri Aug 24 17:50:43 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 24 Aug 2007 16:50:43 +0100 Subject: [erlang-questions] Reading a term from a string In-Reply-To: References: <5521C09B-C40C-4567-94F5-7791A0204F7D@gmail.com> Message-ID: <0B67FC61-BA16-4F09-A12E-FE6A4B7A1E7C@gmail.com> Yes, thank you! On Aug 24, 2007, at 4:33 PM, Caoyuan wrote: > Did you mean: > >> TupleListStr = "[{a, b, c}, {d, e}]". > "[{a, b, c}, {d, e}]" >> {ok, TermTokens, _EndLine} = erl_scan:string(TupleListStr ++ "."). -- http://wagerlabs.com From dmercer@REDACTED Fri Aug 24 18:04:43 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 24 Aug 2007 11:04:43 -0500 Subject: [erlang-questions] Mathematical Library In-Reply-To: <46CEFC5F.3040207@g4dpz.me.uk> References: <46CEFC5F.3040207@g4dpz.me.uk> Message-ID: <013101c7e668$7c2e39e0$891ea8c0@SSI.CORP> On Friday, August 24, 2007 at 10:42, David Johnson wrote: > Is there a math library for Erlang I.e trig, log etc The math module comes standard. Has trig and log. Documentation at http://www.erlang.org/doc/man/math.html Cheers, David From dmercer@REDACTED Fri Aug 24 18:02:49 2007 From: dmercer@REDACTED (David Mercer) Date: Fri, 24 Aug 2007 11:02:49 -0500 Subject: [erlang-questions] Mathematical Library In-Reply-To: <46CEFC5F.3040207@g4dpz.me.uk> References: <46CEFC5F.3040207@g4dpz.me.uk> Message-ID: <012d01c7e668$3908be10$891ea8c0@SSI.CORP> On Friday, August 24, 2007 at 10:42, David Johnson wrote: > Is there a math library for Erlang I.e trig, log etc The math module comes standard. Has trig and log. Documentation at http://www.erlang.org/doc/man/math.html Cheers, David From richardc@REDACTED Fri Aug 24 18:23:37 2007 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 24 Aug 2007 18:23:37 +0200 Subject: [erlang-questions] Error vs. Exit In-Reply-To: <012201c7e661$aa571b40$891ea8c0@SSI.CORP> References: <012201c7e661$aa571b40$891ea8c0@SSI.CORP> Message-ID: <46CF0609.80909@it.uu.se> David Mercer wrote: > How do you decide whether to use erlang:error/1, erlang:error/2, and > exit/1? I can?t quite grok the distinction between ?when you really > want to terminate the current process? and ?something rather nasty has > happened that callers are not really expected to handle.? Please > advise. Thank-you. In the exit/1 case, your code is aware that it is part of a network of processes, and has decided that it has reached a state where it needs to bail out and let any listening processes know about this. Preferably, the set of such exit signals should be documented as part of the possible behaviour of the process (e.g., as part of the documentation of the function(s) used to spawn the process). Code further up in the call chain should hence not catch 'exit' exceptions except in special cases (since it changes the visible process behaviour). A concise way of thinking about it is that exit/1 is like throw/1, but between processes, not between function calls. (Recall that a throw is expected to be caught somewhere before it falls out of the initial call of the executing process - if it does not, it gets rewritten into an error-class exception). With exit(Term), the message sent to linked processes has the form {'EXIT', Pid, Term}, that is, you have more precise control over the Term part, and no messy stack trace is included. This makes it simpler for other processes to match on the exit message. In the error/1 case, your code does not know or care about the process context in which it is used - it just provides some general library functionality. By using error/1, you get a behaviour just like that in built-in functions and operators (e.g., X/0, or 17+'true'). If this kind of exception causes the executing process to terminate, it is not considered normal process behaviour; the message sent to other processes will look like {'EXIT',Pid,{Term,StackTrace}}, and furthermore the event will be written to the error logger, which does not happen for exit/1. /Richard From dave@REDACTED Fri Aug 24 18:58:43 2007 From: dave@REDACTED (David Johnson) Date: Fri, 24 Aug 2007 17:58:43 +0100 Subject: [erlang-questions] Mathematical Library In-Reply-To: <013101c7e668$7c2e39e0$891ea8c0@SSI.CORP> References: <46CEFC5F.3040207@g4dpz.me.uk> <013101c7e668$7c2e39e0$891ea8c0@SSI.CORP> Message-ID: <46CF0E43.7010008@g4dpz.me.uk> Hi David, Thanks very much, just what I want for my application. Can feel a port to Erlang coming on. Regards Dave David Mercer wrote: > On Friday, August 24, 2007 at 10:42, David Johnson wrote: >> Is there a math library for Erlang I.e trig, log etc > > The math module comes standard. Has trig and log. Documentation at > http://www.erlang.org/doc/man/math.html > > Cheers, > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- 73 Dave G4DPZ www.g4dpz.me.uk AMSAT-UK Committee Member www.uk.amsat.org AMSAT_NA Life Member www.amsat.org From tomas.abrahamsson@REDACTED Fri Aug 24 23:10:01 2007 From: tomas.abrahamsson@REDACTED (Tomas Abrahamsson) Date: Fri, 24 Aug 2007 23:10:01 +0200 Subject: [erlang-questions] erl -make exit status In-Reply-To: <20070823135826.GB31070@sphinx.chicagopeoplez.org> References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> Message-ID: On 8/23/07, David Terrell wrote: > % erlc -o ebin src/*.erl > src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" > % echo $? > 1 > > % cat Emakefile > {'src/*', [debug_info, {outdir, "ebin"}]}. > % erl -make > Recompile: src/my_test > src/my_test.erl:5: can't find include lib "eunit/include/eunit.hrl" > % echo %? > 0 > > This is making it hard to use emake in my continuous integration > system... any suggestions? Is emake considered production ready? [one more try, missed sending to the list last time :-)] Here's one way to run erl -make and get a usable exit code: erl -noinput +B -eval 'case make:all() of up_to_date -> halt(0); error -> halt(1) end.' /Tomas From dvrsn@REDACTED Sat Aug 25 00:34:16 2007 From: dvrsn@REDACTED (Jeff Rogers) Date: Fri, 24 Aug 2007 15:34:16 -0700 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46CE8B81.9020006@ericsson.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> <46CE8B81.9020006@ericsson.com> Message-ID: <46CF5CE8.9040302@diphi.com> Mats Cronqvist wrote: > On 2007-08-16 10:52, Joe Armstrong wrote: >> [...] >> (Actually we dont use ? any more so we could say A ? B instead of A !! B >> this might be even better - it saves one character and the ? clearly >> indicates the intent) > > if only... but as far as i know '?' is munched by the preprocessor. > > also, i think that if anything '?' should be used instead of > 'receive' (the way God, or at least Tony Hoare, intended). > > mats Could a parse transform recognize the case where the value A ! B is not discarded and change those cases into some kind of synchronous call? So that A = spawn(...), A ! whatever, ok. is a async call but A = spawn(...), B = A ! whatever, B. is a synchronous call. The return value of ! is normally just the value that was sent, which doesn't seem very useful. The only places where it would not be immediately evident if the return value is ignored is when a function or Fun evaluates to a send. Even so, ! normally looks like an imperative operator more than a functional one so this seems to make it more functional (but also lazy in some respects, which is anti-erlang/soft-rt) -J From rvirding@REDACTED Sat Aug 25 01:32:48 2007 From: rvirding@REDACTED (Robert Virding) Date: Sat, 25 Aug 2007 01:32:48 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46CF5CE8.9040302@diphi.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> <46CE8B81.9020006@ericsson.com> <46CF5CE8.9040302@diphi.com> Message-ID: <3dbc6d1c0708241632j5f61d7f4h32cbb071a94fd37f@mail.gmail.com> On 25/08/07, Jeff Rogers wrote: > > Mats Cronqvist wrote: > > On 2007-08-16 10:52, Joe Armstrong wrote: > >> [...] > >> (Actually we dont use ? any more so we could say A ? B instead of A !! > B > >> this might be even better - it saves one character and the ? clearly > >> indicates the intent) > > > > if only... but as far as i know '?' is munched by the preprocessor. > > > > also, i think that if anything '?' should be used instead of > > 'receive' (the way God, or at least Tony Hoare, intended). > > > > mats > > Could a parse transform recognize the case where the value A ! B is not > discarded and change those cases into some kind of synchronous call? So > that > > A = spawn(...), > A ! whatever, > ok. > > is a async call but > > A = spawn(...), > B = A ! whatever, > B. > > is a synchronous call. The return value of ! is normally just the value > that was sent, which doesn't seem very useful. The only places where it > would not be immediately evident if the return value is ignored is when > a function or Fun evaluates to a send. Even so, ! normally looks like > an imperative operator more than a functional one so this seems to make > it more functional (but also lazy in some respects, which is > anti-erlang/soft-rt) That would result in forcing people to write some really weird code. I could never for example just end a function with a normal async send as that would be interpreted as sync send. Generally the idea of having the semantics of something change depending on what comes after seems a little off. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dvrsn@REDACTED Sat Aug 25 02:22:17 2007 From: dvrsn@REDACTED (Jeff Rogers) Date: Fri, 24 Aug 2007 17:22:17 -0700 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <3dbc6d1c0708241632j5f61d7f4h32cbb071a94fd37f@mail.gmail.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> <46CE8B81.9020006@ericsson.com> <46CF5CE8.9040302@diphi.com> <3dbc6d1c0708241632j5f61d7f4h32cbb071a94fd37f@mail.gmail.com> Message-ID: <46CF7639.7090109@diphi.com> Robert Virding wrote: >> Could a parse transform recognize the case where the value A ! B is not >> discarded and change those cases into some kind of synchronous call? So >> that >> >> A = spawn(...), >> A ! whatever, >> ok. >> >> is a async call but >> >> A = spawn(...), >> B = A ! whatever, >> B. >> >> is a synchronous call. The return value of ! is normally just the value >> that was sent, which doesn't seem very useful. The only places where it >> would not be immediately evident if the return value is ignored is when >> a function or Fun evaluates to a send. Even so, ! normally looks like >> an imperative operator more than a functional one so this seems to make >> it more functional (but also lazy in some respects, which is >> anti-erlang/soft-rt) > > > That would result in forcing people to write some really weird code. I could > never for example just end a function with a normal async send as that would > be interpreted as sync send. I think the opposite would be true - since the compiler (or rather, parse transformer) can only see the immediate surroundings it can make no assumption about other scopes; since it would be new semantics the safe assumption would always be that the old semantics are the default. So you would not be able to end your function with a synchronous send because it would be interpreted as async; you would need to jump through a hoop to send with a sync call. From my very limited understanding of how the AST works, it would need a very simple transform like {match,Ln,L0,{op,SLn,'!',L1,R1}} -> {match,Ln,L0,{call,SLn,{atom,SLn,sync_send},[L1,R1]}} to change "A = B ! C" into "A = sync_send(B,C)" and that wouldn't touch any other syntax. > Generally the idea of having the semantics of something change depending on > what comes after seems a little off. It would be what comes before it, not after it. I would agree that radically changing the semantics of the expression based on external surrounding syntax is odd at best, but I think it could be useful and not terribly confusing (other than the issues that have already been raised about how to specify the behavior of the synchronous call) . -J From md@REDACTED Sat Aug 25 07:11:38 2007 From: md@REDACTED (Maximillian Dornseif) Date: Fri, 24 Aug 2007 22:11:38 -0700 (PDT) Subject: [erlang-questions] io:format vs io_lib:format Message-ID: <12323263.post@talk.nabble.com> I understand that io:format and io_lib:format are to erlang what printf and sprintf are to C. So I wonder why I get different results from them. What am I missing here? 42> [io:format("01-~2.10.0B-01~n", [N]) || N <- lists:seq(1, 3)]. 01-01-01 01-02-01 01-03-01 01-04-01 01-05-01 01-06-01 01-07-01 01-08-01 01-09-01 01-10-01 01-11-01 01-12-01 [ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok] 43> [io_lib:format("01-~2.10.0B-01~n", [N]) || N <- lists:seq(1, 12)]. [[48,49,45,["0","1"],45,48,49,"\n"], [48,49,45,["0","2"],45,48,49,"\n"], [48,49,45,["0","3"],45,48,49,"\n"], [48,49,45,["0","4"],45,48,49,"\n"], [48,49,45,["0","5"],45,48,49,"\n"], [48,49,45,["0","6"],45,48,49,"\n"], [48,49,45,["0","7"],45,48,49,"\n"], [48,49,45,["0","8"],45,48,49,"\n"], [48,49,45,["0","9"],45,48,49,"\n"], [48,49,45,"10",45,48,49,"\n"], [48,49,45,"11",45,48,49,"\n"], [48,49,45,"12",45,48,49,"\n"]] The obvious solution is to use lists:flatten(io_lib:format(...)) but why? Regards Maximillian Dornseif -- View this message in context: http://www.nabble.com/io%3Aformat-vs-io_lib%3Aformat-tf4326912.html#a12323263 Sent from the Erlang Questions mailing list archive at Nabble.com. From chsu79@REDACTED Sat Aug 25 11:00:13 2007 From: chsu79@REDACTED (Christian S) Date: Sat, 25 Aug 2007 11:00:13 +0200 Subject: [erlang-questions] io:format vs io_lib:format In-Reply-To: <12323263.post@talk.nabble.com> References: <12323263.post@talk.nabble.com> Message-ID: 2007/8/25, Maximillian Dornseif : > 43> [io_lib:format("01-~2.10.0B-01~n", [N]) || N <- lists:seq(1, 12)]. > [[48,49,45,["0","1"],45,48,49,"\n"], > [48,49,45,["0","2"],45,48,49,"\n"], ... Do you understand the concept of iolists() ? Check out erlang:iolist_to_binary/1 and erlang:iolist_size/1. Flattening is simply not necessary when writing to files or sending over sockets or directly to ports. [io:put_chars(io_lib:format("01-~2.10.0B-01~n", [N])) || N <- lists:seq(1, 12)]. From juanjo@REDACTED Sat Aug 25 19:43:28 2007 From: juanjo@REDACTED (Juan Jose Comellas) Date: Sat, 25 Aug 2007 14:43:28 -0300 Subject: [erlang-questions] Erlang article Message-ID: <1c3be50f0708251043l7bf7affcre75b3deb73117d7d@mail.gmail.com> There's an Erlang article at http://www.simplexit.com.ar/ that may be interesting for the Spanish speakers in the list. The complete link is: http://www.simplexit.com.ar/editorial/simplex/notas/numero23/0dae3de0-358f-4202-9e4c-b5e0902e15f3.articulo-compuesto/index-detalle.html?produccion=editorial/simplex/notas/numero23/66914962-10ec-45e4-aa70-1d2add4968aa.produccion-contenidos# -------------- next part -------------- An HTML attachment was scrubbed... URL: From als@REDACTED Sat Aug 25 21:10:32 2007 From: als@REDACTED (Anthony Shipman) Date: Sun, 26 Aug 2007 05:10:32 +1000 Subject: [erlang-questions] io:format vs io_lib:format In-Reply-To: <12323263.post@talk.nabble.com> References: <12323263.post@talk.nabble.com> Message-ID: <200708260510.32773.als@iinet.net.au> On Saturday 25 August 2007 15:11, Maximillian Dornseif wrote: > I understand that io:format and io_lib:format are to erlang what printf > and sprintf are to C. So I wonder why I get different results from them. > What am I missing here? ........... > > The obvious solution is to use lists:flatten(io_lib:format(...)) but why? > > Regards > > Maximillian Dornseif The io_lib documentation says: There is no guarantee that the character lists returned from some of the functions are flat, they can be deep lists. lists:flatten/1 can be used for flattening deep lists. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From michael.campbell@REDACTED Sat Aug 25 22:54:29 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Sat, 25 Aug 2007 16:54:29 -0400 Subject: [erlang-questions] Erlang article In-Reply-To: <1c3be50f0708251043l7bf7affcre75b3deb73117d7d@mail.gmail.com> References: <1c3be50f0708251043l7bf7affcre75b3deb73117d7d@mail.gmail.com> Message-ID: <811f2f1c0708251354x5e410eadw24549cad75a700@mail.gmail.com> On 8/25/07, Juan Jose Comellas wrote: > There's an Erlang article at http://www.simplexit.com.ar/ that may be > interesting for the Spanish speakers in the list. The complete link is: > > http://www.simplexit.com.ar/editorial/simplex/notas/numero23/0dae3de0-358f-4202-9e4c-b5e0902e15f3.articulo-compuesto/index-detalle.html?produccion=editorial/simplex/notas/numero23/66914962-10ec-45e4-aa70-1d2add4968aa.produccion-contenidos# I just read it in English via google translate, and its remarkably easy to grok. Good article, especially for someone like me who is just starting. From michael.campbell@REDACTED Sat Aug 25 23:15:03 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Sat, 25 Aug 2007 17:15:03 -0400 Subject: [erlang-questions] GotAPI.com Message-ID: <811f2f1c0708251415u34dbc66fl134bc7d9bc6ce177@mail.gmail.com> This might be old news, but I see that http://gotapi.com has their whiz-bang AJAX-y typeahead suggest API searcher with an section Erlang now. I don't know when it was added; I typically only use it for java, but was pleased to see it. http://gotapi.com From paul-trapexit@REDACTED Sun Aug 26 01:17:34 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sat, 25 Aug 2007 16:17:34 -0700 (PDT) Subject: [erlang-questions] regular expressions on binaries Message-ID: Is there an analog to regexp available that works on binaries? Thanks in advance, -- p From bent@REDACTED Sun Aug 26 01:59:44 2007 From: bent@REDACTED (Ben Munat) Date: Sat, 25 Aug 2007 13:59:44 -1000 Subject: [erlang-questions] regular expressions on binaries In-Reply-To: References: Message-ID: <46D0C270.2030502@munat.com> I think you just want pattern matching on binaries: http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html b Paul Mineiro wrote: > Is there an analog to regexp available that works on binaries? > > Thanks in advance, > > -- p > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From paul-trapexit@REDACTED Sun Aug 26 03:35:39 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sat, 25 Aug 2007 18:35:39 -0700 (PDT) Subject: [erlang-questions] regular expressions on binaries In-Reply-To: <46D0C270.2030502@munat.com> References: <46D0C270.2030502@munat.com> Message-ID: I don't think I do. For instance: to implement "FOO(a|b)*BAR" I would write: -------- match_start (<<>>, _) -> nomatch; match_start (<<"FOO", R/binary>>, pos) -> match_end (R, pos, pos + 3); match_start (<<_:8, R/binary>>, pos) -> match_start (R, pos + 1). match_end (<<>>, _, _) -> nomatch; match_end (<<"BAR", _/binary>>, start, end) -> { match, start, end }; match_end (<<$a:8, R/binary>>, start, end) -> match_end (R, start, end + 1); match_end (<<$b:8, R/binary>>, start, end) -> match_end (R, start, end + 1). -------- To me that's seems tedious, likely to be incorrect (especially for more complicated patterns), and better done by a library. Is there a better way? -- p On Sat, 25 Aug 2007, Ben Munat wrote: > I think you just want pattern matching on binaries: > > http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html > > b > > > Paul Mineiro wrote: > > Is there an analog to regexp available that works on binaries? > > > > Thanks in advance, > > > > -- p > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rvirding@REDACTED Sun Aug 26 03:43:45 2007 From: rvirding@REDACTED (Robert Virding) Date: Sun, 26 Aug 2007 03:43:45 +0200 Subject: [erlang-questions] regular expressions on binaries In-Reply-To: References: <46D0C270.2030502@munat.com> Message-ID: <3dbc6d1c0708251843g158dfd74r91e827356840a79a@mail.gmail.com> I am working on a new regexp module which will work directly on binaries. Hopefully soon done. First version will have POSIX regexps. Robert On 26/08/07, Paul Mineiro wrote: > > I don't think I do. > > For instance: to implement "FOO(a|b)*BAR" I would write: > > -------- > > match_start (<<>>, _) -> nomatch; > match_start (<<"FOO", R/binary>>, pos) -> match_end (R, pos, pos + 3); > match_start (<<_:8, R/binary>>, pos) -> match_start (R, pos + 1). > > match_end (<<>>, _, _) -> nomatch; > match_end (<<"BAR", _/binary>>, start, end) -> { match, start, end }; > match_end (<<$a:8, R/binary>>, start, end) -> match_end (R, start, end + > 1); > match_end (<<$b:8, R/binary>>, start, end) -> match_end (R, start, end + > 1). > > -------- > > To me that's seems tedious, likely to be incorrect (especially for more > complicated patterns), and better done by a library. > > Is there a better way? > > -- p > > > On Sat, 25 Aug 2007, Ben Munat wrote: > > > I think you just want pattern matching on binaries: > > > > > http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html > > > > b > > > > > > Paul Mineiro wrote: > > > Is there an analog to regexp available that works on binaries? > > > > > > Thanks in advance, > > > > > > -- p > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Aug 26 03:59:16 2007 From: rvirding@REDACTED (Robert Virding) Date: Sun, 26 Aug 2007 03:59:16 +0200 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <46CF7639.7090109@diphi.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> <46CE8B81.9020006@ericsson.com> <46CF5CE8.9040302@diphi.com> <3dbc6d1c0708241632j5f61d7f4h32cbb071a94fd37f@mail.gmail.com> <46CF7639.7090109@diphi.com> Message-ID: <3dbc6d1c0708251859s115658beie48673d23ce6573b@mail.gmail.com> On 25/08/07, Jeff Rogers wrote: > > Robert Virding wrote: > > >> Could a parse transform recognize the case where the value A ! B is not > >> discarded and change those cases into some kind of synchronous > call? So > >> that > >> > >> A = spawn(...), > >> A ! whatever, > >> ok. > >> > >> is a async call but > >> > >> A = spawn(...), > >> B = A ! whatever, > >> B. > >> > >> is a synchronous call. The return value of ! is normally just the > value > >> that was sent, which doesn't seem very useful. The only places where > it > >> would not be immediately evident if the return value is ignored is when > >> a function or Fun evaluates to a send. Even so, ! normally looks like > >> an imperative operator more than a functional one so this seems to make > >> it more functional (but also lazy in some respects, which is > >> anti-erlang/soft-rt) > > > > > > That would result in forcing people to write some really weird code. I > could > > never for example just end a function with a normal async send as that > would > > be interpreted as sync send. > > I think the opposite would be true - since the compiler (or rather, > parse transformer) can only see the immediate surroundings it can make > no assumption about other scopes; since it would be new semantics the > safe assumption would always be that the old semantics are the default. > So you would not be able to end your function with a synchronous send > because it would be interpreted as async; you would need to jump > through a hoop to send with a sync call. > > From my very limited understanding of how the AST works, it would need > a very simple transform like > {match,Ln,L0,{op,SLn,'!',L1,R1}} -> > {match,Ln,L0,{call,SLn,{atom,SLn,sync_send},[L1,R1]}} > to change "A = B ! C" into "A = sync_send(B,C)" and that wouldn't touch > any other syntax. > Generally the idea of having the semantics of something change depending > on > > what comes after seems a little off. > > It would be what comes before it, not after it. I would agree that > radically changing the semantics of the expression based on external > surrounding syntax is odd at best, but I think it could be useful and > not terribly confusing (other than the issues that have already been > raised about how to specify the behavior of the synchronous call) . The problem is not whether it is difficult to do in the compiler but rather if we want to do it. Having the semantics of : A ! Msg and B = A ! Msg being different would be a first in the language and I personally think completely horrendous. Also the semantic difference between sending an async message and doing a sync rpc is VERY large. Also if you were to add one end of a sync message passing then you should also add the other end as well, both receiving the message and returning the reply. If instead it was defined to translate into a certain function call which you yourself then had to provide then that would also be a first, and I honestly don't see the benefit of it. Why not just write the function call yourself? Also there are people who use the return value of a send, not just as a side-effect. They won't be happy. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From lcoquelle@REDACTED Sun Aug 26 06:15:16 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Sun, 26 Aug 2007 12:15:16 +0800 Subject: [erlang-questions] GotAPI.com In-Reply-To: <811f2f1c0708251415u34dbc66fl134bc7d9bc6ce177@mail.gmail.com> References: <811f2f1c0708251415u34dbc66fl134bc7d9bc6ce177@mail.gmail.com> Message-ID: Nice! I like the tree view which give an index of available functions in one module. I wish edoc could generate this index ;) On 8/26/07, Michael Campbell wrote: > This might be old news, but I see that http://gotapi.com has their > whiz-bang AJAX-y typeahead suggest API searcher with an section Erlang > now. I don't know when it was added; I typically only use it for > java, but was pleased to see it. > > http://gotapi.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From josephgrossberg.55762538@REDACTED Sun Aug 26 18:11:49 2007 From: josephgrossberg.55762538@REDACTED (josephgrossberg.55762538@REDACTED) Date: 26 Aug 2007 16:11:49 -0000 Subject: [erlang-questions] (newbie) why do I see no output in the erlang shell? Message-ID: <1188144709.2508298430.29905.sendItem@bloglines.com> Apologies if this has already been covered -- I would imagine that others encounter this problem but I could not find the answer to this problem -- and thanks in advance for any help more experienced Erlangers can offer. I am using Mac OS X (10.4) and I downloaded the tarballs of both the most recent and second-most recent versions. I did the configure && make && sudo make install dance (without passing them any options) and fired up erl. And then, this: $ erl Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> 1+1 1> 1 1> According to everything I read, it should print "2" and then "1" after my two commands. So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I really, really want to start hacking away with this language. :( From qrilka@REDACTED Sun Aug 26 19:27:23 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 26 Aug 2007 21:27:23 +0400 Subject: [erlang-questions] (newbie) why do I see no output in the erlang shell? In-Reply-To: <1188144709.2508298430.29905.sendItem@bloglines.com> References: <1188144709.2508298430.29905.sendItem@bloglines.com> Message-ID: <337538cb0708261027n7d64e727p5fe3f92ed5f02eac@mail.gmail.com> Erlang statements (commands) are closed with dot, so you actually didn't closed the command and Erlang shell is waiting you to enter the dot. Regards, Kirill. On 26 Aug 2007 16:11:49 -0000, josephgrossberg.55762538@REDACTED < josephgrossberg.55762538@REDACTED> wrote: > > Apologies if this has already been covered -- I would imagine that others > encounter this problem but I could not find the answer to this problem -- > and thanks in advance for any help more experienced Erlangers can offer. > > I am using Mac OS X (10.4) and I downloaded the tarballs of both the most > recent and second-most recent versions. > > I did the configure && make && > sudo make install dance (without passing them any options) and fired up > erl. > > > And then, this: > $ erl > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] > [kernel-poll:false] > Eshell V5.5.4 (abort with ^G) > 1> 1+1 > 1> 1 > 1> > > According > to everything I read, it should print "2" and then "1" after my two > commands. > > > So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I > really, > really want to start hacking away with this language. :( > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Sun Aug 26 19:30:02 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 26 Aug 2007 19:30:02 +0200 Subject: [erlang-questions] (newbie) why do I see no output in the erlang shell? In-Reply-To: <1188144709.2508298430.29905.sendItem@bloglines.com> References: <1188144709.2508298430.29905.sendItem@bloglines.com> Message-ID: You need a dot to terminate the expression. 1> 1 + 1. 2 26 Aug 2007 16:11:49 -0000, josephgrossberg.55762538@REDACTED : > Apologies if this has already been covered -- I would imagine that others > encounter this problem but I could not find the answer to this problem -- > and thanks in advance for any help more experienced Erlangers can offer. > > I am using Mac OS X (10.4) and I downloaded the tarballs of both the most > recent and second-most recent versions. > > I did the configure && make && > sudo make install dance (without passing them any options) and fired up erl. > > > And then, this: > $ erl > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] > [kernel-poll:false] > Eshell V5.5.4 (abort with ^G) > 1> 1+1 > 1> 1 > 1> > > According > to everything I read, it should print "2" and then "1" after my two commands. > > > So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I really, > really want to start hacking away with this language. :( > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ruslan.spivak@REDACTED Sun Aug 26 19:28:47 2007 From: ruslan.spivak@REDACTED (Ruslan Spivak) Date: Sun, 26 Aug 2007 20:28:47 +0300 Subject: [erlang-questions] (newbie) why do I see no output in the erlang shell? References: <1188144709.2508298430.29905.sendItem@bloglines.com> Message-ID: josephgrossberg.55762538@REDACTED writes: > Apologies if this has already been covered -- I would imagine that others > encounter this problem but I could not find the answer to this problem -- > and thanks in advance for any help more experienced Erlangers can offer. > > I am using Mac OS X (10.4) and I downloaded the tarballs of both the most > recent and second-most recent versions. > > I did the configure && make && > sudo make install dance (without passing them any options) and fired up erl. > > > And then, this: > $ erl > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] > [kernel-poll:false] > Eshell V5.5.4 (abort with ^G) > 1> 1+1 > 1> 1 > 1> > > According > to everything I read, it should print "2" and then "1" after my two commands. > > > So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I really, > really want to start hacking away with this language. :( You should put dot at the end, ie 1> 1+1. Regards, Ruslan -- Two monks were arguing about a flag. One said, "The flag is moving." The other said, "The wind is moving." The sixth patriarch, Zeno, happened to be passing by. He told them, "Not the wind, not the flag. Mind is moving." -- Douglas R. Hofstadter From Lennart.Ohman@REDACTED Sun Aug 26 19:48:57 2007 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Sun, 26 Aug 2007 19:48:57 +0200 Subject: [erlang-questions] (newbie) why do I see no output in the erlangshell? In-Reply-To: <1188144709.2508298430.29905.sendItem@bloglines.com> References: <1188144709.2508298430.29905.sendItem@bloglines.com> Message-ID: Welcome to Erlang, If you look in the "Fine Manual", in the for this situation obviously relevant section "getting started" (sorry couldn't help it, just slipped out :-) about the Erlang shell ....\doc\getting_started\part_frame.html you'll find the solution to your question. Good luck Lennart --------------------------------------------------------------------------- Lennart ?hman phone : +46-8-587 623 27 Sj?land & Thyseliys Telecom AB cellular: +46-70-552 6735 H?lsingegatan 43, 10th floor fax : +46-8-667 8230 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of josephgrossberg.55762538@REDACTED Sent: den 26 augusti 2007 18:12 To: erlang-questions@REDACTED Subject: [erlang-questions] (newbie) why do I see no output in the erlangshell? Apologies if this has already been covered -- I would imagine that others encounter this problem but I could not find the answer to this problem -- and thanks in advance for any help more experienced Erlangers can offer. I am using Mac OS X (10.4) and I downloaded the tarballs of both the most recent and second-most recent versions. I did the configure && make && sudo make install dance (without passing them any options) and fired up erl. And then, this: $ erl Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> 1+1 1> 1 1> According to everything I read, it should print "2" and then "1" after my two commands. So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I really, really want to start hacking away with this language. :( _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From mogorman@REDACTED Sun Aug 26 19:20:32 2007 From: mogorman@REDACTED (Matthew O'Gorman) Date: Sun, 26 Aug 2007 12:20:32 -0500 Subject: [erlang-questions] (newbie) why do I see no output in the erlang shell? In-Reply-To: <1188144709.2508298430.29905.sendItem@bloglines.com> References: <1188144709.2508298430.29905.sendItem@bloglines.com> Message-ID: you did not complete your command, all functions must be terminated with a period > 1 + 1. 2 mog On 26 Aug 2007 16:11:49 -0000, josephgrossberg.55762538@REDACTED wrote: > Apologies if this has already been covered -- I would imagine that others > encounter this problem but I could not find the answer to this problem -- > and thanks in advance for any help more experienced Erlangers can offer. > > I am using Mac OS X (10.4) and I downloaded the tarballs of both the most > recent and second-most recent versions. > > I did the configure && make && > sudo make install dance (without passing them any options) and fired up erl. > > > And then, this: > $ erl > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] > [kernel-poll:false] > Eshell V5.5.4 (abort with ^G) > 1> 1+1 > 1> 1 > 1> > > According > to everything I read, it should print "2" and then "1" after my two commands. > > > So what am I doing wrong here? I've RTFM'd and STFW'd to no avail. I really, > really want to start hacking away with this language. :( > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Sun Aug 26 21:49:15 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 26 Aug 2007 20:49:15 +0100 Subject: [erlang-questions] Search engine in Erlang Message-ID: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> Has anyone implemented a text or tag search engine in Erlang? Would you share implementation tips? I would like to have tagged bits of information and quickly search using a number of tags. Thanks, Joel -- http://wagerlabs.com From bhatti_shahzad@REDACTED Sun Aug 26 22:03:11 2007 From: bhatti_shahzad@REDACTED (shahzad bhatti) Date: Sun, 26 Aug 2007 13:03:11 -0700 (PDT) Subject: [erlang-questions] Suitable applications for Erlang Message-ID: <812691.73014.qm@web81113.mail.mud.yahoo.com> I am looking at Erlang lately and like the support for distributed and concurrent applications. However, I have a question regarding kind of applications that Erlang is best suited for. Since, Erlang uses green threads for user processes (though it has SMP support), I am not sure if it is well suited for CPU intensive applications as opposd to I/O bound applications. For example, I have a system that calculates shortest path for a very large network and I would like to use distributed Erlang to divide the problem (using Google like map-reduce) and create a number of processes per node to calculate the shortest path for smaller network. From prior experience, I have found that for CPU bound applications work best when the number of threads is roughly equal to number of cores/CPUs, and I am concerned about excessive context switching and cache misses. Can someone share their Erlang experience with CPU bound problems. Regards, Shahzad Bhatti Email: bhatti@REDACTED YIM: bhatti_shahzad@REDACTED URL: http://bhatti.plexobject.com Blog: http://weblog.plexobject.com Company: http://www.plexobject.com --------------------------------- Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanobjc@REDACTED Sun Aug 26 23:18:44 2007 From: ryanobjc@REDACTED (Ryan Rawson) Date: Sun, 26 Aug 2007 14:18:44 -0700 Subject: [erlang-questions] Suitable applications for Erlang In-Reply-To: <812691.73014.qm@web81113.mail.mud.yahoo.com> References: <812691.73014.qm@web81113.mail.mud.yahoo.com> Message-ID: You're confusing the issues. Green threads is orthogonal to the performance of CPU bound computations. As a matter of fact, erl spawns a thread for each CPU and extra for certain blocking io operations. I'd be more worried about the bytecode and lack of compact data structures. Of course, this is all wild speculation. Why not do some tests? -ryan Sent from my iPhone On Aug 26, 2007, at 1:03 PM, shahzad bhatti wrote: > I am looking at Erlang lately and like the support for distributed > and concurrent applications. However, I have a question regarding > kind of applications that Erlang is best suited for. Since, Erlang > uses green threads for user processes (though it has SMP support), I > am not sure if it is well suited for CPU intensive applications as > opposd to I/O bound applications. For example, I have a system that > calculates shortest path for a very large network and I would like > to use distributed Erlang to divide the problem (using Google like > map-reduce) and create a number of processes per node to calculate > the shortest path for smaller network. From prior experience, I have > found that for CPU bound applications work best when the number of > threads is roughly equal to number of cores/CPUs, and I am concerned > about excessive context switching and cache misses. Can someone > share their Erlang experience with CPU bound problems. > > > Regards, > Shahzad Bhatti > Email: bhatti@REDACTED > YIM: bhatti_shahzad@REDACTED > URL: http://bhatti.plexobject.com > Blog: http://weblog.plexobject.com > Company: http://www.plexobject.com > > Moody friends. Drama queens. Your life? Nope! - their life, your > story. > Play Sims Stories at Yahoo! Games. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From dvrsn@REDACTED Mon Aug 27 00:13:04 2007 From: dvrsn@REDACTED (Jeff Rogers) Date: Sun, 26 Aug 2007 15:13:04 -0700 Subject: [erlang-questions] Parse-transforming !! to a function call In-Reply-To: <3dbc6d1c0708251859s115658beie48673d23ce6573b@mail.gmail.com> References: <9b08084c0708160152k5f9ff5d5o8c2cc662b31c773d@mail.gmail.com> <46CE8B81.9020006@ericsson.com> <46CF5CE8.9040302@diphi.com> <3dbc6d1c0708241632j5f61d7f4h32cbb071a94fd37f@mail.gmail.com> <46CF7639.7090109@diphi.com> <3dbc6d1c0708251859s115658beie48673d23ce6573b@mail.gmail.com> Message-ID: <46D1FAF0.5090405@diphi.com> Robert Virding wrote: > The problem is not whether it is difficult to do in the compiler but > rather if we want to do it. Having the semantics of : > > A ! Msg > > and > > B = A ! Msg > > being different would be a first in the language and I personally think > completely horrendous. I'm not suggesting this as a change to the language - that would require *far* more thought than a 2-minute brainstorm. I was pondering the idea as a parse-transform only, so that the programmer chooses when to use it with a compiler directive. This thread started with a discussion about how bad it was to need a different compiler to accept a new piece of syntax and I had a thought about how to do it with the same compiler. > Also the semantic difference between sending an async message and doing > a sync rpc is VERY large. No argument here. I'm not saying it wouldn't be different. I am saying it might be useful in some cases. > Also if you were to add one end of a sync message passing then you > should also add the other end as well, both receiving the message and > returning the reply. I could see some benefit to this too, but since in most cases you would want to actually do something before sending the reply a compact representation is tough to come up with. The potentially useful part would be having the response operator implicitly know what process to send the message to. So for example, where the sync-send hides "A ! {self(),B}" behind a simeple "A ! B", the sync receive hides "receive {Pid,Msg} -> Pid ! Fun(Msg)" behind "receive! Msg -> Fun" or something like that. > If instead it was defined to translate into a certain function call > which you yourself then had to provide then that would also be a first, > and I honestly don't see the benefit of it. Why not just write the > function call yourself? It's syntactic sugar, that's all, just like "A ! B" is syntactic sugar for "erlang:send(A,B)". > Also there are people who use the return value of a send, not just as a > side-effect. They won't be happy. I can't claim alot of experience here, but it seems odd to use the return value since it's essentially an identity. The return value of "A ! B" is B, never anything else. The people who wouldn't be happy about it could just not use the parse-transform module in their code. -J From dvrsn@REDACTED Mon Aug 27 00:34:57 2007 From: dvrsn@REDACTED (Jeff Rogers) Date: Sun, 26 Aug 2007 15:34:57 -0700 Subject: [erlang-questions] Search engine in Erlang In-Reply-To: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> References: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> Message-ID: <46D20011.1000900@diphi.com> Joel Reymont wrote: > Has anyone implemented a text or tag search engine in Erlang? > > Would you share implementation tips? > > I would like to have tagged bits of information and quickly search > using a number of tags. I started writing a module to read lucene indexes but didn't get very far - a number of implementation features (variable-length integers so you need to read them a single byte at a time, lengths in characters instead of bytes so you can't just skip over a block that you want to ignore) make them annoying to deal with in their normal form (although I'm sure it makes alot of sense for the java implementation). If you ignore some of those encoding oddities but use the same basic architecture of named fields to search within that might be a reasonable foundation to start building on. -J From chsu79@REDACTED Mon Aug 27 01:06:05 2007 From: chsu79@REDACTED (Christian S) Date: Mon, 27 Aug 2007 01:06:05 +0200 Subject: [erlang-questions] Search engine in Erlang In-Reply-To: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> References: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> Message-ID: I havent actually written one, but I have a bunch of links to information retrieval documents that are interesting: http://del.icio.us/chsu79/ir Your implementation depends entirely on your scalability requirements. In the small scale of things you can probably copy the inverted index from joe armstrongs's book quite verbatim. So how many documents, how many terms? distributed on how many machines? 2007/8/26, Joel Reymont : > Has anyone implemented a text or tag search engine in Erlang? > > Would you share implementation tips? > > I would like to have tagged bits of information and quickly search > using a number of tags. From tom@REDACTED Mon Aug 27 01:16:58 2007 From: tom@REDACTED (Tom Samplonius) Date: Sun, 26 Aug 2007 16:16:58 -0700 (PDT) Subject: [erlang-questions] Search engine in Erlang In-Reply-To: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> Message-ID: <33208459.531188170218183.JavaMail.root@ly.sdf.com> ----- "Joel Reymont" wrote: > Has anyone implemented a text or tag search engine in Erlang? > > Would you share implementation tips? > > I would like to have tagged bits of information and quickly search > using a number of tags. > > Thanks, Joel The Erlang book has a mapreduce example, which is quite interesting. Tom From lcoquelle@REDACTED Mon Aug 27 05:46:29 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Mon, 27 Aug 2007 11:46:29 +0800 Subject: [erlang-questions] inets/httpd: ESI callback examples? Message-ID: Hi, I'm reading the user's guide of inets, and want to use it as a very simple http API for my own application. My guess is that the ESI callbacks could be used for that. But I cannot find the examples in OTP source code. In otp_src_R11B-4/lib/inets/examples/server_root, there is a directory cgi-bin, but no cgi-bin/erl/httpd_example as refered in the other files (htdocs/index.html). Are these examples deprecated (and some other linked files could be clean then)? Are they somewhere else? Thanks in advance for any hint! -------------- next part -------------- An HTML attachment was scrubbed... URL: From lcoquelle@REDACTED Mon Aug 27 05:50:03 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Mon, 27 Aug 2007 11:50:03 +0800 Subject: [erlang-questions] inets/httpd: ESI callback examples? In-Reply-To: References: Message-ID: My mistake! Those files do not exist :) In fact, those are not real URL, and the module httpd_example exists and is located in inets-4.7.6 /src/httpd_example.erl Apologize ... I posted too quickly! On 8/27/07, Ludovic Coquelle wrote: > > Hi, > I'm reading the user's guide of inets, and want to use it as a very simple > http API for my own application. > My guess is that the ESI callbacks could be used for that. > > But I cannot find the examples in OTP source code. > > In otp_src_R11B-4/lib/inets/examples/server_root, there is a directory > cgi-bin, but no cgi-bin/erl/httpd_example as refered in the other files > (htdocs/index.html). > Are these examples deprecated (and some other linked files could be clean > then)? Are they somewhere else? > > Thanks in advance for any hint! > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Mon Aug 27 12:28:15 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 27 Aug 2007 11:28:15 +0100 Subject: [erlang-questions] Search engine in Erlang In-Reply-To: References: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> Message-ID: <41B6FDB5-B996-4DCD-81AB-37425155E877@gmail.com> On Aug 27, 2007, at 12:06 AM, Christian S wrote: > So how many documents, how many terms? distributed on how many > machines? Something built for a potentially large social network. -- http://wagerlabs.com From bengt.kleberg@REDACTED Mon Aug 27 12:36:26 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 27 Aug 2007 12:36:26 +0200 Subject: [erlang-questions] erl -make exit status In-Reply-To: References: <20070823135826.GB31070@sphinx.chicagopeoplez.org> Message-ID: <46D2A92A.6040304@ericsson.com> On 2007-08-23 17:11, Kenneth Lundin wrote: ...deleted > For real building of products we recommend the use of UNIX make or > similar invoking before using unix make on anything bigger than a single directory i would recommend reading ''Recursive Make Considered Harmful'', http://miller.emu.id.au/pmiller/books/rmch bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From klacke@REDACTED Mon Aug 27 12:33:47 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Mon, 27 Aug 2007 12:33:47 +0200 Subject: [erlang-questions] regular expressions on binaries In-Reply-To: References: Message-ID: <46D2A88B.3010306@hyber.org> Paul Mineiro wrote: > Is there an analog to regexp available that works on binaries? > I once wrote a linked-in driver for that: http://yaws.hyber.org/download/posregex-1.0.tgz /klacke From rasmussen.bryan@REDACTED Mon Aug 27 16:17:28 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Mon, 27 Aug 2007 16:17:28 +0200 Subject: [erlang-questions] Accessing COM/OLE/ActiveX In-Reply-To: <46CE8D51.7050602@erix.ericsson.se> References: <46CC79B1.2050004@kleinfelter.com> <46CE8D51.7050602@erix.ericsson.se> Message-ID: <3bb44c6e0708270717o41699c4t65e70a03c833c3b9@mail.gmail.com> Was it just lack of someone to maintain it or was it dropped due to an evaluation of usage/usefulness - i.e. perhaps on the idea that COM is a legacy technology? Cheers, Bryan Rasmussen On 8/24/07, Jakob Cederlund wrote: > Nothing took it's place... However, you can still get Comet from an > older relase, Erlang/OTP 5.1 (R8B) is the last one, and recompile it > with a newer erlang release. (Note that the driver interface has changed > a bit.) > /Jakob > > > Kevin Kleinfelter wrote: > > When Comet was removed from the Erlang distribution, what took its > > place? i.e. Now that Comet is gone, how does a program access a COM > > object on the Windows platform? > > > > TIA > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kenneth.lundin@REDACTED Mon Aug 27 18:16:19 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 27 Aug 2007 18:16:19 +0200 Subject: [erlang-questions] Accessing COM/OLE/ActiveX In-Reply-To: <3bb44c6e0708270717o41699c4t65e70a03c833c3b9@mail.gmail.com> References: <46CC79B1.2050004@kleinfelter.com> <46CE8D51.7050602@erix.ericsson.se> <3bb44c6e0708270717o41699c4t65e70a03c833c3b9@mail.gmail.com> Message-ID: Hi, We removed Comet for several reasons: 1) The project within Ericsson that required COM support was discontinued. 2) Comet was only in alfa or beta status 3) Lack of someone to maintain it (no finance for suitable person because of 1). /Kenneth (Erlang/OTP Team at Ericsson) On 8/27/07, bryan rasmussen wrote: > Was it just lack of someone to maintain it or was it dropped due to an > evaluation of usage/usefulness - i.e. perhaps on the idea that COM is > a legacy technology? > > Cheers, > Bryan Rasmussen > > On 8/24/07, Jakob Cederlund wrote: > > Nothing took it's place... However, you can still get Comet from an > > older relase, Erlang/OTP 5.1 (R8B) is the last one, and recompile it > > with a newer erlang release. (Note that the driver interface has changed > > a bit.) > > /Jakob > > > > > > Kevin Kleinfelter wrote: > > > When Comet was removed from the Erlang distribution, what took its > > > place? i.e. Now that Comet is gone, how does a program access a COM > > > object on the Windows platform? > > > > > > TIA > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Tue Aug 28 00:34:21 2007 From: chsu79@REDACTED (Christian S) Date: Tue, 28 Aug 2007 00:34:21 +0200 Subject: [erlang-questions] Search engine in Erlang In-Reply-To: <41B6FDB5-B996-4DCD-81AB-37425155E877@gmail.com> References: <37140B16-CFB4-4836-8481-D769FD5C2775@gmail.com> <41B6FDB5-B996-4DCD-81AB-37425155E877@gmail.com> Message-ID: 2007/8/27, Joel Reymont : > > So how many documents, how many terms? distributed on how many > > machines? > Something built for a potentially large social network. It is really difficult to guesstimate what is important, but easily scaling by adding more machines is desirable. The winning approach is to partition the documents to be indexed over the machines, instead of partitioning the terms. The way you order the posting list for a term is important, for example, if you order by most-recently at the top you will be more efficient at querying for the last N documents containing a term, since it takes less IO. Similarly, if you are going to get results out in some relevancy-order, you want to have a posting list presorted so most relevant documents are first. But then you also want to include the relevancy measure of the document in the posting list. This allows you to merge posting lists into one posting list still sorted by relevancy cheaply. As there is a tradeoff between cheap-to-write and cheap-to-read you also want to have two different posting lists specialized for each, so you can delay updating the compact cheap-to-read posting list by posting documents to the cheap-to-write lists until it is crowded or old. Lucene uses this to speed up adding documents. Oh, this cheap-to-write store needs a way to indicate that a document has been removed. These are the tricks i know of for inverted indexes. The terminology i use is that term is an integer mapped to a search word/tag, document is an integer mapped to an object you want to find, and posting list is the term and list of documents where it occurs. From dougedmunds@REDACTED Tue Aug 28 00:40:47 2007 From: dougedmunds@REDACTED (DougEdmunds) Date: Mon, 27 Aug 2007 15:40:47 -0700 Subject: [erlang-questions] where to report bugs and documentation errors? Message-ID: <46D352EF.3020009@gmail.com> Where is the appropriate place to report an Erlang bug? Where is the best place to report documentation errors? -dae From bengt.kleberg@REDACTED Tue Aug 28 06:55:20 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 28 Aug 2007 06:55:20 +0200 Subject: [erlang-questions] where to report bugs and documentation errors? In-Reply-To: <46D352EF.3020009@gmail.com> References: <46D352EF.3020009@gmail.com> Message-ID: <46D3AAB8.4090601@ericsson.com> greetings, i would recommend the email list erlang-bugs@REDACTED as with erlang-questions you need to join. right now erlang.org is unresponsive so you can try later. On 2007-08-28 00:40, DougEdmunds wrote: > Where is the appropriate place to > report an Erlang bug? > > Where is the best place to report > documentation errors? bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From ingela@REDACTED Tue Aug 28 11:34:50 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 28 Aug 2007 11:34:50 +0200 Subject: [erlang-questions] http-client fails when gets response w/o headers In-Reply-To: References: Message-ID: <46D3EC3A.10001@erix.ericsson.se> Thank you for reporting this, yes it was a bug and it has been fixed. /Regards Ingela - OTP team > Hello. > > It seems there is yet another bug found in http-client while it gets > response from http-server with omitted headers (?): > > 23> http:request("http://shingler:7070/check?aaa=bbb"). > {error,session_remotly_closed} > From francesco@REDACTED Tue Aug 28 12:09:22 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Tue, 28 Aug 2007 11:09:22 +0100 Subject: [erlang-questions] Commercial Users of Functional Programming Workshop, Freiburg (Germany) October 4th 2007 Message-ID: <46D3F452.1080503@erlang-consulting.com> The program for the 2007 Commercial Users of Functional Programming workshop is now published. http://cufp.galois.com/ The workshop is co-located with ICFP, and will be held in Freiburg, Germany, on 4 October 2007 (The day before the Erlang workshop so you can attend both). We had a terrific response to our call for talks, and there are twelve (!) speakers describing commercial applications, variously written in Caml Erlang F# Haskell ML Scheme This year, there are two Erlang talks. The talks are informal, and there are no proceedings. We'll just have fun learning about functional programming used to solve real problems. Kathleen Fisher, Simon Peyton Jones & Francesco Cesarini From richardc@REDACTED Tue Aug 28 13:57:37 2007 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 28 Aug 2007 13:57:37 +0200 Subject: [erlang-questions] edoc: grouping functions In-Reply-To: References: Message-ID: <46D40DB1.1000406@it.uu.se> Ludovic Coquelle wrote: > Hi, > Is there any way using edoc to create a group of function (like > functions retrieving info, functions updating data, callback of > behaviour ...) ? Not yet, no. It's on my list of ideas to implement, but I have no time. I recently added (by request) an option that turns off sorting of the entries in the long description section, so that you keep the order from the source code. > Also, is there an easy way to change the order in the function index? No. I thought the point of the index is that it should be indexable. But I agree that grouping could be useful. Does anybody out there with spare time and an interest in documentation generation and layout feel like taking over the maintenance and (most of all) the continued development of EDoc? /Richard From seb-cl-mailist@REDACTED Tue Aug 28 14:17:27 2007 From: seb-cl-mailist@REDACTED (=?ISO-8859-1?Q?S=E9bastien_Saint-Sevin?=) Date: Tue, 28 Aug 2007 14:17:27 +0200 Subject: [erlang-questions] Mnesia doc Message-ID: <46D41257.2070903@matchix.com> Hi list, Quite a funny documentation bug (in the sense that the more you are looking at it, the less you see it...). The Mnesia User Guide Pdf file named "mnesia.pdf" has a wrong title: "Managment" is used instead of "Management". Hope this helps, Cheers, Sebastien. From rvirding@REDACTED Tue Aug 28 15:01:29 2007 From: rvirding@REDACTED (Robert Virding) Date: Tue, 28 Aug 2007 15:01:29 +0200 Subject: [erlang-questions] Is it worth commenting this guy? Message-ID: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> When scanning for references to Erlang I occasionally come across this guy: http://rebelscience.blogspot.com/ He is advocating/developing a system called COSA and continually comparing it to Erlang. While I appreciate the references I personally think he is a bit bonkers and just not getting it. Do you think it is worth getting into a discussion with him and try to correct him where he is wrong? Has anyone tried? Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby@REDACTED Tue Aug 28 15:15:14 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 28 Aug 2007 10:15:14 -0300 Subject: [erlang-questions] Mnesia doc In-Reply-To: <46D41257.2070903@matchix.com> References: <46D41257.2070903@matchix.com> Message-ID: <05C2A0F2-F4D3-4A99-BDB9-61C2B1997A5B@smartgames.ca> On 28-Aug-07, at 9:17 AM, S?bastien Saint-Sevin wrote: > Hi list, > Quite a funny documentation bug (in the sense that the more you are > looking at it, the less you see it...). > The Mnesia User Guide Pdf file named "mnesia.pdf" has a wrong > title: "Managment" is used instead of "Management". Almost seems intentional, in light of the Mnesia name itself... --T > > Hope this helps, > Cheers, Sebastien. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vinoski@REDACTED Tue Aug 28 16:33:01 2007 From: vinoski@REDACTED (Steve Vinoski) Date: Tue, 28 Aug 2007 10:33:01 -0400 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <65b2728e0708280732t2ca11024h11ce82a6dd4ece59@mail.gmail.com> On 8/28/07, Robert Virding wrote: > > When scanning for references to Erlang I occasionally come across this > guy: > > http://rebelscience.blogspot.com/ > > He is advocating/developing a system called COSA and continually comparing > it to Erlang. While I appreciate the references I personally think he is a > bit bonkers and just not getting it. Do you think it is worth getting into a > discussion with him and try to correct him where he is wrong? Has anyone > tried? I've seen his postings, too. If I were you, I'd avoid getting into discussions with him, because he's really just looking for attention. But if you just can't resist, I'd ask him for proof that his ideas have been put to the test in real-world production systems and proven to work as advertised. --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjorn@REDACTED Tue Aug 28 16:45:04 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 28 Aug 2007 16:45:04 +0200 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: "Robert Virding" writes: > When scanning for references to Erlang I occasionally come across this guy: > > http://rebelscience.blogspot.com/ > > Do you think it is worth getting into a > discussion with him and try to correct him where he is wrong? No. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From garry@REDACTED Tue Aug 28 16:12:28 2007 From: garry@REDACTED (Garry Hodgson) Date: Tue, 28 Aug 2007 10:12:28 -0400 (EDT) Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <2007082810121188310348@k2.sage.att.com> "Robert Virding" wrote: > When scanning for references to Erlang I occasionally come across this guy: > > http://rebelscience.blogspot.com/ > > He is advocating/developing a system called COSA and continually comparing > it to Erlang. While I appreciate the references I personally think he is a > bit bonkers and just not getting it. Do you think it is worth getting into a > discussion with him and try to correct him where he is wrong? i took a quick look at his blog, in which nearly every post says, "where erlang gets this wrong, cosa gets it right", more or less. my gut is that this would be a waste of time. you're not gonna change his mind, though perhaps you could help prevent others from being misled. ---- Garry Hodgson, Senior Software Geek, AT&T CSO nobody can do everything, but everybody can do something. do something. From tsuraan@REDACTED Tue Aug 28 17:25:33 2007 From: tsuraan@REDACTED (tsuraan) Date: Tue, 28 Aug 2007 10:25:33 -0500 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <84fb38e30708280825y744c97fjfa297bfc0df097cb@mail.gmail.com> He's an idiot; his COSA is somehow based on the idea that hardware design inherently produces a stable and reliable product, whereas software design doesn't, due to its algorthmic nature. He also seems to be convinced that visual design tools are the answer to all life's problems, which indicates that he probably used LogicWorks or the Xilinx visual tools for a highschool/introductory college design course and never actually learned about the existence of VHDL and Verilog. He goes so far as to claim that languages are obsolete and graphical tools are the only correct answer... I wouldn't bother trying to talk to him, anyhow. On 28/08/07, Robert Virding wrote: > > When scanning for references to Erlang I occasionally come across this > guy: > > http://rebelscience.blogspot.com/ > > He is advocating/developing a system called COSA and continually comparing > it to Erlang. While I appreciate the references I personally think he is a > bit bonkers and just not getting it. Do you think it is worth getting into a > discussion with him and try to correct him where he is wrong? Has anyone > tried? > > Robert > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Tue Aug 28 16:56:48 2007 From: matthias@REDACTED (Matthias Lang) Date: Tue, 28 Aug 2007 16:56:48 +0200 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <18132.14256.33695.895251@cors.corelatus.se> Robert Virding writes: > While I appreciate the references I personally think he is a > bit bonkers and just not getting it. Do you think it is worth getting into a > discussion with him and try to correct him where he is wrong? Has anyone > tried? I stumbled across this (from the same author): | I am willing to stick my neck out and make the following prediction: | | The most revolutionary scientific advances in this century will come | from the Bible. | | There is no doubt that the discovery of AI, one of the most coveted | holy grails of modern science, will be shocking news in its own | right. The notion that the secret of AI was written down in a book | nearly two thousand years ago is bound to ruffle many a scientific | feather. And that the book in question should turn out to be the Bible | (of all things!) will be more than many can bear. Indeed, why not the | Koran? Why not the Vedic scriptures? Why did not the secret of AI come | from Buddhism or Hinduism or some other religion? Most important of | all, why did it not come from the scientific community seeing that | they are all so quick to discredit the scientific importance of not | just the Bible, but all ancient scriptures? | | http://www.rebelscience.org/Seven/bible.html Pretty much all of that is outside my area of expertise. Matthias From jakob@REDACTED Tue Aug 28 17:55:23 2007 From: jakob@REDACTED (Jakob Cederlund) Date: Tue, 28 Aug 2007 17:55:23 +0200 Subject: [erlang-questions] Accessing COM/OLE/ActiveX In-Reply-To: References: <46CC79B1.2050004@kleinfelter.com> <46CE8D51.7050602@erix.ericsson.se> <3bb44c6e0708270717o41699c4t65e70a03c833c3b9@mail.gmail.com> Message-ID: <46D4456B.7050403@erix.ericsson.se> If there is any interest in it, I can port comet it to R11B, and fix some of the known problems (e.g. removing features that never worked), but it will have to be maintained as a contribution, not as part of OTP. /Jakob Kenneth Lundin wrote: > Hi, > > We removed Comet for several reasons: > 1) The project within Ericsson that required COM support was discontinued. > 2) Comet was only in alfa or beta status > 3) Lack of someone to maintain it (no finance for suitable person because of 1). > > /Kenneth (Erlang/OTP Team at Ericsson) > > On 8/27/07, bryan rasmussen wrote: > >> Was it just lack of someone to maintain it or was it dropped due to an >> evaluation of usage/usefulness - i.e. perhaps on the idea that COM is >> a legacy technology? >> >> Cheers, >> Bryan Rasmussen >> >> On 8/24/07, Jakob Cederlund wrote: >> >>> Nothing took it's place... However, you can still get Comet from an >>> older relase, Erlang/OTP 5.1 (R8B) is the last one, and recompile it >>> with a newer erlang release. (Note that the driver interface has changed >>> a bit.) >>> /Jakob >>> >>> >>> Kevin Kleinfelter wrote: >>> >>>> When Comet was removed from the Erlang distribution, what took its >>>> place? i.e. Now that Comet is gone, how does a program access a COM >>>> object on the Windows platform? >>>> >>>> TIA >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Tue Aug 28 17:57:39 2007 From: dmercer@REDACTED (David Mercer) Date: Tue, 28 Aug 2007 10:57:39 -0500 Subject: [erlang-questions] edoc: grouping functions In-Reply-To: <46D40DB1.1000406@it.uu.se> References: <46D40DB1.1000406@it.uu.se> Message-ID: <003901c7e98c$29bc5490$891ea8c0@SSI.CORP> What does erlang.org use to generate the official Erlang documentation? It does not look like the output I get from edoc. Cheers, David From kenneth.lundin@REDACTED Tue Aug 28 20:56:46 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 28 Aug 2007 20:56:46 +0200 Subject: [erlang-questions] edoc: grouping functions In-Reply-To: <003901c7e98c$29bc5490$891ea8c0@SSI.CORP> References: <46D40DB1.1000406@it.uu.se> <003901c7e98c$29bc5490$891ea8c0@SSI.CORP> Message-ID: Hi, The official Erlang documentation is generated with an application called 'docbuilder' which is introduced as open source in the OTP R11B-5 release. For the majority of the documentation we use XML and the DTD's documented in the docbuilder application. For some applications we actually use edoc but with a special backend which translate edoc input to our XML DTD's before we process it in the same manner as all the other docs. The extensive documentation for 'docbuilder' can be found here: http://www.erlang.org/doc/apps/docbuilder/index.html The release of docbuilder is the first step in our plan to release the source for all official documentation. The purpose with releasing the source for the documentation is that the Erlang community can contribute with enhanced ways of formatting, indexing, integration with editors etc. Another goal with releasing docbuilder and the source for docs could be to create a standard way of documenting Erlang applications (with docbuilder and edoc and enhancements). /Kenneth (Erlang/OTP team at Ericsson) On 8/28/07, David Mercer wrote: > What does erlang.org use to generate the official Erlang documentation? It > does not look like the output I get from edoc. > > Cheers, > > David > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From david.hopwood@REDACTED Tue Aug 28 22:07:01 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Tue, 28 Aug 2007 21:07:01 +0100 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <46D48065.6000901@industrial-designers.co.uk> Robert Virding wrote: > When scanning for references to Erlang I occasionally come across this guy: > > http://rebelscience.blogspot.com/ > > He is advocating/developing a system called COSA and continually comparing > it to Erlang. I don't buy the argument that deterministic timing is necessary for reliability, which many of his other arguments depend on. > While I appreciate the references I personally think he is a > bit bonkers and just not getting it. Oh, he's a total kook (see and for example). And some of the claims he makes for the model are clearly bonkers: # I will argue further that moving to a signal-based, synchronous (**) # software model will not only result in an improvement of several orders # of magnitude in productivity, but also in programs that are guaranteed # free of defects, regardless of their complexity. The model itself, however, is not nearly as bonkers as some of the other stuff I've looked at. It's a pity that he is overselling it. Indeed, you can buy microcontrollers that are programmed using graphical dataflow diagrams (not quite the same thing as COSA's synchronous reactive model, but close enough), such as Crouzet's Millenium range. They work and they are quite widely used, but personally I find that graphical programming of this type doesn't scale very well -- the diagrams quickly get too messy to understand easily, and there is no automatic way to prettify them, so the programmer's time is wasted in doing so. Many textual programming languages (Erlang, O'Caml, Haskell, E, etc.) can express a given amount of functionality in significantly less space than any graphical language I've seen, and that matters a great deal to being able to grasp enough of the program at one time to avoid some kinds of error. -- David Hopwood From joelr1@REDACTED Wed Aug 29 00:39:24 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 28 Aug 2007 23:39:24 +0100 Subject: [erlang-questions] Linked-in driver nuances Message-ID: <082972EB-2490-488D-83E8-E3FE8D93F285@gmail.com> Do I correctly understand that the best, simplest or least error- prone way to proxy GUI objects with a linked-in driver is to have one port represent one object? This would require creating a port per object of course but seems to be easier than trying to have one port manage all objects behind the scenes. Am I right? Thanks, Joel -- http://wagerlabs.com From mats.cronqvist@REDACTED Wed Aug 29 08:58:40 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 29 Aug 2007 08:58:40 +0200 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <18132.14256.33695.895251@cors.corelatus.se> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> <18132.14256.33695.895251@cors.corelatus.se> Message-ID: <46D51920.5010301@ericsson.com> > Robert Virding writes: > > > While I appreciate the references I personally think he is a > > bit bonkers and just not getting it. Do you think it is worth getting into a > > discussion with him and try to correct him where he is wrong? Has anyone > > tried? now you've gotten him mad. http://rebelscience.blogspot.com/2007/08/seven-deadly-sins-of-erlang.html From rvirding@REDACTED Wed Aug 29 09:01:30 2007 From: rvirding@REDACTED (Robert Virding) Date: Wed, 29 Aug 2007 09:01:30 +0200 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: <3dbc6d1c0708290001uf4c5837lc06128f34e2a6c30@mail.gmail.com> Thanks for all your replies and links. Reading some of his other work more or less answered my question, don't bother. I especially like this one: http://rebelscience.blogspot.com/2007/08/seven-deadly-sins-of-erlang.html We are all damned. :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitriid@REDACTED Wed Aug 29 09:23:25 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Wed, 29 Aug 2007 10:23:25 +0300 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <46D51920.5010301@ericsson.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> <18132.14256.33695.895251@cors.corelatus.se> <46D51920.5010301@ericsson.com> Message-ID: <46D51EED.5020404@gmail.com> Mats Cronqvist wrote: >> Robert Virding writes: >> >> > While I appreciate the references I personally think he is a >> > bit bonkers and just not getting it. Do you think it is worth getting into a >> > discussion with him and try to correct him where he is wrong? Has anyone >> > tried? >> > > now you've gotten him mad. > > http://rebelscience.blogspot.com/2007/08/seven-deadly-sins-of-erlang.html > I'd say this is good :) Every technology has its fans and haters. Erlang has finally got a hater :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordonguthrie@REDACTED Wed Aug 29 09:29:24 2007 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Wed, 29 Aug 2007 08:29:24 +0100 (BST) Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708290001uf4c5837lc06128f34e2a6c30@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> <3dbc6d1c0708290001uf4c5837lc06128f34e2a6c30@mail.gmail.com> Message-ID: <59676.82.41.159.220.1188372564.squirrel@backawinner.gg> The problem is not whether 'it is worth commenting him'... ...but what the hell do we do if he finds out about this thread and comes here and *STARTS COMMENTING US*... :( Gordon From jilani@REDACTED Wed Aug 29 10:33:38 2007 From: jilani@REDACTED (Jilani Khaldi) Date: Wed, 29 Aug 2007 10:33:38 +0200 Subject: [erlang-questions] An article about Erlang in italian Message-ID: <46D52F62.2020607@cheapnet.it> As subject. http://jkhaldi.oltrelinux.com/articoli/erlang.html jk -- Jilani KHALDI http://jkhaldi.oltrelinux.com From Marc.Vanwoerkom@REDACTED Wed Aug 29 11:45:10 2007 From: Marc.Vanwoerkom@REDACTED (Marc van Woerkom) Date: Wed, 29 Aug 2007 11:45:10 +0200 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <46D51920.5010301@ericsson.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> <18132.14256.33695.895251@cors.corelatus.se> <46D51920.5010301@ericsson.com> Message-ID: > http://rebelscience.blogspot.com/2007/08/seven-deadly-sins-of-erlang.html Cool, obviously Web 2.0 manages to create a feedback loop. We know that audio feedback can be quite painful. :-) Regards, Marc From joelr1@REDACTED Wed Aug 29 11:59:32 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 10:59:32 +0100 Subject: [erlang-questions] Starting the Erlang VM in a new thread Message-ID: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> Folks, Would there be any harm if the Erlang VM (erl_start and thus process_main) was started in a new thread, as opposed to thread #0 of the application? Thanks, Joel -- http://wagerlabs.com From jilani@REDACTED Tue Aug 28 19:11:23 2007 From: jilani@REDACTED (Jilani Khaldi) Date: Tue, 28 Aug 2007 19:11:23 +0200 Subject: [erlang-questions] An article about Erlang in italian Message-ID: <46D4573B.1060409@cheapnet.it> As subject. http://jkhaldi.oltrelinux.com/articoli/erlang.html jk -- Jilani KHALDI http://jkhaldi.oltrelinux.com From toby@REDACTED Wed Aug 29 14:21:32 2007 From: toby@REDACTED (Toby Thain) Date: Wed, 29 Aug 2007 09:21:32 -0300 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <59676.82.41.159.220.1188372564.squirrel@backawinner.gg> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> <3dbc6d1c0708290001uf4c5837lc06128f34e2a6c30@mail.gmail.com> <59676.82.41.159.220.1188372564.squirrel@backawinner.gg> Message-ID: On 29-Aug-07, at 4:29 AM, Gordon Guthrie wrote: > The problem is not whether 'it is worth commenting him'... > > ...but what the hell do we do if he finds out about this thread and > comes > here and *STARTS COMMENTING US*... We take off every ZIG. And blame Robert. --Toby > > :( > > Gordon > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Wed Aug 29 14:27:18 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 29 Aug 2007 14:27:18 +0200 Subject: [erlang-questions] Starting the Erlang VM in a new thread In-Reply-To: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> References: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> Message-ID: <20070829122718.GA6823@erix.ericsson.se> Why would it be desired? On Wed, Aug 29, 2007 at 10:59:32AM +0100, Joel Reymont wrote: > Folks, > > Would there be any harm if the Erlang VM (erl_start and thus > process_main) was started in a new thread, as opposed to thread #0 of > the application? > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From joelr1@REDACTED Wed Aug 29 14:30:44 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 13:30:44 +0100 Subject: [erlang-questions] Starting the Erlang VM in a new thread In-Reply-To: <20070829122718.GA6823@erix.ericsson.se> References: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> <20070829122718.GA6823@erix.ericsson.se> Message-ID: <91051366-A574-47B6-B529-9C760477AE7A@gmail.com> On Aug 29, 2007, at 1:27 PM, Raimo Niskanen wrote: > Why would it be desired? To integrate the Erlang runtime into a Mac Cocoa application. Yes, I specifically want to link against librts.a. Thanks, Joel -- http://wagerlabs.com From samuel.tesla@REDACTED Wed Aug 29 15:28:35 2007 From: samuel.tesla@REDACTED (Samuel Tesla) Date: Wed, 29 Aug 2007 08:28:35 -0500 Subject: [erlang-questions] Fwd: Starting the Erlang VM in a new thread In-Reply-To: <4bd555f70708290627w35d161d3y4ef2bba611e42553@mail.gmail.com> References: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> <20070829122718.GA6823@erix.ericsson.se> <91051366-A574-47B6-B529-9C760477AE7A@gmail.com> <4bd555f70708290627w35d161d3y4ef2bba611e42553@mail.gmail.com> Message-ID: <4bd555f70708290628m5577a666iffa9ed2627f43fa4@mail.gmail.com> (Aplogies to Joel to whom I sent this directly already, I forgot to Reply-To-All...need coffee.) Is it necessary for your project to link it in and execute it as a thread? You might want to consider just including the necessary bits of the erlang distribution inside your application bundle and launch it as a child process. -- Samuel On 8/29/07, Joel Reymont wrote: > > > On Aug 29, 2007, at 1:27 PM, Raimo Niskanen wrote: > > > Why would it be desired? > > To integrate the Erlang runtime into a Mac Cocoa application. > > Yes, I specifically want to link against librts.a. > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Aug 29 15:47:10 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 14:47:10 +0100 Subject: [erlang-questions] Fwd: Starting the Erlang VM in a new thread In-Reply-To: <4bd555f70708290628m5577a666iffa9ed2627f43fa4@mail.gmail.com> References: <5F36BE22-DD8E-4640-A183-CBE4C997D74C@gmail.com> <20070829122718.GA6823@erix.ericsson.se> <91051366-A574-47B6-B529-9C760477AE7A@gmail.com> <4bd555f70708290627w35d161d3y4ef2bba611e42553@mail.gmail.com> <4bd555f70708290628m5577a666iffa9ed2627f43fa4@mail.gmail.com> Message-ID: <7E2857E5-5EE4-42E0-A690-006F86CD0D81@gmail.com> On Aug 29, 2007, at 2:28 PM, Samuel Tesla wrote: > Is it necessary for your project to link it in and execute it as a > thread? Yes, that's how I want it. This is an IDE and I don't want to send text buffers back and forth over the TCP loopback. I especially don't want to do this for every key press which is something that likely will be needed to provide IntelliSense and similar functionality. Then again, why NOT do it the way I want? Simply because it hasn't been done yet? -- http://wagerlabs.com From joelr1@REDACTED Wed Aug 29 16:24:43 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 15:24:43 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) Message-ID: <4690174B-B135-4C85-B371-35A472313722@gmail.com> I thought I should turn my previous question around and ask it differently. Suppose I wanted to provide IntelliSense and similar functionality for Erlang. I think this will require re-parsing the code buffer on every keystroke or whenever "." (dot) is typed. What is the most efficient way to implement the interface between the editor and the Erlang VM? Would this be pipes? TCP? Building the IDE on top of the Erlang VM itself? In the later case it seems that the buffer would need to be copied in memory to be moved from the Cocoa structures to an Erlang binary that can be supplied to Erlang code. Thanks, Joel -- http://wagerlabs.com From michael.campbell@REDACTED Wed Aug 29 16:44:29 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Wed, 29 Aug 2007 10:44:29 -0400 Subject: [erlang-questions] Reply-to, was Starting the Erlang VM in a new thread Message-ID: <811f2f1c0708290744s3e7fa958x3e491ca451389b2a@mail.gmail.com> On 8/29/07, Samuel Tesla wrote: > (Aplogies to Joel to whom I sent this directly already, I forgot to > Reply-To-All...need coffee.) ...or a list that has a default reply-to as the list. Why does this list NOT do that? It's certainly uncommon in that regard. From jerith@REDACTED Wed Aug 29 16:58:15 2007 From: jerith@REDACTED (Jeremy Thurgood) Date: Wed, 29 Aug 2007 16:58:15 +0200 Subject: [erlang-questions] Reply-to, was Starting the Erlang VM in a new thread In-Reply-To: <811f2f1c0708290744s3e7fa958x3e491ca451389b2a@mail.gmail.com> References: <811f2f1c0708290744s3e7fa958x3e491ca451389b2a@mail.gmail.com> Message-ID: <46D58987.4040506@jerith.za.net> Michael Campbell wrote: > On 8/29/07, Samuel Tesla wrote: >> (Aplogies to Joel to whom I sent this directly already, I forgot to >> Reply-To-All...need coffee.) > > ...or a list that has a default reply-to as the list. Why does this > list NOT do that? It's certainly uncommon in that regard. http://www.unicom.com/pw/reply-to-harmful.html http://woozle.org/~neale/papers/reply-to-still-harmful (Replied to list so we don't inundate the poor chap with responses to this effect.) --J From joelr1@REDACTED Wed Aug 29 16:58:43 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 15:58:43 +0100 Subject: [erlang-questions] Fwd: Starting the Erlang VM in a new thread In-Reply-To: <596131.85171.qm@web27012.mail.ukl.yahoo.com> References: <596131.85171.qm@web27012.mail.ukl.yahoo.com> Message-ID: On Aug 29, 2007, at 3:48 PM, Ewan Higgs wrote: >> You want to use Erlang as a shared memory system? If > you want to implement an Intellisense system at the > keystroke level, I think you should investigate some > more optimal bookkeeping with the Erlang process > rather than moving to a shared memory basis. What I'm investigating is whether I can do _all the coding_ in Erlang, with the exception of visualization. This could be done by means of a Cocoa bridge. To figure out what changed in the buffer I would need to do the bookkeeping in Objective-C which I don't fancy. > For example, you could limit the text sent as deltas > rather than the full text each time. Since you're > fairly proficient with Haskell, how about hijacking > the darcs patch system and using that as the basis for > your bookkeeping. I don't see how this would work since I would need to apply the patch on the receiving end and that code would need to be written in Erlang. Then again, the hard part is figuring out the delta... It could well work but then the IDE would need to be written in Haskell. Thanks, Joel -- http://wagerlabs.com From joelr1@REDACTED Wed Aug 29 17:27:33 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 16:27:33 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <4690174B-B135-4C85-B371-35A472313722@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> Message-ID: <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> Unix pipes are, apparently, faster than TCP sockets on the same machine. http://rikkus.info/sysv-ipc-vs-pipes-vs-unix-sockets.html -- http://wagerlabs.com From bob@REDACTED Wed Aug 29 18:34:04 2007 From: bob@REDACTED (Bob Ippolito) Date: Wed, 29 Aug 2007 09:34:04 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> Message-ID: <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> All that tells you is that pipes were faster than TCP 5 years ago on and old i386 Linux kernel on i386. Nothing about those benchmarks can really be applied to anything you'd deploy on today. Also, it looks like the benchmark is probably synchronous, you could very well get entirely different results with an epoll based stack, like Erlang would use. On 8/29/07, Joel Reymont wrote: > Unix pipes are, apparently, faster than TCP sockets on the same machine. > > http://rikkus.info/sysv-ipc-vs-pipes-vs-unix-sockets.html > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Aug 29 18:59:28 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 17:59:28 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> Message-ID: <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> On Aug 29, 2007, at 5:34 PM, Bob Ippolito wrote: > you could very well get > entirely different results with an epoll based stack, like Erlang > would use. How do you enable epoll on the Mac? On 10.4.10 I see the following when configuring Erlang... checking sys/epoll.h usability... no checking sys/epoll.h presence... no checking sys/devpoll.h usability... no checking sys/devpoll.h presence... no checking for sys/devpoll.h... no checking for working poll()... broken or based on select() checking whether kqueue() is known to be broken... no checking whether kqueue() fd can be select()ed on... yes checking whether kernel poll support should be enabled... yes; kqueue After all is said and built I still end up with Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [kernel-poll:false] What am I doing wrong? Thanks, Joel -- http://wagerlabs.com From hubaghdadi@REDACTED Wed Aug 29 18:58:16 2007 From: hubaghdadi@REDACTED (Lone Wolf) Date: Wed, 29 Aug 2007 09:58:16 -0700 (PDT) Subject: [erlang-questions] Functional Programming Message-ID: <312328.49257.qm@web51106.mail.re2.yahoo.com> Hi. Consider please this Erlang code: code: --------------------------------- fac(1) -> 1; fac(N) -> N * fac(N - 1). --------------------------------- I don't understand whats happening when I call: fac(5) I'm not sure but it seems to me it is "Recursion", right? 5 * fac(4) 4 * fac(3) 3 * fac(2) etc.. Thanks. Deep into that darkness peering, long I stood there, wondering, fearing, Doubting, dreaming dreams no mortal ever dreamed before. E.A Poe --------------------------------- Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dustin@REDACTED Wed Aug 29 20:07:35 2007 From: dustin@REDACTED (Dustin Sallings) Date: Wed, 29 Aug 2007 11:07:35 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> Message-ID: On Aug 29, 2007, at 9:59 , Joel Reymont wrote: > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] > [kernel-poll:false] kqueue is good stuff, but you have to specifically enable it with +K. Then again, I don't know why it's disabled by default. -- Dustin Sallings From kip.macy@REDACTED Wed Aug 29 20:12:05 2007 From: kip.macy@REDACTED (Kip Macy) Date: Wed, 29 Aug 2007 11:12:05 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> Message-ID: On 8/29/07, Joel Reymont wrote: > On Aug 29, 2007, at 5:34 PM, Bob Ippolito wrote: > > > you could very well get > > entirely different results with an epoll based stack, like Erlang > > would use. > > How do you enable epoll on the Mac? epoll(4) is a linux primitive, BSD derived operating systems use kqueue for efficient event notification. Nonetheless, it doesn't matter that much for small numbers of descriptors. -Kip From kip.macy@REDACTED Wed Aug 29 20:15:04 2007 From: kip.macy@REDACTED (Kip Macy) Date: Wed, 29 Aug 2007 11:15:04 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> Message-ID: On 8/29/07, Bob Ippolito wrote: > All that tells you is that pipes were faster than TCP 5 years ago on > and old i386 Linux kernel on i386. Nothing about those benchmarks can > really be applied to anything you'd deploy on today. Also, it looks > like the benchmark is probably synchronous, you could very well get > entirely different results with an epoll based stack, like Erlang > would use. Linux has a pretty efficient TCP stack, unless one bypasses the TCP/IP layers when connecting over localhost pipes will have fundamentally less work to do i.e. just copy in to the kernel, copy out of the kernel - or for larger transfers the kernel can map the destination buffer into the OS and copy directly. -Kip > > On 8/29/07, Joel Reymont wrote: > > Unix pipes are, apparently, faster than TCP sockets on the same machine. > > > > http://rikkus.info/sysv-ipc-vs-pipes-vs-unix-sockets.html > > > > -- > > http://wagerlabs.com > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From samuel.tesla@REDACTED Wed Aug 29 20:17:10 2007 From: samuel.tesla@REDACTED (Samuel Tesla) Date: Wed, 29 Aug 2007 13:17:10 -0500 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <4690174B-B135-4C85-B371-35A472313722@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> Message-ID: <4bd555f70708291117x13850674x4f155ddd0c468a0b@mail.gmail.com> On 8/29/07, Joel Reymont wrote: > > Suppose I wanted to provide IntelliSense and similar functionality > for Erlang. I think this will require re-parsing the code buffer on > every keystroke or whenever "." (dot) is typed. > > What is the most efficient way to implement the interface between the > editor and the Erlang VM? > While this is a valuable question to ask, I'd think it's a bit premature. Are you sure that just using the erl_interface isn't going to be performant enough? Have you profiled it? If the easy solution ends up being fast enough, why bang your head against trying to engineer a faster one? There are at least two other projects that are similar to what you seem to be doing, that I know of. For Emacs: http://fresh.homeunix.net/~luke/distel/ For Eclipse: http://erlide.sourceforge.net/ I know that Distel connects to any Erlang node, so it is using the TCP. I use distel myself and it does context sensitive parsing so that function signatures show up in my Emacs minibuffer and various other things, and I never even notice any performance penalty. I haven't used Erlide myself, but I imagine it's pretty decent. I assume that it is using the JInterface, so it is doing the same thing. -- Samuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Aug 29 20:27:23 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 19:27:23 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <4bd555f70708291117x13850674x4f155ddd0c468a0b@mail.gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4bd555f70708291117x13850674x4f155ddd0c468a0b@mail.gmail.com> Message-ID: <964301BD-FB72-4939-AC2A-B6719D63B3A0@gmail.com> On Aug 29, 2007, at 7:17 PM, Samuel Tesla wrote: > If the easy solution ends up being fast > enough, why bang your head against trying to engineer a faster one? True. > There are at least two other projects that are similar to what you > seem to > be doing, that I know of. > > For Emacs: http://fresh.homeunix.net/~luke/distel/ > For Eclipse: http://erlide.sourceforge.net/ I don't believe the parsing of the Erlang code in these two is done in Erlang. Distel is surely using Emacs Lisp and ErlIDE must be using Java. Joel -- http://wagerlabs.com From vladdu55@REDACTED Wed Aug 29 20:28:23 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 29 Aug 2007 18:28:23 +0000 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <4690174B-B135-4C85-B371-35A472313722@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> Message-ID: <95be1d3b0708291128u74f9d2cbl18756e464cc7d3ba@mail.gmail.com> Hi, On 8/29/07, Joel Reymont wrote: > > > Suppose I wanted to provide IntelliSense and similar functionality > for Erlang. I think this will require re-parsing the code buffer on > every keystroke or whenever "." (dot) is typed. > > No, not all the buffer. At every moment, you have the token stream corresponding to the test. Entering a character is a local change, only the tokens around that position need to be examined. Of course, entering a " (for example) is non-local, but one can assume that the user will insert the contents of the string and another ", so one doesn't need to rescan everything unless there is a longer pause or some other event that signals the insertion is over. In the same spirit, each node in the parse tree can hold references to the beginning and ending tokens and keep reparsing at a minimum while there is an edit going on. This is what we are trying to do in Erlide, but I confess it's not yet as stable and bug-free as I'd like it. Returning to your question, I think that with such incremental scanner and parser it could be fast enough to send each entered character to Erlang. best regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon.j.miller@REDACTED Wed Aug 29 20:49:00 2007 From: gordon.j.miller@REDACTED (Jim Miller) Date: Wed, 29 Aug 2007 14:49:00 -0400 Subject: [erlang-questions] Stopping a port from within erlang Message-ID: I'm trying to wrap some legacy applications behind a gen_server interface to allow me to supervise them in an OTP fashion. I can start the processes fine with the open_port but I'm looking for a way to stop the spawned application from within erlang. At the moment, when I terminate the gen_server wrapper that spawns the process it leaves the process running, even after I exit erlang. Regretably I can't modify the spawned application to listen to a message from erlang and I'd rather not write another layer to do this. I'm currently using the open_port because the only other function os.Cmd isn't quite what I'm looking for. Is there something equivalent to exec? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Aug 29 20:49:46 2007 From: bob@REDACTED (Bob Ippolito) Date: Wed, 29 Aug 2007 11:49:46 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> Message-ID: <6a36e7290708291149s380fc7adqfee75e21d65ca3b4@mail.gmail.com> On 8/29/07, Joel Reymont wrote: > On Aug 29, 2007, at 5:34 PM, Bob Ippolito wrote: > > > you could very well get > > entirely different results with an epoll based stack, like Erlang > > would use. > > How do you enable epoll on the Mac? > Oh sorry, you don't. I had forgot you were talking about Cocoa, because you referred to ancient Linux benchmarks! Mac OS X is kqueue, and its networking stack has totally different performance characteristics than Linux. -bob From vladdu55@REDACTED Wed Aug 29 20:50:02 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 29 Aug 2007 18:50:02 +0000 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <964301BD-FB72-4939-AC2A-B6719D63B3A0@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4bd555f70708291117x13850674x4f155ddd0c468a0b@mail.gmail.com> <964301BD-FB72-4939-AC2A-B6719D63B3A0@gmail.com> Message-ID: <95be1d3b0708291150h39697222nee3b64cb889422eb@mail.gmail.com> On 8/29/07, Joel Reymont wrote: > > I don't believe the parsing of the Erlang code in these two is done > in Erlang. Distel is surely using Emacs Lisp and ErlIDE must be using > Java. > > Actually, Erlide is using Erlang. Why write a scanner and aparser from scratch when we have perfectly good tools at our disposal? We are trying to move as much as possible of the functionality to the Erlang side, leaving Java just as thin wrappers, possibly with some caching if necessary. This is harder than it sounds, because Eclipse is so complex. To this reason I implemented a way to call Java code from Erlang, so that for example we can pass a progress monitor to a lengthy operation and have it called from the Erlang code. The biggest problem we have is the impedance mismatch between the natural concurrency of an Erlang system and the relatively contrived use of threading in a Java application with a GUI. best regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From dking@REDACTED Wed Aug 29 21:04:53 2007 From: dking@REDACTED (David King) Date: Wed, 29 Aug 2007 12:04:53 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> Message-ID: > How do you enable epoll on the Mac? > On 10.4.10 I see the following when configuring Erlang... The erlang from MacPorts has kernel polling by default: ~% uname -a Darwin ayla.local 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386 ~% echo $ERL_FLAGS -smp auto +K true +Bc ~% erl Erlang (BEAM) emulator version 5.5.5 [source] [smp:2] [async-threads: 0] [hipe] [kernel-poll:true] > > checking sys/epoll.h usability... no > checking sys/epoll.h presence... no > > checking sys/devpoll.h usability... no > checking sys/devpoll.h presence... no > checking for sys/devpoll.h... no > > checking for working poll()... broken or based on select() > checking whether kqueue() is known to be broken... no > checking whether kqueue() fd can be select()ed on... yes > checking whether kernel poll support should be enabled... yes; kqueue > > After all is said and built I still end up with > > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] > [kernel-poll:false] > > > What am I doing wrong? > > Thanks, Joel > > -- > http://wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlangx@REDACTED Wed Aug 29 21:13:07 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 29 Aug 2007 12:13:07 -0700 Subject: [erlang-questions] Stopping a port from within erlang In-Reply-To: References: Message-ID: <20070829191307.GX23220@delora.autosys.us> On Wed, Aug 29, 2007 at 02:49:00PM -0400, Jim Miller wrote: > I'm trying to wrap some legacy applications behind a gen_server interface to > allow me to supervise them in an OTP fashion. I can start the processes fine > with the open_port but I'm looking for a way to stop the spawned application > from within erlang. At the moment, when I terminate the gen_server wrapper > that spawns the process it leaves the process running, even after I exit > erlang. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Here's how I'm using open_port and killing the spawned process. You may be able to use something similar. Platform specific as well. my platform $ uname -a Linux delora 2.6.20-15-386 #2 Sun Apr 15 07:34:00 UTC 2007 i686 GNU/Linux ==> starting ... {Port, Pid} = port(). % first received data from port should be Pid port() -> Port = open_port( {spawn, MyProgram}, [eof, exit_status, use_stdio, binary] ), receive {Portb, {data, Pid_with_linefeed}} -> {ok, Pid, 1} = regexp:gsub( binary_to_list(Pid_with_linefeed), "\n", "") end , {Port, Pid} . ==> use the port with receive for the "real" data receive {Port, {data, Data}} -> blah blah ... end ==> when time to cleanup os:cmd("/bin/kill -9 " ++ Pid). ~Michael > > Regretably I can't modify the spawned application to listen to a message from > erlang and I'd rather not write another layer to do this. I'm currently using > the open_port because the only other function os.Cmd isn't quite what I'm > looking for. Is there something equivalent to exec? > > Thanks > > !DSPAM:52,46d5bfb673321047272708! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,46d5bfb673321047272708! -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From grpack@REDACTED Wed Aug 29 21:01:52 2007 From: grpack@REDACTED (Gabriel Pack) Date: Wed, 29 Aug 2007 12:01:52 -0700 Subject: [erlang-questions] Functional Programming In-Reply-To: <312328.49257.qm@web51106.mail.re2.yahoo.com> References: <312328.49257.qm@web51106.mail.re2.yahoo.com> Message-ID: <40396DF5-940E-484C-928F-99EBB7241EC8@mac.com> Yes, your function fac/1 is using recursion to calculate the product of the first N natural numbers. Something to be worried about is if N is less than 1. When you call fac(5), you get successive calls to fac(4), fac(3), and fac(2). All 4 of these calls go to the second clause of your function (i.e. fac(N)). The final call is to fac(1) which is handled by the first clause of your function (i.e. fac(1)). This is the terminal case of your recursion. Gabe On Aug 29, 2007, at 9:58 AM, Lone Wolf wrote: > Hi. > Consider please this Erlang code: > > code: > > fac(1) -> > 1; > fac(N) -> > N * fac(N - 1). > > I don't understand whats happening when I call: > fac(5) > I'm not sure but it seems to me it is "Recursion", right? > 5 * fac(4) > 4 * fac(3) > 3 * fac(2) > etc.. > Thanks. > > > Deep into that darkness peering, long I stood there, wondering, > fearing, Doubting, dreaming dreams no mortal ever dreamed before. > E.A Poe > > > Boardwalk for $500? In 2007? Ha! > Play Monopoly Here and Now (it's updated for today's economy) at > Yahoo! Games. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Aug 29 20:34:33 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 19:34:33 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <95be1d3b0708291128u74f9d2cbl18756e464cc7d3ba@mail.gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <95be1d3b0708291128u74f9d2cbl18756e464cc7d3ba@mail.gmail.com> Message-ID: On Aug 29, 2007, at 7:28 PM, Vlad Dumitrescu wrote: > Returning to your question, I think that with such incremental > scanner and > parser it could be fast enough to send each entered character to > Erlang. What do you do when text is cut or pasted? -- http://wagerlabs.com From klacke@REDACTED Wed Aug 29 21:50:33 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Wed, 29 Aug 2007 21:50:33 +0200 Subject: [erlang-questions] Stopping a port from within erlang In-Reply-To: References: Message-ID: <46D5CE09.70805@hyber.org> Jim Miller wrote: > I'm trying to wrap some legacy applications behind a gen_server > interface to allow me to supervise them in an OTP fashion. I can start > the processes fine with the open_port but I'm looking for a way to stop 4> open_port({spawn, "echo $$; sleep 1000"}, []). #Port<0.105> 5> flush(). Shell got {#Port<0.105>,{data,"3578\n"}} ok Pick up the integer and then os:cmd("kill " ++ IntList) /klacke From qrilka@REDACTED Wed Aug 29 21:28:33 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 29 Aug 2007 23:28:33 +0400 Subject: [erlang-questions] Sending funs between nodes Message-ID: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> I was trying to do the following: 1) a module on node X - ------------------- -module(test1). -export([go/0]). go() -> P = spawn(fun() -> receive X -> X() end end), register(rrr, P). ------------------- 2) a module on node Y - ------------------- -module(test2). -export([go/0]). go() -> {rrr, x@REDACTED}!fun() -> io:format("bar",[]) end. ------------------- LOKI is my hostname :) So If I run test1:go() and then test2:go() on other node I get =ERROR REPORT==== 29-Aug-2007::22:34:29 === Error in process <0.35.0> on node 'y@REDACTED' with exit value: {undef,[{shell_defau lt,fun_to_list,[#Fun]},{erl_eval,do_apply,5},{shell,exprs, 6},{shell,eval_loop,3}]} ** exited: {undef,[{shell_default,fun_to_list,[#Fun]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** It looks like fun needs code of the module where it was defined. Why is it so? is there any way around this issue? Or I need the same beams on all the nodes? Best regards, Kirill Zaborski. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Aug 29 22:41:32 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 29 Aug 2007 21:41:32 +0100 Subject: [erlang-questions] Cocoa bridge Message-ID: <8DB57EA2-E763-4013-94B3-823229BBEA59@gmail.com> An interesting stumbling block is the implementation of the Erlang wrapper for objc_msgSend. This function has the following signature id objc_msgSend(id theReceiver, SEL theSelector, ...) so a var args list (...) needs to be built to invoke it. The port output function takes a buffer, though, so the meaning of each argument needs to be extracted from that. I see no option other than to make objc:send take a list of tuples where the first element of each tuple specifies the type of the argument. Joel -- http://wagerlabs.com From billclem@REDACTED Wed Aug 29 23:09:15 2007 From: billclem@REDACTED (Bill Clementson) Date: Wed, 29 Aug 2007 14:09:15 -0700 Subject: [erlang-questions] Cocoa IDE for Erlang (again) References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4bd555f70708291117x13850674x4f155ddd0c468a0b@mail.gmail.com> <964301BD-FB72-4939-AC2A-B6719D63B3A0@gmail.com> Message-ID: Joel Reymont writes: > On Aug 29, 2007, at 7:17 PM, Samuel Tesla wrote: > >> If the easy solution ends up being fast >> enough, why bang your head against trying to engineer a faster one? > > True. > >> There are at least two other projects that are similar to what you >> seem to >> be doing, that I know of. >> >> For Emacs: http://fresh.homeunix.net/~luke/distel/ >> For Eclipse: http://erlide.sourceforge.net/ > > I don't believe the parsing of the Erlang code in these two is done > in Erlang. Distel is surely using Emacs Lisp and ErlIDE must be using > Java. Distel uses a combination of Emacs Lisp and Erlang code. The documents linked to from the Distel home page provide a good description of where each is used: http://fresh.homeunix.net/~luke/distel/ - Bill From wglozer@REDACTED Thu Aug 30 00:39:46 2007 From: wglozer@REDACTED (Will) Date: Wed, 29 Aug 2007 15:39:46 -0700 Subject: [erlang-questions] regular expressions on binaries In-Reply-To: References: Message-ID: On 8/25/07, Paul Mineiro wrote: > > Is there an analog to regexp available that works on binaries? oregexp, http://glozer.net/code.html#oregexp, is another linked in driver (using Oniguruma) that supports both binaries and lists. From zac@REDACTED Wed Aug 29 23:56:08 2007 From: zac@REDACTED (Zac Brown) Date: Wed, 29 Aug 2007 17:56:08 -0400 Subject: [erlang-questions] [Fwd: Re: Functional Programming] Message-ID: <46D5EB78.9030701@zacbrown.org> Hi: You're correct that it is recursion and the calls you listed are corrected. Essentially this is a stack-expanding recursive call which are bad because you're building up your recursive calls and if its a big number, you risk blowing the stack. The best way to define this function in the manner you have is as follows: fac(N) - > fac_helper(N, 1). fac_helper(1, Tot) -> Tot; fac_helper(N, Tot) -> fac_helper(N - 1, Tot * N). We keep track of the current sum with the variable Tot, which means that we don't build the stack, we call in place because we don't rely on later function calls in order to get our answer, we only rely on a variable that keeps track of your current total. This is called tail recursion and is the best way to write recursive functions. Cheers, Zac Lone Wolf wrote: > Hi. > Consider please this Erlang code: > > code: > ------------------------------------------------------------------------ > > > fac(1) -> > 1; > fac(N) -> > N * fac(N - 1). > > ------------------------------------------------------------------------ > > > I don't understand whats happening when I call: > fac(5) > I'm not sure but it seems to me it is "Recursion", right? > 5 * fac(4) > 4 * fac(3) > 3 * fac(2) > etc.. > Thanks. > > > */Deep into that darkness peering, long I stood there, wondering, > fearing, Doubting, dreaming dreams no mortal ever dreamed before./* > */E.A Poe/* > *//* > *//* > > ------------------------------------------------------------------------ > Boardwalk for $500? In 2007? Ha! > Play Monopoly Here and Now > > (it's updated for today's economy) at Yahoo! Games. > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From codeslinger@REDACTED Thu Aug 30 03:47:40 2007 From: codeslinger@REDACTED (Toby DiPasquale) Date: Wed, 29 Aug 2007 21:47:40 -0400 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> <83360EF5-F088-4FA0-94FC-1B7DC9A1B6B5@gmail.com> Message-ID: <876ef97a0708291847y6a9aba5dq5397bd7f5c603fe9@mail.gmail.com> On 8/29/07, Dustin Sallings wrote: > > On Aug 29, 2007, at 9:59 , Joel Reymont wrote: > > > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] > > [kernel-poll:false] > > kqueue is good stuff, but you have to specifically enable it with +K. > > Then again, I don't know why it's disabled by default. Most likely because kqueue(2)/kevent(2) on Mac OS X was broken until Tiger (10.4). Just a guess, though. -- Toby DiPasquale From bengt.kleberg@REDACTED Thu Aug 30 08:41:53 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 30 Aug 2007 08:41:53 +0200 Subject: [erlang-questions] Sending funs between nodes In-Reply-To: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> References: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> Message-ID: <46D666B1.4090503@ericsson.com> Greetings, yes, the fun needs the code. yes, you need the beam files on both nodes. bengt Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." On 2007-08-29 21:28, Kirill Zaborski wrote: > I was trying to do the following: > 1) a module on node X - > ------------------- > -module(test1). > -export([go/0]). > > go() -> > P = spawn(fun() -> receive X -> X() end end), > register(rrr, P). > ------------------- > 2) a module on node Y - > ------------------- > -module(test2). > -export([go/0]). > > go() -> > {rrr, x@REDACTED}!fun() -> io:format("bar",[]) end. > ------------------- > > LOKI is my hostname :) > > So If I run test1:go() and then test2:go() on other node I get > > =ERROR REPORT==== 29-Aug-2007::22:34:29 === > Error in process <0.35.0> on node 'y@REDACTED' with exit value: > {undef,[{shell_defau > lt,fun_to_list,[#Fun]},{erl_eval,do_apply,5},{shell,exprs, > 6},{shell,eval_loop,3}]} > > ** exited: {undef,[{shell_default,fun_to_list,[#Fun]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > It looks like fun needs code of the module where it was defined. Why is > it so? > is there any way around this issue? Or I need the same beams on all the > nodes? > > > Best regards, > Kirill Zaborski. > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From lenartlad@REDACTED Thu Aug 30 09:23:28 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Thu, 30 Aug 2007 09:23:28 +0200 Subject: [erlang-questions] Sending funs between nodes In-Reply-To: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> References: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> Message-ID: <46D67070.2070501@volny.cz> Kirill Zaborski wrote: > It looks like fun needs code of the module where it was defined. Why is > it so? > is there any way around this issue? Or I need the same beams on all the > nodes? Hello, if I recall it correctly, funs are always passed as references. Therefore you have to load at least modules that contain funs that are sent to other nodes. Hope this helps, Ladislav Lenart From petrilli@REDACTED Thu Aug 30 06:56:10 2007 From: petrilli@REDACTED (Christopher Petrilli) Date: Thu, 30 Aug 2007 00:56:10 -0400 Subject: [erlang-questions] Strange meshing behavior between 3 machines Message-ID: Here's the background: Host A = Ubuntu 7.04 w/R11B-5 Host B = Ubuntu 7.05 w/R11B-5 Host C = MacOS X 10.4.10 w/R11B-4 As far as I know the patch level different shouldn't matter. The .hosts.erlang file on each is as follows: Host A: 'B'. 'C'. Host B: 'A'. 'C'. Host C: 'A'. 'B'. Now here's where it gets interesting. I have the following set of VMs running: one@REDACTED two@REDACTED three@REDACTED four@REDACTED five@REDACTED So far, so good, right? Each of these was started with 'erl -sname one/two/three'. What's weird is the behavior of the meshing. On host A, I see all 5 nodes. On host B, I see all 5 nodes. This is verified with nodes/0, net_adm:world/0 and net_adm:names/0, which as far as I know, feeds net_adm:world/0. That's as it should be. The weird part is that on host C, I see weird things depending on what command I use: nodes/0: all nodes are seen net_adm:names/0: all nodes are seen net_adm:world/0: only sees one@REDACTED and two@REDACTED, but no other @C If I run net_adm:world(verbose), it shows it's only pinging one@REDACTED and two@REDACTED, even though net_adm:names/0 seems to see them all. If I change the .hosts.erlang file on Host C to: 'A'. 'B'. 'C'. It works. This is a totally different behavior from hosts A and B. Any thoughts on where this oddity is coming from? The machines all share a private VMware network (vmnet1) on 172.16.170.x and have no firewalls prohibiting them inside that network. Chris -- | Chris Petrilli | petrilli@REDACTED From hendrik.muller@REDACTED Thu Aug 30 10:09:26 2007 From: hendrik.muller@REDACTED (HJ Muller) Date: Thu, 30 Aug 2007 10:09:26 +0200 Subject: [erlang-questions] Making sense of MnesiaCore dumps Message-ID: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> Hi everyone, Is there anyway to make sense of an mnesia core dump ? I have about 20 core dumps of +/-40Mb each, and I can't even make sense of one. Is there maybe some tool that can use ? Regards, Hendrik Email legal notice can be viewed at http://www.swisttech.com/email.htm or call: + 27 21 888 7920 From adam@REDACTED Thu Aug 30 10:16:56 2007 From: adam@REDACTED (Adam Lindberg) Date: Thu, 30 Aug 2007 10:16:56 +0200 Subject: [erlang-questions] Dialyzer "function X has no local return"? Message-ID: <6344005f0708300116u3812f57byb3b3ba4a86ebdddc@mail.gmail.com> Hi all, What are the implications of adding a local return value? Let's consider the following code which will raise the warning: x() -> head_of_to_a_loop_which_will_never_return(). The warning: module.erl:3: Function x/0 has no local return This can be changed to the function below just to satisfy Dialyzer: x() -> head_of_to_a_loop_which_will_never_return(), nobody_will_ever_see_this_atom. Wouldn't that last atom stay somewhere in case the above function call actually would return. Because I guess there is no way for the compiler to know that so it has to keep that last line, thus no tail optimizations are possible. Am I right? Any thoughts on this? Cheers! Adam -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Aug 30 10:29:23 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 30 Aug 2007 10:29:23 +0200 Subject: [erlang-questions] Making sense of MnesiaCore dumps In-Reply-To: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> References: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> Message-ID: <46D67FE3.9080503@ericsson.com> HJ Muller wrote: > Hi everyone, > > Is there anyway to make sense of an mnesia core dump ? > I have about 20 core dumps of +/-40Mb each, and I can't even make sense > of one. Is there maybe some tool that can use ? AFAIR: {ok, Bin} = file:read_file(CoreDump). Term = binary_to_term(Bin). {ok,Fd} = file:open(CoreDump ++ ".txt", [write]). io:fwrite(Fd, "~p~.~n", [Term]). file:close(Fd). Then you have the dump as pretty-printed text in a file. (Note, the above is written from memory - not verified). BR, Ulf W From pacini@REDACTED Thu Aug 30 11:24:03 2007 From: pacini@REDACTED (Filippo Pacini) Date: Thu, 30 Aug 2007 11:24:03 +0200 Subject: [erlang-questions] Making sense of MnesiaCore dumps In-Reply-To: <46D67FE3.9080503@ericsson.com> References: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> <46D67FE3.9080503@ericsson.com> Message-ID: <46D68CB3.60503@sgconsulting.it> Or use webtool. 1> webtool:start(). WebTool is available at http://localhost:8888/ Or http://127.0.0.1:8888/ {ok,<0.35.0>} Then open your browser and load the core dump file. filippo Ulf Wiger (TN/EAB) wrote: > HJ Muller wrote: >> Hi everyone, >> >> Is there anyway to make sense of an mnesia core dump ? >> I have about 20 core dumps of +/-40Mb each, and I can't even make sense >> of one. Is there maybe some tool that can use ? > > AFAIR: > > {ok, Bin} = file:read_file(CoreDump). > Term = binary_to_term(Bin). > {ok,Fd} = file:open(CoreDump ++ ".txt", [write]). > io:fwrite(Fd, "~p~.~n", [Term]). > file:close(Fd). > > Then you have the dump as pretty-printed text > in a file. > > (Note, the above is written from memory - not verified). > > BR, > Ulf W From qrilka@REDACTED Thu Aug 30 11:27:43 2007 From: qrilka@REDACTED (Kirill Zaborski) Date: Thu, 30 Aug 2007 09:27:43 +0000 Subject: [erlang-questions] Sending funs between nodes In-Reply-To: <46D666B1.4090503@ericsson.com> References: <337538cb0708291228u415559a1jd02bbbcecb9b3ccb@mail.gmail.com> <46D666B1.4090503@ericsson.com> Message-ID: <337538cb0708300227o3efb0b8bk84b4a413613b7875@mail.gmail.com> But I do not see the reason of it. Any hints? Are funs implemented somewhat like "anonymous" functions (so internally they are normal functions but they do not have "normal" name)? Regards, Kirill. On 8/30/07, Bengt Kleberg wrote: Greetings, > > > yes, the fun needs the code. > yes, you need the beam files on both nodes. > > > bengt > > Those were the days... > EPO guidelines 1978: \\\"If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims.\\\" > > > On 2007-08-29 21:28, Kirill Zaborski wrote: > > I was trying to do the following: > > 1) a module on node X - > > ------------------- > > -module(test1). > > -export([go/0]). > > > > go() -> > > P = spawn(fun() -> receive X -> X() end end), > > register(rrr, P). > > ------------------- > > 2) a module on node Y - > > ------------------- > > -module(test2). > > -export([go/0]). > > > > go() -> > > {rrr, x@REDACTED}!fun() -> io:format(\\\"bar\\\",[]) end. > > ------------------- > > > > LOKI is my hostname :) > > > > So If I run test1:go() and then test2:go() on other node I get > > > > =ERROR REPORT==== 29-Aug-2007::22:34:29 === > > Error in process <0.35.0> on node \\\'y@REDACTED\\\' with exit value: > > {undef,[{shell_defau > > lt,fun_to_list,[#Fun]},{erl_eval,do_apply,5},{shell,exprs, > > 6},{shell,eval_loop,3}]} > > > > ** exited: {undef,[{shell_default,fun_to_list,[#Fun]}, > > {erl_eval,do_apply,5}, > > {shell,exprs,6}, > > {shell,eval_loop,3}]} ** > > > > It looks like fun needs code of the module where it was defined. Why is > > it so? > > is there any way around this issue? Or I need the same beams on all the > > nodes? > > > > > > Best regards, > > Kirill Zaborski. > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dgud@REDACTED Thu Aug 30 11:40:34 2007 From: dgud@REDACTED (Dan Gudmundsson) Date: Thu, 30 Aug 2007 11:40:34 +0200 Subject: [erlang-questions] Making sense of MnesiaCore dumps In-Reply-To: <46D68CB3.60503@sgconsulting.it> References: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> <46D67FE3.9080503@ericsson.com> <46D68CB3.60503@sgconsulting.it> Message-ID: <46D69092.7020909@erix.ericsson.se> mnesia_lib:view(File). /Dan Filippo Pacini wrote: > Or use webtool. > > 1> webtool:start(). > WebTool is available at http://localhost:8888/ > Or http://127.0.0.1:8888/ > {ok,<0.35.0>} > > Then open your browser and load the core dump file. > > filippo > > Ulf Wiger (TN/EAB) wrote: >> HJ Muller wrote: >>> Hi everyone, >>> >>> Is there anyway to make sense of an mnesia core dump ? >>> I have about 20 core dumps of +/-40Mb each, and I can't even make sense >>> of one. Is there maybe some tool that can use ? >> AFAIR: >> >> {ok, Bin} = file:read_file(CoreDump). >> Term = binary_to_term(Bin). >> {ok,Fd} = file:open(CoreDump ++ ".txt", [write]). >> io:fwrite(Fd, "~p~.~n", [Term]). >> file:close(Fd). >> >> Then you have the dump as pretty-printed text >> in a file. >> >> (Note, the above is written from memory - not verified). >> >> BR, >> Ulf W > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pacini@REDACTED Thu Aug 30 12:55:06 2007 From: pacini@REDACTED (Filippo Pacini) Date: Thu, 30 Aug 2007 12:55:06 +0200 Subject: [erlang-questions] Making sense of MnesiaCore dumps In-Reply-To: <46D68CB3.60503@sgconsulting.it> References: <1188461366.5249.13.camel@HENNIE-PC.mxit.corp> <46D67FE3.9080503@ericsson.com> <46D68CB3.60503@sgconsulting.it> Message-ID: <46D6A20A.2020807@sgconsulting.it> Ops. I read MnesiaCore dumps and thought of a erlang crash dump. I don't know if webtool can show also mnesia core dumps. filippo Filippo Pacini wrote: > Or use webtool. > > 1> webtool:start(). > WebTool is available at http://localhost:8888/ > Or http://127.0.0.1:8888/ > {ok,<0.35.0>} > > Then open your browser and load the core dump file. > From joelr1@REDACTED Thu Aug 30 14:33:52 2007 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Aug 2007 13:33:52 +0100 Subject: [erlang-questions] driver_output_term, driver_send_term and ei Message-ID: It seems that the erl_driver docs recommend using driver_output_term for efficiency reason. It seems the difference bewteeen driver_output_term and driver_send_term is that the former only sends data to the port owner process. I noticed that Klacke uses driver_send_term in his posregex linked-in driver. Would driver_output_term work just as well if the driver was given the pid of the caller to be given back to the port owner process? Generally speaking, are there guidelines for when to use each function? Should I use term_to_binary nowadays to send data to the driver, ei to decode in the driver and driver_output_term to send back? Thanks, Joel P.S. I'm familiar with the FFI in Lisp, Haskell and OCaml. I must admit that the Erlang FFI seems to be the most pain in the rear of them all. I think it's also the least efficient when dealing with GUI APIs like Cocoa on the Mac since data needs to be convert to and from Erlang binaries and then back to C structures. -- http://wagerlabs.com From bitcowboy@REDACTED Thu Aug 30 14:33:31 2007 From: bitcowboy@REDACTED (Jeffrey Chen) Date: Thu, 30 Aug 2007 20:33:31 +0800 Subject: [erlang-questions] How can I implement a priority queue with Erlang? Message-ID: I'm trying to implement a priority queue using heap struct. But I can't do that efficient. Can anybody help me? I'll post my code below. Thanks. CODE: exchange([], _, _, _, _, _) -> []; exchange([_ | Rest], IndexA, ValueA, IndexB, ValueB, Index) when IndexA == Index -> [ValueB | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]; exchange([_ | Rest], IndexA, ValueA, IndexB, ValueB, Index) when IndexB == Index -> [ValueA | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]; exchange([Head | Rest], IndexA, ValueA, IndexB, ValueB, Index) -> [Head | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]. %%% Heap %%% max_heapify(Heap, Index) when Index * 2 > length(Heap) -> Heap; max_heapify(Heap, Index) -> IndexValue = lists:nth(Index, Heap), LeftIndex = 2 * Index, LeftValue = lists:nth(LeftIndex, Heap), if 2 * Index + 1 > length(Heap) -> RightIndex = LeftIndex, RightValue = LeftValue; true -> RightIndex = 2 * Index + 1, RightValue = lists:nth(RightIndex, Heap) end, if LeftValue > IndexValue, LeftValue >= RightValue -> LargestIndex = LeftIndex, LargestValue = LeftValue; RightValue > IndexValue, RightValue >= LeftValue -> LargestIndex = RightIndex, LargestValue = RightValue; true -> LargestIndex = Index, LargestValue = IndexValue end, if LargestIndex /= Index -> NewHeap = exchange(Heap, Index, IndexValue, LargestIndex, LargestValue, 1), max_heapify(NewHeap, LargestIndex); true -> Heap end. build_heap(L, 0) -> L; build_heap(L, Index) -> NewL = max_heapify(L, Index), build_heap(NewL, Index - 1). make_heap([]) -> []; make_heap(L) -> build_heap(L, trunc(length(L) / 2)). heap_pop([Head | Rest]) when length(Rest) == 0 -> {Head, []}; heap_pop([Head | Rest]) -> {RestBody, RestTail} = lists:split(length(Rest) - 1, Rest), {Head, max_heapify(RestTail ++ RestBody, 1)}. test_heap_pop([]) -> done; test_heap_pop(Heap) -> {P, H} = heap_pop(Heap), io:format("~w, ~w~n", [P, H]), test_heap_pop(H). adjust_heap_node(Heap, Index) when trunc(Index / 2) == 0 -> Heap; adjust_heap_node(Heap, Index) -> IndexValue = lists:nth(Index, Heap), ParentIndex = trunc(Index / 2), ParentValue = lists:nth(ParentIndex, Heap), if IndexValue > ParentValue -> NewHeap = exchange(Heap, Index, IndexValue, ParentIndex, ParentValue, 1), adjust_heap_node(NewHeap, ParentIndex); true -> Heap end. heap_push(Heap, Push) -> adjust_heap_node(Heap ++ [Push], length(Heap) + 1). -- Victory won't come to me, unless I go to it. From lcoquelle@REDACTED Thu Aug 30 16:15:03 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Thu, 30 Aug 2007 22:15:03 +0800 Subject: [erlang-questions] How can I implement a priority queue with Erlang? In-Reply-To: References: Message-ID: Sorry, I may not be able to help you with the code. But I can point you to a very simple priority queue solution using gb_tree proposed by Ulf Wiger: http://www.erlang.org/pipermail/erlang-questions/2007-June/027585.html I would be interested to know about has any other solutions. On 8/30/07, Jeffrey Chen wrote: > > I'm trying to implement a priority queue using heap struct. But I > can't do that efficient. Can anybody help me? I'll post my code below. > Thanks. > > > CODE: > exchange([], _, _, _, _, _) -> > []; > exchange([_ | Rest], IndexA, ValueA, IndexB, ValueB, Index) when > IndexA == Index -> > [ValueB | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]; > exchange([_ | Rest], IndexA, ValueA, IndexB, ValueB, Index) when > IndexB == Index -> > [ValueA | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]; > exchange([Head | Rest], IndexA, ValueA, IndexB, ValueB, Index) -> > [Head | exchange(Rest, IndexA, ValueA, IndexB, ValueB, Index + 1)]. > > > %%% Heap %%% > > max_heapify(Heap, Index) when Index * 2 > length(Heap) -> > Heap; > max_heapify(Heap, Index) -> > IndexValue = lists:nth(Index, Heap), > > LeftIndex = 2 * Index, > LeftValue = lists:nth(LeftIndex, Heap), > > if > 2 * Index + 1 > length(Heap) -> > RightIndex = LeftIndex, > RightValue = LeftValue; > true -> > RightIndex = 2 * Index + 1, > RightValue = lists:nth(RightIndex, Heap) > end, > > if > LeftValue > IndexValue, LeftValue >= RightValue -> > LargestIndex = LeftIndex, > LargestValue = LeftValue; > RightValue > IndexValue, RightValue >= LeftValue -> > LargestIndex = RightIndex, > LargestValue = RightValue; > true -> > LargestIndex = Index, > LargestValue = IndexValue > end, > > if > LargestIndex /= Index -> > NewHeap = exchange(Heap, Index, IndexValue, LargestIndex, > LargestValue, 1), > max_heapify(NewHeap, LargestIndex); > true -> > Heap > end. > > build_heap(L, 0) -> > L; > build_heap(L, Index) -> > NewL = max_heapify(L, Index), > build_heap(NewL, Index - 1). > > make_heap([]) -> > []; > make_heap(L) -> > build_heap(L, trunc(length(L) / 2)). > > heap_pop([Head | Rest]) when length(Rest) == 0 -> > {Head, []}; > heap_pop([Head | Rest]) -> > {RestBody, RestTail} = lists:split(length(Rest) - 1, Rest), > {Head, max_heapify(RestTail ++ RestBody, 1)}. > > test_heap_pop([]) -> > done; > test_heap_pop(Heap) -> > {P, H} = heap_pop(Heap), > io:format("~w, ~w~n", [P, H]), > test_heap_pop(H). > > adjust_heap_node(Heap, Index) when trunc(Index / 2) == 0 -> > Heap; > adjust_heap_node(Heap, Index) -> > IndexValue = lists:nth(Index, Heap), > ParentIndex = trunc(Index / 2), > ParentValue = lists:nth(ParentIndex, Heap), > > if > IndexValue > ParentValue -> > NewHeap = exchange(Heap, Index, IndexValue, ParentIndex, > ParentValue, 1), > adjust_heap_node(NewHeap, ParentIndex); > true -> > Heap > end. > > heap_push(Heap, Push) -> > adjust_heap_node(Heap ++ [Push], length(Heap) + 1). > > -- > Victory won't come to me, unless I go to it. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Tobias.Lindahl@REDACTED Thu Aug 30 16:48:37 2007 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Thu, 30 Aug 2007 16:48:37 +0200 Subject: [erlang-questions] Dialyzer "function X has no local return"? In-Reply-To: <6344005f0708300116u3812f57byb3b3ba4a86ebdddc@mail.gmail.com> References: <6344005f0708300116u3812f57byb3b3ba4a86ebdddc@mail.gmail.com> Message-ID: <46D6D8C5.7090700@it.uu.se> Adam Lindberg wrote: > Hi all, > > What are the implications of adding a local return value? Let's consider > the following code which will raise the warning: > > x() -> > head_of_to_a_loop_which_will_never_return(). > > The warning: > > module.erl:3: Function x/0 has no local return > > This can be changed to the function below just to satisfy Dialyzer: > > x() -> > head_of_to_a_loop_which_will_never_return(), > nobody_will_ever_see_this_atom. > > Wouldn't that last atom stay somewhere in case the above function call > actually would return. Because I guess there is no way for the compiler > to know that so it has to keep that last line, thus no tail > optimizations are possible. Am I right? Any thoughts on this? The compiler cannot reason about the function call never returning, so there will not a tail call to the looping function. Dialyzer however, can find that the function will never return. There should be a warning for this in Dialyzer, and there will be. Dialyzer is fooled by the phony return in the current version, but this will change. We have had problems analyzing non-terminating functions. The immediate problem was solved, but unfortunately left this loophole (no pun intended). Fooling Dialyzer in this way is not recommended, since you are only hiding the warning, and paying the price of a lost tail call optimization. Tobias > > Cheers! > Adam > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dmercer@REDACTED Thu Aug 30 16:48:59 2007 From: dmercer@REDACTED (David Mercer) Date: Thu, 30 Aug 2007 09:48:59 -0500 Subject: [erlang-questions] How can I implement a priority queue with Erlang? In-Reply-To: References: Message-ID: <000001c7eb14$e6bc6c90$891ea8c0@SSI.CORP> On Thursday, August 30, 2007 at 07:34, Jeffrey Chen wrote: > I'm trying to implement a priority queue using heap struct. But I > can't do that efficient. Can anybody help me? I'll post my code below. I'm thinking heap structures are not going to be very efficient in Erlang. Not having looked at your code in particular, but if I recall correctly, heaps are efficient when you have random access into an array. In Erlang, you'll be doing a lot of list traversals to get to the nth element, and to switch elements, etc. It would be more efficient simply to do a single scan of the list and insert the element in the appropriate place. Or use gb_tree (or some other tree structure) to help. They are going to be more efficient than a linear list implementing a heap. Cheers, David From dking@REDACTED Thu Aug 30 17:59:03 2007 From: dking@REDACTED (David King) Date: Thu, 30 Aug 2007 08:59:03 -0700 Subject: [erlang-questions] gen_server and multiple workers Message-ID: I imagine that this is a problem that has been solved a hundred times and that I just don't have the right search terms :) I need to communicate with an outside program, for which I'm using a port and a gen_server. However, I may be getting many requests for communication to this port at a time, and I don't want to introduce a bottleneck in the gen_server, nor do I want to fork() a new instance of the program for every request. So I think I'd like to have several workers, where each request grabs an available worker (blocking until one is available), ideally with some place to put logic to expand or reduce the size of the worker-pool with load, but that's optional. Having several copies of the external program open at a time isn't a problem (it's just a text-transform done by a Perl program). My gen_server doesn't keep any state except for the Port, so that could be managed another way. It seems that I can't combine this with gen_server, as gen_server seems to want to register() its PID, and I can't have multiple workers with the same register()ed name. I have a supervisor watching the gen_server. supervisor's required export init/1 returns (among other things) a list of processes to enter the supervision, but it just calls start_link on the gen_server, which registers its name. I could have the worker-pool managed by the single gen_server instance, but I'd like them to be able to crash independently, and it seems that that would complicate the handle_call function (as gen_server seems to assume that it's synchronous). Complication is okay, but I'd like to avoid it if it turns out that there is a single library that already does what I want :) I could also have the supervisor pass in a different name to register to gen_server:start_link (worker1,worker2, ...) and have the supervisor manage the pool, but that seems messy (which, again, is okay, but is to be avoided if possible). Anyway, I'm sure this is a solved problem and I'm just looking in the wrong places. How would you do this? From olopierpa@REDACTED Thu Aug 30 18:17:04 2007 From: olopierpa@REDACTED (Pierpaolo Bernardi) Date: Thu, 30 Aug 2007 18:17:04 +0200 Subject: [erlang-questions] How can I implement a priority queue with Erlang? In-Reply-To: References: Message-ID: <7352e43a0708300917q10073f1bu3ceb2791d9f5a00b@mail.gmail.com> On 8/30/07, Jeffrey Chen wrote: > I'm trying to implement a priority queue using heap struct. But I > can't do that efficient. Can anybody help me? I'll post my code below. For priority queues, I use the one below. HTH P. %%% File : skew.erl %%% Author : %%% Description : Skew heaps %%% Created : 30 May 2003 by Pierpaolo BERNARDI -module(skew). -export([empty/0, is_empty/1, min/1, delete_min/1, insert/2, merge/2 ]). %% Aggressive inlining - will increase code size. %%-compile(inline). %%-compile({inline_size,100}). %%-define(TESTING,true). -ifdef(TESTING). -compile(export_all). -endif. -define(THE_EMPTY_HEAP, the_empty_heap). empty() -> ?THE_EMPTY_HEAP. is_empty(?THE_EMPTY_HEAP) -> true; is_empty(_) -> false. min({X, _, _}) -> X. delete_min({_X, A, B}) -> merge(A, B). insert(X, A) -> merge({X, ?THE_EMPTY_HEAP, ?THE_EMPTY_HEAP}, A). merge(A, ?THE_EMPTY_HEAP) -> A; merge(?THE_EMPTY_HEAP, B) -> B; merge({MA, LA, RA}, B={MB, _, _}) when MA =< MB -> {MA, RA, merge(LA, B)}; merge(A, {M, L, R}) -> {M, R, merge(L, A)}. -ifdef(TESTING). test() -> test(100000, 1, 1000000000). test(N, Da, A) -> pblib:randomize(), Q = fa_random_heap(N, Da, A), scrivi_heap(Q). misura() -> T0 = pblib:mo(), _Q = fa_random_heap(100000, 1, 1000000000), T1 = pblib:mo(), T1 - T0. fa_random_heap(Quanti, Da, A) -> fa_random_heap(Quanti, Da, A, empty()). fa_random_heap(0, _Da, _A, Q) -> Q; fa_random_heap(N, Da, A, Q) -> fa_random_heap(N-1, Da, A, insert(random:uniform(A- Da+1)+Da-1, Q)). fa_random_heap2(Quanti, Da, A) -> fa_random_heap2(Quanti, Da, A, empty()). fa_random_heap2(0, _Da, _A, Q) -> Q; fa_random_heap2(N, Da, A, Q) -> fa_random_heap2(N-1, Da, A, insert(1000000-N, Q)). scrivi_heap(Q) -> case is_empty(Q) of true -> ok; false -> M = min(Q), Q1 = delete_min(Q), io:fwrite("~s\n", [pblib:ultospun(M)]), scrivi_heap(Q1) end. profo(?THE_EMPTY_HEAP) -> 0; profo({_, A, B}) -> 1 + lists:max([profo(A), profo(B)]). dimen(?THE_EMPTY_HEAP) -> 0; dimen({_, A, B}) -> 1 + dimen(A) + dimen(B). -endif. From dot@REDACTED Thu Aug 30 17:52:05 2007 From: dot@REDACTED (Tony Finch) Date: Thu, 30 Aug 2007 16:52:05 +0100 Subject: [erlang-questions] Is it worth commenting this guy? In-Reply-To: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> References: <3dbc6d1c0708280601u447395edr7a08110ea8796640@mail.gmail.com> Message-ID: On Tue, 28 Aug 2007, Robert Virding wrote: > When scanning for references to Erlang I occasionally come across this > guy: > > http://rebelscience.blogspot.com/ There was a thread about him on RISKS back in January this year. Here's a link to my comments: http://catless.ncl.ac.uk/Risks/24.56.html#subj7.3 Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From dave.rafkind@REDACTED Thu Aug 30 18:56:44 2007 From: dave.rafkind@REDACTED (Dave Rafkind) Date: Thu, 30 Aug 2007 12:56:44 -0400 Subject: [erlang-questions] erlang vs java floating point format Message-ID: <2ae2b2da0708300956v18c8e16s65e4ec425f11bcca@mail.gmail.com> Hello great list! I am a newcomer to Erlang, so perhaps this is an easy question: If I send a java float to an Erlang process over TCP, I can match against the resulting four bytes with something like <> This seems to indicate that Erlang and Java floating point formats are the same (at least for my setup which is Erlang 5.5.4, java 1.5 on an Intel/Linux box), which is IEEE 754: http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 My question is, can this be reliably depended on to work across all versions of Erlang and java and all supported architectures? Are the floating point formats always guaranteed to be in sync? Thanks, Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul-trapexit@REDACTED Thu Aug 30 18:57:17 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Thu, 30 Aug 2007 09:57:17 -0700 (PDT) Subject: [erlang-questions] gen_server and multiple workers In-Reply-To: References: Message-ID: Hey David, You could create multiple gen_servers and instead of registering their pids (using start_link/4) instead keep them anonymous (using start_link/3) and then have them joined a named process group (using pg2:join/2) and then issue requests using pg2:get_closest_pid/1. -- p On Thu, 30 Aug 2007, David King wrote: > I imagine that this is a problem that has been solved a hundred times > and that I just don't have the right search terms :) > > I need to communicate with an outside program, for which I'm using a > port and a gen_server. However, I may be getting many requests for > communication to this port at a time, and I don't want to introduce a > bottleneck in the gen_server, nor do I want to fork() a new instance > of the program for every request. So I think I'd like to have several > workers, where each request grabs an available worker (blocking until > one is available), ideally with some place to put logic to expand or > reduce the size of the worker-pool with load, but that's optional. > Having several copies of the external program open at a time isn't a > problem (it's just a text-transform done by a Perl program). > > My gen_server doesn't keep any state except for the Port, so that > could be managed another way. It seems that I can't combine this with > gen_server, as gen_server seems to want to register() its PID, and I > can't have multiple workers with the same register()ed name. > > I have a supervisor watching the gen_server. supervisor's required > export init/1 returns (among other things) a list of processes to > enter the supervision, but it just calls start_link on the > gen_server, which registers its name. > > I could have the worker-pool managed by the single gen_server > instance, but I'd like them to be able to crash independently, and it > seems that that would complicate the handle_call function (as > gen_server seems to assume that it's synchronous). Complication is > okay, but I'd like to avoid it if it turns out that there is a single > library that already does what I want :) > > I could also have the supervisor pass in a different name to register > to gen_server:start_link (worker1,worker2, ...) and have the > supervisor manage the pool, but that seems messy (which, again, is > okay, but is to be avoided if possible). > > Anyway, I'm sure this is a solved problem and I'm just looking in the > wrong places. How would you do this? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > "A hot dog and bun, you have to have a style and strategy that's different from a chicken wing, which is different from a matzo ball," he says. "Athletics are not really about superior fitness. They're about superior refinement of skill. That's what Babe Ruth did. That's what this is." http://en.wikipedia.org/wiki/Competitive_eating From dking@REDACTED Thu Aug 30 19:09:01 2007 From: dking@REDACTED (David King) Date: Thu, 30 Aug 2007 10:09:01 -0700 Subject: [erlang-questions] gen_server and multiple workers In-Reply-To: References: Message-ID: <047C6550-339F-4D5E-BBC4-621A80570319@ketralnis.com> > You could create multiple gen_servers and instead of registering > their pids (using start_link/4) instead keep them anonymous (using > start_link/3) and then have them joined a named process group (using > pg2:join/2) and then issue requests using pg2:get_closest_pid/1. That sounds like exactly what I want. Does pg2:get_closest_pid/1 handle balancing, or will it return the same PID every time it's called from a given machine? (The documentation is not clear on this.) Is a named process group accessible from any machine in a cluster? Thanks for getting back to me so quickly, by the way! > On Thu, 30 Aug 2007, David King wrote: > >> I imagine that this is a problem that has been solved a hundred times >> and that I just don't have the right search terms :) >> >> I need to communicate with an outside program, for which I'm using a >> port and a gen_server. However, I may be getting many requests for >> communication to this port at a time, and I don't want to introduce a >> bottleneck in the gen_server, nor do I want to fork() a new instance >> of the program for every request. So I think I'd like to have several >> workers, where each request grabs an available worker (blocking until >> one is available), ideally with some place to put logic to expand or >> reduce the size of the worker-pool with load, but that's optional. >> Having several copies of the external program open at a time isn't a >> problem (it's just a text-transform done by a Perl program). >> >> My gen_server doesn't keep any state except for the Port, so that >> could be managed another way. It seems that I can't combine this with >> gen_server, as gen_server seems to want to register() its PID, and I >> can't have multiple workers with the same register()ed name. >> >> I have a supervisor watching the gen_server. supervisor's required >> export init/1 returns (among other things) a list of processes to >> enter the supervision, but it just calls start_link on the >> gen_server, which registers its name. >> >> I could have the worker-pool managed by the single gen_server >> instance, but I'd like them to be able to crash independently, and it >> seems that that would complicate the handle_call function (as >> gen_server seems to assume that it's synchronous). Complication is >> okay, but I'd like to avoid it if it turns out that there is a single >> library that already does what I want :) >> >> I could also have the supervisor pass in a different name to register >> to gen_server:start_link (worker1,worker2, ...) and have the >> supervisor manage the pool, but that seems messy (which, again, is >> okay, but is to be avoided if possible). >> >> Anyway, I'm sure this is a solved problem and I'm just looking in the >> wrong places. How would you do this? From paul-trapexit@REDACTED Thu Aug 30 19:46:21 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Thu, 30 Aug 2007 10:46:21 -0700 (PDT) Subject: [erlang-questions] gen_server and multiple workers In-Reply-To: <047C6550-339F-4D5E-BBC4-621A80570319@ketralnis.com> References: <047C6550-339F-4D5E-BBC4-621A80570319@ketralnis.com> Message-ID: The document is a little ambiguous wrt whether load pids are load balanced. Fortunately the source is not. ------- pmineiro@REDACTED% grep -n -A15 'get_closest_pid(Name)' /sw/lib/erlang/lib/kernel-2.11.5/src/pg2.erl 122:get_closest_pid(Name) -> 123- case get_local_members(Name) of 124- [Pid] -> 125- Pid; 126- [] -> 127- {_,_,X} = erlang:now(), 128- case get_members(Name) of 129- [] -> {error, {no_process, Name}}; 130- Members -> 131- lists:nth((X rem length(Members))+1, Members) 132- end; 133- Members when is_list(Members) -> 134- {_,_,X} = erlang:now(), 135- lists:nth((X rem length(Members))+1, Members); 136- Else -> 137- Else ------- line 135 indicates randomization. -- p On Thu, 30 Aug 2007, David King wrote: > > You could create multiple gen_servers and instead of registering > > their pids (using start_link/4) instead keep them anonymous (using > > start_link/3) and then have them joined a named process group (using > > pg2:join/2) and then issue requests using pg2:get_closest_pid/1. > > That sounds like exactly what I want. Does pg2:get_closest_pid/1 > handle balancing, or will it return the same PID every time it's > called from a given machine? (The documentation is not clear on > this.) Is a named process group accessible from any machine in a > cluster? > > Thanks for getting back to me so quickly, by the way! > > > On Thu, 30 Aug 2007, David King wrote: > > > >> I imagine that this is a problem that has been solved a hundred times > >> and that I just don't have the right search terms :) > >> > >> I need to communicate with an outside program, for which I'm using a > >> port and a gen_server. However, I may be getting many requests for > >> communication to this port at a time, and I don't want to introduce a > >> bottleneck in the gen_server, nor do I want to fork() a new instance > >> of the program for every request. So I think I'd like to have several > >> workers, where each request grabs an available worker (blocking until > >> one is available), ideally with some place to put logic to expand or > >> reduce the size of the worker-pool with load, but that's optional. > >> Having several copies of the external program open at a time isn't a > >> problem (it's just a text-transform done by a Perl program). > >> > >> My gen_server doesn't keep any state except for the Port, so that > >> could be managed another way. It seems that I can't combine this with > >> gen_server, as gen_server seems to want to register() its PID, and I > >> can't have multiple workers with the same register()ed name. > >> > >> I have a supervisor watching the gen_server. supervisor's required > >> export init/1 returns (among other things) a list of processes to > >> enter the supervision, but it just calls start_link on the > >> gen_server, which registers its name. > >> > >> I could have the worker-pool managed by the single gen_server > >> instance, but I'd like them to be able to crash independently, and it > >> seems that that would complicate the handle_call function (as > >> gen_server seems to assume that it's synchronous). Complication is > >> okay, but I'd like to avoid it if it turns out that there is a single > >> library that already does what I want :) > >> > >> I could also have the supervisor pass in a different name to register > >> to gen_server:start_link (worker1,worker2, ...) and have the > >> supervisor manage the pool, but that seems messy (which, again, is > >> okay, but is to be avoided if possible). > >> > >> Anyway, I'm sure this is a solved problem and I'm just looking in the > >> wrong places. How would you do this? > "A hot dog and bun, you have to have a style and strategy that's different from a chicken wing, which is different from a matzo ball," he says. "Athletics are not really about superior fitness. They're about superior refinement of skill. That's what Babe Ruth did. That's what this is." http://en.wikipedia.org/wiki/Competitive_eating From yerl@REDACTED Thu Aug 30 22:54:09 2007 From: yerl@REDACTED (Yerl) Date: Thu, 30 Aug 2007 22:54:09 +0200 Subject: [erlang-questions] External sort and merge In-Reply-To: References: <047C6550-339F-4D5E-BBC4-621A80570319@ketralnis.com> Message-ID: <46D72E71.4@club-internet.fr> Hi! Is there any Erlang implementation of external file sorting (and merging) ? cheers Y. From per@REDACTED Fri Aug 31 00:59:21 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 31 Aug 2007 00:59:21 +0200 (CEST) Subject: [erlang-questions] Strange meshing behavior between 3 machines In-Reply-To: Message-ID: <200708302259.l7UMxLOD050820@pluto.hedeland.org> "Christopher Petrilli" wrote: > >The weird part is that on host C, I see weird things depending on what >command I use: > >nodes/0: all nodes are seen >net_adm:names/0: all nodes are seen >net_adm:world/0: only sees one@REDACTED and two@REDACTED, but no other @C Which seems to be exactly the behaviour documented in net_adm(3): This function calls names(Host) for all hosts which are speci- fied in the Erlang host file .hosts.erlang, [...] Since your .hosts.erlang on host C has only A and B, you shouldn't see the nodes on C when you run net_adm:world/0 there. >If I change the .hosts.erlang file on Host C to: > > 'A'. > 'B'. > 'C'. > >It works. Seems like a good idea to do that then:-) (and ditto on A and b), since it's clearly the intent. > This is a totally different behavior from hosts A and B. Yes, if they really include themselves in the list, it's strange - are you sure you aren't actually seeing 4 nodes from net_adm:world/0 on them rather than 5? I.e. two@REDACTED, three@REDACTED, four@REDACTED, and five@REDACTED on A, and correspondingly on B. --Per Hedeland From ryanobjc@REDACTED Thu Aug 30 23:39:32 2007 From: ryanobjc@REDACTED (Ryan Rawson) Date: Thu, 30 Aug 2007 14:39:32 -0700 Subject: [erlang-questions] erlang vs java floating point format In-Reply-To: <2ae2b2da0708300956v18c8e16s65e4ec425f11bcca@mail.gmail.com> References: <2ae2b2da0708300956v18c8e16s65e4ec425f11bcca@mail.gmail.com> Message-ID: Note that java floats are almost but not quite IEEE 754 floats. Depending on the complexity of your problem domain you may not notice. This is one very dissapointing part of the java spec. On Aug 30, 2007, at 9:56 AM, "Dave Rafkind" wrote: > Hello great list! > > I am a newcomer to Erlang, so perhaps this is an easy question: > > If I send a java float to an Erlang process over TCP, I can match > against the resulting four bytes with > something like > > <> > > This seems to indicate that Erlang and Java floating point formats > are the same > (at least for my setup which is Erlang 5.5.4, java 1.5 on an Intel/ > Linux box), which is > IEEE 754: > http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 > > My question is, can this be reliably depended on to work across all > versions > of Erlang and java and all supported architectures? Are the floating > point formats > always guaranteed to be in sync? > > > Thanks, > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From yarivsadan@REDACTED Fri Aug 31 02:10:18 2007 From: yarivsadan@REDACTED (Yariv Sadan) Date: Thu, 30 Aug 2007 17:10:18 -0700 Subject: [erlang-questions] flv streaming/recording Message-ID: <17244f480708301710s1180ba92w5b028e8e158b90b9@mail.gmail.com> Hi, Does anyone have an Erlang implementation of RTMP that they are planning to open source? I would like to have an Erlang server capable of streaming and recording .flv files, but I don't want to do the work to create one :) Here's more info: http://osflash.org/rtmp_os. Thanks, Yariv From lcoquelle@REDACTED Fri Aug 31 02:49:56 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Fri, 31 Aug 2007 08:49:56 +0800 Subject: [erlang-questions] External sort and merge In-Reply-To: <46D72E71.4@club-internet.fr> References: <047C6550-339F-4D5E-BBC4-621A80570319@ketralnis.com> <46D72E71.4@club-internet.fr> Message-ID: Is the following what you want? http://www.erlang.org/doc/man/file_sorter.html On 8/31/07, Yerl wrote: > > Hi! > > Is there any Erlang implementation of external file sorting (and merging) > ? > > cheers > Y. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Fri Aug 31 04:55:39 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 30 Aug 2007 21:55:39 -0500 Subject: [erlang-questions] driver_output_term, driver_send_term and ei In-Reply-To: References: Message-ID: <46D7832B.1030007@gmail.com> Joel Reymont wrote: > It seems that the erl_driver docs recommend using driver_output_term > for efficiency reason. That is compared to ei and the driver_output{2,v} family of functions as there's no extra copying involved in the former. > I noticed that Klacke uses driver_send_term in his posregex linked-in > driver. Would driver_output_term work just as well if the driver was > given the pid of the caller to be given back to the port owner process? > > Generally speaking, are there guidelines for when to use each function? It depends on your application's architecture. If you marshal all interface with the driver through Erlang's middleman gen_server process, then you would want to use driver_output_term to pass data to port owner process that would send a reply back to the caller. Alternatively, if you allow other processes to communicate with the driver directly, use driver_caller and driver_send_term. Also be extra careful as driver_output_term is not thread-safe and driver_send_term is only thread-safe when SMP is used. So either function should be called from within the context of the emulator's thread (e.g. in body of driver_entry's callbacks). > Should I use term_to_binary nowadays to send data to the driver, ei > to decode in the driver and driver_output_term to send back? While you can use ei, you don't need to or else pay performance penalty. The fastest way to deliver data back to Erlang is to use ErlDrvTermData stucts and LOAD_ATOM/TUPLE/PORT/etc macros (see inet_drv.c in distribution) to populate the structures and use driver_send_term / driver_output_term for delivery. This avoids extra binary conversion and data is received by an Erlang process as a term. When calling C code from Erlang using erlang:port_call/3 or erlang:port_command/2 external binary term format is used, so ei can be used to decode data. A convenience of port_call/3 is that you can pass a term "as is" whereas port_command/2 requires you to convert a term to binary (or iolist()) yourself. Serge From saifi@REDACTED Fri Aug 31 05:49:11 2007 From: saifi@REDACTED (Saifi Khan) Date: Fri, 31 Aug 2007 09:19:11 +0530 (IST) Subject: [erlang-questions] erlang Perl5 dependency Message-ID: Hi: Erlang OTP compilation requires Perl5. Which components have a Perl5 dependency ? There seems to be only directory which needs Perl ie. otp_src_R11B-5/lib/snmp/bin Thanks in advance. thanks Saifi. ------------------------------------------------------- TWINCLING Society http://www.twincling.org/ freedom of innovation Hyderabad AP, India. ------------------------------------------------------- From saifi@REDACTED Fri Aug 31 05:49:53 2007 From: saifi@REDACTED (Saifi Khan) Date: Fri, 31 Aug 2007 09:19:53 +0530 (IST) Subject: [erlang-questions] erlang daemon port Message-ID: Hi: The file otp_src_R11B-5/erts/vsn.mk has the following lines. # Port number 4365 in 4.2 # Port number 4366 in 4.3 # Port number 4368 in 4.4.0 - 4.6.2 # Port number 4369 in 4.6.3 - ERLANG_DAEMON_PORT = 4369 It seems that across versions the port number gets bumped up by one ! Is there a possibility of having a fixed IANA registered Erlang port ? Anyone could just use the entry from /etc/services. Or am I missing something here ? thanks Saifi. ------------------------------------------------------- TWINCLING Society http://www.twincling.org/ freedom of innovation Hyderabad AP, India. ------------------------------------------------------- From bitcowboy@REDACTED Fri Aug 31 06:46:47 2007 From: bitcowboy@REDACTED (Jeffrey Chen) Date: Fri, 31 Aug 2007 12:46:47 +0800 Subject: [erlang-questions] How can I implement a priority queue with Erlang? In-Reply-To: <000001c7eb14$e6bc6c90$891ea8c0@SSI.CORP> References: <000001c7eb14$e6bc6c90$891ea8c0@SSI.CORP> Message-ID: Thanks David. That're indeed a lot of traversals in the exchange operate, and that's why I think it's inefficient. I'll try tree structure later. On 8/30/07, David Mercer wrote: > On Thursday, August 30, 2007 at 07:34, Jeffrey Chen wrote: > > I'm trying to implement a priority queue using heap struct. But I > > can't do that efficient. Can anybody help me? I'll post my code below. > > I'm thinking heap structures are not going to be very efficient in Erlang. > Not having looked at your code in particular, but if I recall correctly, > heaps are efficient when you have random access into an array. In Erlang, > you'll be doing a lot of list traversals to get to the nth element, and to > switch elements, etc. It would be more efficient simply to do a single scan > of the list and insert the element in the appropriate place. Or use gb_tree > (or some other tree structure) to help. They are going to be more efficient > than a linear list implementing a heap. > > Cheers, > > David > > > -- Victory won't come to me, unless I go to it. From bitcowboy@REDACTED Fri Aug 31 07:09:24 2007 From: bitcowboy@REDACTED (Jeffrey Chen) Date: Fri, 31 Aug 2007 13:09:24 +0800 Subject: [erlang-questions] How can I implement a priority queue with Erlang? In-Reply-To: <7352e43a0708300917q10073f1bu3ceb2791d9f5a00b@mail.gmail.com> References: <7352e43a0708300917q10073f1bu3ceb2791d9f5a00b@mail.gmail.com> Message-ID: It's a good idea of exchang left and right branch in each merge operate to trying to balance the tree. On 8/31/07, Pierpaolo Bernardi wrote: > On 8/30/07, Jeffrey Chen wrote: > > I'm trying to implement a priority queue using heap struct. But I > > can't do that efficient. Can anybody help me? I'll post my code below. > > For priority queues, I use the one below. > > HTH > > P. > > %%% File : skew.erl > %%% Author : > %%% Description : Skew heaps > %%% Created : 30 May 2003 by Pierpaolo BERNARDI > > -module(skew). > > -export([empty/0, > is_empty/1, > min/1, > delete_min/1, > insert/2, > merge/2 > ]). > > > %% Aggressive inlining - will increase code size. > %%-compile(inline). > %%-compile({inline_size,100}). > > %%-define(TESTING,true). > > -ifdef(TESTING). > -compile(export_all). > -endif. > > -define(THE_EMPTY_HEAP, the_empty_heap). > > empty() -> > ?THE_EMPTY_HEAP. > > is_empty(?THE_EMPTY_HEAP) -> true; > is_empty(_) -> false. > > min({X, _, _}) -> X. > > delete_min({_X, A, B}) -> merge(A, B). > > insert(X, A) -> > merge({X, ?THE_EMPTY_HEAP, ?THE_EMPTY_HEAP}, A). > > merge(A, ?THE_EMPTY_HEAP) -> > A; > merge(?THE_EMPTY_HEAP, B) -> > B; > merge({MA, LA, RA}, B={MB, _, _}) when MA =< MB -> > {MA, RA, merge(LA, B)}; > merge(A, {M, L, R}) -> > {M, R, merge(L, A)}. > > > -ifdef(TESTING). > > test() -> > test(100000, 1, 1000000000). > > test(N, Da, A) -> > pblib:randomize(), > Q = fa_random_heap(N, Da, A), > scrivi_heap(Q). > > misura() -> > T0 = pblib:mo(), > _Q = fa_random_heap(100000, 1, 1000000000), > T1 = pblib:mo(), > T1 - T0. > > fa_random_heap(Quanti, Da, A) -> > fa_random_heap(Quanti, Da, A, empty()). > > fa_random_heap(0, _Da, _A, Q) -> > Q; > fa_random_heap(N, Da, A, Q) -> > fa_random_heap(N-1, Da, A, insert(random:uniform(A- Da+1)+Da-1, Q)). > > > fa_random_heap2(Quanti, Da, A) -> > fa_random_heap2(Quanti, Da, A, empty()). > > fa_random_heap2(0, _Da, _A, Q) -> > Q; > fa_random_heap2(N, Da, A, Q) -> > fa_random_heap2(N-1, Da, A, insert(1000000-N, Q)). > > scrivi_heap(Q) -> > case is_empty(Q) of > true -> > ok; > false -> > M = min(Q), > Q1 = delete_min(Q), > io:fwrite("~s\n", [pblib:ultospun(M)]), > scrivi_heap(Q1) > end. > > profo(?THE_EMPTY_HEAP) -> > 0; > profo({_, A, B}) -> > 1 + lists:max([profo(A), > profo(B)]). > > dimen(?THE_EMPTY_HEAP) -> > 0; > dimen({_, A, B}) -> > 1 + dimen(A) + dimen(B). > > -endif. > -- Victory won't come to me, unless I go to it. From juhani@REDACTED Fri Aug 31 10:21:46 2007 From: juhani@REDACTED (=?ISO-8859-1?Q?Juhani_R=E4nkimies?=) Date: Fri, 31 Aug 2007 11:21:46 +0300 Subject: [erlang-questions] flv streaming/recording In-Reply-To: <17244f480708301710s1180ba92w5b028e8e158b90b9@mail.gmail.com> References: <17244f480708301710s1180ba92w5b028e8e158b90b9@mail.gmail.com> Message-ID: I've played a little with RTMP. Not with media streaming, but function calls. I think I was able to initiate an RTMP connection and make a simple function call when my Flex Builder trial expired. I cannot commit myself to creating a full implementation, but if someone is working on it, I'm willing to contribute. -juhani 2007/8/31, Yariv Sadan : > > Hi, > > Does anyone have an Erlang implementation of RTMP that they are > planning to open source? I would like to have an Erlang server capable > of streaming and recording .flv files, but I don't want to do the work > to create one :) > > Here's more info: http://osflash.org/rtmp_os. > > Thanks, > Yariv > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hubaghdadi@REDACTED Fri Aug 31 12:42:57 2007 From: hubaghdadi@REDACTED (Lone Wolf) Date: Fri, 31 Aug 2007 03:42:57 -0700 (PDT) Subject: [erlang-questions] Learning Erlang from the scratch Message-ID: <333875.88446.qm@web51105.mail.re2.yahoo.com> Hi. I'm an enterprise Java developer. What is the best way to learn Erlang language from the scratch? Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or this books assumes the reader is Erlang programmer ? BTW, I don't know "Functional Programming" at all. Thanks. Deep into that darkness peering, long I stood there, wondering, fearing, Doubting, dreaming dreams no mortal ever dreamed before. E.A Poe --------------------------------- Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tblachowicz@REDACTED Fri Aug 31 14:01:01 2007 From: tblachowicz@REDACTED (=?ISO-8859-2?Q?Tomasz_B=B3achowicz?=) Date: Fri, 31 Aug 2007 13:01:01 +0100 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: Hi Lone, I've started learning Erlang/OTP recently and I've gor similar background, bacause I've been Java developer for couple of years. I started from reading 'Programming Erlang. Software for a Concurrent World' by Joe Armstrong and frankly speaking the book is just brilliant! Furthermore, I've found Erlang online documentation really useful, esp. 'OTP Design Principles' [2] and 'Programming Examples' [3] [1] http://www.erlang.org/doc [2] http://www.erlang.org/doc/design_principles/part_frame.html [3] http://www.erlang.org/doc/programming_examples/part_frame.html Take care, Tom On 8/31/07, Lone Wolf wrote: > > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or > this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. > > *Deep into that darkness peering, long I stood there, wondering, fearing, > Doubting, dreaming dreams no mortal ever dreamed before.* > *E.A Poe* > ** > ** > > ------------------------------ > Looking for a deal? Find great prices on flights and hotelswith Yahoo! FareChase. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Aug 31 14:00:36 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 31 Aug 2007 14:00:36 +0200 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <46D802E4.1030107@ericsson.com> The new book does not assume any previous experience of Erlang, nor of Functional Programming. It is a good way to learn Erlang from the beginning. bengt Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." On 2007-08-31 12:42, Lone Wolf wrote: > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? > or this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. From jesper.louis.andersen@REDACTED Fri Aug 31 14:08:01 2007 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 31 Aug 2007 14:08:01 +0200 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <56a0a2840708310508p6ca1a86u8f86c5fe995be4ea@mail.gmail.com> On 8/31/07, Lone Wolf wrote: > > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or > this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. "One will first truly understand a programming language when he builds something non-trivial with it". Your best bet, as I see it, is to get the book. From a skimming it seems like a good way to begin learning about erlangs concepts (I don't own the book myself). Then try to find something and build it. You will learn a lot by doing that. You can also begin reading code for a project that interests you. Regarding the Functional Programming: If you understand recursion, you are about halfway there. If you also understand that functions are first class values and can be passed as parameters to other functions and returned from functions, then you are almost over the goal line. It takes a bit of time to accustom oneself to that. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dunceor@REDACTED Fri Aug 31 14:08:00 2007 From: dunceor@REDACTED (=?UTF-8?Q?Karl_Sj=C3=B6dahl_-_dunceor?=) Date: Fri, 31 Aug 2007 14:08:00 +0200 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <5d84cb30708310508u2acacc2fgdf0c4674979f689@mail.gmail.com> On 8/31/07, Lone Wolf wrote: > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or > this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. > > > > Deep into that darkness peering, long I stood there, wondering, fearing, > Doubting, dreaming dreams no mortal ever dreamed before. > E.A Poe > Well I can't speak for the best way to learn Erlang from scratch but the new "Programming Erlang" book starts from the beginning and explains the core of the language. I think this would be a great book to learn Erlang. It's well worth the money. Br Karl Sj?dahl From als@REDACTED Fri Aug 31 14:09:37 2007 From: als@REDACTED (Anthony Shipman) Date: Fri, 31 Aug 2007 22:09:37 +1000 Subject: [erlang-questions] definition of iolist Message-ID: <200708312209.37474.als@iinet.net.au> The documentation often says this: iolist = [char() | binary() | iolist()] a binary is allowed as the tail of the list This says to me that an iolist is a list whose members can be characters, binaries or iolists. In which case it is automatic that a binary can be the tail of the list. So what is the point of the comment? -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From bjorn@REDACTED Fri Aug 31 14:27:54 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 31 Aug 2007 14:27:54 +0200 Subject: [erlang-questions] definition of iolist In-Reply-To: <200708312209.37474.als@iinet.net.au> References: <200708312209.37474.als@iinet.net.au> Message-ID: Anthony Shipman writes: > The documentation often says this: > > iolist = [char() | binary() | iolist()] > a binary is allowed as the tail of the list > > This says to me that an iolist is a list whose members can be characters, > binaries or iolists. In which case it is automatic that a binary can be the > tail of the list. So what is the point of the comment? A character is not allowed in the tail. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From pacini@REDACTED Fri Aug 31 14:32:52 2007 From: pacini@REDACTED (Filippo Pacini) Date: Fri, 31 Aug 2007 14:32:52 +0200 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <46D80A74.9080200@sgconsulting.it> Hi, I've just finished reading the book and IMHO it's the best place to start learning Erlang. filippo Lone Wolf wrote: > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? > or this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. > From hughperkins@REDACTED Fri Aug 31 14:43:27 2007 From: hughperkins@REDACTED (Hugh Perkins) Date: Fri, 31 Aug 2007 20:43:27 +0800 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <46D80A74.9080200@sgconsulting.it> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> <46D80A74.9080200@sgconsulting.it> Message-ID: <837db430708310543n24dc03ffv7a92626e1ebc0c91@mail.gmail.com> Can someone recommend some problems to work through, starting from simple hello worlds, to more complex distributed applications? From kevin@REDACTED Fri Aug 31 15:15:42 2007 From: kevin@REDACTED (Kevin A. Smith) Date: Fri, 31 Aug 2007 09:15:42 -0400 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <837db430708310543n24dc03ffv7a92626e1ebc0c91@mail.gmail.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> <46D80A74.9080200@sgconsulting.it> <837db430708310543n24dc03ffv7a92626e1ebc0c91@mail.gmail.com> Message-ID: <61BD2A81-88F1-46EF-BE07-059333383281@hypotheticalabs.com> One of the things I've done is to start porting some Lisp programming exercises to Erlang: http://weblog.hypotheticalabs.com/?p=129 This has helped me come to grips with the nuts n' bolts syntax and concepts of the language. Also, our local Erlang meetup group is working on reading through the chat server code from Joe's "Programming Erlang" and adding new features to it. --Kevin On Aug 31, 2007, at 8:43 AM, Hugh Perkins wrote: > Can someone recommend some problems to work through, starting from > simple hello worlds, to more complex distributed applications? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlangx@REDACTED Fri Aug 31 15:34:01 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Fri, 31 Aug 2007 06:34:01 -0700 Subject: [erlang-questions] erlang daemon port In-Reply-To: References: Message-ID: <20070831133401.GE25506@delora.autosys.us> On Fri, Aug 31, 2007 at 09:19:53AM +0530, Saifi Khan wrote: > Hi: > > The file otp_src_R11B-5/erts/vsn.mk has the following lines. > > # Port number 4365 in 4.2 > # Port number 4366 in 4.3 > # Port number 4368 in 4.4.0 - 4.6.2 > # Port number 4369 in 4.6.3 - > > ERLANG_DAEMON_PORT = 4369 > > It seems that across versions the port number gets bumped up > by one ! > > Is there a possibility of having a fixed IANA registered > Erlang port ? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "oops" ... The Erlang port mapper daemon epmd runs on the IANA ([14]Internet Assigned Number Authority) well-known port [15]4369 and is reserved for both TCP and UDP protocols. It was registered by [16]Ericsson Corporation for the [17]Erlang language. [14] http://www.iana.org/ [15] http://www.iana.org/assignments/port-numbers [16] http://www.ericsson.com/technology/opensource/index.shtml [17] http://www.erlang.org/ ~Michael > > Anyone could just use the entry from /etc/services. > Or am I missing something here ? > > > thanks > Saifi. > > ------------------------------------------------------- > TWINCLING Society http://www.twincling.org/ > freedom of innovation Hyderabad AP, India. > ------------------------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,46d78efb73321896912433! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From dbt@REDACTED Fri Aug 31 16:40:31 2007 From: dbt@REDACTED (David Terrell) Date: Fri, 31 Aug 2007 09:40:31 -0500 Subject: [erlang-questions] definition of iolist In-Reply-To: References: <200708312209.37474.als@iinet.net.au> Message-ID: <20070831144031.GF16422@sphinx.chicagopeoplez.org> On Fri, Aug 31, 2007 at 02:27:54PM +0200, Bjorn Gustavsson wrote: > > Anthony Shipman writes: > > > The documentation often says this: > > > > iolist = [char() | binary() | iolist()] > > a binary is allowed as the tail of the list > > > > This says to me that an iolist is a list whose members can be characters, > > binaries or iolists. In which case it is automatic that a binary can be the > > tail of the list. So what is the point of the comment? > > A character is not allowed in the tail. I think I'm misunderstanding you... wouldn't this forbid a normal erlang string from being considered a valid iolist? 1> list_to_binary(["abcdefg", $h]). <<"abcdefgh">> -- David Terrell dbt@REDACTED ((meatspace)) http://meat.net/ From david.hopwood@REDACTED Fri Aug 31 17:06:59 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Fri, 31 Aug 2007 16:06:59 +0100 Subject: [erlang-questions] erlang vs java floating point format In-Reply-To: References: <2ae2b2da0708300956v18c8e16s65e4ec425f11bcca@mail.gmail.com> Message-ID: <46D82E93.70609@industrial-designers.co.uk> Ryan Rawson wrote: > Note that java floats are almost but not quite IEEE 754 floats. Assuming strictmath is in effect, and excluding NaN payloads and signalling NaNs, how are they different? > On Aug 30, 2007, at 9:56 AM, "Dave Rafkind" wrote: > >> Hello great list! >> >> I am a newcomer to Erlang, so perhaps this is an easy question: >> >> If I send a java float to an Erlang process over TCP, I can match >> against the resulting four bytes with something like >> >> <> >> >> This seems to indicate that Erlang and Java floating point formats are >> the same (at least for my setup which is Erlang 5.5.4, java 1.5 on an >> Intel/Linux box), which is >> IEEE 754: >> http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 >> >> My question is, can this be reliably depended on to work across all >> versions of Erlang and java and all supported architectures? It will work on any platform for which the C ABI defines floats to be in IEEE 754 format. I don't know whether that is all architectures supported by Erlang/OTP. -- David Hopwood From klacke@REDACTED Fri Aug 31 17:02:57 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Fri, 31 Aug 2007 17:02:57 +0200 Subject: [erlang-questions] definition of iolist In-Reply-To: <20070831144031.GF16422@sphinx.chicagopeoplez.org> References: <200708312209.37474.als@iinet.net.au> <20070831144031.GF16422@sphinx.chicagopeoplez.org> Message-ID: <46D82DA1.4040007@hyber.org> David Terrell wrote: > On Fri, Aug 31, 2007 at 02:27:54PM +0200, Bjorn Gustavsson wrote: >> Anthony Shipman writes: >> >>> The documentation often says this: >>> >>> iolist = [char() | binary() | iolist()] >>> a binary is allowed as the tail of the list >>> >>> This says to me that an iolist is a list whose members can be characters, >>> binaries or iolists. In which case it is automatic that a binary can be the >>> tail of the list. So what is the point of the comment? >> A character is not allowed in the tail. > 5> list_to_binary(["abcdefg"| <<"bb">>]). <<97,98,99,100,101,102,103,98,98>> 6> list_to_binary(["abcdefg"| $b]). =ERROR REPORT==== 31-Aug-2007::17:01:39 === Error in process <0.39.0> with exit value: {badarg,[{erlang,list_to_binary,[["abcdefg"|98]]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {badarg,[{erlang,list_to_binary,[["abcdefg"|98]]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Note the | in the list as opposed to , In [1,2] the [] is the end of the list /klacke From kostis@REDACTED Fri Aug 31 17:11:25 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 31 Aug 2007 18:11:25 +0300 Subject: [erlang-questions] definition of iolist In-Reply-To: <20070831144031.GF16422@sphinx.chicagopeoplez.org> References: <200708312209.37474.als@iinet.net.au> <20070831144031.GF16422@sphinx.chicagopeoplez.org> Message-ID: <46D82F9D.4070709@cs.ntua.gr> David Terrell wrote: > On Fri, Aug 31, 2007 at 02:27:54PM +0200, Bjorn Gustavsson wrote: >> Anthony Shipman writes: >> >>> The documentation often says this: >>> >>> iolist = [char() | binary() | iolist()] >>> a binary is allowed as the tail of the list >>> >>> This says to me that an iolist is a list whose members can be characters, >>> binaries or iolists. In which case it is automatic that a binary can be the >>> tail of the list. So what is the point of the comment? >> A character is not allowed in the tail. > > I think I'm misunderstanding you... wouldn't this forbid a > normal erlang string from being considered a valid iolist? > > 1> list_to_binary(["abcdefg", $h]). > <<"abcdefgh">> You probably have not fully grasped what constitutes the tail of a list. Compare your thing above with: list_to_binary(["abcdefg" | $h]). and list_to_binary(["abcdefg" | <<42>>]). Kostis PS. I've repeatedly mentioned to the OTP group that there is very little reason for an IOList to allow binaries in the tail. Allowing binaries in the tail of the list only saves one cons cell but it disallows the use of many/most lists functions for IOLists. For example lists:length/1 cannot be safely used for IOLists because its use may or might not throw an exception. IMO, IOLists should not allow for binaries in the tail position. Other than that, IOLists are great. From david.hopwood@REDACTED Fri Aug 31 17:17:53 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Fri, 31 Aug 2007 16:17:53 +0100 Subject: [erlang-questions] definition of iolist In-Reply-To: <20070831144031.GF16422@sphinx.chicagopeoplez.org> References: <200708312209.37474.als@iinet.net.au> <20070831144031.GF16422@sphinx.chicagopeoplez.org> Message-ID: <46D83121.20104@industrial-designers.co.uk> David Terrell wrote: > On Fri, Aug 31, 2007 at 02:27:54PM +0200, Bjorn Gustavsson wrote: >> Anthony Shipman writes: >> >>> The documentation often says this: >>> >>> iolist = [char() | binary() | iolist()] >>> a binary is allowed as the tail of the list >>> >>> This says to me that an iolist is a list whose members can be characters, >>> binaries or iolists. In which case it is automatic that a binary can be the >>> tail of the list. So what is the point of the comment? >> A character is not allowed in the tail. > > I think I'm misunderstanding you... wouldn't this forbid a > normal erlang string from being considered a valid iolist? > > 1> list_to_binary(["abcdefg", $h]). > <<"abcdefgh">> The final tail of "abcdefg" (and any other proper list) is nil. A list that has a binary as its tail is an improper list. -- David Hopwood From lenartlad@REDACTED Fri Aug 31 17:25:39 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 31 Aug 2007 17:25:39 +0200 Subject: [erlang-questions] definition of iolist In-Reply-To: <20070831144031.GF16422@sphinx.chicagopeoplez.org> References: <200708312209.37474.als@iinet.net.au> <20070831144031.GF16422@sphinx.chicagopeoplez.org> Message-ID: <46D832F3.9090901@volny.cz> David Terrell wrote: > On Fri, Aug 31, 2007 at 02:27:54PM +0200, Bjorn Gustavsson wrote: >> Anthony Shipman writes: >> >>> The documentation often says this: >>> >>> iolist = [char() | binary() | iolist()] >>> a binary is allowed as the tail of the list >>> >>> This says to me that an iolist is a list whose members can be characters, >>> binaries or iolists. In which case it is automatic that a binary can be the >>> tail of the list. So what is the point of the comment? >> A character is not allowed in the tail. > > I think I'm misunderstanding you... wouldn't this forbid a > normal erlang string from being considered a valid iolist? > > 1> list_to_binary(["abcdefg", $h]). > <<"abcdefgh">> Hello, I think not. The list in your example actually ends with an empty list ([]): [$a | [$b | [$c | [$d]]]] and therefore it is a valid iolist. But the following is NOT an iolist: [$a | [$b | [$c | $d]]]] The difference is in the last $d character. Hope this helps, Ladislav Lenart From erlang@REDACTED Fri Aug 31 17:53:28 2007 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 31 Aug 2007 17:53:28 +0200 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <9b08084c0708310853m6f0482f3m62ba622f67a1cdb4@mail.gmail.com> The book was specifically written with Java programmers in mind. When I started the book my target audience was Erlang programmers - but Dave Thomas soon convinced me that I was wrong and that I should target Java programmers. As the book progressed we tested the text on some tame Java programmers and adjusted the text to suit the audience. No previous knowledge of any functional programming language is assumed and the introduction to unfamiliar concepts like "assign once variables" is taken pretty slowly with lots of examples. /Joe Armstrong On 8/31/07, Lone Wolf wrote: > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or > this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. > > > > Deep into that darkness peering, long I stood there, wondering, fearing, > Doubting, dreaming dreams no mortal ever dreamed before. > E.A Poe > > > > ________________________________ > Looking for a deal? Find great prices on flights and hotels with Yahoo! > FareChase. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From cmeyer@REDACTED Fri Aug 31 18:07:11 2007 From: cmeyer@REDACTED (Colin Meyer) Date: Fri, 31 Aug 2007 09:07:11 -0700 Subject: [erlang-questions] memoization (was: Re: [Fwd: Re: Functional Programming]) In-Reply-To: <46D5EB78.9030701@zacbrown.org> References: <46D5EB78.9030701@zacbrown.org> Message-ID: <20070831160711.GA26010@infula.helvella.org> Hi, I've been following the recent Erlang hype, and reading Joe Armstrong's excellent book. Fun stuff. On Wed, Aug 29, 2007 at 05:56:08PM -0400, Zac Brown wrote: > Hi: > > You're correct that it is recursion and the calls you listed are > corrected. Essentially this is a stack-expanding recursive call which > are bad because you're building up your recursive calls and if its a big > number, you risk blowing the stack. The best way to define this function > in the manner you have is as follows: > > fac(N) - > fac_helper(N, 1). > > fac_helper(1, Tot) -> Tot; > fac_helper(N, Tot) -> > fac_helper(N - 1, Tot * N). In stateful languages, a typical optimization would be to memoize the return value of stable functions. This style of recursive factorial calculator is a classic candidate for memoization. On each call to a function, a cache is examined to find if the result is already known. If the result is known, it is returned. Otherwise it is calculated, cached for future use and returned. Do Erlang programmers have an analogous optimization for not repeatedly calculating the same values? I recognize that one could create a process to wrap the function, and cache the results in the process dictionary. That doesn't feel very Erlangish to me. Thanks, -Colin. From gbulmer@REDACTED Fri Aug 31 18:10:58 2007 From: gbulmer@REDACTED (G Bulmer) Date: Fri, 31 Aug 2007 17:10:58 +0100 Subject: [erlang-questions] Learning Erlang from the scratch Message-ID: <5B54D301-31CD-42C6-85E8-519FA23E5193@gmail.com> Hi Lone On 8/31/07, Lone Wolf wrote: > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming > Erlang" ? or this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. I concur with the comments on 'Programming Erlang. Software for a Concurrent World' by Joe Amstrong - Briliant I give it 9 out of 10 (very small room for improvement :-). It really does start out with very few assumptions, and uses C and Java occasionally as examples of 'traditional' code. After 10 days, I'm more than 50% through (and I do have a life). IMHO, the writing style is better than Joe's lectures and blog. It reads like he really wants you to try Erlang, and it's presented in a very practical, hands-on style. He uses the interactive shell to get you started, and hence avoids having to show a load of detail before you can get some results. I found myself extending bits of code, trying to write little servers and stuff while watching TV (yes, Erlang is that addictive). I hope the book does for Erlang what the 'Pickaxe' book did for Ruby. I would recommend getting the PDF of the book too (if you have a computer next to you a lot of the time). The PDF gets a 60% if you buy the book (you can buy the book from elsewhere, and still get the discount from the pragmatic' web site). I sometimes found the books index a bit weak, but the searchable PDF is well worth the $9. I strongly suggest you get started with Joe Armstrong's book, *but* If you feel *very* nervous about Functional Programming, or want to understand alternative Functional Programming technologies, I recommend Programming in Haskell (Paperback) by Graham Hutton. I've looked at most Haskell, SML and OCaml books, and this is far and away the most approachable. BUT be aware that Haskell (and the rest) are statically typed (and have very, very powerful type systems), and Erlang is dynamically typed. Sequential Erlang is more like Lisp/ Scheme with helpful syntax than the newer FP languages, so be careful. Another idea for exercises - you might take a look at "The Computer Language Benchmarks Game" at http://shootout.alioth.debian.org/ They have a bunch of small benchmarks coded in Java and Erlang (and 30 + other languages), so you can see how the same algorithm would be coded in both languages, or try coding it yourself based on the Java code. Who knows, you may come up with a better implementation. HTH - Garry B-) From mogorman@REDACTED Fri Aug 31 18:24:52 2007 From: mogorman@REDACTED (Matthew O'Gorman) Date: Fri, 31 Aug 2007 11:24:52 -0500 Subject: [erlang-questions] memoization (was: Re: [Fwd: Re: Functional Programming]) In-Reply-To: <20070831160711.GA26010@infula.helvella.org> References: <46D5EB78.9030701@zacbrown.org> <20070831160711.GA26010@infula.helvella.org> Message-ID: i have this memo.erl: -module (memo). -export ([y/1, memoize/1, fib/1]). y (F) -> F (fun (X) -> (y (F)) (X) end). memoize (Tab, F) -> fun (B) -> fun (C) -> case ets:lookup (Tab, C) of [] -> R = (F (B)) (C), ets:insert (Tab, {C, R }), R; [{C, R}] -> R end end end. memoize (F) -> fun (X) -> Tab = ets:new (?MODULE, [ private ]), Ans = (y (memoize (Tab, F))) (X), ets:delete (Tab), Ans end. fibimpl (P) -> fun (0) -> 1; (1) -> 1; (N) when N > 1 -> P (N - 1) + P (N - 2) end. fib (N) -> (memoize (fun fibimpl/1)) (N). memoize.erl: -define(eval(Expr) -> memo:eval(fun() -> Expr end)). eval(F) when is_function(F, 0) -> case memo_db:lookup(F) of {ok, Cached} -> Cached; error -> Value = F(), memo_db:store(F, Value), Value end mog From cmeyer@REDACTED Fri Aug 31 18:50:05 2007 From: cmeyer@REDACTED (Colin Meyer) Date: Fri, 31 Aug 2007 09:50:05 -0700 Subject: [erlang-questions] memoization (was: Re: [Fwd: Re: Functional Programming]) In-Reply-To: References: <46D5EB78.9030701@zacbrown.org> <20070831160711.GA26010@infula.helvella.org> Message-ID: <20070831165005.GC5323@infula.helvella.org> Hi, Thanks for your reply. I hadn't gotten to learning about ETS yet. I guess that this is fairly similar to my idea of caching results in the process dictionary. Is it a correct understanding that caching is not practical with "pure" Erlang data structures? Thanks, -Colin. On Fri, Aug 31, 2007 at 11:24:52AM -0500, Matthew O'Gorman wrote: > i have this > memo.erl: > -module (memo). > -export ([y/1, memoize/1, fib/1]). > > y (F) -> > F (fun (X) -> (y (F)) (X) end). > > memoize (Tab, F) -> > fun (B) -> > fun (C) -> > case ets:lookup (Tab, C) of > [] -> > R = (F (B)) (C), > ets:insert (Tab, {C, R }), > R; > [{C, R}] -> > R > end > end > end. [...] From tsuraan@REDACTED Fri Aug 31 19:09:19 2007 From: tsuraan@REDACTED (tsuraan) Date: Fri, 31 Aug 2007 12:09:19 -0500 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <9b08084c0708310853m6f0482f3m62ba622f67a1cdb4@mail.gmail.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> <9b08084c0708310853m6f0482f3m62ba622f67a1cdb4@mail.gmail.com> Message-ID: <84fb38e30708311009m740c0e7al618153b44a9b00f2@mail.gmail.com> But for those fence-sitters out there, the book really isn't noticably targetted towards Java people (at least, i never got that impression). I haven't used java in years, and I didn't enjoy it when I did use it, but I thought the book was great. It really made a great case for Erlang, and explains the language well. On 31/08/2007, Joe Armstrong wrote: > > The book was specifically written with Java programmers in mind. > > When I started the book my target audience was Erlang programmers - but > Dave Thomas soon convinced me that I was wrong and that I should target > Java programmers. As the book progressed we tested the text on some > tame Java programmers and adjusted the text to suit the audience. > > No previous knowledge of any functional programming language is assumed > and the introduction to unfamiliar concepts like "assign once variables" > is > taken pretty slowly with lots of examples. > > /Joe Armstrong > > > > On 8/31/07, Lone Wolf wrote: > > Hi. > > I'm an enterprise Java developer. > > What is the best way to learn Erlang language from the scratch? > > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? > or > > this books assumes the reader is Erlang programmer ? > > BTW, I don't know "Functional Programming" at all. > > Thanks. > > > > > > > > Deep into that darkness peering, long I stood there, wondering, fearing, > > Doubting, dreaming dreams no mortal ever dreamed before. > > E.A Poe > > > > > > > > ________________________________ > > Looking for a deal? Find great prices on flights and hotels with Yahoo! > > FareChase. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Fri Aug 31 19:14:23 2007 From: bob@REDACTED (Bob Ippolito) Date: Fri, 31 Aug 2007 10:14:23 -0700 Subject: [erlang-questions] memoization (was: Re: [Fwd: Re: Functional Programming]) In-Reply-To: <20070831165005.GC5323@infula.helvella.org> References: <46D5EB78.9030701@zacbrown.org> <20070831160711.GA26010@infula.helvella.org> <20070831165005.GC5323@infula.helvella.org> Message-ID: <6a36e7290708311014y584322c5l3a9a128f4e0ff7d1@mail.gmail.com> If you use pure Erlang data structures you could only cache results during the tail recursion (by adding another parameter, perhaps behind the scenes with a parse transform or macro). Since ets is mutable and lasts longer than the function call, you can cache results for the duration of the process. Also, the performance of pure Erlang dict/gb_trees/etc. is not generally as good as ets. ets is generally preferred over the process table, as far as I have seen. -bob On 8/31/07, Colin Meyer wrote: > Hi, > > Thanks for your reply. I hadn't gotten to learning about ETS yet. I > guess that this is fairly similar to my idea of caching results in the > process dictionary. > > Is it a correct understanding that caching is not practical with "pure" > Erlang data structures? > > Thanks, > -Colin. > > On Fri, Aug 31, 2007 at 11:24:52AM -0500, Matthew O'Gorman wrote: > > i have this > > memo.erl: > > -module (memo). > > -export ([y/1, memoize/1, fib/1]). > > > > y (F) -> > > F (fun (X) -> (y (F)) (X) end). > > > > memoize (Tab, F) -> > > fun (B) -> > > fun (C) -> > > case ets:lookup (Tab, C) of > > [] -> > > R = (F (B)) (C), > > ets:insert (Tab, {C, R }), > > R; > > [{C, R}] -> > > R > > end > > end > > end. > > [...] > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From parlar@REDACTED Fri Aug 31 19:47:03 2007 From: parlar@REDACTED (Jay Parlar) Date: Fri, 31 Aug 2007 13:47:03 -0400 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <9b08084c0708310853m6f0482f3m62ba622f67a1cdb4@mail.gmail.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> <9b08084c0708310853m6f0482f3m62ba622f67a1cdb4@mail.gmail.com> Message-ID: On 8/31/07, Joe Armstrong wrote: > The book was specifically written with Java programmers in mind. > > When I started the book my target audience was Erlang programmers - but > Dave Thomas soon convinced me that I was wrong and that I should target > Java programmers. As the book progressed we tested the text on some > tame Java programmers and adjusted the text to suit the audience. > > No previous knowledge of any functional programming language is assumed > and the introduction to unfamiliar concepts like "assign once variables" is > taken pretty slowly with lots of examples. I'm a Python programmer, and the book has been fantastic for me. It's also the first time I felt like I really "got" functional programming (in terms of pattern matching). I've used map/filter/apply/list-comprehensions in Python before, but trying to learn Haskell, I could never comprehend how to write entire programs with that style. With Joe's book and writing style, everything has just clicked for me. Jay P. From david.hopwood@REDACTED Fri Aug 31 19:51:04 2007 From: david.hopwood@REDACTED (David Hopwood) Date: Fri, 31 Aug 2007 18:51:04 +0100 Subject: [erlang-questions] [Off-topic, correction] erlang vs java floating point format In-Reply-To: <46D82E93.70609@industrial-designers.co.uk> References: <2ae2b2da0708300956v18c8e16s65e4ec425f11bcca@mail.gmail.com> <46D82E93.70609@industrial-designers.co.uk> Message-ID: <46D85508.2030900@industrial-designers.co.uk> David Hopwood wrote: > Ryan Rawson wrote: >> Note that java floats are almost but not quite IEEE 754 floats. > > Assuming strictmath is in effect, I meant "strictfp". > and excluding NaN payloads and signalling NaNs, how are they different? -- David Hopwood From michael.campbell@REDACTED Fri Aug 31 20:54:43 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Fri, 31 Aug 2007 14:54:43 -0400 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <5B54D301-31CD-42C6-85E8-519FA23E5193@gmail.com> References: <5B54D301-31CD-42C6-85E8-519FA23E5193@gmail.com> Message-ID: <811f2f1c0708311154m5eeb73bdk3b5d73dfc05ac6b7@mail.gmail.com> On 8/31/07, G Bulmer wrote: > Another idea for exercises - you might take a look at "The Computer > Language Benchmarks Game" at http://shootout.alioth.debian.org/ > They have a bunch of small benchmarks coded in Java and Erlang (and 30 > + other languages), so you can see how the same algorithm would be > coded in both languages, or try coding it yourself based on the Java > code. Who knows, you may come up with a better implementation. Be careful with that. Alioth's shootouts are for how quickly a language can run a particular *algorithm*, which can at times be VERY DIFFERENT from how you would normally do it in that language. So some of the code on that will be weirdly contorted to fit the particular algorithm, rather than what the prevailing idiom is for that language. A somewhat more harsh criticism can be found here: http://yarivsblog.com/articles/2006/07/11/erlang-yaws-vs-ruby-on-rails/#comment-70 From michael.campbell@REDACTED Fri Aug 31 21:52:58 2007 From: michael.campbell@REDACTED (Michael Campbell) Date: Fri, 31 Aug 2007 15:52:58 -0400 Subject: [erlang-questions] Learning Erlang from the scratch In-Reply-To: <333875.88446.qm@web51105.mail.re2.yahoo.com> References: <333875.88446.qm@web51105.mail.re2.yahoo.com> Message-ID: <811f2f1c0708311252ma2554ecp887858e081b380d7@mail.gmail.com> On 8/31/07, Lone Wolf wrote: > Hi. > I'm an enterprise Java developer. > What is the best way to learn Erlang language from the scratch? > Can I depend on the new PragmaticProgrammer book "Programming Erlang" ? or > this books assumes the reader is Erlang programmer ? > BTW, I don't know "Functional Programming" at all. > Thanks. For everyone on this thread, there's also a slew (over 1000!) of programming exercises (not sorted by difficulty, however), here: http://www.spoj.pl/problems/classical/ Make sure you look at the left navbar for different categories - that particular link goes to the "classic" ones. From dot@REDACTED Thu Aug 30 18:08:38 2007 From: dot@REDACTED (Tony Finch) Date: Thu, 30 Aug 2007 17:08:38 +0100 Subject: [erlang-questions] Cocoa IDE for Erlang (again) In-Reply-To: <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> References: <4690174B-B135-4C85-B371-35A472313722@gmail.com> <4C29586E-2960-4991-828C-E3AE5F40FF49@gmail.com> <6a36e7290708290934m1f88bc10y5fcf52ae1b37b12a@mail.gmail.com> Message-ID: On Wed, 29 Aug 2007, Bob Ippolito wrote: > All that tells you is that pipes were faster than TCP 5 years ago on > and old i386 Linux kernel on i386. Nothing about those benchmarks can > really be applied to anything you'd deploy on today. Actually, it doesn't measure TCP at all: unix domain sockets don't go through the IP stack. On any system, unix domain sockets and pipes will be faster than TCP over the loopback interface because there is much less protocol overhead. On some BSDs, pipes use the same code as unix domain sockets - I'm not sure if Mac OS X has copied the faster pipe implementation from more recent versions of FreeBSD. Tony. -- f.a.n.finch http://dotat.at/ IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR.