C to Go: Could Go replace C?
www-cs-students.stanford.edu
www-cs-students.stanford.edu
This is by far the #1 requirement: extensions to all VMs and scripting languages are shared libraries. Plugins for various servers are shared libraries, heck pretty much everything which is not a web app is a shared library, either on windows or linux.
In my life as a C++ developer (about 7 years) I have never, even once, worked on an executable. All my code, at all companies where I worked, always ran inside of either a DLL or a so-file loaded by some hosting process.
In fact, I believe that so-files must have been the default compilation target for both Go and D. So millions of Ruby/Perl/Python/Java/<anything goes> programmers could have used those languages for performance-critical or OS-dependent code in their programs, after all that's what "systems languages" are for.
But it rocks to deploy a Go app by just sending the binary to a dozen of servers and never have to worry about any dependencies on shared libraries.
should, no? Considering you can not — as far as I know — compile to shared libraries in Go.
I'm somewhat hijacking the discussion with this, but with storage getting cheaper, why do we need dynamic linking anymore?
What if they miss some? Wouldn't an architecture that allows the distribution to define and replace Z on its own be valuable?
In theory, sure. But how many more years of practice do we need before we accept that it doesn't work that way in reality? That any change in Z is as likely to break apps that use it, as save them some hassle?
There's no theory at work here. Static linkage of common components is a security vulnerability.
Here is a good list of reasons why you should never use dynamic linking:
And dynamic linking does save a lot of memory. That's one of big wins for Google's Dalvik: standard JVM is unable to share code - that's why all JVM processes are memory hogs.
Looking at my process map right now. Gnome-panel has 20MB in resident memory (not all of it is code, mind you) - and 13 of them are shared with other processes. Unity-window-decorator shares over half of its code with others. Just for the kicks open your process monitor, have "shared memory" column open, and sum up all those numbers - those are megabytes you would have lost without the shared code.
It is also about CPU as well. Moving sort() implementation in and out of L2 cache is expensive, better to have a single instance of those opcodes do sorting for multiple processes.
Sorry, but our operating systems and programs we run on them are mostly composed of shared libraries. The debate of either they're good or not is largely pointless unless we migrate to different OS designs.
What do you mean when you say that the operating system is dynamically linked? I don't even think Linux kernel modules count. I run OpenBSD, and all the base packages are statically linked. Many applications (esp. graphical ones) are dynamically linked, but there's not many reasons they have to be. The biggest one is bloatware libraries full of buggy crap you don't want or need. But dynamic linking isn't a solution for that problem.
By that I mean this: grab a debugger, attach to a random process you have running. Pause and look at the current stack: you'll notice that the code you're looking at resides in a so. And everything on the current call stack is all shared code, loads of it, sandwiched between the kernel at the bottom and a thin layer of hosting executable on top.
Here's another way to look at it: http://paste.ofcode.org/diZdtuH8uPs2UBWHEvTYWh (try to ram all that code into gnome-panel itself and ship with next Ubuntu - see what users will tell you)
One more time: shared code is absolutely essential. Only "one-process-per-machine" datacenter approach can do without. That's why there is no Java on the desktop.
If your metric is the memory usage of one arbitrary program. If your metric is the total memory usage of the system, it's likely that dynamic linking is a win because many applications can reuse the same pages in memory.
Most systems (including Unix, which did not have dynamic linking until late 80s/early 90s) worked just fine without it.
That's neither-here-nor-there; most systems worked just fine without operating systems until those were invented, too.
In short, to be able to run a C library means that you language must hand over total control to that C library, who may then dance all over memory, if it chooses. You can't build a system that enforces any further constraints. And you don't have to be an "academic weirdo" language anymore to want to be able to enforce constraints; even something like Go has a significant runtime that you need to work with properly to get the benefits of go, and a C library simply expects to own its thread for as long as it wants, do whatever it wants to allocate memory, use whatever resources it wants, not be scheduled in any way by anything other than the OS, and just this immense laundry list of requirements that all looked OK 30 years ago, but it's increasingly clear that to get to the next step of systems design, some of those are going to have to be modified. And C is not the language that will allow this.
The only language I know that manages to have radically different semantics that C at the deepest levels, yet can still talk to C libraries without (much) compromise of those semantics, is Haskell.
Somehow we've got to escape from C-type linking dictating requirements to the deepest levels of the semantics of the new language, or we're not going to escape from the local optima we are in right now.
The fact that you can run everything from Erlang to Python to Lisp to a JVM on the same machine and under the same OS is thanks to C, not in spite of it!
C exposes the machine at a low level, which means that you can innovate in the language/VM space without having to beg the runtime gatekeepers to please implement your new experimental semantic. Anyone can generate machine code that will run directly on the hardware -- I recently wrote a JIT that parses Protocol Buffers 2x the speed of any existing parser. Don't take away from the the ability to do this!
Higher level VMs like the JVM can impose further constraints -- this is already possible today. But those VMs can compete for popularity in user-space without imposing limitations on the kinds of VMs you can write directly on the hardware.
Turing completeless, not C.
"you can innovate..."
We have. We've innovated for 40 years. It turns out we've learned some stuff since then, and it's time to move some of those innovations down to the lower parts of the system. Sorry, that means bumping C. But I assure you, I will celebrate C and put it on a pedestal and remember it fondly, even as I'm shoving it out the door and glad that it is no longer the constraint for all future systems.
It's not that it sucks, it's that it's basically used up. An immense amount of problems with modern computing basically boil down to having C at the lowest level of the system, and we aren't going to fix them until we get something else at the lowest level. The hardware model that it embraces is simply not appropriate for building the networked future on.
Be serious. Brainfuck is Turing-complete: are you suggesting that other programming languages could reasonably be implemented on top of it?
Almost every single VM or programming language implementation is written in C. What are people going to write programming languages in when you take C away from them?
> We have. We've innovated for 40 years. It turns out we've learned some stuff since then, and it's time to move some of those innovations down to the lower parts of the system.
So your opinion is basically that it's time to stop innovating, because now we know the best answer. What do you have to say to the fact that I wrote a JIT two weeks ago that effectively improved the state of the art in network protocol parsing? How is that not part of "the networked future?"
Your arguments that C is holding us back are vague and unconvincing. People write VMs all the time. Code that runs on these VMs can be as insulated as you want from the underlying system. The entire web is built on JavaScript which doesn't know a lick about C -- how would that whole ecosystem be any better if C wasn't underneath it? I argue it would be much worse, because the radical performance improvements of the last 4 years (which came from writing JITs that target the bare metal) would not have been possible.
You can pry address spaces and machine code from my cold, dead hands.
Be serious yourself. With that sort of hostile characterization, I have little interest in following up in a dead conversation. You don't appear to have spent even a second trying to understand what I'm saying before leaping to a nonsensical strawman. (And I am well aware that understand != agree. But you didn't take the time to even know what you disagree with.)
"So your opinion is basically that it's time to stop innovating,"
No, it's time to resume. C is not where the innovation is.
- what will people write language implementations in, if not C?
- why don't you consider my JIT an innovation worth supporting?
- if C is a barrier to innovation, why is the JavaScript landscape so thriving?
My point about Brainfuck (that's a language by the way, not a slur, in case that wasn't clear) is that Turing-completeness says almost nothing about the systems-level capabilities of the language. Turning completeness means that a language can calculate Pi: it doesn't mean that it can open a file or send data over a network, and it says nothing about efficiency. So when you argue that Turing-completeness is what makes it possible to run lots of different kinds of VMs on the same machine, it's hard to take such an argument seriously.Turing completeness is why you can run a JVM on top of a C environment. It means that any computation that C could do, the JVM could do. It means that I can run a JVM on top of any Turing Complete environment. The JVM could be ported to a modern day Lisp machine. The JVM could run on a Russian ternary machine. C does not get "credit" for enabling the existence of the JVM, because the JVM could run on any Turing complete substrate. You have the causality backwards.
"- what will people write language implementations in, if not C?"
The new systems languages will be written in themselves! What do you think C is written in? "Bootstrapping."
"- if C is a barrier to innovation, why is the JavaScript landscape so thriving?"
Wrong question for what I'm talking about. Javascript has no innovation of interest to systems level programming, it's just a thin layer over C. I'm talking more like something like Go, which is hampered by the fact that it can't really use C libraries properly because Go can't grab and schedule C routines properly. Or how E [1] is really hampered by the fact that it basically can't work properly in a C environment, its whole schtick really only works if it's down to the OS level. The entire point is that I want to replace the foundation, so it can do things that C basically can't. Like, write a secure operating system, which C is incapable of, despite immense amounts of effort.
Basically, why is UNIX still the preeminent OS? Yes, it was good, I know that, there's a reason why it's the only survivor of its time period, but where's the capabilities-based system? Where's the thing we can't even think of because we're too stuck on C? Why is one of the preeminent kernels of the day, the Linux kernel, still adding an average of two security vulnerabilities a week, the same ones, over and over? Why are buffer overflows still coming out in 2011? Why do I still get segmentation faults in 2011? Why are we building the very foundations of our system on a language that all but mandates such failures, when we know how to not do that?
C.
As for any response you might have as to why C is still worth it, my reply in advance is that every one of those things is room for "innovation", much of which has already been done.
I'm genuinely confused: I thought this was the argument you called a strawman when I argued against it before.
I've already rebutted this argument twice: Brainfuck (http://en.wikipedia.org/wiki/Brainfuck) is a Turing-complete programming language, and yet you categorically could not implement the Java class libraries on top of it. For example, the java.io.FileReader class could not be implemented on top of it, because Brainfuck does not have any API for opening a file.
Even in cases where you can implement one language on top of another, it may not be efficient to do so. For example, Adobe Alchemy runs C/C++ code on top of Flash/ActionScript at a 2-10x slowdown compared with running the C/C++ directly on the hardware. Implementing a JVM on top of Java appears to be 4-9x slower than implementing it in C/C++ [0] (and that's only comparing two interpreters: the difference is far greater when the C/C++ implementation generates machine code directly).
C gets credit for efficiently supporting a whole host of different VMs with divergent GC schemes and synchronization primitives. That is what makes C special, and why it continues to dominate in system space.
C's mix of portability, simplicity, flexibility, and expressiveness made it the ideal choice for developing operating systems that had to run on a wide variety of architectures.
Perhaps a simple example of where C gets in the way would help clarify your case.
Personally, I think I might avoid a language that defined how the end product could be packaged, that just seems outside the range of what a good language should focus on.
Go definitely bucks the trend in modern web age language development,for starters it generates raw binaries. That alone puts it in a different category than just about everything else of significance that has been developed over the last decade. Rather than coming out with a full auto-completing IDE from the start or a plugin for netbeans or eclipse, they've got a lightning fast object code compiler. The natural evolution of these things is to get raw binaries working, get the langauge pretty much stablizied, then add some default libraries and tools to make shared libraries and get dynamic linking and PIC code type stuff working and the language shouldn't have to actually change for that to happen, you just change the tools and create different ways to compile stuff. I'd expect shared libs to come along.
The same thing will probably happen to C. Modern languages like Python or have arguably "replaced C" in several use-cases already. Go will probably claim a few more. On the other hand, Go is completely unsuitable for applications that cannot tolerate garbage collection, such as embedded firmware. Some other language will have to come along and claim that niche from C as well.
I think you're spot on.
Console games, for instance, are often largely garbage collected, despite being hugely performance critical applications. The way this is generally achieved is by allocating 100% of the console's memory upfront as object pools. The game then utilizes domain specific collection mechanisms on those pools.
Shawn Hargreaves has a good article on dealing with C#'s garbage collection in XNA games: http://blogs.msdn.com/b/shawnhar/archive/2007/07/02/twin-pat...
The problem in .NET land is that some base class library methods allocate internally, so you need to completely avoid them if you use "Path 1" (avoid collections). You wind up having to do funky things like re-implementing core methods and pre-allocating pools of strings to avoid concatenation. Presumably, a language designed to be a systems language could avoid these library problems.
I don't know much about Go, but if allocations are clearly demarcated and easily avoidable when necessary, you could allocate 100% of memory up front. You could treat virtual memory as an object pool of memory pages and perform domain specific allocation on those.
Alternatively, a collector with a richer interface, such as generation control, multiple heaps, etc. Would allow for "Path 2" (avoid latency) by performing very small, simple collections.
Things that need to be really seriously realtime, such as aeroplane pilot assistance AI, and medical equipment firmware, I think these cannot use stuff like GC because there is no room for the slightest deviation in performance.
Real-time garbage collection (hard and soft) is not a work of fiction. Hell, the first papers on real-time GCs were in the 70s.
> I think these cannot use stuff like GC because there is no room for the slightest deviation in performance.
IBM's Metronome (Bacon & al) is a hard real-time GC.
Nope - real time systems have room for deviation. They "just" have different bounds. Specifically, hard real time "merely" requires guarantees that operations complete before their deadline.
For example, real-time systems can have caches even though they introduce varibility in execution time.
Of course, the closer one is to the edge, the less room for error or mis-allocation, aka "time fragmentation".
>I'm not so sure there are applications which simply cannot tolerate garbage collection.
From your post, it sounds like "tolerating garbage collection" is the same as making sure it never ever happens. The application clearly doesn't tolerate GC, the programmer tolerates the language enough to bend over backwards to avoid one of its central features.
But as computer technology in general improves, the use-cases for C do not disappear. C is still needed where it's good. So unlike a floppy drive, a replacement programming language will have to compete with C's strengths.
Google can release something else, like high performance webservers, databases or other web infrastructure. They are in as much demand as probably an operating system. And they make good applications for a killer app.
I don't think they are capable of such mistake ;-)
There are plenty of free more-than-good-enough OSs to build upon. Unless Google needs something more revolutionary than Plan-9, they don't need to create another OS.
The only reason I would find sane to develop an entirely new OS would be to use all these new shiny toys we got in specialized processors inside our computers. It would be awesome to have a machine with lots (hundreds?) of cores of varying capabilities that could be powered up or down according to load, with processes being transparently migrated between binary-compatible ones or between similar virtual machines hosted on diverse cores.
It's been a while since I have seen a cool new research OS.
Apple was failing. It had an ancient and crufty OS and needed to find a new OS outside the company because it failed to develop one internally at least twice. They could go with BeOS, NeXT or MkLinux (I run MkLinux on one Mac in my collection). NeXT came with Steve Jobs bundled for free.
At that time, Apple leveraged its bets making Java development a first-class citizen. It was not clear whether Objective-C would gain any foothold because it failed to get traction during its NeXT years.
It's entirely possible for another language, any language, to become more popular than C even if the OS hosting that language's runtime is itself written in C. Hell, according to some sources [1], Java's already there.
However, for a language to replace C, to truly uproot C, I absolutely agree it must be fast and flexible enough for one to write an OS that is comparable or superior to peer OSs written in C. As I've heard from some sources, C# and the .NET runtime may excellent examples of an environment that fell short – Longhorn reputedly was attempted in C# and MS had to fall back to C for performance and reliability reasons. [Edit: My info on Longhorn's bad, per neilc, below.]
[1] http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
That is not the case, as far as I know (see also http://en.wikipedia.org/wiki/Development_of_Windows_Vista).
MS have written at least one OS on top of the CLR -- Singularity. Very cool stuff, albeit a research system.
Singularity is indeed fascinating, but it does remain a research OS. I hope something like it finally comes to light in a future release.
WP7 might have been a good breeding ground for such technology, but even that never managed to shake off it's own legacy OS underpinnings.
Modern day applications like webservers, middle ware layers and caching applications are all written in C(or at maximum C++). Not to mention, C syntax is almost every where. So there are many trained programmers already here.
If go needs serious adoption Google will have to do the following things. Develop killer apps in Go, give the world few things written in Go the world just can't live without. Write real cool tutorials/documentation/recipes and manuals for Go. Take it to enterprise have you people talk in every other conference on the Globe, convince universities to teach it. Make sure the day to day programmers has all the right tooling, support and batteries to use Go everyday.
Sun did a lot of this stuff to promote Java. I think there is a lot to learn from that.
I do not think that performance is the main reason to choose C for writing a compiler -- I'd rather say it is because of the ubiquity of C compilers on all the platforms.
"Hey, I think Go picked a few good and important things to look at, but I think they called it "experimental" for a reason. I think it looks like they made a lot of reasonable choices.
But introducing a new language? It's hard. Give it a couple of decades, and see where it is then."
http://www.realworldtech.com/forums/index.cfm?action=detail&...
Maybe there's a point in there somewhere, but bad code samples distract from it.
Intuitions like these are rough though - it depends on how low in your perception stack you have the C operators etc. embedded.
if(...) ...;ELSE {
}
That's the first time I see this and hope the last.
"By itself, the yes command outputs 'y' or whatever is specified as an argument, followed by a newline repeatedly until stopped by the user or otherwise killed; when piped into a command, it will continue until the pipe breaks (i.e., the program completes its execution)."
yes - output a string repeatedly until killed
Look at Python. Python is over 20 years old. It has been here since before Windows 95 but only got prominent (in the broad public) in the last few years because some opinion leaders of the hip and young crowd found out you could make cool web apps with it and hyped it into oblivion.
I bet if Go hadn't the names behind it it wouldn't get any more traction than any other of the gazillions of programming languages that die silently. I guess not many home brew languages get talking time at a Google conference.
Let's be just happy that Go seems to get a little popular - maybe it will be enough for a break through. I'd love that.
Every tool has its own merit Python is nothing special in this regard. Python's low barrier to entry has invited many newbie's to pick it up in a day or two and get going with solving problems. But it has its own flaws and isn't that great as often people project it to be.
My own experience with Python, after being a heavy Perl and Ruby user isn't that good. Especially if you are coming from a language like Perl, Python as a language has an interesting trend. At first you feel very happy that things are so simple with it. Then slowly once you learn the language and start getting deeper into it, you try to use it for day to day work. Suddenly you realize that text processing sucks badly, something that is very big problem on Unix based environments. Writing a single regex takes a 10's of lines of exception handling. You try to use it for quick dirty scripting, again the language runs out of steam very soon. Its just too verbose for scripting class.
Now coming to more important reasons. Sacrificing power for readability might be great for newbie's but isn't good experienced programmers. Lack of multiline lambda's, no good support for TOC, GIL, barely there object system(compared to Moose), lack of extensibility, lack of syntax plugins. Forcing one way of doing things, all this is great hindrance if one wants to climb upper steps in the ladder of programming. And above all lack of thing like CPAN is just something more than sufficient reason above everything else.
I left Python for Perl, but had to go back again. Python wasn't just serving the need for day to day quick scripting. Which I often need to do twice or thrice a day. Text is uneliminable part of large IT projects. Tools like Perl, sed , awk help me do my job quickly everyday.
Slowly I realized if I'm using Perl every 50 minutes, I might as well use it for long term projects. On the other hand, Best practices matter for every project. You can writeable and un maintainable code both in any language.
We are back to being a Perl shop again. And its the best decision we have made.
As for exception handling, I guess it'll always be shorter in Perl since it doesn't really support exceptions...
Another advantage Perl has over Python in case of parsing is that regular expressions are first class elements in Perl, so they can be passed around like objects. Combine them with more powerful things like given-when(http://perldoc.perl.org/perlsyn.html#Switch-statements) and parsing becomes a lot more easier when compared to Python. Smart matching is a great feature. And all this obviously leads to better performance in terms of speed because less code to process means (to an extent faster code). And syntactically as well.
Imagine doing such a thing in Python. There isn't smart match operator at the first place, there is no switch statement, and on top of that dealing with innumerable regular expression functions(compile,match,search) with try-catch statements inside if-else loops. This piece of code in Python won't be easy to read and solution isn't elegant and better than Perl either.
Perl turns out to be better in all ways, the code is readable, concise, faster and powerful.
"Perl turns out to be better in all ways, the code is readable, concise, faster and powerful."
To each his own, I guess.
Without a doubt the Perl solution is a lot more cleaner than Python solution.
m = re.match("some_regexp", my_str)
You don't need to compile regexps before use but you get better performance if you do when matching the same thing multiple times (no idea if there's a Perl equivalent). Also match() and search() have different semantics and you don't use them at the same time. So it's one statement in Python per match.
Also how do you propose to get an equivalent of (non-mandatory) exception handling in Perl code without extra statements?
Perl exception handling is quirky, but pretty clean. You raise an exception with die() and "try" a block with a simple eval. It's basically the same amount of syntax. The one bit perl lacks as a builtin is the type-based exception matching; you have to do that logic yourself.
eval() and eval {} are very different constructs in Perl 5. The questionable design decision there is reusing the keyword.
In the second form, the code within the BLOCK is parsed only
once--at the same time the code surrounding the "eval" itself
was parsed--and executed within the context of the current Perl
program. This form is typically used to trap exceptions more
efficiently than the first (see below), while also providing
the benefit of checking the code within BLOCK at compile time.
The only (significant) questionable decision there is the name; its functionality is the same as 'try' in other languages. There are some issues, however, with properly dealing with failures in an eval block. They're fairly obscure, and won't often come up, but they're explained in the "Background" section of the Try::Tiny docs: http://search.cpan.org/~doy/Try-Tiny-0.09/lib/Try/Tiny.pm#BA...Try::Tiny is a minimal module with no dependencies that does the least amount necessary to get 'try' and 'catch' keywords into the language, connecting handler blocks to guarded blocks. There are some problems with this, like trying to use loop control or return statements inside of a catch block. The normal way to get good error handling that deals with all of the potential issues without introducing others is TryCatch, which also adds extra features, like Moose type constraints on multiple catch blocks: http://search.cpan.org/~ash/TryCatch-1.003000/lib/TryCatch.p...
Python's approach also eliminates the pattern of `if (preg_match(...)) { use captured groups; }` since the match object comes back as a return value instead of either a reference or magic variables, and assignment of that value is illegal inside the if's condition. Very Pythonic, but adds an extra line of code to assign the match separately from testing the result.
(Edited a bunch because I fail at non-markdown.)
http://search.cpan.org/~elliotjs/Perl-Critic-1.115/lib/Perl/...
I do a fair amount of text parsing in Python for my job, and only very rarely import the regular expression module - because most of the time I don't need it. My code is faster and more easily read for it, as well.
And what are those specialized toolchest of string tools that Python offers? I have clearly explained(In comments above and below) Perl's 'tool chest', now can you please explain how Python 'tool chest' beats it?
Seems, languages like Python and Java are best when all your application needs a glue between one part of architecture(webserver, UI etc) and other(database, XML, JSON). Or at maximum some extra stuff like sockets.
The problem with Python sort of languages starts when you alter you inputs and outputs such that they are no longer standard and structured. All examples that Python folks give as superiority of Python over Perl come around in areas where data input is structured enough. Things like scientific computing, web programming(Interaction with databases, XML, JSON).
There are a lot of languages which can do this, The actual challenge is in areas dealing with unstructured data. There are very few languages which offer convenient tools to deal with those sort of problems.
Unfortunately Python isn't one of them
Hmm, I thought it became popular for scientific applications and as an anti-Perl for scripting before it became popular for web apps? I first got into Python because I needed a scripting language. People said, "If you don't like the design philosophy of Perl, then you might like Python, which made the opposite choices." The centerpiece of Python advocacy back in the day was this article by Eric Raymond: http://www.linuxjournal.com/article/3882
I know that's the article that convinced me to try Python. Everything he praised about Python screamed "opposite of Perl!" and after experiencing my mind rejecting Perl like a body rejecting a transplanted organ, I was desperate for an alternative that would make me as productive at scripting as the Perl gurus. (Yes, I'm still jealous of the one-liners.)
So there is certainly room for a language to grow and become popular without having a first-class web framework. (These days any popular language will sprout a few web frameworks, but they don't have to become popular for the language to succeed.)
We recently reached self-hosting status, in which we compiled Rust with itself, and over the past few weeks we've been working on making the compiler much faster (over 7x in fact).
Despite their inherent flaws they haven't gone away, no matter how attractive alternatives exist. Because they solve certain set of problems so well, you just can't do without them.
Even tools like sed and awk have their own niches and uses, and replacing them with something else is just isn't going to happen.
The thing is for this kind of language C/C++ won. None of the others offers any substantial advantages over C/C++ so that's what stuck.
C for systems programming and C++ for applications programming could well be the default 20 years into the future just as they were 20 years in the past.
2. We wanted something that would give us a single, staticly-linked binary that we could easily push out to the nodes. Does Python allow that?
3. Go's goroutines and channels fit beautifully with what we were trying to do.
If you happen to like/need its particular combination of strengths it may be a good choice, but I think much better can be done. It's a good experiment, but I think they're taking it too seriously in some regards and not seriously enough in others. I just don't see it lasting.
The thing about compiling to native code is interesting. Why is that important? And are you excluding VM languages which nevertheless produce system binaries in that?
The payoff of C->Go comes if you have 1M LOC of C. 900k LOC of Go is much better. For most of us, just-getting-it-to-run is awesome and that's why Ruby, Python, Lisp and Clojure dominate.
The best part of the post is that (until later) I didn't know that the "ooh-wow" bits on http://www-cs-students.stanford.edu/~blynn/c2go/ch04.html#_f... were Go and were longer than their C equivalents. Sure, the C bits look scary to a noob; they look perfectly sane to a journeyman.
I'm not sure how it can succeed at either when when it borrows a so much from C (a language which is at least a couple generations dated when it comes to general purpose languages) while adding garbage collection.
In general, Go isn't meant to replace C but to replace C++ and Java.
Regarding garbage collections Go has the ability to use unmanaged memory although I haven't had occasion to try that, so I don't know how good it actually is.
On the other hand, C can't be improved much without compromising the 'as much speed as possible but handle with care' philosophy (like introducing GC while sacrificing a bit of speed).
Really, the title should be "Can simple C programs be written in Go in about the same number of lines?" because that's all that was demonstrated.
All the bitching about ';' comes from people that clearly have not used Go or tried to parse it.
I probably would have kept at it a bit longer if the dev team was more accepting of feedback presented in good faith. I'm not really surprised -- it's often hard to tell the difference between fruitless bikeshedding and oh guys FYI you might consider this a problem, I do.
I am biased towards semis though, when I first saw OCaml's ';;' I was pleased.
That said, I remember seeing something about a way that semi-colon insertion leads to the possibility of a misleading "if", but I can't find it anymore.
As a rule, never start a new line with an opening brace;
it belongs with the previous line.
I'm always using the "one true brace style", so that wouldn't be a problem for me personally; however I feel the pain for people using BSD style. Using a consistent indentation and brace style across all languages you're working with, be it C, Java, Javascript, Perl, PHP is a must, and that Go idiosyncrasy seems really wrong to me; this kind of detail may hamper Go acceptance quite a lot.http://robertnyman.com/2008/10/16/beware-of-javascript-semic...
From http://research.microsoft.com/pubs/52716/tr-2005-135.pdf:
3.4 Garbage Collection
Garbage collection is an essential component of most safe languages,
as it prevents memory deallocation errors that can subvert safety
guarantees. In Singularity, the kernel and processes object spaces
are garbage collected.
I appreciate that Microsoft Research is saying "why not?" rather than "why?". Singularity is a fascinating OS and I hope it, or some derivative or something like it from someone else, eventually reaches the mainstream market.http://lambda-the-ultimate.org/node/4165
They're using the VT-x for the virtualized page tables and still run the GC in userspace, but if you move the GC into the kernel you won't even need virtualized page tables.
The cheapest ATTiny AVR chip is $0.60/ea bulk. The cheapest ARM chip like an AT91 is about $4.00/ea bulk. Ship a few million units and suddenly the cost difference between developing in C and Go is pittance.
I have yet to see a convincing argument why I should choose Google's little (and relatively immature) language over anything else and I'm very close to assuming this thing is pure hype and has nothing actual newsworthy. Ofcourse, as always I'd love to be proved wrong.
1. Procedural -- OO (with its interface subtyping resembling Haskell type classes with default instances for every type)
2. Languages without safe automatic memory management -- languages with an explicit VM
Occupying sweet spots is usually opposed to having radically unique features.
not quite; using comparisons from the The Computer Language Benchmarks Game [http://shootout.alioth.debian.org/u32/which-programming-lang...], Go is currently (in general) slower than C++ gnu g++, C gnu gcc, Java 6 -server, Haskell GHC, C# mono, just to name a few. Sure, it's not a definitive view, but it's better than code not run and compared.
Also, the 32bit compilers are specially bad as they are not really used by most of the Go developers, the 64bit compilers do much better as you can see here:
http://shootout.alioth.debian.org/u64/which-programming-lang...
For 5 of those 10 tasks, the measurements on x64 show a C program less than twice as fast as a Go program.
http://shootout.alioth.debian.org/u64q/compare.php?lang=go
Could it be that those C programs were more highly optimised by the C programmers?
http://shootout.alioth.debian.org/u64q/program.php?test=spec...
http://shootout.alioth.debian.org/u64q/program.php?test=spec...
I've found Python to be quite obtuse at times, particularly with the notion that it's sometimes functional and sometimes not. (Consider generators being promoted and map being demoted by Guido for not being 'pythonic').
Expressiveness is hard to measure I agree, but I find enough utility in Go to perform the same amount of work in a roughly equivalent number of keypresses. That's my metric.
Now, seriously, it has some nice constructs like goroutines and channels. Go check http://golang.org/doc/effective_go.html
The Heroku guys have seen this & used Go to build their own clone of Google's Chubby service called Doozer.
But that is not (and should not be) the point of the language, it is not about how many features it has, but about the right and very careful selection of features and how they interact with each other.
Or as others have said ( http://go-lang.cat-v.org/quotes ) "Go is not meant to innovate programming theory. It’s meant to innovate programming practice."
Unique features in programming languages are rare and often unwelcome (cf. perl's references).