Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go has an escape hatch (interface{} and downcasts) that basically give it an embedding of a dynamic type system inside the static one. You end up having to use this a lot if you're doing things like decoding complex JSON data structures or working with containers, since Go doesn't have generics.


> Go has an escape hatch (interface{} and downcasts) that basically give it an embedding of a dynamic type system inside the static one.

No, that gives you a static type system with loopholes, same as Java, you have to use reflect to get a dynamic system in which you can invoke an arbitrary and unchecked method on an object (also same as Java).

Granted, because Go's type system is structural you could define an interface with just the method(s) you want, cast your object to that interface and then call the methods, and you can even define the interface anonymously and inline. Still, go requires your static types to match unless you use reflect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: