Re:Poll: How many programming languages do you command fluen...
by jerf on Saturday January 04, 2014 @02:58PM
(#7012617)
I wouldn't call Go's typing "very weak". It's not Haskell, but it's still a fairly typical manifestly-typed language like C# or Java (minus contra- and/or covariance), and you certainly can't just slop values around without thinking about their type. "Very weak" I'd reserve for Perl, Javascript, or (I think) PHP, with their propensity to turn "anything" into a string or a number out from underneath you.
It is generally stronger than C's, in that C lets you be quite... creative... in how you cast values. Go qua Go does not let you do that, though it does have an escape hatch via the unsafe package that lets you do anything C can, mostly used for interfacing with C.
Re:Poll: How many programming languages do you command fluen...
by jrockway on Saturday January 04, 2014 @10:02PM
(#7014297)
Go does indeed add some nice checks over C. For example, given:
type foo int
var (
A foo = iota
B
C
D
)
func bar(x foo) ...
It's an error to write: bar(2)
That's enough typing to prevent many types of annoying mistakes.
Re:Poll: How many programming languages do you command fluen...
by jbooth on Saturday January 04, 2014 @02:54PM
(#7012600)
Yeah, the only gotcha I've ever had with Go was being confused about why I couldn't pass a pointer to an interface. Then I grokked what interfaces are in Go (a pointer to an implementation satisfies an interface, a pointer to an interface is nonsensical), and was good to go.
- syntax (curly braces, star for pointers and dereferencing, ampersand for getting the address etc., cleaned up for faster parsing and with some genuinely new things)
- iteration via for loops (no iterators, no map/fold/...)
- structs for data abstraction
- layout of variables in structs corresponding directly to memory layout
- argument passing by value or via pointers
- very weak typing
Look at it from the other side, what new things has a C programmer coming to Go learn, besides the syntax? Slices, goroutines, make/new, and some little bits related to packages/runtime, all hardly difficult concepts. Some old habits do not work anymore, mostly minor things. Finally both authors (Thompson and Pike) were C coders for decades...