Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: perl5 road map?

by zwon (Monsignor)
on Mar 24, 2012 at 14:54 UTC ( #961408=note: print w/ replies, xml ) Need Help??


in reply to Re: perl5 road map?
in thread perl5 road map?

How much time it will take if you add -MMoose I wonder? The thing is that in Erlang time and memory required to create a new process (it doesn't have threads) don't depend on what modules are loaded. At any time you can spawn several dozens of thousands of processes and it won't generally consume all available memory. Perl creates full copy of the interpreter for every thread, so you can't have too many of them, especially if you want to use something heavy in threads, like Moose. Don't pretend you don't know that.

Comparison doesn't really make sense and one-liners are not a strong side of Erlang, but here's an example from Erlang Programming that creates 10000 processes (in the book they actually starting at 100000):

-module(myring). -export([start/1, start_proc/2]). start(Num) -> start_proc(Num, self()). start_proc(0, Pid) -> Pid ! ok; start_proc(Num, Pid) -> NPid = spawn(?MODULE, start_proc, [Num-1, Pid]), NPid ! ok, receive ok -> ok end.

And running it from the erl:

3> timer:tc(myring,start,[10000]). {14283,ok}

Time is in microseconds.


Comment on Re^2: perl5 road map?
Select or Download Code
Re^3: perl5 road map?
by BrowserUk (Pope) on Mar 24, 2012 at 15:27 UTC
    The thing is that in Erlang ... create processes (it doesn't have threads)

    Sorry, but you are wrong. Erlang does use threads.

    • Firstly: Erlang processes are actually 'green threads'.

      That is, user-space execution contexts, running in shared memory space, managed by an custom-written, in-process scheduler.

    • Secondly: Since the release of R13B in 2006; as a result of the realisation that green threading didn't scale on modern hardware -- whether multi-processor SMP or multi-core SMP or a combination of the two -- Erlang now uses kernel threads internally, in order to achieve scalable concurrency.

      For a little more detail of the history and reasoning, please see one I prepared earlier.

      And see the Erlang development team paper: "Inside the Erlang VM: with focus on SMP. Prepared by Kenneth Lundin, Ericsson AB Presentation held at Erlang User Conference, Stockholm, November 13, 2008 ". (I linked to the PDF in the earlier reference.)

    here's an example from Erlang Programming that creates 10000 processes (in the book they actually starting at 100000):

    Yes. And the Go language proponents promote that it can do the same thing:

    package main import ("flag"; "fmt") var ngoroutine = flag.Int("n", 100000, "how many") func f(left, right chan int) { left <- 1 + <-right } func main() { flag.Parse(); leftmost := make(chan int); var left, right chan int = nil, leftmost; for i:= 0; i< *ngoroutine; i++ { left, right = right, make(chan int); go f(left, right); } right <- 0; // bang! x := <-leftmost; // wait for completion fmt.Println(x); // 100000 }

    The Mercedes CLK63 AMG Black has so much power that Jeremy Clarkson (Top Gear) managed to sustain a power-slide for so long that he completely destroyed a brand new pair of 1,000/pair rear tyres in about 10 minutes. It was spectacular to watch; and I bet it was fun to do; but as a measure of the utility of the vehicle, it is entirely pointless!

    And the same goes for both the Erlang and Go threading demos. They are entirely useless as demonstrations of anything practical or useful.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Erlang processes don't share anything, hence they actually different from 'green threads' like in Java, you can't rewrite your example with threads::shared in Erlang (and I mean using shared variable). VM itself indeed implemented with using threads, but they are not visible for Erlang programs, and don't map to Erlang processes.

      And the same goes for both the Erlang and Go threading demos. They are entirely useless as demonstrations of anything practical or useful.

      Agreed. So why the hell you first gave useless demonstration in Perl, then asked Let's see your Erlang one-liner, and finally thrown up even more useless Go? ;)

        Erlang processes don't share anything, hence they actually different from 'green threads'

        Of course they share stuff. It is an illusion of the programing model -- functional programming with single assignment variables -- that they appear not to. But just as they don't throw away a chunk of ram just because you used it once, there is nothing to stop errant (compiler or runtime) code scribbling all over everything in the process virtual memory space.

        Everything lives in a single process; ergo, everything is shared.

        So why the hell you first gave useless demonstration in Perl,

        Because the OP said: "who determine if ... perl5? For example: can create 1000+ fast,light, reliable threads easily without any crash like erlang"

        I simply demonstrated that it was possible to do that now, and had been possible for a long time.

        But I went on to say: "Of course, I cannot actually think of a valid use for it, but doing it is not a problem."

        My exact point was that it is just as useless to do in Perl as it is in Erlang or Go -- but if you want to, you can.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-07-22 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (119 votes), past polls