News for hackers. Stuff that matters.
Re:Why Go? Use Racket by mediocregopher on Wednesday September 18, 2013 @09:35AM (#6405089)
> But it is inefficient to pass an array or struct; instead, we should pass pointers to these types.

I feel like the author hasn't used go much. You almost never work with arrays directly, you use slices, which CAN be efficiently passed around.

EDIT: Upon re-reading I think the author was making a point about the consistency of go, and how different types have different behavior with regards to pass-by-reference/copy. There's actually a pretty simple rule for it:

If the variable is a primitive, or defined by the user, it is passed by copy (ints, strings, structs, etc...). Everything else (compositional types like slices and maps, and others like channels) are passed by reference.

The outlier are raw arrays, but again you don't ever actually use those, so you can just ignore them.

Re:Why Go? Use Racket by NateDad on Wednesday September 18, 2013 @12:43PM (#6406317)
So... you have the right idea, but your statement about passing is technically wrong.

Everything in Go is passed by copying its value.

However, slices, maps, channels, and interfaces all have small values, which are just a pointer and some other small data (length, type, etc), so passing them directly (rather than by pointer) is not a big deal.

Re:Why Go? Use Racket by twic on Wednesday September 18, 2013 @10:53AM (#6405624)
As some one who is not familiar with Go, that sounds like it supports his statement that the type system is confusing.
Re:Why Go? Use Racket by tankenmate on Wednesday September 18, 2013 @11:44AM (#6405929)
I think it might be stretching it a bit to say that one lesser used exception makes the whole system copy/reference system confusing. There is also the upside that if you know what you are doing you can extract significant improvements in performance by being able to specify which passing method is used; a fair number of newer languages offer you no such option.
Re:Why Go? Use Racket by fauigerzigerk on Wednesday September 18, 2013 @12:34PM (#6406256)
I do appreciate the additional optimization opportunities that derive from the fact that user defined types can be used as values and not just references like in Java. That's very important for memory usage.

But the complexity that comes with it is undeniable. It's not just one exception that is confusing. The whole business with nil interface values versus non-nil interface values that contain nil pointers is not exactly pretty. It is consistent though.

Re:Why Go? Use Racket by twic on Thursday September 19, 2013 @01:01PM (#6412816)
I don't dispute the usefulness of being able to control how parameters are passed, especially in a systems language. But it seems like the two ways of passing could be consistently marked by syntax. They are in C, C++, and Rust, right? In Rust, if you had some type 'channel', then:

fn spam(victim: channel)

takes the channel by value (impossible in Go, and probably nonsensical anyway), whereas:

fn spam(victim: @channel)

takes a pointer to the channel.

I think the str type is currently an exception to this in Rust.