I Don’t Much Get Go
Join the DZone community and get the full member experience.
Join For FreeWhen Google announced their new Go programming language, I was quite excited and happy. Yay, another language to fix all the world’s problems! No more suckage! Suckage sucks! Give me a good language that doesn’t suffer suckage, so that my daily routine can suck less!
And Google certainly presented Go as “a C++ fixxer-upper”. I just watched this video
of Rob Pike describing the objectives of Go, and I can definitely say
that Google’s mantra still lines up. The video demonstrates a lot of
evils of C++. Despite some attempts at self-edumacation, I personally
cannot read nor write real-world C++ because I get lost in the
gobbligook that he demonstrated.
But here’s my comment on YouTube:
100% of the examples of "why C++ and Java suck" are C++. Java's not anywhere near that bad. Furthermore, The ECMA open standard language known as C#--brought about by a big, pushy company no different in this space than Google--already had the exact same objectives as Java and now Go had, and it has actually been fundamentally evolving at the core, such as to replace patterns with language features (as seen in lambdas and extension methods). Google just wanted to be INDEPENDENT, typical anti-MS.
While trying to take Go in with great
excitement, I’ve been forced to conclude that Google’s own message
delivery sucks, mainly by completely ignoring some of the successful
languages in the industry—namely C# (as well as some of the lesser-used
excellent languages out there)—much like Microsoft’s message delivery of
C#’s core objectives somewhat sucked by refraining from mentioning Java
even once when C# was announced (I spent an hour looking for the C#
announcement white paper from 2000/2001 to back up this memory but I
can’t find it). The video linked above doesn’t even show a single
example of Java suckage; it just made these painful accusations of Java
being right in there with C++ as being a crappy language to work with. I
haven’t coded in Java in about a decade, honestly, but back then Java
was the shiznat and code was beautiful, elegant, and more or less easy
to work with.
Meanwhile, Java has been evolving in some strange ways and ultimately I find it far less appetizing than C#. But where is Google’s nod to C#? Oh that’s right, C# doesn’t exist, it’s a fragment of someone’s imagination because Google considers Microsoft (C#’s maintainer) a competitor, duh. This is an attitude that should make anyone automatically skeptical of the language creator’s true intentions, and therefore of the language itself. C# actually came about in much the same way as Go did as far as trying to “fix” C++. In fact, most of the problems Go describes of C++ were the focus of C#’s objectives, along with a few thousand other objectives. Amazingly, C# has met most of its objectives so far.
If we break down Google’s objectives themselves, we don’t see a lot of meat. What we find, rather, are Google employees trying to optimize their coding workflow for previously C++ development efforts using perhaps emacs or vi (Rob even listed IDEs as a failure in modern languages). Their requirements in Go actually appear to be rather trivial. It seems that they want to write quick-and-easy C-syntax-like code that doesn’t get in the way of their business objectives, that performs very fast, and fast compilation that lets them escape out of vi to invoke gcc or whatever compiler very quickly and go back to coding. These are certainly great nice-to-haves, but I’m pretty sure that’s about it.
Consider, in contrast,
.NET’s objectives a decade ago, .NET being at the core of applied C# as
C# runs on the CLR (the .NET runtime):
- To provide a very high degree of language interoperability
- Visual Basic and C++ and Java, oh my! How do we get them to talk to each other with high performance?
- COM was difficult to swallow. It didn’t suck because its intentions were gorgeous—to have a language-netural marshalling paradigm between runtimes—but then the same objectives were found in CORBA, and that sucked.
- Go doesn’t even have language interoperability. It has C (and only C) function invocators. Bleh! Google is not in the real world!
- To provide a runtime environment that completely manages code execution
- This in itself was not a feature, it was a liability. But it enabled a great deal, namely consolidating QA resources for low-level functionality, which in turn brought about instantaneous quality and productivity on Microsoft’s part across the many languages and the tools because fewer resources had to focus on duplicate details.
- The Mono runtime can run a lot of languages now. It is slower than C++, but not by a significant level. A C# application, fully ngen’d (precompiled to machine-level code), will execute at roughly 90-95% of C++’s and thus theoretically Go’s performance, which frankly is pretty darn good.
- To provide a very simple software deployment and versioning model
- A real-world requirement which Google in its corporate and web sandboxes is oblivious to, I’m not sure that Go even has a versioning model
- To provide high-level code security through code access security and strong type checking
- Again, a real-world requirement which Google in its corporate and web sandboxes is oblivious to, since most of their code is only exposed to the public via HTML/REST/JSON/SOAP.
- To provide a consistent object-oriented programming model
- It appears that Go is not an OOP language. There is no class support in Go. No objects at all, really. Just primitives, arrays, and structs. Surpriiiiise!! :D
- To facilitate application communication by using industry standards such as SOAP and XML.
- Google innovated with Protocol Buffers, but I don’t see any of that in Go’s current strategy, at least not yet.
- .. to which I must point out: http://blogs.tedneward.com/2008/07/11/So+You+Say+You+Want+To+Kill+XML.aspx
- Google innovated with Protocol Buffers, but I don’t see any of that in Go’s current strategy, at least not yet.
- To simplify Web application development
- I really don’t see Google innovating here, instead they push Python and Java on their app cloud? I most definitely don’t see this applying to Go at all.
- To support hardware independence and portability
- Although the implementation of this (JIT) is a liability, the objective is sound. Old-skool Linux folks didn’t get this; it’s stupid to have to recompile an application’s distribution, software should be precompiled.
- Java and .NET are on near-equal ground here. When Java originally came about, it was the silver bullet for “Write Once, Run Anywhere”. With the successful creation and widespread adoption of the Mono runtime, .NET has the same portability. Go, however, requires recompilation. Once again, Google is not out in the real world, they live in a box (their headquarters and their exposed web).
And with the goals of C#,
- C# language is intended to be a simple, modern, general-purpose, object-oriented programming language.
- Go: “OOP is cruft.”
- The
language, and implementations thereof, should provide support for
software engineering principles such as strong type checking, array
bounds checking, detection of attempts to use uninitialized variables,
and automatic garbage collection. Software robustness, durability, and
programmer productivity are important.
- Go: “Um, check, maybe. Especially productivity. Productivity means clean code.”
- (As I always say, the more you know, the more you realize how little you know. Clearly you think you’ve got it all down, little Go.)
- The language is intended for use in developing software components suitable for deployment in distributed environments.
- Go: “Yeah we definitely want that. We’re Google.”
- Source
code portability is very important, as is programmer portability,
especially for those programmers already familiar with C and C++.
- Go: “Just forget C++. It’s bad. But the core syntax (curly braces) is much the same, so ... check!”
- Support for internationalization is very important.
- Go: “Check! Check out my samples, I can take Chinese characters in my strings as part of the source code! Oh yes!”
- (I think Go misses the point here. Rich internationalization support goes far beyond Unicode strings. *facepalm* But since Go has zero support for GUIs, little of internationalization really applies.)
- http://golang.org/search?q=international
- http://golang.org/search?q=internationalization
- http://golang.org/search?q=globalization
- http://golang.org/search?q=i18n
- C#
is intended to be suitable for writing applications for both hosted and
embedded systems, ranging from the very large that use sophisticated
operating systems, down to the very small having dedicated functions.
- Go: “Check!”
- (Yeah, except that Go isn’t an applications platform. At all. So, no. Uncheck that.)
- Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.
Right
now, Go just looks like a syntax with a few basic support classes for
I/O and such. I must confess I was somewhat unimpressed by what I saw at
Go’s web site (http://golang.org/) because the language does not look like much of a readability / maintainability improvement to what Java and C# offered up.
- Go supposedly offers up memory management, but still heavily uses pointers. (C# supports pointers, too, by the way, but since pointers are not safe you must declare your code as “containing unsafe code”. Most C# code strictly uses type-checked references.)
- Go
eliminates semicolons as statement terminators. “…they are inserted
automatically at the end of every line that looks like the end of a
statement…” Sorry, but semicolons did not make C++ unreadable or
unmaintainable
Personally I think code without punctuation (semicolons) looks like English grammar without punctuations (no period)
You end up with what look like run-on sentences
Of course they’re not run-on sentences, they’re just lazily written ones with poor grammar
wat next, lolcode? - “{Sample tutorial code} There is no implicit
this
and the receiver variable must be used to access members of the structure.” Wait, what, what? Hey, I have an idea, let’s make all functions everywhere static! - Actually, as far as I can tell, Go doesn’t have class support at all. It just has primitives, arrays, and structs.
- Go uses the := operator syntax rather than the = operator for assignment. I suppose this would help eliminate the issue where people would type = where they meant to type == and destroy their variables.
- Go has a nice “defer” statement that is akin to C#’s using() {} and try...finally blocks. It allows you to be lazy and disorganized such that late-executed code that should called after immediate code doesn’t require putting it below immediate code, we can just sprinkle late-executed code in as we go. We really needed that. (Except, not.) I think defer’s practical applicability is for some really lightweight AOP (Aspect Oriented Programming) scenarios, except that defer is a horrible approach to it.
- Go has both new() and make(). I feel like I’m learning C++ again. It’s about those pesky pointers ...
- Seriously, how the heck is
var p *[]int = new([]int) // allocates slice structure; *p == nil; rarely useful
var v []int = make([]int, 100) // the slice v now refers to a new array of 100 ints
.. a better solution to “improving upon” C++ with a new language than, oh I don’t know ..
int[] p = null; // declares an array variable; p is null; rarely useful
var v = new int[100]; // the variable v now refers to a new array of 100 ints
..? I’m sure I’m missing something here, particularly since I don’t understand what a “slice” is, but I suspect I shouldn’t care. Oh, nevermind, I see now that it “is a three-item descriptor containing a pointer to the data (inside an array), the length, and the capacity; until those items are initialized, the slice is nil.” Great. More pointer gobbligook. C# offers richly defined System.Array and all this stuff is transparent to the coder who really doesn’t need to know that there are pointers, somewhere, associated with the reference to your array, isn’t that the way it all should be? Is it really necessary to have a completely different semantic (new() vs. make())? Ohh yeah. The frickin pointer vs. the reference.
- Seriously, how the heck is
- I see Go has a fmt.Printf(), plus a fmt.Fprintf(), plus a fmt.Sprintf(), plus Print() plus Println(). I’m beginning to wonder if function overloading is missing in Go. I think it is; http://golang.org/search?q=overloading
- Go has “goroutines”. It’s basically, “go func() { /* do stuff */ }” and it will execute the code as a function on the fly, in parallel. In C# we call these anonymous delegates, and delegates can be passed along to worker thread pool threads on the fly with only one line of code, so yes, it’s supported. F# (a young .NET sibling of C#) has this, too, by the way, and its support for inline anonymous delegate declarations and spawning them off in parallel is as good as Go’s.
- Go has channels for communication purposes. C# has WCF for this which is frankly a mess. The closest you can get to Go on the CLR as far as channels go is Sing#, which is variation of C# with rich channel support.
- Go does not throw exceptions. It panics, from which it might recover.
While
I greatly respect the contributions Google has made to computing
science, and their experience in building web-scalable applications
(that, frankly, typically suck at a design level when they aren’t tied
to the genius search algorithms), and I have no doubt that Google is an
experienced web application software developer with a lot of history,
honestly I think they are clueless when it comes to real-world
applications programming solutions. Microsoft has been demonized the
world over since its beginnings, but one thing they and few others have
is some serious, serious real-world experience with
applications. Between all of the web sites and databases and desktop
applications combined everywhere on planet Earth through the history of
man, Microsoft has probably been responsible for the core applications
plumbing for the majority of it all, followed perhaps by Oracle.
It wasn’t my intention to make this a Google vs. Microsoft debate, but frankly the fact that Go presentations neglect C# severely causes question to Go’s trustworthiness.
In my opinion, a better approach to what Google was trying to do with Go would be to take a popular language, such as C# or Spec#, and break it away from the language’s implementation libraries, i.e. the .NET platform’s BCL, replacing them with the simpler constructs, support code, and lightweight command-line tooling found in Go. Honestly, I think that would be both a) a much better language and runtime than Go because it would offer most of the benefits of Go but in a manner than retains most or all of the advantages of the selected runtime (i.e. the CLR’s and C#’s multitude of advantages over C/C++), but also b) a flop, and a waste of time, because C#/Spec# is not really broken. Coupled with F#, et al, our needs are quite well met. So thanks anyway, Google, but, really, you should go now.
Published at DZone with permission of Jon Davis, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments