144 points · by hanszeir · 15y ago · 154 comments
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.
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.
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.
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?
Here is a good list of reasons why you should never use dynamic linking:
What if they miss some? Wouldn't an architecture that allows the distribution to define and replace Z on its own be valuable?
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.
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.
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.
I think you're spot on.
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.
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.
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.
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.
"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.
if(...) ...;ELSE {
}
That's the first time I see this and hope the last.
Intuitions like these are rough though - it depends on how low in your perception stack you have the C operators etc. embedded.
"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
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.
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.
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.)
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.
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.
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.
All the bitching about ';' comes from people that clearly have not used Go or tried to parse it.
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.
Unique features in programming languages are rare and often unwelcome (cf. perl's references).
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."
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.
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...
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...
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.