Live data from Hacker News

Go 1/2 Proposal: Immutable Types

news.ycombinator.com

1–10 of 27 posts

Go 1/2 Proposal: Immutable Types

#1
Hey guys, I just published the Go 1.x / Go 2.x proposal to "Immutable Types" that I've been working on for the past month and it's now official:

https://github.com/golang/go/issues/27975

Please be sure to check it out and feel free to join the conversation! Even if this feature is never introduced to the language specification - reading the design document will make you a better Go developer, that I guarantee!

original design document: https://github.com/romshark/Go-1-2-Proposal---Immutability

Re: Go 1/2 Proposal: Immutable Types

#2
Hi,

my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements.

The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features.

Example like "type ImmutableMapAndKey const map[const * const Object] const * const Object" looks like really ugly Go to me... this is starting to look like C++...

https://www.youtube.com/watch?v=cQ7STILAS0M (why Golang is Sucessful by Creator of Golang Rob-pike)

P.S.: I wouldn't mind having "Immutable Types", "Reference Types", ADTs, etc. in Go. But not if it means abandoning simplicity of the language.

Re: Go 1/2 Proposal: Immutable Types

#3
post #2

Hi, my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements. The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features. Example like "type Immut…

I don’t know exactly why Go become successful but it is not because it’s a great language.

Re: Go 1/2 Proposal: Immutable Types

#4
post #3
post #2

Hi, my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements. The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features. Example like "type Immut…

I don’t know exactly why Go become successful but it is not because it’s a great language.

Why do you think that?

I like it's stripped-down feature set, and opinionated concurrency (although it's occasionally clunky).

It's not perfect, and could have a lot more support for concurrency, but it's very workable and a joy to program in.

Re: Go 1/2 Proposal: Immutable Types

#5
post #2

Hi, my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements. The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features. Example like "type Immut…

The word "simplicity" has become a thought-terminating cliche in programming circles

https://en.wikipedia.org/wiki/Cliché#Thought-terminating_cli...

Re: Go 1/2 Proposal: Immutable Types

#6
post #3
post #2

Hi, my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements. The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features. Example like "type Immut…

I don’t know exactly why Go become successful but it is not because it’s a great language.

I'm looking for a new language to write server code in. I have been using Node for years but I want something that compiles to machine code and is statically typed.

I've been looking at Go and I like that it is simple, has opinionated, official tooling, compiles very quickly for multiple platforms, is popular enough to have a decent library ecosystem, and I really like the idea of goroutines.

What language would you suggest would be better? Nim sounds cool but it's too new. It's not stable and has a small ecosystem.

Re: Go 1/2 Proposal: Immutable Types

#7
post #6
post #3

Earlier quoted context omitted.

I don’t know exactly why Go become successful but it is not because it’s a great language.

I'm looking for a new language to write server code in. I have been using Node for years but I want something that compiles to machine code and is statically typed. I've been looking at Go and I like that it is simple, has opinionated, official tooling, compiles very quickly for multiple platforms, is popular enough to have a decent library ecosystem, and I really like the idea of goroutines. What language would you…

You should give Nim a go. The ecosystem is growing fast :)

Re: Go 1/2 Proposal: Immutable Types

#8
post #2

Hi, my humble opinion: how much would "Immutable Types" add to the language? How much complexity would it add? Things can already be made immutable from outside by hiding them in private variables/struct elements. The question is: why did Go became successful without having "Immutable Types"? (or "Reference Types", ADTs too please?) Maybe those things are just frills, "nice to have" features. Example like "type Immut…

It'd rather reduce complexity. It'll make Go code less ambiguous leading to fewer bugs that you'll have to spend your time debugging. When working in big teams on big projects you better describe your intentions clearly.

Yes, you can hide state behind interfaces and opaque types, but you don't take into account, that the implementations of those types and interfaces need to be reliable as well. An interface with read-only types, for example, can declare its methods immutable enforcing an immutable receiver type on the implementing functions which makes sure that it's always correctly implemented and doesn't mutate its object for sure! A field can be declared immutable to make sure it remains immutable after the object is initialized, and so on. Immutable types allow you to better express your intentions when implementing something because in a month from now you'll be a different person too and you won't remember certain implementation details like "why you shouldn't mutate this inner slice in this struct" etc.

The whole concept is actually composed of 5 fundamental rules that are relatively easy to pick up. It also shouldn't be compared to C++ or even C style const qualification, because it's easier and safer.

Re: Go 1/2 Proposal: Immutable Types

#9
post #4
post #3

Earlier quoted context omitted.

I don’t know exactly why Go become successful but it is not because it’s a great language.

Why do you think that? I like it's stripped-down feature set, and opinionated concurrency (although it's occasionally clunky). It's not perfect, and could have a lot more support for concurrency, but it's very workable and a joy to program in.

My personal problem with Go is that it doesn’t fit in any niche.

If you want language optimized for productivity with a lot of high-level features, use Python. If you want maximum performance and low-level control, use C++ (or C, or Rust). If you need relatively high performance but can tolerate it not being 100% in exchange for nice things like GC, use Java. Where does Go fit?

Re: Go 1/2 Proposal: Immutable Types

#10
post #4
post #3

Earlier quoted context omitted.

I don’t know exactly why Go become successful but it is not because it’s a great language.

Why do you think that? I like it's stripped-down feature set, and opinionated concurrency (although it's occasionally clunky). It's not perfect, and could have a lot more support for concurrency, but it's very workable and a joy to program in.

> I like it's stripped-down feature set

How could the absence of sum types possibly be a good thing?

Post reply on HN