"Golang has been pleasing me lately although it's interfaces have a very tiny hole in the type safety."
Go/Golang is indeed an amazing language -- my favorite, in fact, even beating out Python for my #1 spot. Go's creators guarantee its type safety; what hole do you speak of?
To hopefully assuage your concerns and to make an assumption about what you may worry is a hole in Go's type safety...
Empty interfaces allow one to contain _any_ value (such as a string) in an interface{}, but in order to use such a value, one must access the underlying type of the interface{} (i.e., the aforementioned string value). To do so, a type assertion is required, thereby preserving type safety... unless I'm missing something?
The interface{} is a contributor to the hole but not the cause.
The hole occurs when I want to make a generic container like say a binary tree. I can create a node interface that satisfies my needs for a binary tree. What I can't do is guarantee that at compile time every element in my container is of the type that I expect. If they ever add generics of some sort this hole will be closed. It's a very tiny one and can usually be limited to a single functions scope but it still exists and certainly not enough to make me dismiss the languange out of hand. You can see examples of the hole by looking at Go's container/* packages. Some of them had a completely separate implementation for each of the primitive types. Type assertions ensure type safety at runtime provided the programmer does their job. But it depends on the programmer doing their job so it could be better.
Go and ML were two examples that come the closest to my "ideal" language. Go just happens to be one that I have the greatest chance of actually using in a job :-)
> You can see examples of the hole by looking at Go's container/*
container/* is a bit of a corner case which is rarely used, specially since append() was added to the language and container/vector was deprecated I can't remember the last time I needed anything from container/*.
Go/Golang is indeed an amazing language -- my favorite, in fact, even beating out Python for my #1 spot. Go's creators guarantee its type safety; what hole do you speak of?
To hopefully assuage your concerns and to make an assumption about what you may worry is a hole in Go's type safety...
Empty interfaces allow one to contain _any_ value (such as a string) in an interface{}, but in order to use such a value, one must access the underlying type of the interface{} (i.e., the aforementioned string value). To do so, a type assertion is required, thereby preserving type safety... unless I'm missing something?