<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[GopherJS - Medium]]></title>
        <description><![CDATA[A compiler from Go to JavaScript for running Go code in a browser - Medium]]></description>
        <link>https://medium.com/gopherjs?source=rss----1d6966d814e3---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>GopherJS - Medium</title>
            <link>https://medium.com/gopherjs?source=rss----1d6966d814e3---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:02:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/gopherjs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GopherJS user survey results — 2021]]></title>
            <link>https://medium.com/gopherjs/gopherjs-user-survey-results-2021-d094e2402a25?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/d094e2402a25</guid>
            <category><![CDATA[gopherjs]]></category>
            <category><![CDATA[user-survey]]></category>
            <dc:creator><![CDATA[Nevkontakte]]></dc:creator>
            <pubDate>Wed, 29 Dec 2021 10:03:18 GMT</pubDate>
            <atom:updated>2021-12-29T10:03:17.812Z</atom:updated>
            <content:encoded><![CDATA[<h3>GopherJS user survey results — 2021</h3><p>It is that time of the year when everyone is reflecting on the achievements of the past and making plans for the future. GopherJS is no exception — this has been an eventful year for us, and the future looks even more interesting (generics?! 🎁).</p><p>This year we ran a <a href="https://forms.gle/inPHMz4Myn18SXGH8">user survey</a> to help us better understand what our users value the most in GopherJS, and what they wish was available. It was also important to us to evaluate technical decisions, for example whether we can part with our ECMAScript 5 compatibility policy and take advantage of the newer features. It is time for us to share the data we got from the survey, and the decisions we make based on it.</p><p>Before we dive in, it is important to say that we’ve received 53 responses (thank you all who took time!). This is enough for us to discern general trends, but we are aware that this is only a small fraction of our userbase.</p><p>There are three popular ways to run Go in a browser: GopherJS, Go WebAssembly and TinyGo WebAssembly. We wanted to understand whether there is an overlap between users of these projects. We asked which, if any, of these projects are you using.</p><figure><img alt="A matrix plot showing how many survey responders reported using different combinations of GopherJS, Go Wasm and TinyGo Wasm simultaneously. GopherJS users total: 60%, GopherJS and Go Wasm: 28%, GopherJS and TinyGo: 8%." src="https://cdn-images-1.medium.com/max/1024/1*BayQsqNySZ_5d8Hbs7W8xw.png" /><figcaption>Percentage of survey responders who reported using different client-size Go technologies at the same time.</figcaption></figure><p>This plot tells us a few important things:</p><ul><li>The results are naturally biased towards GopherJS — this is to be expected, since our users are more likely to respond to our survey.</li><li>Almost half of GopherJS users also use Go WebAssembly.</li><li>TinyGo seems to be less popular among survey responders, but not insignificant. Smaller output size is likely a factor here.</li><li>Among responders who reported <strong>not </strong>using GopherJS, Go WebAssembly appears to be approximately twice as popular as TinyGo WebAssembly.</li></ul><p>Another important thing for us to understand is where our users run their code. JavaScript (for better or worse) can run almost anywhere, but each environment has its own subtle differences, and we need to know where to focus our attention. We also asked the same question to the WebAssembly users in case it reveals unexpected differences, but the picture is quite similar:</p><figure><img alt="A bar chart showing popularity of different runtime environments among GopherJS and WebAssembly users. Browser is by far the most popular one with NodeJS being the second." src="https://cdn-images-1.medium.com/max/1024/1*OsH2Z4KC53Ayd7J6NKqZoA.png" /><figcaption>Number of responders who reported targeting each runtime environment (multiple selections were allowed).</figcaption></figure><ul><li>Browser is by far the most popular environment. This makes sense: almost anywhere where NodeJS can run, native Go can too.</li><li>NodeJS usage is not insignificant. We would like to know the exact use cases, but we are guessing it might be gopherjs test and special cases like <a href="https://www.steveyackey.com/post/gopherjs-github-actions/">custom GitHub Actions</a>.</li><li>We were really surprised to see React Native appear in two different responses — this is a use case we never though of. But we would like to read a blog post about it one day 😉</li></ul><p>Next question we wanted to settle is whether we should stick to our current policy of ECMAScript 5 compatibility for the generated code. In the past this has been an important feature of GopherJS, ensuring that generated code can run in almost every browser. However, recently <a href="https://github.com/gopherjs/gopherjs/issues/891">requests</a> for ECMAScript 2015+ features became more frequent, for example better integration with <a href="https://github.com/gopherjs/gopherjs/issues/524">ES6 modules</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1YqIQbC22A-cINY55nnwA.png" /><figcaption>Plot shows number of respondents selected corresponding options to each question. The results only include respondents who reported using GopherJS.</figcaption></figure><p>We filtered results of this plot to GopherJS users, since the biggest concern here is breaking compatibility for existing users targeting old browsers. This reduced the number of data points, but is still enough to draw some conclusions:</p><ul><li>Looks like most of our users set their compatibility requirements relative to the browser or NodeJS age, rather than specific ECMAScript versions. Most appear to be targeting at most 5 years old versions.</li><li>There still are folks who need ES5 compatibility. Although there are only a few of them in the survey, this means that when we decide to begin using ES6 features, we need to provide a well-documented path to transpile GopherJS output into ES5.</li><li>Overall, it seems that it is ok for GopherJS to use newer ECMAScript features, as long as they have been supported in popular browsers for 5 years and there is a documented fallback or polyfill for older versions.</li></ul><p>Finally, we’ve asked a few open-ended questions to understand what is important to our users. We won’t go into a lot of detail here, and highlight some common trends:</p><ul><li>Output size is by far the most common request for improvement — almost 80% of responders brought it up. This is not a surprise to us — the corresponding <a href="https://github.com/gopherjs/gopherjs/issues/136">GitHub issue</a> is probably one of the longest in our tracker. This isn’t an easy problem to solve, but clearly an important one.</li><li>Support for “embed” package, ES6+ features and in-browser test support are other popular requests each getting around 30% of votes.</li><li>Preference for Go as a language (70%) and ability to share libraries with the backend (60%) are the biggest reasons for people to choose GopherJS. To us it means that code portability between regular Go and GopherJS is important, and we need to keep up with language features the best we can.</li><li>Interacting with native JavaScript libraries is a very common use case. 80% of responders named js field tags the most valuable feature in GopherJS. Questions about using GopherJS output as a ES6 module and importing ES6 modules into GopherJS programs are also frequent occurrences in our issue tracker 🙂</li><li>Quite a lot of folks expressed interest in contributing to the project, but lack of documentation on GopherJS internals is making it hard for them.</li><li>50% of responders report adopting a new Go release within 6 months and 90% — within a year. So I guess we should get going on <a href="https://github.com/gopherjs/gopherjs/issues/1092">Go 1.18 support</a> 😅</li></ul><p>We would also like to take a moment and say thank you for all the words of support that you put in the survey! 🙏 Reading them it a massive source of motivation for us to keep moving GopherJS forward.</p><p>That’s about it for the survey. It was incredibly useful for us, and we plan to <a href="https://forms.gle/inPHMz4Myn18SXGH8">keep it open</a> as an ongoing channel of feedback. Happy holidays and see you next year!</p><p>— <a href="https://medium.com/u/362ddae42bbb">Nevkontakte</a> and <a href="https://medium.com/u/fab8e9148375">Jonathan Hall</a> on behalf of the GopherJS project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d094e2402a25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-user-survey-results-2021-d094e2402a25">GopherJS user survey results — 2021</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.16 released!]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-16-released-73805c81674c?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/73805c81674c</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gopherjs]]></category>
            <dc:creator><![CDATA[Jonathan Hall]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 12:25:56 GMT</pubDate>
            <atom:updated>2021-04-06T12:25:56.578Z</atom:updated>
            <content:encoded><![CDATA[<h3>GopherJS 1.16 released</h3><p>After lagging behind Go for about 2 years (since version 1.12), <a href="https://github.com/gopherjs/gopherjs/releases/tag/1.16.0%2Bgo1.16.3">GopherJS 1.16.0+go1.16.3</a> has been released with Go 1.16 support!</p><p>GopherJS compiles Go code to pure JavaScript code (not WebAssembly). It’s main purpose is to give you the opportunity to write front-end code in Go, which will still run in all browsers, while allowing integration with existing JavaScript libraries.</p><p>This comes on the heels of a recent reorganization of the GopherJS community, and a resurgence of activity and interest in the project.</p><p>You can try out GopherJS without installing it by using the <a href="https://gopherjs.github.io/playground/">GopherJS playground</a>.</p><p>GopherJS 1.16 is still lacking a couple important features of modern Go, which are on the roadmap. Most notably:</p><ul><li>Go modules are not yet supported. You can still build with GOPATH mode, or <a href="https://jhall.io/posts/gopherjs-with-modules/">use a workaround</a>.</li><li>Go 1.16’s embed directive is still forthcoming.</li></ul><p>For these features, as well as the upcoming support for Generics in Go 1.17, we would gladly welcome volunteers from the community!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73805c81674c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-16-released-73805c81674c">GopherJS 1.16 released!</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.12–1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-12-1-is-released-2d2a63d748b8?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/2d2a63d748b8</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gopherjs]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[compilers]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Fri, 29 Mar 2019 02:51:28 GMT</pubDate>
            <atom:updated>2019-03-29T02:51:28.356Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are happy to announce the release of GopherJS 1.12–1. You can <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">get it on GitHub</a> as usual.</p><p>This release adds support for <a href="https://blog.golang.org/go1.12">Go 1.12</a>. The support for Go 1.12 means that GopherJS 1.12–1 requires Go 1.12 and no longer works with Go 1.11. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot upgrade from Go 1.11 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/tree/go1.11">go1.11 branch</a>.</p><p>Installation or upgrade steps remain the same as before. To get the latest official stable release of GopherJS, please <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">follow the instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.12-1.</p><p>GopherJS 1.12–1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines, channels, select statement. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.11 version is still supported, as are many of the additions that are new to Go 1.12. If you run into any issues or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">report an issue</a>.</p><p>Thank you to <a href="https://github.com/hajimehoshi">Hajime Hoshi</a> and <a href="https://github.com/myitcv">Paul Jolly</a> who worked on Go 1.12 support, and all contributors who have helped with this release. It is greatly appreciated.</p><p>If you’d like to get started with GopherJS, here are some next steps:</p><ul><li>Try it right now in your browser with the <a href="https://gopherjs.github.io/playground/#/1pp8a59LAX">GopherJS Playground</a>.</li><li>Use the <a href="https://github.com/gopherjs/gopherjs#gopherjs-serve">gopherjs serve command</a> and execute your favorite Go package in the browser.</li><li>Join the <a href="https://gophers.slack.com/messages/gopherjs/">#gopherjs channel</a> on <a href="https://invite.slack.golangbridge.org/">Gophers Slack</a> for GopherJS-related chat.</li></ul><p>Happy surfing with Go 1.12 and GopherJS 1.12–1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d2a63d748b8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-12-1-is-released-2d2a63d748b8">GopherJS 1.12–1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future of GopherJS and Go in the browser]]></title>
            <link>https://medium.com/gopherjs/future-of-gopherjs-and-go-in-the-browser-cc1667468160?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc1667468160</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[webassembly]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Fri, 14 Dec 2018 15:11:00 GMT</pubDate>
            <atom:updated>2018-12-15T04:48:58.189Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post compares GopherJS to Go 1.11 and its new experimental WebAssembly port, suggests how Web API binding libraries can evolve to support both compilers, and provides context on the history and the future possibilities of Go in the browser.</em></p><h3>Background and Future</h3><p>Go 1.11 and GopherJS 1.11–1 mark an important and exciting milestone in the journey of Go in the browser. Go 1.11 added an <a href="https://golang.org/wiki/WebAssembly">experimental port to WebAssembly</a>, giving Go programmers a second choice of a tool for compiling Go code into a format supported by modern web browsers. It was contributed to the Go project by <a href="https://github.com/neelance">Richard Musiol</a>, the creator of GopherJS itself.</p><p>Richard started the GopherJS project in <a href="https://github.com/gopherjs/gopherjs/commit/2f31215a988a07bca0c320a619f190c8decf5737">August of 2013</a> with the purpose of giving programmers the possibility of writing frontend code in Go. At that time, the major browsers provided only one¹ choice of an executable format: the JavaScript language. GopherJS had no choice but to use it as its compilation target.</p><p>GopherJS started out being very simple, and supported a handful of Go expressions, but then grew into an advanced Go compiler that supported nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines, channels, and the select statement.</p><p>WebAssembly is a modern binary format designed specifically as a compilation target for high-level languages. It is still in early stages of development with <a href="https://hacks.mozilla.org/2018/10/webassemblys-post-mvp-future/">many planned post-MVP future improvements</a>, and it has the potential for reaching performance and binary size efficiency that surpasses what’s possible when compiling into JavaScript.</p><p>Having two working Go compilers that can target browsers is good for the Go ecosystem health. This is akin to gc and gccgo, the two backend Go compilers. It creates new opportunities, and helps discover or work around issues. At this time, there will be some programs and use cases that perform better when compiled with Go 1.11 to WebAssembly, and others where GopherJS does better.</p><h3>Browser API Binding Packages</h3><p>Package authors who have created <a href="https://github.com/gopherjs/gopherjs/wiki/bindings">bindings for various web APIs</a> previously targeted only the GopherJS compiler and <a href="https://godoc.org/github.com/gopherjs/gopherjs/js">github.com/gopherjs/gopherjs/js</a> package for calling into JavaScript. With Go 1.11, there is a new experimental <a href="https://godoc.org/syscall/js">syscall/js</a> package in the standard library for the same purpose, which offers a similar but not identical API.</p><p>Authors of existing browser API bindings can add support for WebAssembly. Doing so is very helpful, as it allows users to write Go programs that can be compiled with both GopherJS to JavaScript and with Go 1.11 to WebAssembly. There are a few ways to accomplish this, described below.</p><p>Consider the following example Go binding for a small subset of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert">DOM Web API</a>. It starts by targeting only GopherJS, like so:</p><pre>// +build js</pre><pre>// Package window is a binding for a tiny subset of the DOM Web API,<br>// concerned with the Window interface as documented at<br>// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window">https://developer.mozilla.org/en-US/docs/Web/API/Window</a>.<br>package window</pre><pre>import &quot;github.com/gopherjs/gopherjs/js&quot;</pre><pre>// Alert displays an alert dialog with the specified message<br>// and an OK button. See its reference at<br>// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert">https://developer.mozilla.org/en-US/docs/Web/API/Window/alert</a>.<br>func Alert(message string) {<br>    js.Global.Call(&quot;alert&quot;, message)<br>}</pre><p>We’ll use this simple library to demonstrate different approaches to add WebAssembly support.</p><h4>Using build tags</h4><p>One of the <a href="https://go-proverbs.github.io/">Go proverbs</a> states:</p><blockquote>Syscall must always be guarded with build tags.</blockquote><p>The <a href="https://godoc.org/github.com/gopherjs/gopherjs/js">github.com/gopherjs/gopherjs/js</a> and <a href="https://godoc.org/syscall/js">syscall/js</a> packages are no exception. We can use build tags (aka build constraints) to guard their use.</p><p>The <a href="https://github.com/gopherjs/gopherjs#architecture">architecture</a> section of the GopherJS README notes:</p><blockquote>The <em>GOARCH</em> value of GopherJS is <em>js</em>. You may use it as a build constraint: <em>// +build js</em>.</blockquote><p>Go 1.11 uses GOOS=js and GOARCH=wasm values for WebAssembly. That means the // +build js build constraint will match both, and we need to use more specific // +build js,!wasm build constraint to differentiate code for GopherJS from code for WebAssembly. It looks like this:</p><pre>// +build js,!wasm</pre><pre>// Package window ...<br>package window</pre><pre>import &quot;github.com/gopherjs/gopherjs/js&quot;</pre><pre>// Alert displays ...<br>func Alert(message string) {<br>    js.Global.Call(&quot;alert&quot;, message)<br>}</pre><p>The code above will be used when compiling package window with GopherJS. For WebAssembly, another .go file is added with // +build js,wasm build constraint:</p><pre>// +build js,wasm</pre><pre>// Package window ...<br>package window</pre><pre>import &quot;syscall/js&quot;</pre><pre>// Alert displays ...<br>func Alert(message string) {<br>    js.Global().Call(&quot;alert&quot;, message)<br>}</pre><p>Note that it has a different build constraint, imports syscall/js, and uses its slightly different API.</p><p>This approach requires more maintenance work from the library authors, but offers the greatest flexibility and least overhead. It also precludes the wrapper from leaking the internal js details into its public API.</p><h4>Using the gopherwasm wrapper</h4><p>Another approach is to use the <a href="https://godoc.org/github.com/gopherjs/gopherwasm/js">github.com/gopherjs/gopherwasm/js</a> wrapper. This library abstracts over the github.com/gopherjs/gopherjs/js and syscall/js APIs, and presents a syscall/js-like API that is supported both by GopherJS and Go 1.11 WebAssembly.</p><p>To add WebAssembly support to our original example GopherJS binding, we need only to modify the single .go file to import gopherwasm and use its API:</p><pre>// +build js</pre><pre>// Package window ...<br>package window</pre><pre>import &quot;github.com/gopherjs/gopherwasm/js&quot;</pre><pre>// Alert displays ...<br>func Alert(message string) {<br>    js.Global().Call(&quot;alert&quot;, message)<br>}</pre><p>This approach offers the benefit of there being only one .go file to maintain for the library authors. However, it adds some indirection and doesn’t allow to continue to rely on peculiarities of the github.com/gopherjs/gopherjs/js API that are not supported by gopherwasm (e.g., js struct field tags and what’s described <a href="https://github.com/gopherjs/gopherjs/wiki/JavaScript-Tips-and-Gotchas">here</a>).</p><p>***</p><p>These two are the most common approaches that are coming up in practice so far. You can find some real examples of WebAssembly support being added at:</p><ul><li><a href="https://github.com/goxjs/gl/pull/27">https://github.com/goxjs/gl/pull/27</a></li><li><a href="https://github.com/gopherjs/websocket/pull/27">https://github.com/gopherjs/websocket/pull/27</a></li><li><a href="https://github.com/dominikh/go-js-dom/issues/57">https://github.com/dominikh/go-js-dom/issues/57</a></li></ul><p>There may be other approaches to consider, such as creating distinct packages for GopherJS and WebAssembly, and more. You’ll need to find what works best for your needs.</p><p>In general, adding WebAssembly support is more viable for high-level GopherJS bindings that provide an idiomatic Go API and not expose the *js.Object details in the public API. This is a good practice when you think about the js packages as equivalent to other syscall packages: it’s better to avoid leaking such low-level details into public APIs for users to deal with.</p><h3>Conclusion</h3><p>Go 1.11 support for WebAssembly brings Go in the browser to a bigger audience, and pushes the state of technology forward in this exciting new space.</p><p>It’s a great time to build new things, experiment, find out what’s possible and works well, in order to advance the state of Go in the browser. Share what you create with your fellow gophers. Good luck and have fun!</p><p><em>¹ At that time, asm.js was just announced and beginning to appear in some browsers. It was too early to start targeting it right away.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc1667468160" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/future-of-gopherjs-and-go-in-the-browser-cc1667468160">Future of GopherJS and Go in the browser</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.11–1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-11-1-is-released-7aad12f7e646?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/7aad12f7e646</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gopherjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Sat, 25 Aug 2018 21:55:59 GMT</pubDate>
            <atom:updated>2018-08-25T21:58:23.864Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Who says releasing on Saturday is a bad idea?</blockquote><p>Today we are happy to announce the release of GopherJS 1.11–1. You can <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">get it on GitHub</a> as usual.</p><p>It adds support for the <a href="https://blog.golang.org/go1.11">recent release of Go 1.11</a>. The support for Go 1.11 means that GopherJS 1.11–1 requires Go 1.11 and no longer works with Go 1.10. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot upgrade from Go 1.10 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/tree/go1.10">go1.10 branch</a>.</p><p>Installation or upgrade steps remain the same as before. To get the latest official stable release of GopherJS, please <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">follow the instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.11-1.</p><p>GopherJS 1.11–1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines, channels, select statement. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.10 version is still supported, as are many of the additions that are new to Go 1.11. If you run into any issues or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">report an issue</a>.</p><p>Thank you to all contributors who have helped with this release. It is greatly appreciated.</p><p>If you’d like to get started with GopherJS, here are some next steps you can take:</p><ul><li>Try it right now in your browser with the <a href="https://gopherjs.github.io/playground/#/1pp8a59LAX">GopherJS Playground</a>.</li><li>Use the <a href="https://github.com/gopherjs/gopherjs#gopherjs-serve">gopherjs serve command</a> and execute your favorite Go package in the browser.</li><li>Join the <a href="https://gophers.slack.com/messages/gopherjs/">#gopherjs channel</a> on <a href="https://invite.slack.golangbridge.org/">Gophers Slack</a> for GopherJS-related chat.</li></ul><p>Happy surfing with Go 1.11 and GopherJS 1.11–1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7aad12f7e646" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-11-1-is-released-7aad12f7e646">GopherJS 1.11–1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.10-1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-10-1-is-released-2ff9002a6712?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ff9002a6712</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[gopherjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 19:34:29 GMT</pubDate>
            <atom:updated>2018-02-26T19:34:29.060Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are happy to announce the release of GopherJS 1.10-1. You can <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">get it on GitHub</a> as usual.</p><p>It adds support for the <a href="https://blog.golang.org/go1.10">recent release of Go 1.10</a>. The support for Go 1.10 means that GopherJS 1.10-1 requires Go 1.10 and no longer works with Go 1.9. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot upgrade from Go 1.9 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/tree/go1.9">go1.9 branch</a>.</p><p>Installation or upgrade steps remain the same as before. To get the latest official stable release of GopherJS, please <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">follow the instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.10-1.</p><p>GopherJS 1.10-1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines, channels, select statement. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.9 version is still supported, as are many of the additions that are new to Go 1.10. If you run into any issues or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">report an issue</a>.</p><p>To see some of the new features available in Go 1.10, take a look at <a href="https://gopherjs.github.io/playground/#/UdyEyAtguS">this example program</a> on the GopherJS Playground.</p><p>Thank you to all contributors who have helped with this release, whether that’s by improving documentation, investigating and <a href="https://github.com/gopherjs/gopherjs/issues?q=is%3Aissue+is%3Aclosed">resolving issues</a>, helping review <a href="https://github.com/gopherjs/gopherjs/pulls">open PRs</a>, <a href="https://github.com/gopherjs/gopherjs/compare/f7c56533adfac99e12ccdccfec04a466d2a778da...4ebbd33f7fb1fca27e0a0a413c2729ae8cb4d958">contributing code</a> and maintaining <a href="https://github.com/gopherjs/gopherjs/wiki/bindings">bindings to browser APIs</a>. It is greatly appreciated. We welcome all help; if you’d like to get involved, see the <a href="https://github.com/gopherjs/gopherjs#community">community section</a>. If you have a good experience with GopherJS, tell your fellow gophers about it and share your GopherJS-powered projects!</p><p>If you’d like to get started with GopherJS, here are some next steps you can take:</p><ul><li>Try it right now in your browser with the <a href="https://gopherjs.github.io/playground/#/UdyEyAtguS">GopherJS Playground</a>.</li><li>Use the <a href="https://github.com/gopherjs/gopherjs#gopherjs-serve">gopherjs serve command</a> and execute your favorite Go package in the browser.</li><li>Join the <a href="https://gophers.slack.com/messages/gopherjs/">#gopherjs channel</a> on <a href="https://invite.slack.golangbridge.org/">Gophers Slack</a> for GopherJS-related chat.</li></ul><p>Happy surfing with Go 1.10 and GopherJS 1.10-1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ff9002a6712" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-10-1-is-released-2ff9002a6712">GopherJS 1.10-1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.9-1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-9-1-is-released-e4d808e58f19?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4d808e58f19</guid>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[gopherjs]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Sun, 27 Aug 2017 00:55:39 GMT</pubDate>
            <atom:updated>2017-08-27T00:55:38.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are happy to announce the release of GopherJS 1.9-1. You can <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">get it on GitHub</a> as usual. It adds support for the <a href="https://blog.golang.org/go1.9">recent release of Go 1.9</a>. There have been many minor improvements since GopherJS 1.8-1.</p><p>The support for Go 1.9 means that GopherJS 1.9-1 requires Go 1.9 and no longer works with Go 1.8. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot upgrade from Go 1.8 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/tree/go1.8">go1.8 branch</a>.</p><p>Installation or upgrade steps remain the same as before. To get the latest official stable release of GopherJS, please <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">follow the instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.9-1.</p><p>GopherJS 1.9-1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.8 version is still supported, as are many of the additions that are new to Go 1.9. If you run into any issues or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">create an issue report</a>.</p><p>Some of the changes that have gone into the new release include:</p><ul><li>Support for type alias declarations. E.g., type T1 = T2.</li><li>Support for new math/bits package in the standard library.</li><li>Fixed evaluation order of type conversions (<a href="https://github.com/gopherjs/gopherjs/issues/649">#649</a>).</li><li>Fixed externalization of empty typed arrays (<a href="https://github.com/gopherjs/gopherjs/issues/597">#597</a>).</li><li>In net/http package, improved error messages on failed requests when using Fetch (<a href="https://github.com/gopherjs/gopherjs/pull/647">#647</a>), and improved handling of requests with empty bodies when using XMLHttpRequest (<a href="https://github.com/gopherjs/gopherjs/pull/600">#600</a>).</li><li>Optimized ASCII detection during string internalization/externalization (<a href="https://github.com/gopherjs/gopherjs/pull/628">#628</a>).</li><li>Fixed bug in gopherjs build staleness calculation that was causing it to sometimes use stale archives and produce incorrect build output (<a href="https://github.com/gopherjs/gopherjs/issues/559">#559</a>).</li><li>Improved support for import path patterns and relative import paths in the gopherjs command (<a href="https://github.com/gopherjs/gopherjs/issues/302">#302</a>).</li><li>Prevent gopherjs command from misbehaving unnecessarily when GOARCH environment variable is set to an unexpected value (<a href="https://github.com/gopherjs/gopherjs/issues/594">#594</a> and <a href="https://github.com/gopherjs/gopherjs/issues/601">#601</a>).</li><li>Support for gopherjs test --count flag. It behaves like the equivalent flag in go test command.</li><li>Improved example execution allows additional examples to run without deadlocking (<a href="https://github.com/gopherjs/gopherjs/issues/529">#529</a>).</li><li>Improved determinism in code generation, removing a difference in output when compiling the same program.</li></ul><p>Thank you to all contributors who have helped with this release, whether that’s by improving documentation, investigating and <a href="https://github.com/gopherjs/gopherjs/issues?q=is%3Aissue+is%3Aclosed">resolving issues</a>, <a href="https://github.com/gopherjs/gopherjs/compare/b9bcb1da229a59cc1e1d168401662cb6450aae08...fe63fb1b9957f490d5011c8bb0a254db64e6a138">contributing code</a> and maintaining <a href="https://github.com/gopherjs/gopherjs/wiki/bindings">bindings to browser APIs</a>. It is greatly appreciated. We welcome all help; if you’d like to get involved, see the <a href="https://github.com/gopherjs/gopherjs#community">community section</a>. If you have a good experience with GopherJS, tell your fellow gophers about it and share your GopherJS-powered projects!</p><p>If you’d like to get started with GopherJS, here are some next steps you can take:</p><ul><li>Try it right now in your browser with the <a href="http://www.gopherjs.org/playground/#/9BFl7LuHv-">GopherJS Playground</a>.</li><li>Use the <a href="https://github.com/gopherjs/gopherjs#gopherjs-serve">gopherjs serve command</a> and execute your favorite Go package in the browser.</li><li>Join the <a href="https://gophers.slack.com/messages/gopherjs/">#gopherjs channel</a> on <a href="https://invite.slack.golangbridge.org/">Gophers Slack</a> for GopherJS-related chat.</li></ul><p>Happy surfing with Go 1.9 and GopherJS 1.9-1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4d808e58f19" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-9-1-is-released-e4d808e58f19">GopherJS 1.9-1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.8-1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-8-1-is-released-b4473712ab95?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/b4473712ab95</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Fri, 17 Feb 2017 21:45:26 GMT</pubDate>
            <atom:updated>2017-02-17T21:52:11.225Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are happy to announce the release of GopherJS 1.8-1. You can <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">get it on GitHub</a>. It adds support for the <a href="https://blog.golang.org/go1.8">recent release of Go 1.8</a>. There have been significant performance improvements and enhancements since GopherJS 1.7-1.</p><p>The support for Go 1.8 means that GopherJS 1.8-1 requires Go 1.8 and no longer works with Go 1.7. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot upgrade from Go 1.7 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/tree/go1.7">go1.7 branch</a>.</p><p>Installation or upgrade steps remain the same as before. To get the latest official stable release of GopherJS, please <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">follow the instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.8-1.</p><p>GopherJS 1.8-1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.7 version is still supported, as are many of the additions that are new to Go 1.8. If you run into any bugs or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">file an issue</a>.</p><p>Some of the highlights of changes that have gone into the new release include:</p><ul><li>GopherJS now <a href="https://github.com/gopherjs/gopherjs/pull/584">generates more optimized code for bounds checking</a>. It has led to significant performance increases, up to 20–50% as measured by go1 benchmarks. It helps fmt, regexp, crypto and slice manipulation heavy code the most.</li><li>A bug in combination of defer and blocking code <a href="https://github.com/gopherjs/gopherjs/commit/50101461d59f26b13c876f57aab314ce55387671">has been fixed</a>.</li><li>Examples (ExampleFoo()) are now <a href="https://github.com/gopherjs/gopherjs/pull/528">supported and executed during tests</a>.</li><li>Support for <a href="https://github.com/gopherjs/gopherjs/pull/508">build tags</a> and <a href="https://github.com/gopherjs/gopherjs/pull/578">--benchtime parameter</a> for thegopherjs test command has been added.</li><li>In package net/http, <a href="https://github.com/gopherjs/gopherjs/pull/535">request’s context is now used for request cancelation</a>.</li><li>Some situations where errors should be reported, but weren’t, are now fixed (e.g., <a href="https://github.com/gopherjs/gopherjs/commit/e34a5cd6a1bc7c4fde759f2d3039852fc68b5fcc">string bounds checking</a> and <a href="https://github.com/gopherjs/gopherjs/commit/f3471911039c5eec1b0ea655c810e25cd736560f">assignment to underscore</a>).</li><li>Various improvements to GopherJS error messages, exit codes, source maps, documentation, limitations, and contributing guidelines have been made.</li></ul><p>Thank you to all contributors who have helped with this release, whether that’s by improving documentation, helping <a href="https://github.com/gopherjs/gopherjs/issues?q=is%3Aissue+is%3Aclosed">resolve issues</a>, <a href="https://github.com/gopherjs/gopherjs/compare/45518c130e5bd1525f20110830a4986365a153de...16fddcc8fbbe8b9e97e3837bace35b5120c6030e">contributing code</a> and maintaining <a href="https://github.com/gopherjs/gopherjs/wiki/bindings">bindings to browser APIs</a>. It is greatly appreciated. We welcome all help; if you’d like to get involved, see the <a href="https://github.com/gopherjs/gopherjs#community">community section</a>. If you have a good experience with GopherJS, tell your fellow gophers about it!</p><p>If you’d like to get started with GopherJS, here are some next steps you can take:</p><ul><li>Try it right now in your browser with the <a href="http://www.gopherjs.org/playground/#/-MweO3kLBk">GopherJS Playground</a>.</li><li>Use the <a href="https://github.com/gopherjs/gopherjs#gopherjs-serve">gopherjs serve command</a> and execute your favorite Go package in the browser.</li></ul><p>Happy surfing with Go 1.8 and GopherJS 1.8-1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4473712ab95" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-8-1-is-released-b4473712ab95">GopherJS 1.8-1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GopherJS 1.7–1 is released]]></title>
            <link>https://medium.com/gopherjs/gopherjs-1-7-1-is-released-39b7d85dfdc4?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/39b7d85dfdc4</guid>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Sun, 22 Jan 2017 22:02:00 GMT</pubDate>
            <atom:updated>2017-02-17T05:25:56.210Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello gophers,</p><p>Today, we are happy to make two announcements for GopherJS. First, GopherJS now officially supports Go 1.7, which is the current stable release of Go that came out recently. Second, GopherJS has its first named version attached to it, and we’re calling it GopherJS 1.7–1. This makes it possible to have a release history tracking major changes and additions between versions.</p><p>The support for Go 1.7 means that GopherJS 1.7–1 requires Go 1.7 and no longer works with Go 1.6. It’s highly recommended to be using the latest version of Go and GopherJS, but if you cannot update from Go 1.6 right away, you should continue to use GopherJS on the <a href="https://github.com/gopherjs/gopherjs/commits/go1.6">go1.6 branch</a>.</p><p>GopherJS 1.7–1 continues to support nearly everything of the <a href="https://golang.org/ref/spec">Go language specification</a>, including goroutines. Please consult the <a href="https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md">package compatibility table</a> to see which standard library packages are supported. Everything from the previous Go 1.6 version is still supported, as are many additions to Go 1.7, but there are some exceptions. For example, the new <a href="https://godoc.org/reflect#StructOf">reflect.StructOf function</a> is not yet supported, but <a href="https://github.com/gopherjs/gopherjs/issues/499">issue #499</a> tracks its implementation status. If you run into any bugs or discrepancies with what the compatibility table says, please <a href="https://github.com/gopherjs/gopherjs/issues">file an issue</a>.</p><p>Installation or upgrade instructions remain the same, even though GopherJS has a version number now. To get the latest official stable release, please follow the <a href="https://github.com/gopherjs/gopherjs#installation-and-usage">instructions in the README</a>. You can confirm that you have the right version if gopherjs version prints GopherJS 1.7-1.</p><p>Over the last few years, GopherJS has become increasingly complete and stable. Many advanced features of the Go language specification were implemented (such as goroutines, channels, and select statements). More and more of the viable standard library packages had all their tests pass and became officially supported. Many bugs were reported, investigated, and fixed. Today, it is used by many people for a broad range of projects.</p><p>However, many of those improvements to GopherJS were done quietly and internally, so only developers and people who follow the project very closely would become aware. Without a version number and release history, it’s harder for newcomers or people waiting for a stable release to have insight on the readiness state of GopherJS. With this version number and future release history, we hope to better communicate the maturity level of GopherJS and the fact that you can get started with it today.</p><p>In closing, we would like to thank everyone who contributed to this release of GopherJS. The Go team created and released Go 1.7. Richard Musiol created and implemented the core parts of GopherJS and Go 1.7 support. Many people have contributed code and bug fixes, reported/investigated/helped reproduce issues, created libraries and wrappers for various browser APIs. Everyone’s effort has helped get GopherJS to where it is today, giving us the opportunity to write front-end code in Go which will run in all modern browsers. See <a href="https://github.com/gopherjs/gopherjs/graphs/contributors">list of code contributors</a> and <a href="https://github.com/gopherjs/gopherjs/issues?q=is%3Aissue+is%3Aclosed">list of closed issues</a>. We welcome all help; if you’d like to get involved, see the <a href="https://github.com/gopherjs/gopherjs#community">community section</a>. If you have a good experience with GopherJS, tell your fellow gophers about it!</p><p>If you’d like to get started with GopherJS, here are some next steps you can take:</p><ul><li>Try it right now in your browser with the <a href="http://www.gopherjs.org/playground/#/-MweO3kLBk">GopherJS playground</a>.</li><li>Begin creating your web app using the <a href="https://github.com/gopherjs/gopherpen#readme">gopherpen template project</a> as a starting point.</li></ul><p>Happy surfing with Go 1.7 and GopherJS 1.7–1!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39b7d85dfdc4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/gopherjs-1-7-1-is-released-39b7d85dfdc4">GopherJS 1.7–1 is released</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Surprises in GopherJS Performance]]></title>
            <link>https://medium.com/gopherjs/surprises-in-gopherjs-performance-4a0a49b04ecd?source=rss----1d6966d814e3---4</link>
            <guid isPermaLink="false">https://medium.com/p/4a0a49b04ecd</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dmitri Shuralyov]]></dc:creator>
            <pubDate>Sun, 22 Jan 2017 21:49:07 GMT</pubDate>
            <atom:updated>2017-01-22T21:49:06.905Z</atom:updated>
            <content:encoded><![CDATA[<p>The GopherJS project first caught my attention about 2 years ago, back when few parts of the Go spec were implemented. However, I noticed the incredible pace at which Richard was working, making multiple sophisticated commits per day, as well as fixing reported compiler issues within hours. A few months later, I decided to download it and give it try on a relatively <a href="https://godoc.org/github.com/shurcooL/markdownfmt/markdown?import-graph&amp;hide=1">large pure Go package</a> for formatting Markdown, and I was quite shocked when it… <a href="https://github.com/shurcooL/atom-markdown-format/commit/6b5f21c4457309f8eba3a78b82e0c9a458ff13b4">simply worked</a>.</p><p>Since then, GopherJS has made significant progress, both in feature support (by now, full support for goroutines, channels, select statement, and the rest of the Go language spec), as well as quite a few performance leaps. For example, in <a href="https://github.com/gopherjs/gopherjs/issues/142">issue 142</a>, I reported a case where the GopherJS performance was pretty bad, taking nearly 30 seconds to do what native Go did in under 100 ms. Fast forward just a few days later, and Richard came up with optimizations that lead to a <a href="https://github.com/gopherjs/gopherjs/issues/142#issuecomment-68664354">10x improvement</a> in performance!</p><p>One day, I was perusing the golang.org home page and decided to play with the <a href="https://play.golang.org/p/RdbPXQcZHi">concurrent pi</a> sample. I wanted to see how much overhead using goroutines was (they were used to demonstrate how lightweight they are compared to threads, but it’s still suboptimal for performance), so I converted the program to a purely iterative one. It looked like this:</p><pre>// Play with benchmarking a tight loop with many iterations and a func call, compare gc vs GopherJS performance.<br>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;math&quot;<br>    &quot;time&quot;<br>)<br><br>func term(k float64) float64 {<br>    return 4 * math.Pow(-1, k) / (2*k + 1)<br>}<br><br>// pi performs n iterations to compute an approximation of pi using math.Pow.<br>func pi(n int32) float64 {<br>    f := 0.0<br>    for k := int32(0); k &lt;= n; k++ {<br>        f += term(float64(k))<br>    }<br>    return f<br>}<br><br>func main() {<br>    // Start measuring time from now.<br>    started := time.Now()<br><br>    const n = 50 * 1000 * 1000<br>    fmt.Printf(&quot;approximating pi with %v iterations.\n&quot;, n)<br>    fmt.Println(pi(n))<br><br>    fmt.Println(&quot;total time taken is:&quot;, time.Since(started))<br>}</pre><p>I ran the program on my computer:</p><pre>$ go run main.go<br>approximating pi with 50000000 iterations.<br>3.1415926735902504<br>total time taken is: 8.358498915s</pre><p>8.35 seconds to perform 50 million iterations, not bad. Then I got curious how long it would take if compiled to JavaScript via GopherJS.</p><p>I realized that this is a very tight loop, so any overhead incurred by the conversion of Go to JavaScript would be multiplied and be very visible. Still, I was curious, so fired up GopherJS and ran the same program by compiling it to JavaScript and running it with node:</p><pre>$ gopherjs run main.go<br>approximating pi with 50000000 iterations.<br>3.1415926735902504<br>total time taken is: 2.317s</pre><p>23 seconds, that’s actually… wait, WHAT!?</p><p>2.3 seconds! That’s 4 times faster than the native Go version. For a few minutes, I looked at the two numbers in disbelief. Then I decided to investigate what’s going on. Is the same code running in both cases? Is the program correct? Is node doing something weird?</p><p>I tried running it in the GopherJS Playground, which you can also do at:</p><p><a href="https://gopherjs.github.io/playground/#/K7r0-q_Jwc">https://gopherjs.github.io/playground/#/K7r0-q_Jwc</a></p><p>And got the same time in Chrome browser (stable channel).</p><p>The calculated value of pi was the same, and after adding some debugging statements I was sure the calculation was indeed correct, and iterations were not being skipped.</p><p>But how could it be that taking this Go program and compiling it to JavaScript and executing that would be 4 times faster? I had to get to the bottom of it.</p><p>The first thing I needed to ensure, was the same code being run in both cases? The entire code is plain Go, with the exception of math.Pow. So I looked at how <a href="http://gotools.org/math#Pow">Go implements it</a>. Pretty straightforward Go code. Now I knew GopherJS uses some JavaScript native APIs to implement parts of the standard library, so I checked how <a href="https://github.com/gopherjs/gopherjs/blob/master/compiler/natives/math/math.go#L157">it implemented </a><a href="https://github.com/gopherjs/gopherjs/blob/master/compiler/natives/math/math.go#L157">math.Pow</a>. Aha! It&#39;s not the same code after all. GopherJS implements it by using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math">JavaScript&#39;s </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math">Math object</a>, so it translates to the following JavaScript code:</p><pre>Math.pow(x, y)</pre><p>That’s when it hit me. In this code, which was taken from a snippet that optimized for brevity and demonstration purposes rather than performance, math.Pow was being used with the first argument of -1, and the second argument are values 0, 1, 2, 3, etc., in sequence. The output of that is an alternating sequence of 1, -1, 1, -1, 1, -1, etc. But using math.Pow for that is extremely inefficient, since it&#39;s meant to work with arbitrary inputs that are much harder to calculate. This can be trivially rewritten with an if statement.</p><p>So, in order to ensure the same code runs in both cases, I did that and tried this program:</p><pre>// Play with benchmarking a tight loop with many iterations and a func call, compare gc vs GopherJS performance.<br>//<br>// An alternative more close-to-metal implementation that doesn&#39;t use math.Pow.<br>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br><br>func term(k int) float64 {<br>    if k%2 == 0 {<br>        return 4 / (2*float64(k) + 1)<br>    } else {<br>        return -4 / (2*float64(k) + 1)<br>    }<br>}<br><br>// pi performs n iterations to compute an approximation of pi.<br>func pi(n int) float64 {<br>    f := 0.0<br>    for k := int(0); k &lt;= n; k++ {<br>        f += term(k)<br>    }<br>    return f<br>}<br><br>func main() {<br>    // Start measuring time from now.<br>    started := time.Now()<br><br>    const n = 1000 * 1000 * 1000<br>    fmt.Printf(&quot;approximating pi with %v iterations.\n&quot;, n)<br>    fmt.Println(pi(n))<br><br>    fmt.Println(&quot;total time taken is:&quot;, time.Since(started))<br>}</pre><p>Let’s try that:</p><pre>$ go run main.go<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br>total time taken is: 10.916861037s<br><br>$ gopherjs run main.go<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br>total time taken is: 6.585s</pre><p>I had to bump up the number of iterations to 1 billion, because this code runs so much faster than the naive math.Pow-using version, in both cases. But GopherJS version is still faster.</p><p>Aha, then I realized that <a href="https://github.com/gopherjs/gopherjs#architecture">GopherJS emulates a 32-bit architecture</a>. But I’m running native Go on a 64-bit machine. So the size of int is 32-bit for GopherJS code but 64-bit for Go code. Let&#39;s make it use int32 consistently and try again:</p><pre>$ go run main.go<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br>total time taken is: 6.658s<br><br>$ gopherjs run main.go<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br>total time taken is: 6.549s</pre><p>As expected, the GopherJS time did not change because it was a no-op, but the native Go performance has now caught up to the GopherJS version!</p><p>Just to be sure, I wanted to see if 6.5 seconds was as fast as these 1 billion iterations could happen, even if you were to implement this in a low-level language like C:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;time.h&gt;<br><br>double term(int k) {<br>    if (k%2 == 0) {<br>        return 4.0 / (2.0*(double)(k) + 1.0);<br>    } else {<br>        return -4.0 / (2.0*(double)(k) + 1.0);<br>    }<br>}<br><br>// pi performs n iterations to compute an approximation of pi.<br>double pi(int n) {<br>    double f = 0.0;<br>    for (int k = 0; k &lt;= n; k++) {<br>        f += term(k);<br>    }<br>    return f;<br>}<br><br>int main() {<br>    int n = 1000 * 1000 * 1000;<br>    printf(&quot;approximating pi with %d iterations.\n&quot;, n);<br>    printf(&quot;%.16f\n&quot;, pi(n));<br><br>    return 0;<br>}</pre><p>The <a href="http://en.cppreference.com/w/c/chrono">timing library</a> of C isn’t as friendly to use as the Go time package, so I gave up and just used time instead:</p><pre>$ gcc main.c<br>$ time ./a.out<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br><br>real    0m11.385s<br>user    0m11.377s<br>sys     0m0.006s</pre><p>11.3 seconds? Slower? Ah, of course, I was too used to go build tool that uses optimization by default, and forgot that C compilers don&#39;t do that.</p><pre>$ gcc -O3 main.c<br>$ time ./a.out<br>approximating pi with 1000000000 iterations.<br>3.1415926545880506<br><br>real    0m6.434s<br>user    0m6.427s<br>sys     0m0.004s</pre><p>Nice, it’s the same time as the Go and GopherJS versions. That means a few things.</p><p>The V8 JavaScript engine is incredible. It’s able to take Go code that is compiled to JavaScript code, and just-in-time compile to it to machine instructions that are as efficient as the native Go compiler.</p><p>The JavaScript Math.pow implementation is faster when value of x is -1 and values of y are integers. I haven&#39;t compared its performance for other inputs; let me know if you do. However, using Pow with such inputs is silly and should not be done, as you can see by the 50 million to 1 billion iteration increase when rewriting it with an equivalent if statement.</p><p>You can try the final optimized version of GopherJS in your browser via the GopherJS Playground:</p><p><a href="https://gopherjs.github.io/playground/#/sDEYM2TwC7">https://gopherjs.github.io/playground/#/sDEYM2TwC7</a></p><p>It’s fascinating to think about what happens when you do that. The GopherJS compiler, written in pure Go, has compiled itself to JavaScript, which runs in your browser. That compiler takes your input Go program, compiles it to JavaScript and runs it. The V8 engine (or whatever JavaScript engine your browser uses) takes the generated JavaScript and JITs it to the equivalent machine code as produced by a low-level C implementation compiled with -O3, the max optimization setting.</p><p>There are still cases where the code GopherJS generates does not translate to something JS engines can optimize really well. For example, in <a href="https://github.com/gopherjs/gopherjs/issues/276">issue 276</a>, GopherJS version runs an unusually 1000x slower than native version. But I’m sure with some work, significant performance improvements can be made there, and in most other cases the performance is much better.</p><p>With the prospects of asm.js and the upcoming WebAssembly, I think there’s a bright future for having Go language as a viable choice for the browser. I suggest you give it a try for your next little frontend project, or play with compiling any pure Go package to run in the browser. You may end up being pleasantly surprised, like I was.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a0a49b04ecd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gopherjs/surprises-in-gopherjs-performance-4a0a49b04ecd">Surprises in GopherJS Performance</a> was originally published in <a href="https://medium.com/gopherjs">GopherJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>