<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Airs &#8211; Ian Lance Taylor</title>
	<atom:link href="https://www.airs.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>https://www.airs.com/blog</link>
	<description>Ian Lance Taylor</description>
	<lastBuildDate>Thu, 23 Oct 2025 03:27:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>JSON Schemas in Go</title>
		<link>https://www.airs.com/blog/archives/675</link>
					<comments>https://www.airs.com/blog/archives/675#respond</comments>
		
		<dc:creator><![CDATA[Ian Lance Taylor]]></dc:creator>
		<pubDate>Thu, 23 Oct 2025 03:27:08 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">https://www.airs.com/blog/?p=675</guid>

					<description><![CDATA[In 2024 I did some work on a project at Google (the Go version of Genkit) that used JSON schemas. JSON schemas let programs specify how JSON data should be structured. Basically, you can say things like &#8216;this JSON data must have a field &#8220;name&#8221; which is a string and a field &#8220;age&#8221; which is [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>In 2024 I did some work on a project at Google (<a href="https://pkg.go.dev/github.com/firebase/genkit/go">the Go version of Genkit</a>) that used <a href="https://json-schema.org/">JSON schemas</a>.</p>



<p>JSON schemas let programs specify how JSON data should be structured. Basically, you can say things like &#8216;this JSON data must have a field &#8220;name&#8221; which is a string and a field &#8220;age&#8221; which is a number.&#8217; Of course you can get much more complicated than that. JSON schemas can themselves be represented as JSON values, and there is a metaschema that verifies whether a JSON value is a valid JSON schema.</p>



<p>For Genkit we needed Go code that could</p>



<ul class="wp-block-list">
<li>Read the JSON form of a JSON schema</li>



<li>Construct a JSON schema by hand</li>



<li>Construct a JSON schema that described a Go <code>struct</code> type</li>



<li>Validate a JSON value against a JSON schema</li>
</ul>



<p>The overall Genkit system could use JSON schemas to help people enter data in the expected format, although that was implemented in TypeScript, not Go.</p>



<p>At the time we couldn&#8217;t find one Go package that could do all of those operations, so we used a couple of packages (<a href="https://pkg.go.dev/github.com/invopop/jsonschema">github.com/invopop/jsonschema</a> and <a href="https://pkg.go.dev/github.com/xeipuuv/gojsonschema">github.com/xeipuuv/gojsonschema</a>). We converted between their data structures as needed by marshaling one implementation to JSON and unmarshaling into the other implementation.</p>



<p>Since then Jonathan Amsterdam and others at Google have written a package that does everything necessary: <a href="https://pkg.go.dev/github.com/google/jsonschema-go">github.com/google/jsonschema-go</a>. However, at the time we didn&#8217;t have that.</p>



<p>JSON schemas are moderately complex, with multiple drafts of the specification, support for cross-referencing within a schema and to external schemas, and checks like &#8220;every field that wasn&#8217;t explicitly mentioned must satisfy this subschema.&#8221; The specification is somewhat abstract and seems to have evolved over time as people have found interesting uses for schemas, especially when working in a dynamic language like JavaScript.</p>



<p>I&#8217;ve always enjoyed the implementation of complex specifications, and it&#8217;s led me to side projects like demangling C++ identifiers (<a href="https://pkg.go.dev/github.com/ianlancetaylor/demangle">github.com/ianlancetaylor/demangle</a> in Go and <a href="https://gcc.gnu.org/pipermail/gcc-patches/2003-November/120086.html">the first draft of the current GCC demangler</a> in C) and doing stack backtraces in C code (<a href="https://github.com/ianlancetaylor/libbacktrace">github.com/ianlancetaylor/libbacktrace</a>, which had to be async signal safe and required implementing three (3) different decompression algorithms).</p>



<p>So I started working on a JSON schema implementation on the side. It took a while, but I finally published it at <a href="https://pkg.go.dev/github.com/ianlancetaylor/jsonschema">github.com/ianlancetaylor/jsonschema</a>.</p>



<p>Rather than implementing JSON schemas as a struct, as the other Go implementations do, JSON schemas are represented as a slice of keyword/value pairs. This is somewhat more space efficient, which doesn&#8217;t matter much. It is also more efficient at validating JSON objects: rather than checking every field of the JSON schema struct, it only has to validate the keywords that are actually specified.</p>



<p>Not using a single struct also makes it easier to implement multiple drafts of the JSON schema. The current implementation supports draft-07, draft2019-09, and draft2020-12. Adding support for more drafts should be straightforward.</p>



<p>Now that I&#8217;ve written this package, I have no particular use for it. If other people find it useful, I&#8217;ll fix bugs and tweak the API for usability. In particular it&#8217;s a bit awkward to change any aspect of an existing JSON schema in Go code, which might be useful for some applications. It also doesn&#8217;t have full support for JSON schema annotations, as it&#8217;s not clear to me that they are useful in Go. And I&#8217;m sure there are a number of other infelicities.</p>



<p>Let me know if you find this package useful. Happy hacking.</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.airs.com/blog/archives/675/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The Conversation Game</title>
		<link>https://www.airs.com/blog/archives/673</link>
					<comments>https://www.airs.com/blog/archives/673#respond</comments>
		
		<dc:creator><![CDATA[Ian Lance Taylor]]></dc:creator>
		<pubDate>Mon, 26 May 2025 21:30:26 +0000</pubDate>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://www.airs.com/blog/?p=673</guid>

					<description><![CDATA[Some people are arguing that artificial intelligence technology has advanced so much, so quickly, that we are now close to artificial general intelligence (AGI): a computer program that has the intelligence and flexibility of a human. Popular programs like ChatGPT are examplars of what modern AI can accomplish: they can summarize text, they can answer [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Some people are arguing that artificial intelligence technology has advanced so much, so quickly, that we are now close to <a href="https://en.wikipedia.org/wiki/Artificial_general_intelligence">artificial general intelligence (AGI)</a>: a computer program that has the intelligence and flexibility of a human. Popular programs like <a href="https://chatgpt.com/">ChatGPT</a> are examplars of what modern AI can accomplish: they can summarize text, they can answer questions, they can suggest new ideas, and, in general, they can simply talk to you like a person would. It&#8217;s easy to imagine that they will improve to the level of human in intelligence.</p>



<p>I&#8217;ve come to believe that this is misleading. I don&#8217;t deny that ChatGPT, and the many other AI chatbots that have been created in the last couple of years, have a form of intelligence. <a href="https://en.wikipedia.org/wiki/AlphaGo">AlphaGo</a>, which in 2017 defeated the number one ranked (human) Go player, also has a form of intelligence. So does <a href="https://en.wikipedia.org/wiki/Deep_Blue_(chess_computer)">Deep Blue</a>, which defeated the number one ranked (human) chess player in 1997. And likewise for <a href="https://en.wikipedia.org/wiki/Chinook_(computer_program)">Chinook</a> which won checkers in 1994.</p>



<p>Of course, those other programs are playing games, while AI chatbots are just talking. Those seem like significantly different things. But I&#8217;ve come to believe that they are actually similar, and that seeing that similarity helps to clarify the gaps that remain between chatbot intelligence and AGI.</p>



<p>I think it&#8217;s accurate, and useful, to see chatbots as playing a game, just like AlphaGo plays a game. Chatbots play what I call the conversation game. This is a simple game with two players who take turns. At each turn the player says something. It can be anything at all. The goal of the game is to keep the conversation going. There is no winner or loser. A game keeps going until time expires or there is nothing left to say.</p>



<p>Humans play this game all the time. It&#8217;s practically default human behavior: it&#8217;s what we do when we are with another person and there is nothing else to do.</p>



<p>Chatbots play this game quite well. They aren&#8217;t as good as a typical human, but they are very good. Playing this game well requires a lot of general knowledge and a lot of intelligence. Chatbot technology is very impressive.</p>



<p>However, there are a lot of things that are not required to play the conversation game. You don&#8217;t need to be able to solve problems. You don&#8217;t need to deal with the unexpected, except to say something like &#8220;What do you mean by that?&#8221; You don&#8217;t need to have a goal, except to keep playing the game. Although you need to be able to make associations of ideas, <a href="https://en.wikipedia.org/wiki/Stochastic_parrot">you don&#8217;t need to actually understand any of those ideas</a>, or those associations. You just need to be able to mention them when it&#8217;s a good move in the game.</p>



<p>Making a better chatbot means making a better player of the conversation game. It&#8217;s possible to imagine a chatbot that plays the game better than any human. But that need not be an example of AGI.</p>



<p>In order to get to AGI, we need something beyond chatbots. The refinements I&#8217;ve seen published, such as reinforcement learning, just give us better chatbots. They aren&#8217;t steps toward AGI.</p>



<p>Of course, somebody may come up with a new idea to move toward AGI. But that will be a new idea. What I&#8217;m saying is that refining and improving the current ideas won&#8217;t get us there.</p>



<p>I&#8217;m aware that this critique follows a long line of critiques of AI, which is that as soon as a computer can do something, we redefine &#8220;general intelligence&#8221; as being something different from what the computer is doing. From one point of view, we are constantly moving the goalpost.</p>



<p>From another point of view, though, AI is investigating the nature of intelligence, an idea that we still don&#8217;t clearly understand. AI is helping to clarify what general intelligence is, by showing us what it is not. It&#8217;s not chatbots.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.airs.com/blog/archives/673/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Leaving Google</title>
		<link>https://www.airs.com/blog/archives/670</link>
					<comments>https://www.airs.com/blog/archives/670#comments</comments>
		
		<dc:creator><![CDATA[Ian Lance Taylor]]></dc:creator>
		<pubDate>Sun, 11 May 2025 02:07:08 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">https://www.airs.com/blog/?p=670</guid>

					<description><![CDATA[I&#8217;ve left Google after working there for 19 years. For most of that time I&#8217;ve been fortunate in being able to work on the Go programming language. Go was started by Rob Pike, Ken Thompson, and Robert Griesemer in the fall of 2007. I joined the team in June, 2008, about the same time as [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;ve left Google after working there for 19 years.</p>



<p>For most of that time I&#8217;ve been fortunate in being able to work on the <a href="https://go.dev/" data-type="link" data-id="https://go.dev/">Go programming language</a>. Go was started by Rob Pike, Ken Thompson, and Robert Griesemer in the fall of 2007. I joined the team in June, 2008, about the same time as Russ Cox. I&#8217;ve been very lucky to be able to work with such remarkable people on such an interesting project.</p>



<p>I am astonished at how much use Go has gotten over the years. Go has reached the status of being just another programming language, one that any programmer can choose when appropriate. That is far beyond what any of us expected in the early days, when our best hope was that Go might serve as an example for useful ideas that other languages and programming environments could adopt.</p>



<p>I started on Go by adding a Go frontend to the <a href="https://gcc.gnu.org/" data-type="link" data-id="https://gcc.gnu.org/">GCC compiler</a>. The Go project already had a compiler, of course, based on the Inferno C compiler. Having two compilers helped ensure that the language was clearly defined. When the two compilers differed, we knew that we had to clarify the spec and figure out what the right behavior should be.</p>



<p>In general my self-appointed role on the Go team consisted of tracking everything I could about the project and looking for areas that needed help. Among other things in the earlier years I added Go support to Google&#8217;s internal build system, and to <a href="https://www.swig.org/" data-type="link" data-id="https://www.swig.org/">the SWIG tool</a>. For a couple of years I was the team manager. From the first days of Go people asked for support for some sort of generics or type parameterization; working with Robert Griesemer I developed a series of language change proposals, and generics were added to the language in the <a href="https://go.dev/blog/intro-generics" data-type="link" data-id="https://go.dev/blog/intro-generics">Go 1.18 release in 2022</a>.</p>



<p>My approach had its good points and its bad points. I was quick to see the problems that people were running into today, and the problems they would run into tomorrow, and I was often able to get those problems addressed. But I was slow to see the ideas that would help people do new things that they weren&#8217;t trying to do and thus weren&#8217;t missing, things such as the Go module proxy and the Go vulnerability database.</p>



<p>Overall I think my approach was a good one in helping to build a successful project. But Google has changed, and Go has changed, and the overall computer programming environment has changed. It&#8217;s become clear over the last year or so that I am no longer a good fit for the Go project at Google. I have to move on.</p>



<p>I&#8217;m still interested in Go. I don&#8217;t think that the language is done. I don&#8217;t think that any programming language is ever done&#8211;the programming environment changes all the time, and languages must evolve or die. That is doubly true for a language like Go that comes equipped with a substantial standard library, one that must adapt to the new needs of programmers.</p>



<p>I will be taking a break for a while, but I hope to be able to contribute to Go again in the future.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.airs.com/blog/archives/670/feed</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>Electrification</title>
		<link>https://www.airs.com/blog/archives/599</link>
					<comments>https://www.airs.com/blog/archives/599#respond</comments>
		
		<dc:creator><![CDATA[Ian Lance Taylor]]></dc:creator>
		<pubDate>Sat, 05 Sep 2020 22:40:21 +0000</pubDate>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[climate change]]></category>
		<category><![CDATA[electrification]]></category>
		<guid isPermaLink="false">https://www.airs.com/blog/?p=599</guid>

					<description><![CDATA[This is a note about some steps that I and my family have taken to work to reduce our carbon emissions. According to the EPA, commercial and residential use is the fourth largest source of carbon emissions overall in the U.S., generating about 12% of carbon emissions. Some sizable chunk of that is fossil fuels [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>This is a note about some steps that I and my family have taken to work to reduce our carbon emissions.</p>



<p><a href="https://www.epa.gov/ghgemissions/sources-greenhouse-gas-emissions">According to the EPA</a>, commercial and residential use is the fourth largest source of carbon emissions overall in the U.S., generating about 12% of carbon emissions.  Some sizable chunk of that is fossil fuels burned in the home for heating, for hot water, for gas dryers, and for cooking.</p>



<p>This matters because this use of fossil fuels is widely distributed and is controlled by homeowners.  The largest source of carbon emissions, transportation, is also widely distributed, but we know how to reduce those emissions: we must switch to zero-emission cars.  This is a fairly easy switch for an individual: when you must buy a new car, buy an electric car.  There are many good electric cars out there, and, speaking as someone has owned one for some seven years now, electric cars are better for most uses.</p>



<p>The second and third largest sources of carbon emissions, electricity generation and industry, are problems that can&#8217;t be tackled by individuals, beyond general efforts like education and voting.  These problems require work by the groups that run the plants.  Fortunately, this work, while complex and expensive, is mostly a set of discrete large scale projects.</p>



<p>That is not true for home use of fossil fuels.  Reducing fossil fuel use in the home requires tens of millions of individual small changes.  Government can encourage these changes via the tax system, but it&#8217;s implausible for government to actually do it.  Each individual home owner must make the changes themselves.</p>



<p>The goal is to remove any use of fossil fuel in the home.  In our case, it meant no longer using natural gas.  For other homes it may mean getting off oil or, occasionally, coal.</p>



<p>At present the only reasonable alternative is electricity.  This may seem counter-productive, as electricity is also often generated by fossil fuels.  Fortunately, non-carbon sources of electricity are available and are spreading fast.  For example, in California, where we live, <a href="https://en.wikipedia.org/wiki/Energy_in_California">less than half of the electricity in the grid is produced by non-renewable sources</a>.  Where we live more specifically, in Berkeley, we can <a href="https://ebce.org/compare-plans-residential/">pay slightly extra to get only electricity from renewable sources</a> (though of course this is something of a fiction as electrons are fungible).  Also, in our case, we have solar panels.</p>



<p>More generally, as mentioned above, reducing carbon emissions from electricity is a set of discrete large projects.  By shifting our energy use to electricity, we reduce the scale of the problem from the impossible (tens of millions changes) to the possible (there are <a href="https://www.washingtonpost.com/graphics/national/power-plants/#:~:text=Natural%20gas%2Dpowered%20electric%20plants,plants%20in%20the%20United%20States.">fewer than 2500 fossil fuel electrical plants in the U.S.</a>).  It becomes possible to either replace the electricity generation with renewables, or to capture the carbon emissions at a set of locations many orders of magnitude smaller than the number of households in the country.</p>



<p>Moving on to what we actually did, we had three uses of natural gas: our furnace (forced hot air), our water heater, and our cooktop.  As it happened, we already had an electric dryer and an electric oven.</p>



<p>I am strictly a software person, so the work was going to be done by other people.  The first obstacle we had to overcome was explaining what we wanted.  I expect that this will become easier over time.  In talking to several different companies, we would explain that our goal was to stop using natural gas entirely, and they would respond with ways to reduce our overall energy use.  Typical examples of this were installing better windows and improving our insulation, especially in the attic.  We were also offered options like an electric water heater with natural gas for backup.  We had to go back and forth with explanations of &#8220;sure, reducing energy use is great, but what we really want is to stop using natural gas.&#8221;</p>



<p>The second obstacle was our electrical panel.  While there are many details and I don&#8217;t understand all of them, the simple view is that electrical appliances require a certain number of amps.  (There are also volts and watts, but when it comes to electrifying your house they don&#8217;t actually matter.)  Your house has a bunch of circuit breakers, or, in older houses, fuses, that limit the number of amps that will flow at one time.  If you turn on too many appliances they will try to pull too many amps and your circuit breaker will flip.  A house will have several circuit breakers, and each one is responsible for some set of lights or plugs or specific appliances.  There is also a limit on how much the whole house can draw at a time, which is the size of your overall electrical service.  All of these circuit breakers are there to prevent the electrical wiring from heating up too much and starting a fire.</p>



<p>This matters because a house that was built for fossil fuels is typically not built to have everything done by electricity.  There may not be enough amps coming into the house.  And the existing circuit breakers may not be large enough for the requirements of your new electrical appliances.</p>



<p>It turns out that getting more amps is not just a matter of swapping in a larger fuse.  Upgrading electrical service is expensive.  Replacing the electrical panel to get bigger or more circuit breakers is expensive.  In our case we had to spend on the order of $10,000 for all the electrical improvements, though that required an additional subpanel in a different part of the house, which might not be required in every home.</p>



<p>The point is, if you don&#8217;t know how all of this works (I certainly didn&#8217;t), an early step in the electrification process is going to be to have an electrician come out and take a look at your system and tell you what will have to change.</p>



<p>The third obstacle is choice of systems.  For the cooktop, this is easy: use an induction cooktop.  For anything that doesn&#8217;t require actual flame, an induction cooktop works just as well as a gas cooktop.  For some things, like a low simmer, an induction cooktop is actually better.  Some kinds of pots and pans don&#8217;t work on an induction cooktop, but as it happened all of ours did work.  You can get induction cooktops to replace any standard size gas cooktop.  Since you aren&#8217;t burning gas, the air in the kitchen is cleaner.  This is a straightforward change, once you&#8217;ve set up the electrical service: our new cooktop can use up to 50 amps, which is a lot.</p>



<p>For the furnace and hot water heater, the best choice at least in California is a heat pump system.  These are two part systems: the heat pump, which goes outside, and the tank or air handler, which goes inside.  The heat pump is basically a large fan, and is something like the external part of a whole house air conditioner.  It is not terribly noisy, but it&#8217;s not silent.  And you have to find some place to put it.  One nice feature about a heat pump furnace is that you can run the heat pump backward and get air conditioning; no need for a separate unit.</p>



<p>You can get combined water heater/furnace systems that use a single heat pump, but for our house configuration it was simpler to get two different systems.  For us each heat pump takes 20 amps, and then the air handler takes 40 amps (the water heater doesn&#8217;t need any electricity beyond the heat pump).  So you can see how the amps add up pretty quickly.</p>



<p>Specifically our cooktop is a <a href="http://resources.gaggenau.com/us/product/36-200-series-flex-induction-cooktop-frameless-new-launch-available-march-2017/">Gaggenau CI 292-601</a>, our water heater is a <a href="https://foursevenfive.com/sanden-sanco2/">Sanden SanCO2</a>, and our furnace is a <a href="https://www.carrier.com/residential/en/ca/products/heat-pumps/25hha4/">Carrier Performance Series heat pump </a>and air handler.  We&#8217;ve had them for over a year now, with no problems at all.</p>



<p>While we did all of this at about the same time, I expect that most people would do it as needed.  When your water heater breaks, replace it with an electrical one.  The main thing is to make sure your electrical service is ready.</p>



<p>Of course it&#8217;s also worth asking how much you have to pay beyond the price of installation.  In our case, since we replaced the systems at about the same time, it&#8217;s an easy comparison.  The year before installing them, we spent $250 per month for combined electricity and gas charges.  The year after installing them, we spent $270 per month, just for electricity (with no gas charges).  (These prices include charging our electric car, by the way.)  So the electrical appliances are a bit more expensive, but it&#8217;s in the same ballpark.</p>



<p>And, of course, no more natural gas.  Our local gas company, PG&amp;E, removed our gas line entirely, cutting it off at the street, for no charge.  This may make our house slightly safer in case of an earthquake: no danger of a spark from a gas leak.</p>



<p>If you&#8217;ve read this far, remember: check your electrical service, and the next time you have to replace any fossil fuel powered appliance, make sure to replace with an electrical one.  The planet will thank you, and it&#8217;s the right thing to do.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.airs.com/blog/archives/599/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Go experience report: the append function</title>
		<link>https://www.airs.com/blog/archives/559</link>
					<comments>https://www.airs.com/blog/archives/559#comments</comments>
		
		<dc:creator><![CDATA[Ian Lance Taylor]]></dc:creator>
		<pubDate>Sun, 16 Jul 2017 03:53:24 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">http://www.airs.com/blog/?p=559</guid>

					<description><![CDATA[When the Go language was first publicly released it contained a package named container/vector.  The type vector.Vector was a name for the type []interface{}.  Vector supported methods like Len, Cap, At, Set, Insert, Delete, Push, Pop, and several more.  You can see the source code at on Github.  An interesting aspect of the package is that [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When the Go language was first publicly released it contained a package named container/vector.  The type <code>vector.Vector</code> was a name for the type <code>[]interface{}</code>.  <code>Vector</code> supported methods like <code>Len</code>, <code>Cap</code>, <code>At</code>, <code>Set</code>, <code>Insert</code>, <code>Delete</code>, <code>Push</code>, <code>Pop</code>, and several more.  You can see the source code at <a href="https://github.com/golang/go/tree/059c68bf0cccea85bea19c44c15d7fec9e9cbd21/src/pkg/container/vector">on Github</a>.  An interesting aspect of the package is that <code>string</code> and <code>int</code> versions of <code>Vector</code> were automatically generated by copying the file vector.go with edits applied by gofmt -r.</p>
<p>The container/vector package was deleted in October, 2011, before the Go 1 release, because by that time it added nothing that was not available more simply using slices.  But it was useful once; in October, 2010, it was used by 18 packages in the standard library.  By the time it was deleted one year later, it was not used by any.  This change occurred because of a key feature added to the language: the built-in <code>append</code> function.</p>
<p>The <code>append</code> function was first proposed by Robert Griesemer in an internal e-mail sent in November, 2009, during a discussion of whether to add the built-in <code>copy</code> function (as a result of that discussion <code>copy</code> was added to the language in <a href="https://golang.org/cl/156089">CL 156089</a>).  At that time I replied about both <code>copy</code> and <code>append</code> saying &#8220;It seems to me that these functions are not useful if we figure out a way to implement generics. Not necessarily a strong argument against them, I suppose, but do we want to introduce new builtin functions if we may not need them?&#8221;</p>
<p>In 2009 we added <code>copy</code> but not <code>append</code>.  In October, 2010, David Symonds proposed <code>append</code> independently, saying &#8220;It&#8217;s been getting tiresome having to write the same old boilerplate to grow a slice on demand. container/vector would be suitable if it were generic, but cluttering code with type assertions is worse than the expansion.&#8221;  Robert picked this up and outlined the function we know today, adding &#8220;Should we ever have some form of genericity, this could even become a library function. For now, the implementation would be a built-in.&#8221;  I replied to the thread, essentially repeating myself from a year before: &#8220;I&#8217;m not really opposed to a builtin append function but I want to make the obvious comment that, like copy, this is a function we are only considering because we don&#8217;t have generics.&#8221;  The result of this discussion was to add <code>append</code> as we know it today to the Go language (<a href="https://golang.org/cl/2627043">CL 2627043</a>).</p>
<p>The point I want to make here is that because we had no way to write a generic <code>Vector</code> type with an <code>Append</code> method, we wound up adding a special purpose language feature to implement it.  A language that supported parameterized types with methods would not have required a special built-in function that only works with slices.  An append operation makes sense for other sorts of data structures, such as various kinds of linked lists.  The built-in <code>append</code> function can not be used for them.</p>
<p>I am writing this note as a user experience report to add to the <a href="https://golang.org/wiki/ExperienceReports">Go wiki</a>.  To fit the format there, what we wanted to do was to add a generally useful mechanism for extending a slice.  What we had to do was extend the language.  That wasn&#8217;t great because it made the language more complex by adding a special purpose, non-generalizable, non-orthogonal, feature.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.airs.com/blog/archives/559/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
