|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D - Rob Pike's Newsqueak - some good concepts
Today I watched an excellent presentation by Mr. Rob Pike on Google Tech Talks. (Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak - http://video.google.com/url?docid=810232012617965344&esrc=rss_uds&ev=v&q=user:%22Google+engEDU%22&vidurl=http://video.google.com/videoplay%3Fdocid%3D810232012617965344%26q%3Duser%253A%2522Google%2BengEDU%2522%26hl%3Den&usg=AL29H22XDZMMUf udHDB2dqX9jtFEE4L9w ) There are several very interesting concepts in his Newsqueak langauge which I would be very happy to see in D. One of such is the ability to execute ANY function as a new process (thread) via keyword "begin". An example: <code> // makes no sense, but should work begin int sum(int a, int b) { return a+b; } begin int doConcurrently(int a, int b) { for (; a>0; a--) print(b); // prints in background } // same, like lambda begin int doConcurrently2(int a, int b) { for (; a>0; a--) print(b); // prints in background }(20, sum(23, 5)) </code> As You can see, begin makes expression/function work in a separate process/thread. It has been discussed about having lambda-functions here on these newsgroups, so I will not touch that topic in this thread... Second very interesting concept is connected with the "become" keyword. With it you can replace function with it's execution, which basically generalizes tail recursion. This is better explained with an example: <code> // Any expression int function(int a, int b) { become a + b; } int sum(int a, int b) { return a+b; } // Any function invocation // Reuses sum's stack space! int difference(int a, int b) { become sum(a, -b); } </code> There are more interesting things, I haven't had time to write about them, so I strongly recommend seeing this presentation! :) Cheers! May 18 2007
Yes, I have forgotten to say something about chan-nels - and the "select" statement which is part of the languge. I would BEG Mr. Walter to incorporate something like this into D! :) May 18 2007
Concurrent programming has enormous applications, but it has yet to gain much mainstream traction yet. Partly because present implementations are inefficient, and partly because there is a substantial knowledge barrier to entry. This is a shame, since you can easily write all sorts of programs extremely elegantly. Especially interactive applications and simulations, such as games, webapps, databases, fluid dynamics code etc. Right now, it is possible to write CSP-style programs in D. DCSP already does all of these things discussed in this talk, though the structure has more in common with occam than Newsqueak. You can check it out at: http://assertfalse.com Part of the problem with CSP-style languages is that implementing a non-deterministic choice operator or 'guarded' select is that it is very difficult. Frankly, the version in DCSP is rather slow and unnecessarily limited. In the future, I hope to address these issues, but I won't be able to do any work until I finish up my current projects. -Mik May 18 2007
Mr. Lysenko, thanks for the information! I have a link to assert(false) from my home page since last year, but I haven't seen DCSP! Excellent! :) May 18 2007
Mikola Lysenko Wrote:Concurrent programming has enormous applications, but it has yet to gain much mainstream traction yet. Partly because present implementations are inefficient, and partly because there is a substantial knowledge barrier to entry. -Mik May 19 2007
noname a écrit :Mikola Lysenko Wrote:Concurrent programming has enormous applications, but it has yet to gain much mainstream traction yet. Partly because present implementations are inefficient, and partly because there is a substantial knowledge barrier to entry. -Mik May 19 2007
On Sat, 19 May 2007 13:32:02 +0400, noname = <noname lolrofl.fakeaddress.net> wrote:It is surprising how much difference in performance there is between = May 19 2007
Mikola Lysenko wrote:Part of the problem with CSP-style languages is that implementing a non-deterministic choice operator or 'guarded' select is that it is very difficult. Frankly, the version in DCSP is rather slow and unnecessarily limited. In the future, I hope to address these issues, but I won't be able to do any work until I finish up my current projects. May 20 2007
Dejan Lekic wrote:Today I watched an excellent presentation by Mr. Rob Pike on Google Tech Talks. (Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak - http://video.google.com/url?docid=810232012617965344&esrc=rss_uds&ev=v&q=user:%22Google+engEDU%22&vidurl=http://video.google.com/videoplay%3Fdocid%3D810232012617965344%26q%3Duser%253A%2522Google%2BengEDU%2522%26hl%3Den&usg=AL29H22XDZMMUf udHDB2dqX9jtFEE4L9w ) There are several very interesting concepts in his Newsqueak langauge which I would be very happy to see in D. One of such is the ability to execute ANY function as a new process (thread) via keyword "begin". An example: <code> // makes no sense, but should work begin int sum(int a, int b) { return a+b; } begin int doConcurrently(int a, int b) { for (; a>0; a--) print(b); // prints in background } // same, like lambda begin int doConcurrently2(int a, int b) { for (; a>0; a--) print(b); // prints in background }(20, sum(23, 5)) </code> As You can see, begin makes expression/function work in a separate process/thread. It has been discussed about having lambda-functions here on these newsgroups, so I will not touch that topic in this thread... Second very interesting concept is connected with the "become" keyword. With it you can replace function with it's execution, which basically generalizes tail recursion. This is better explained with an example: <code> // Any expression int function(int a, int b) { become a + b; } int sum(int a, int b) { return a+b; } // Any function invocation // Reuses sum's stack space! int difference(int a, int b) { become sum(a, -b); } </code> There are more interesting things, I haven't had time to write about them, so I strongly recommend seeing this presentation! :) Cheers! May 18 2007
Dejan Lekic a écrit :Today I watched an excellent presentation by Mr. Rob Pike on Google Tech Talks. (Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak - http://video.google.com/url?docid=810232012617965344&esrc=rss_uds&ev=v&q=user:%22Google+engEDU%22&vidurl=http://video.google.com/videoplay%3Fdocid%3D810232012617965344%26q%3Duser%253A%2522Google%2BengEDU%2522%26hl%3Den&usg=AL29H22XDZMMUfZudHDB2dqX9jtFEE4L9w ) There are several very interesting concepts in his Newsqueak May 18 2007
renoX wrote:That said I thought that the content of the presentation is a bit 'old': after all he was presenting 20+ old ideas. May 20 2007
Limbo has a ref keyword that makes a ref to an adt so you just copy refs around not huge copies of the data structure. I've done a postgresql client in Limbo, it's great having the CSP co-routines just chat away to each other. It really separates out the way you approach a problem. May 22 2007
Dejan Lekic wrote:Today I watched an excellent presentation by Mr. Rob Pike on Google Tech Talks. (Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak - http://video.google.com/url?docid=810232012617965344&esrc=rss_uds&ev=v&q=user:%22Google+engEDU%22&vidurl=http://video.google.com/videoplay%3Fdocid%3D810232012617965344%26q%3Duser%253A%2522Google%2BengEDU%2522%26hl%3Den&usg=AL29H22XDZMMUf udHDB2dqX9jtFEE4L9w ) There are several very interesting concepts in his Newsqueak langauge which I would be very happy to see in D. One of such is the ability to execute ANY function as a new process (thread) via keyword "begin". May 20 2007
|