首页
29 条评论
fidotron超过 11 年前
While I agree with the end goal here, isn't 60k lines of C actually a rather small program to attempt to port in a one shot effort? There will also be an inevitable clean up phase since the Go generated is less than likely to be idiomatic.<p>For me the really fun bit is getting to having the whole runtime in Go, which would be a situation not dissimilar from classic Smalltalk environments - especially writing the GC in the target language.
评论 #6932758 未加载
评论 #6933432 未加载
评论 #6932501 未加载
cpeterso超过 11 年前
For comparison, the original Rust compiler was written in OCaml. AIUI, the Rust compiler build now has three stages: a blessed binary snapshot of Rust+LLVM (stage0) compiles and tests a new build (stage1) from source, then (as a bootstrap sanity check) the stage1 compiles and tests a new build (stage2) from the same sources. Needless to say, this is a time-consuming process. :)
评论 #6933599 未加载
评论 #6932790 未加载
Locke1689超过 11 年前
This seems like definitely the right decision. If the C# compiler had been written in C# from nearly the beginning I think it would have heavily influenced language and infrastructure development going forward.<p>It's much better to be in the position now, when the language is barely used, than to have to support it later.
评论 #6933307 未加载
heydenberk超过 11 年前
Besides the immediate appeal of bootstrapped compilers, we're also going to have a tool to turn C code into Go code when this is done. I imagine this might breathe some new life into some stagnant projects.
评论 #6932764 未加载
评论 #6932562 未加载
jmspring超过 11 年前
Interesting development, but to be a bit crusty, statements like:<p>"It is easier to write correct Go code than to write correct C code."<p>and<p>"It is easier to debug incorrect Go code than to debug incorrect C code."<p>and<p>"Go is much more fun to use than C."<p>Really are very subjective and don't add much beyond setting a POV for reading the article.
评论 #6932895 未加载
评论 #6933243 未加载
评论 #6933232 未加载
评论 #6933149 未加载
bluesnowmonkey超过 11 年前
I don't really get the motivation behind this effort. I'm not very familiar with the Go compiler, but it seems like make-work.<p>> It is easier to write correct Go code than to write correct C code.<p>But the correct C code is already written.<p>> It is easier to debug incorrect Go code than to debug incorrect C code.<p>Is the C code incorrect? How much debugging is left to be done?<p>> Work on a Go compiler necessarily requires a good understanding of Go. Implementing the compiler in C adds an unnecessary second requirement.<p>The compiler is already implemented in C.<p>> Go makes parallel execution trivial compared to C.<p>Is it not trivial to run multiple C compilers in different processes?
评论 #6932975 未加载
评论 #6933046 未加载
评论 #6933150 未加载
评论 #6932972 未加载
评论 #6933374 未加载
评论 #6933369 未加载
charlieflowers超过 11 年前
(Update: TLDR --> Modifying the Dick Sites quote from the original article: "I would rather write programs to help me <i>refactor/transform</i> programs than <i>refactor/transform</i> programs." So, a programming language highly amenable to that would be very powerful).<p>I just had an insight while reading this. It's a powerful insight. (I am surely not the first person to have this insight, but it's WAY ahead of being mainstream).<p>A programming language that could be PROGRAMMATICALLY REFACTORED would be a HUGE home run.<p>I know Lispers will jump in here. But I know Lisp (somewhat), and it does not have what I'm talking about. (Hell, maybe Go does ... if so, I finally get what the fuss is about).<p>The idea is that you could develop a huge codebase in this language, and then you could write code (probably in some other language) that REFACTORS the original codebase. Of course, you CAN write translators, as the original article mentions. But I want a whole new programming language that is designed from the GROUND UP to be amenable to programmatic transformation.<p>NOT just Lisp with its AST's and macros. The "transformation language" should be able to understand the following aspects of the original code: its modularity, its test coverage, which parts are functionally pure/impure, which parts are parallel/not, and the full compiler-level semantics of every piece of text in the code (in other words, what JetBrains knows ... this is a local variable name, this is a function name, etc.)<p>In other words, the original language has to capture more of the programmers intent (probably by inferring most of it). The intent-information is mostly or completely unneeded at runtime, but it is VITAL at automated translation time.<p>Imagine having such a codebase, and being able to pull up a REPL and interactively start changing the modularity of the code by issuing commands. Or telling the transformation system to parallelize some portion of code that wasn't parallelized previously. Or saying something like, "Take all the code snippets that instantiate the xyz data structure, and change them to call this function instead."<p>Don't miss my point -- we have features like this here and there. Some IDE's more than others, some languages more than others. Nothing new there. But I'm talking about a <i>new programming language designed from the ground up to be highly amenable to this kind of interactive, automated transformation</i>. In other words, I think this might be the killer feature that allows one programming language to outcompete most others.<p>This might be the one programming language feature that we should focus on now, more than any other.
评论 #6933798 未加载
评论 #6933301 未加载
评论 #6933536 未加载
评论 #6932999 未加载
评论 #6933849 未加载
评论 #6933681 未加载
评论 #6933031 未加载
评论 #6933381 未加载
laureny超过 11 年前
Go is already extremely fast to compile, I'm puzzled that they choose to improve this aspect of the compiler, which nobody really complains about, while ignoring elephants in the room such as generics and a proper exception mechanism.<p>It's almost as if they choose to tackle the easy problems instead of the hard ones.
评论 #6933494 未加载
评论 #6933513 未加载
评论 #6933455 未加载
评论 #6933592 未加载
laureny超过 11 年前
> But I want a whole new programming language that is designed from the GROUND UP to be amenable to programmatic transformation.<p>Pretty much any modern statically typed language can easily be refactored.<p>The problem is not the refactoring, it's deciding when to refactor and to what (e.g. renaming). This is much more of a human than a computer problem, and as such, it will probably be intractable for a very long time.
评论 #6933732 未加载
Scaevolus超过 11 年前
I'm most excited about Phase 4b. The Go compiler currently leaves a lot of performance on the table with its weak optimization capabilities. Having an intermediate representation and a few optimization passes will recover the majority of that performance.
jhawk28超过 11 年前
This is really exciting. I can't wait to port some legacy C code using it. It should make it a lot easier than doing it by hand.
aabalkan超过 11 年前
This explains why there is "goto" keyword in Go spec. Nobody uses it, except state machines and reducers for compilers. They probably thought they'll rewrite compiler in Go and didn't drop that keyword?
评论 #6932954 未加载
评论 #6932903 未加载
评论 #6933037 未加载
评论 #6932715 未加载
评论 #6933269 未加载
tehwalrus超过 11 年前
Very interesting. The cat-and-mouse problem mentioned a couple of times - finding a solution that allows development on the old to continue while still working on the new - is very similar to a problem I had in a previous job.<p>We had an Actionscript 2 application that was under constant development and use on the web, and we needed/wanted to port it to Actionscript 3 to make use of new language features. I would write a tool that would attempt to translate between the two automatically, and then any more complex transformations could be hand coded and/or added to the translation engine.<p>Of course, the project did not succeed during my time at the company, mostly because the scope of the translator was so limited; there were too many concepts in AS2 (the borrowed javascript setInterval, for example) that had no equivalent line-for-line in AS3 (where you had to use the new Timer class to delay/loop execution) and therefore couldn't be simply substituted. Perhaps if the parser had tried to represent higher order concepts than files and lines of code (e.g. classes, instance data, methods) the project would have got further - but we simply didn't have the resource to spend on it, nor the ability to freeze features on the AS2 codebase.<p>As it was, the AS3 version of the app never quite reached feature parity with the AS2 version, which raced ahead too quickly for the new features to be added by hand in AS3 (and too many changes had already been made by hand to make re-running the parser viable.)<p>If Go is indeed simple enough to translate into from (a specific subset of) C, and if Google can afford more than one engineer for a week to write the tool, then this sounds like it's off to a better start than my project was.
blt超过 11 年前
> There are many corners of C that have no direct translation into Go; macros, unions, and bit fields are probably highest on the list. Fortunately (but not coincidentally), those features are rarely used, if at all, in the code being translated.<p>Sounds like they had this idea in the back of their minds from the beginning, and wrote the C code accordingly.
评论 #6932963 未加载
评论 #6932863 未加载
评论 #6932868 未加载
评论 #6932789 未加载
xiaq超过 11 年前
Alas, that means "Plan 9" bits in go is going to vanish. Luckily some of Plan 9's legacies (saner stdio, simpler socket interface, channels) are embodied in go itself and hopefully getting into mainstream.<p>9P was not so lucky (it's more of an OS thing than a language thing), but I wish it could take off somewhere.
frou_dh超过 11 年前
Noice. Business case aside, that sounds like a fun exercise for those with the chops to tackle it.
评论 #6932231 未加载
gress超过 11 年前
The mention of porting the rest of the plan 9 system to Go is the most interesting part of this document. Is this just academic, or does Google actually want a complete new system (kernel and all) implemented in Go?
评论 #6932360 未加载
评论 #6932361 未加载
seunosewa超过 11 年前
I don't think the tool to automagically convert C code to Go will work. At the very least it will take much longer than expected to get it right. And when it's finally ready, he resulting Go code will be very slow, so they won't be able to use it without serious manual modification. Meanwhile, the C compiler will continue to add new features, and each one will have to be converted to Go and then refactored for performance. It won't work.
评论 #6935322 未加载
评论 #6935340 未加载
Cort3z超过 11 年前
Why not start from scratch in go? C and go are different programming languages with different standards etc. Why rely on shoehorning the C version into go?
评论 #6932796 未加载
评论 #6932458 未加载
评论 #6932457 未加载
twotwotwo超过 11 年前
Fascinating and fun. I really hope perf doesn't regress much from this: the zippy edit-compile-run loop is part of why Go's fun to use.
评论 #6933033 未加载
melling超过 11 年前
"The Go compilers are also significantly larger than anything we’ve converted: over 60,000 lines of C."<p>Couldn't the compiler translation just be crowd sourced by a small group of people? It wouldn't be the best result but if people just stuck to the original C design, it would work as a first implementation.
评论 #6932883 未加载
评论 #6932284 未加载
评论 #6933797 未加载
swah超过 11 年前
A related article from a few weeks ago: <a href="http://tratt.net/laurie/blog/entries/the_bootstrapped_compiler_and_the_damage_done" rel="nofollow">http://tratt.net/laurie/blog/entries/the_bootstrapped_compil...</a>
pjmlp超过 11 年前
This are great news. I always defend bootstrapping is the proper way to write compilers for general purpose languages.<p>Looking forward to the day Go's runtime is free from C code.
评论 #6933240 未加载
dysoco超过 11 年前
Is translating seriously the best option? Are the translators accurate enough?
评论 #6932426 未加载
conroy超过 11 年前
Anyone have a non-Google Docs link? It isn't loading on my end.
评论 #6932264 未加载
评论 #6932279 未加载
abjorn超过 11 年前
Now if only they'd do something about that garbage collector.
RamiK超过 11 年前
How would this affect the Plan9 and Dragonfly ports?
swah超过 11 年前
So, can Go channels be implemented using channels?
puppetmaster3超过 11 年前
This is the best argument to go D.<p>The D compiler is waaaaay better, written by a compiler expert.