text
stringlengths
0
1.62k
[1332.70 --> 1337.70] just be the place for you working as a freelance software developer with top towel means your days
[1337.70 --> 1343.10] of searching for long-term high quality work and getting paid what you're worth will be over let's
[1343.10 --> 1347.86] face it you're an awesome developer and you deserve to be composite like one joining top top means
[1347.86 --> 1352.58] you'll have the opportunity to travel the world as an elite engineer on top of that top towel can help
[1352.58 --> 1358.02] provide the software hardware and support you need to work effectively no matter where you are in the
[1358.02 --> 1365.52] world head to top towel.com slash developers that's t-o-p-t-a-l.com slash developers to learn more
[1365.52 --> 1367.10] and tell them the changelog sent you
[1367.10 --> 1371.72] all right we're back the state of go in 2015
[1371.72 --> 1378.32] andrew you've kind of teed it off before we took that break there so um sorry i threw you curveball
[1378.32 --> 1383.62] there too by the way it wasn't uh let me know i was gonna do that but anyways so c2go you know when
[1383.62 --> 1388.78] i when i read this in your talk when i now listening to your talk and reading your talk was two different
[1388.78 --> 1395.52] things but whenever i heard you talk about the prep work for the c2go tool chain conversion i was like
[1395.52 --> 1401.56] wow okay so they're writing and having gone back and listened to episode 100 just to kind of prep for this call
[1401.56 --> 1405.22] too to kind of get back into grips with what you and rob talked about with andrew
[1405.22 --> 1409.20] uh on the show before i was thinking man rob's gotta be excited because
[1409.20 --> 1413.84] the the c and c plus programs he had written 20 years ago cannot be reported to go
[1413.84 --> 1420.38] and that's not the case so let's talk about the c2go tool chain conversion and what you actually mean by that
[1420.38 --> 1428.98] right so you know originally when go was first being developed uh ken thompson wrote the original
[1428.98 --> 1437.48] compiler in c um which he was leveraging a lot of the work of and the design of the plan 9 c compiler
[1437.48 --> 1446.16] which uh you know is just a standalone c linker and assembler and it's nicely cross-platform
[1446.16 --> 1451.12] or at least you know it was in its old form so that was just kind of an expedient way to get
[1451.12 --> 1455.72] started and it was the system that they already knew so they built it in c um and then we've just
[1455.72 --> 1463.06] kind of taken that and kept working on it for five years and you know it got to the point where
[1463.06 --> 1469.20] we have more and more people working on it and it really wasn't an accessible code base at all
[1469.20 --> 1478.32] i mean like ken is a tremendous programmer but his code is unlike anyone else's code and i don't mean
[1478.32 --> 1484.66] that in like a negative way it's not me being sort of snide about it it's just his mind actually works
[1484.66 --> 1491.92] in a way that is very unusual and so you know first of all there's the ken factor and then there is
[1491.92 --> 1497.40] you know the fact that the code had just kind of grown over a long period of time and you know
[1497.40 --> 1502.32] originally it suited us really well because we were developing a new language and making changes
[1502.32 --> 1506.88] to the language and if we'd written the original compiler in go then we would have constantly had
[1506.88 --> 1514.86] to sort of reboot strap and update the go compiler written in go as we change the go language and
[1514.86 --> 1520.40] that would have been it would have added a lot of friction to making any kinds of language changes
[1520.40 --> 1526.44] whereas you know having it in c you know we see as a language we understand hasn't changed for a
[1526.44 --> 1531.76] very long time this is plain c not c plus plus you know we could make changes freely to the language
[1531.76 --> 1536.84] without having to refactor the tool chain at the same time and so that suited us really well that's
[1536.84 --> 1543.52] the project now we have so many more people working on the tool chain it's it's about time that we use the
[1543.52 --> 1548.84] nice stable language that we spend this time developing and so you know we made the decision to convert the
[1548.84 --> 1554.72] tool chain into go so not to rewrite like if we rewrote we felt like it would just set us back
[1554.72 --> 1559.68] you know you end up in second system syndrome you end up recreating the same bugs that you've already
[1559.68 --> 1567.10] fixed we were somewhat hampered by not having a really thorough set of unit tests like we have a
[1567.10 --> 1574.48] lot of integration tests but as a whole the sort of the the compiler was was more or less a black box
[1574.48 --> 1580.08] we had these tests where we put stuff in and saw what came out so we decided that what we would do is is
[1580.08 --> 1585.96] convert the tool chain from c to go and that doesn't mean like by hand it means we actually
[1585.96 --> 1592.78] well russ cox wrote a program to convert the c sources into go and it meant that work could continue
[1592.78 --> 1601.14] on the c compiler while the trans the translator was being developed and when it was time to cut it over
[1601.14 --> 1608.08] you know russ could run the translator and check in all the go tool chain the tool chain written in go
[1608.08 --> 1613.62] and then later delete the tool chain written in c and so this has actually been a really huge
[1613.62 --> 1621.12] engineering project in a way but the end result is like we we now today have the go compiler written
[1621.12 --> 1627.88] in go at the moment it's slightly slower than the c version because some things that you do in c are
[1627.88 --> 1634.06] much more efficient in c than they are in go and vice versa and so we're sort of gradually now we have a
[1634.06 --> 1641.78] very ugly go program right because it's all written in a c style and so work is now being done to tidy
[1641.78 --> 1646.94] that up and make it look more like a nice go program and you talk about that a little bit where you go
[1646.94 --> 1654.10] from c to go ugly and then go pretty well for instance you know the whole thing when you converted
[1654.10 --> 1661.52] it was just one big package because c just has one uh namespace right that okay that everyone shares
[1661.52 --> 1668.34] whereas go has these individual packages that each have their own namespace and so you know when you
[1668.34 --> 1675.00] convert c to go you just end up with this one big package with like hundreds or even thousands of names
[1675.00 --> 1681.62] inside it um and that's very that's very ugly go you know that's you you would never do that if you
[1681.62 --> 1687.24] were writing go from scratch and you know all of the function names are not really very idiomatic all the
[1687.24 --> 1695.10] types and so on you know in the original go compiler there was one big c struct uh called node
[1695.10 --> 1700.86] that represented like uh a node in the ast or a node in the generated code and it was kind of like a
[1700.86 --> 1706.52] multi-purpose type that was used at different parts of the compiler and so it was this huge data structure
[1706.52 --> 1715.12] which included unions um which is where you can have a a struct that has the same kind of size
[1715.12 --> 1720.46] but it can be used in different ways where fields can share the same piece of memory so you can only
[1720.46 --> 1725.96] use one or the other of those fields simultaneously and that's not a feature that go has at all and so
[1725.96 --> 1731.48] like when we converted that node type into go we had to like explode out all of those unions and
[1731.48 --> 1737.94] suddenly the nodes were so much bigger um and an interesting issue came up recently where
[1737.94 --> 1741.80] i apologize if i'm getting a little bit wrong i just heard it in passing
[1741.80 --> 1749.58] but in c you know you you declare your variables like up front at the top of your function and then
[1749.58 --> 1756.24] like reuse them and so on throughout the function and there were all these uh functions in the c the
[1756.24 --> 1762.06] c version of the compiler that were very long that had lots and lots of variables and the number of
[1762.06 --> 1767.44] variables like being used in there was something that you would never see in go and so the go compiler
[1767.44 --> 1772.70] when it was doing registerization for the function to see like which of those variables should be kept
[1772.70 --> 1778.92] in cpu registers for efficiency it it just saw oh my god there's like 100 variables in this function
[1778.92 --> 1785.12] i'm not going to registerize anything and so these kind of like core parts of the compiler wouldn't use
[1785.12 --> 1792.26] registers to do any of the work and so they just became way slower whereas the c compiler could handle
[1792.26 --> 1798.36] it fine because it was it was designed to to cope with that and so it's just interesting uh i think
[1798.36 --> 1803.40] we're going to see a talk probably at gophicon this year that talks about a lot of this stuff so that
[1803.40 --> 1809.48] should be that should be a pretty interesting talk yeah and so russ got started on this i see the
[1809.48 --> 1816.40] abstract that he written for the the overhaul is uh dated december 2013 so this is yeah like 18 months
[1816.40 --> 1823.64] ago almost it's a while so this is an undertaking for sure oh yeah yeah and you know i think russ is
[1823.64 --> 1829.02] looking forward to the compiler being more accessible to more people so that you know the responsibility
[1829.02 --> 1834.92] is on his shoulders so much anymore um yeah you know we have we have some great people that we've
[1834.92 --> 1840.88] hired at google to work on the compiler um recently and the and the runtime like garbage collector and so on
[1840.88 --> 1845.62] and russ has really been spinning up that team of people and also there are people in the community who
[1845.62 --> 1850.80] are just really interested in working on this stuff and doing great work and so far they've been doing
[1850.80 --> 1855.66] great work despite the fact that it's this really inaccessible c code base now that we have this go
[1855.66 --> 1860.64] code base that's only going to get nicer um i'm excited to see you know what people will do
[1860.64 --> 1868.04] so i guess we're sort of chicken and egg kind of in a sense because you'll be compiling go with go
[1868.04 --> 1873.60] so if you don't have go how do you compile go well what you do is you download a binary distribution of go
[1873.60 --> 1881.94] and when you build go you just give it the location of that okay distribution it's the same thing as if
[1881.94 --> 1888.30] you build gcc or you know any any c compiler you need a c compiler to build the c compiler i know that
[1888.30 --> 1893.94] gcc actually has a pretty elaborate bootstrapping process to build itself from something very simple
[1893.94 --> 1902.74] but we don't we don't have that the baseline for us is um go 1.4 so we're requiring that the
[1902.74 --> 1911.42] compiler be written in go 1.4 compatible go so that if we add new libraries or um you know
[1911.42 --> 1918.18] language features even though that's unlikely but if we add things in go 1.5 and above
[1918.18 --> 1922.32] um we're not going to be able to use those in the compiler we're sort of guaranteeing that the
[1922.32 --> 1930.36] compiler will always build with 1.4 you mentioned uh the garbage collector in there and i think that
[1930.36 --> 1934.76] you got some something to mention about that as well so you've got a concurrent garbage collector
[1934.76 --> 1940.14] now you got new work on that that's going into the going to 1.4 can you talk a bit about that yeah
[1940.14 --> 1946.08] look that'll go into 1.5 so oh sorry yeah yeah that'll be like in august yeah there's some really