TechHui

Hawaiʻi's Technology Community

I just read through the language spec and memory model for Go, Google's new language (thank you for the link Scott.) There are a lot of things l like about the language, such as its approach to concurrency, heavy use of type inference (which we also see in C# and Java 7), ruby-like array and map manipulation syntax, etc., but I'm not entirely sold on the type system. Go has no concept of inheritance, which they cite as a good thing because Go types are "light". From the Go docs:
Rather than requiring the programmer to declare ahead of time that two types are related, in Go a type automatically satisfies any interface that specifies a subset of its methods. Besides reducing the bookkeeping, this approach has real advantages. Types can satisfy many interfaces at once, without the complexities of traditional multiple inheritance. Interfaces can be very lightweight—having one or even zero methods in an interface can express useful concepts. Interfaces can be added after the fact if a new idea comes along or for testing—without annotating the original types. Because there are no explicit relationships between types and interfaces, there is no type hierarchy to manage or discuss.
Um... OK, so you have this sort of loosey-goosey approach to interfaces (if I have the methods, I satisfy the interface), but what about super class constructors and concrete (non-abstract) methods? I'm having trouble imagining libraries such as UI toolkits (WPF, Flex, Swing, etc.), which effectively make heavy use of relatively deep inheritance trees, being written in as elegant a manner in Go. Those super classes are doing a lot of work, and the type hierarchies provide a nice taxonomy for the API. Perhaps Go is advocating the use of a different paradigm to accomplish the same thing, but it doesn't seem to be readily evident from the docs.

Two areas where I think they are definitely making a mistake:
- The lack of exceptions. I guess they don't like the whole concept of signals.
- The lack of generics. The docs say they may get around to generics, but that it isn't a priority.

Thoughts?

Update 5/13/11: Go has introduced signal constructs called Defer, Panic and Recover that provide a form of exception handling. I haven't yet decided if I like them better than exception handling in Java / C#.

Ikayzo - Design • Build • Localize | Web • Desktop • Mobile

Views: 138

Comment

You need to be a member of TechHui to add comments!

Join TechHui

Comment by Konstantin A Lukin on November 18, 2009 at 12:53pm
Being mostly a Java programmer, I am intrigued by this new language. In the Java world, things are pretty slow.. Having a C equivalent that improves on its language constructs while still maintaining its speed sounds very attractive. I would be curious to know how this language can be applied in the real world, which infrastructures would support it, which libraries can be used to accomplish which tasks.. basically like a cook book of some sort.

Especially I'd be curious if it can be applied for web development in any way. For example, since it is owned by Google, they could include support for 'Go' in their app engine for handling cron jobs, tasks, etc.. But in general, I can also see this new language generating excitement around building low level infrastructure, which eventually could end up benefiting Google's Chrome OS and the web to tomorrow initiative, the Android, or maybe even something else, new and exciting that we haven't thought of just yet :)
Comment by Daniel Leuck on November 18, 2009 at 12:43pm
Tim Dysinger: "(C, C++) are unnecessarily cumbersome and unsafe" I would add C# Java and the rest of OO in the "unsafe and cumbersome" lot. :)
In what sense? You can make a lot of valid criticisms about Java and C#, but type and memory safety aren't among them.

I'd like to see a c# or java "safely" write an app for 256 cores. ;)
It sounds like you are conflating discussion of safety and performance (and perhaps concurrency.) The JVM and CRE can map threads onto multicore processors. The performance is a function of the quality of the VM implementation on your platform. Can you do fancier things with scheduling and parallelization if you write code in C? Sure. You can also do more precise gardening with a teaspoon :-) Note that in C# you can mark code as unsafe and do pretty much anything you can do in C.

I believe Go is designed to be the words fastest GCed language. Looking at design decisions in the language - no type hierarchies, no stack walking signals (exceptions), etc., and the memory model, its clearly designed to be Java or C#-like but allow for much faster implementations. If this is the case, a lot of systems programming at Google currently being done in C/C++ could be replaced by Go. In other words, I think they are trying to find a middle ground between Java and C.
Comment by Tim Dysinger on November 18, 2009 at 10:49am
"(C, C++) are unnecessarily cumbersome and unsafe" I would add C# Java and the rest of OO in the "unsafe and cumbersome" lot. :). I'd like to see a c# or java "safely" write an app for 256 cores. ;) Ok, I'm done razzing peoples :)
Comment by Tim Dysinger on November 18, 2009 at 10:45am
"but what about super class constructors and concrete (non-abstract) methods?" this is OO thinking. Everything new coming out of language research is moving away from OO and towards functional programming.
"The lack of generics." It's pretty generic to not have Types.
"The lack of exceptions" exceptions are just message-passing - you can pass errors back to callers in Erlang without exception classes.
Comment by Tim Dysinger on November 18, 2009 at 10:40am
Actually 100% of the languages I use all day long are functional and have NO TYPES other than the primitives that come with the language. I think OO is a thing of the past and functional languages are Back to the Future.
Comment by Tim Dysinger on November 18, 2009 at 10:33am
I must qualify my "blech" - I love learning new languages. But I don't think I am going to bother with this one.
Comment by Tim Dysinger on November 18, 2009 at 10:31am
No thanks. The headlines from some blogs described as a cross of Python and C++. Blech!
Comment by Ken Berkun on November 12, 2009 at 6:44pm
Reasonable overview of Go and its purposes:
http://news.cnet.com/8301-30685_3-10393210-264.html?tag=rtcol;pop
Comment by Ken Berkun on November 12, 2009 at 4:28pm
Good reply Dan. It pains me to think that I've fallen into a niche where I don't have the time or need to explore new technologies. I have to remind myself that I am learning other things...

Ken
Comment by Daniel Leuck on November 12, 2009 at 3:51pm
> I enjoy all these articles about languages, but, and this is a serious question,
> why do we care?

Hi Ken - A fair question. I'm not particularly interested in languages that simply play with syntax, but every once in a while a language combined with a new programming paradigm, and in some cases an innovative runtime, comes along and really changes the way people approach software development. That interests me.

I chose to post about Go and C# because they are doing interesting things with their typing systems and runtimes. These things play a big part in productivity and code safety. Also, I think they have the potential to replace C and C++ in many cases. These languages are unnecessarily cumbersome and unsafe. Its not C's fault - its nearly 40 years old, but I'm tired of having to read and write software in languages older than me. :-) Its time for better systems level languages.

> Who has time to evaluate a new language when there is so much work to
> be done and the current tools, if not perfect, are adequate?

A lot of what we do is advise people on software architectures and platform decisions. In short, its part of our job to watch what companies like Google, Microsoft, Sun/Oracle and Adobe are doing in this space. I don't get to work on cool inventions all day like my friends from Seattle ;-)

Sponsors

web design, web development, localization

© 2022   Created by Daniel Leuck.   Powered by

Badges  |  Report an Issue  |  Terms of Service