Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: perl5 road map?

by BrowserUk (Pope)
on Mar 23, 2012 at 16:26 UTC ( #961256=note: print w/ replies, xml ) Need Help??


in reply to perl5 road map?

create 1000+ fast,light, reliable threads easily without any crash like erlang

Perl's been able to do that for years:

[16:20:43.22] C:\test>perl -mthreads=stack_size,4096 -mthreads::shared + -E"my $n:shared=0; async{{lock$n; ++$n;} sleep 1e3}->detach for 1..1e3 +; sleep 1 while threads::list > 1; say $n" 999 [16:20:44.72] C:\test>

(Let's see your Erlang one-liner to do that in 1.5 seconds?)

Of course, I cannot actually think of a valid use for it, but doing it is not a problem.


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?


Comment on Re: perl5 road map?
Download Code
Re^2: perl5 road map?
by zwon (Monsignor) on Mar 24, 2012 at 14:54 UTC

    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.

      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? ;)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-12-27 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls