HNHacker News
TopNewBestAskShowJobs

aodin

474 karma · joined July 14, 2011

https://aaronoellis.com https://github.com/aodin
submissionscomments
aodin··on How to start a Go project in 2018
Using the `golang:1.10-alpine` image to run your binary would defeat the purpose of a multi-stage build, since it includes everything needed to compile Go and weighs in around 376MB. The `alpine:3.7` image is about 4MB.

edit

I misunderstood the parent, they meant to use `golang:1.10-alpine` as the build image, not the run image, as in:

    FROM golang:1.10-alpine
    COPY . /go/src/bitbucket.code.company-name.com.au/scm/code
    WORKDIR /go/src/bitbucket.code.company-name.com.au/scm/code/
    RUN go build main.go

    FROM alpine:3.7
    RUN apk add --no-cache ca-certificates
    COPY --from=0 /go/src/bitbucket.code.company-name.com.au/scm/code/main .
    CMD ["./main"]
Which works! Thank you!
aodin··on How to start a Go project in 2018
As the parent mentions, vgo is still very experimental. But if you'd like to try it out (or contribute!), I recommend the following links:

The official Go issue: https://github.com/golang/go/issues/24301

And Russ Cox's Tour of vgo: https://research.swtch.com/vgo-tour

Which is part of Russ Cox's vgo series: https://research.swtch.com/vgo

aodin··on How to start a Go project in 2018
If you're using Go with Docker 17.05 or higher, I recommend a multi-stage Docker build. Official documentation here: https://docs.docker.com/develop/develop-images/multistage-bu...

The default Go Docker images include everything needed to compile Go. But once you have a binary, you really only need an image capable of running your binary. I've seen images sizes reduced by over 95%.

Revising the example in the article:

    FROM golang:1.10
    COPY . /go/src/bitbucket.code.company-name.com.au/scm/code
    WORKDIR /go/src/bitbucket.code.company-name.com.au/scm/code/
    RUN CGO_ENABLED=0 go build main.go

    FROM alpine:3.7
    RUN apk add --no-cache ca-certificates
    COPY --from=0 /go/src/bitbucket.code.company-name.com.au/scm/code/main .
    CMD ["./main"]
The `CGO_ENABLED=0` and `apk` are oddities of Alpine Linux specifically. The image you choose to run your binary may not need these.
aodin··on Practical Go benchmarks
The majority of the performance difference between strings concat and builder in your example is explained by memory allocation. Every loop of concat will result in a new allocation, while the builder - which uses []bytes internally - will only allocate when length equals capacity, and the newly allocated slice will be approx. twice the capacity of the old slice (see: https://golang.org/src/strings/builder.go?#L62).

Therefore, 500,000 rounds of concat is about 500,000 allocations, while 200,000,000 rounds of builder is ~ 27.5 allocations (=log2(200000000)).

I would suggest a different benchmark to approximate real world usage:

    func BenchmarkConcatString(b *testing.B) {
        for n := 0; n < b.N; n++ {
            var str string
            str += "x"
            str += "y"
            str += "z"
        }
    }

    func BenchmarkConcatBuilder(b *testing.B) {
        for n := 0; n < b.N; n++ {
            var builder strings.Builder
            builder.WriteString("x")
            builder.WriteString("y")
            builder.WriteString("z")
            builder.String()
        }
    }
Which still shows a significant performance advantage for using builder (-40% ns/op):

    BenchmarkConcatString-4     20000000            93.5 ns/op
    BenchmarkConcatBuilder-4    30000000            54.6 ns/op
aodin··on China Blocks WhatsApp
> At a White House dinner in 2015, Mr. Zuckerberg had even asked the Chinese president, Xi Jinping, whether Mr. Xi might offer a Chinese name for his soon-to-be-born first child — usually a privilege reserved for older relatives, or sometimes a fortune teller. Mr. Xi declined, according to a person briefed on the matter.

https://www.nytimes.com/2017/09/17/technology/facebook-gover...

aodin··on Bitcoin Is Likely to Split Again in November, Say Major Players
Matt Levine wrote a great article about the side effects of the split and how various exchanges handled it: https://www.bloomberg.com/view/articles/2017-08-02/bitcoin-e...
aodin··on Email Address Disclosures, Preliminary Report
I was part of the disclosed list and can confirm that this is exactly what happened (plus an extra newline!)
aodin··on Qb: Database toolkit for Go
In https://github.com/aodin/sol#sol I separated the table schema, which is a function, from the destination / receiver structs. This approach allows you to build tables programmatically and do condensed selections, such as all IDs into a []int. However, this process still has to match database columns to struct field names for most selections.
aodin··on A Review of Her by Ray Kurzweil
Plutarch described this paradox of gradual replacement in the ship of Theseus: http://en.wikipedia.org/wiki/Ship_of_Theseus
aodin··on Replacing Clever Code with Unremarkable Code in Go
Russ Cox, one of programmers working on Go, described the dilemma as: "do you want slow programmers, slow compilers and bloated binaries, or slow execution times?"

He expanded on this dilemma with examples from major languages: http://research.swtch.com/generic

aodin··on How I develop Django projects
Django 1.4 introduced custom templates for projects and applications. Useful for when you've settled on a file structure: https://docs.djangoproject.com/en/dev/ref/django-admin/#djan...
aodin··on Want A Great Team? Focus On Talent, Not Hiring
The author has the right idea with the first item. Time, trust, and communication are essentials in hiring.

But flying this under the banner of "talent" is bordering on link-bait. Look at all the points he makes about hiring a "talented" individual:

* "...we’re asking whether you have the mettle to be part of an elite team."

* "A new hire won’t come up with something mind blowing if the team doesn’t bring the new hire up to speed quickly."

* "I don’t necessarily expect a new hire to do something amazing while he or she works with us."

* "A new hire won’t do something amazing, now or in the future, if the organization he or she works for doesn’t hold up its end of the bargain."

None of this is about talent. It's about a supportive ecosystem and cohesive team.

"Talent" is just a label that HR applies to people they think will succeed in an organization, and an after-the-fact definition when an individual has found success in his or her role. And it's been my experience that those two groups are far from congruent.

aodin··on Windows 8 Developer Preview is Live
Additional note for networking: I had to set the virtual NIC to "Bridged Adapter" and the type to "Intel PRO/1000 MT Desktop".

Besides that, the guide worked great, thanks! (I'm on Ubuntu 11.04 and VirtualBox 4.1.2)

aodin··on Renting vs Buying, Foreclosures and Job Growth across 50 US Cities
Any chance you can install chrome frame? It no longer requires admin access: http://code.google.com/chrome/chromeframe/
aodin··on Detroit in Ruins
I'm an alum of UofM.

If graduates do stay in Michigan, it's to continue working or studying in the Ann Arbor area. Only a handful do find jobs in the metro Detroit area (mainly engineers and consultants), but that's a trickle opposed to the flood.

Detroit's premier college is Wayne State University, and I can not speak for its graduates.

aodin··on Who Rules America: An Investment Manager's View on the Top 1%
To those curious about this claim, I would recommend Nomi Prin's "It takes a Pillage". She, a former manager at Goldman Sachs, makes a strong argument for the bailouts being criminal.
← PreviousPage 3 of 3