Re:Why Go is elegant and makes my code elegant
by vectorpush on Wednesday April 09, 2014 @07:42PM
(#7563282)
Right, and this is what happens in Go. I can use a string or struct as a signal for what type to produce, but I wish I could communicate that type in a "first class" way, rather than using another data type as a proxy signal. Check my reply to melvinmt for a more clear example of what I mean.
[ Parent
| on HN ]
Re:Why Go is elegant and makes my code elegant
by AnimalMuppet on Wednesday April 09, 2014 @07:48PM
(#7563312)
I'm still unclear on what you mean by "first class".
In Java, you could pass in WeatherProvider.class to tell it that you want it to produce a WeatherProvider instance or a string that said "WeatherProvider". Is that the kind of thing you have in mind?
Re:Why Go is elegant and makes my code elegant
by vectorpush on Wednesday April 09, 2014 @08:07PM
(#7563408)
I am not a Java programmer but the Java class literal seems like a perfect example. The class literal provides a language mechanism for representing a type of class (in Go's case it would be a type of struct) without the need for an actual instance of the class or another arbitrary data type (like a string or const) that the application is programmed to recognize as a signal for that class.