A few notes on choosing between Go and D for a quick project

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 14 11:24:40 PDT 2015


On Sat, 2015-03-14 at 10:11 -0700, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 3/14/15 2:02 AM, Russel Winder via Digitalmars-d wrote:
> > On Fri, 2015-03-13 at 07:55 -0700, Andrei Alexandrescu via Digitalmars-d
> > wrote:
> >> On 3/13/15 6:45 AM, Russel Winder via Digitalmars-d wrote:
> >>> The removal of shared memory multi-threading in favour of using
> >>> processes and channels should never be underestimated as a Really Good
> >>> Thing™ that other native code languages (*) have failed to do anything
> >>> about. Thus Go wins, others lose.
> >>
> >> That's a marketing success as well. Go didn't "remove" shared memory
> >> multi-threading, it just unrecommends it. That's quite unremarkable from
> >> a programming language design standpoint, but as discussed that's not
> >> always crucial for success. -- Andrei
> >
> > I think you need to show a bit of Go code that uses threads to be able
> > to back up that claim.
> 
> package main
> 
> type Data struct {
>      i int
> }
> 
> func func1(c chan *Data ) {
>      var t *Data;
>      t = <-c
>      println(t)
> }
> 
> func func2(c chan *Data ) {
>      var t *Data;
>      t = <-c
>      println(t)
> }
> 
> func main() {
>      c := make(chan *Data)
>      t := Data{10}
>      go func1(c)
>      c <- &t
>      go func2(c)
>      c <- &t
>      println(&t)
> }
> 
I see no threads in this code! :-)

But yes, it certainly shows you can create shared-memory
"multi-threading" this way, but anyone actually doing it would be being
very silly. Sending addresses down multiple channels is obvious here and
definitely not the right thing to do unless the datum contains an
embedded lock which is then used. cf.
https://talks.golang.org/2012/10things.slide#3

It would be better if channels could only accept value types, and not
reference types.

Go is only a CSP-like, it isn't CSP. cf Python-CSP and PyCSP, not to
mention JCSP and GPars.


-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150314/df8f2f34/attachment.sig>


More information about the Digitalmars-d mailing list