Python & Go
Sat Nov 14 04:38:04 CET 2009
Duncan Booth <duncan.booth at invalid.invalid> writes:
> > Haskell handles lookups through its type system; dealing with
> > lookup errors (say by chaining the Maybe type) is clean and elegant.
> I said exceptions or any other method of error handling.
I think the use of an option type (like Maybe) is pretty standard
and works fine. Go's use of multiple-value returns isn't so bad,
but seems old-fashioned.
> go routines are executed using a thread pool,...
> Most types are not thread safe, so you should never access any mutable
> value from more than one go routine. If you need to access something
> like a map from multiple parallel routines you need to use channels to
> protect it.
OK, this sounds sort of like Erlang.
> var ch = make(chan int, 3);
> would create a channel that holds 3 int values. ...
> You can also use a select statement (syntax similar to a switch
> statement) to read or write channels in parallel. It arbitrarily chooses
> one of the case statements that can proceed to execute,...
Thanks, that is informative. The mechanism looks kind of primitive
and it would be nice if there were a higher level wrapper of some
sort. But again, it seems sort of Erlang-like (though I haven't used
Erlang so I only have a vague sense of its similarity).
> There doesn't seem to be any way to specify a timeout on a read or
> write. I think you can create a timer channel with regular ticks and
> select from that to provide an effective timeout, but that sounds like a
> lot of boilerplate if you have to do very often.
I wonder how Erlang handles this.
It seems a little weird to me that they (Google) are concerned with
the speed of the compiler, indicating that they plan to write enormous
programs in the language. I've heard they use a 1000-node cluster to
compile their large C++ apps. Go seems too primitive (so far) to
really be suitable for such large-scale development, and (for a newly
designed language) seems to be missing a lot of the latest ideas.
More information about the Python-list