HNHacker News
TopNewBestAskShowJobs

jamespwilliams

2,548 karma · joined August 15, 2020

https://github.com/jamespwilliams

Submissions != endorsements

submissionscomments
jamespwilliams··on Trying Out Generics in Go
You can use type parameters in functions, but not methods. Methods are functions which have a receiver, so:

    // This is a function, you can use type parameters here:
    func Foo[T any](g T) { ... }
    
    type bar struct {}

    // This is a method, you can't use type parameters here:
    func (b bar) Foo[T any](g T) { ... }
In the second case, "Foo" is a method which has a "bar" instance as a receiver.

I've edited my original post to make it a bit clearer.

jamespwilliams··on Trying Out Generics in Go
One annoying bit about Go's generics is that you can use type parameters in functions, but not in methods.

So for example, maybe you'd want to write a Map function for the Optional type in this article, which returns None if the option is None, or calls a given function with the value of the Optional otherwise.

You'd probably write it like this:

    func (o Option[T]) Map[U any](f func(a T) U) Option[U] { ... }
But that doesn't work: "option/option.go:73:25: methods cannot have type parameters"

The type inference is also a bit limited, e.g: let's say you have a None method:

    func None[T any]() Option[T] { ... }
And you call it somewhere like:

    func someFunction() option.Option[int] {
        if (!xyz) {
            return option.None()
        }
        // ...
    }
it isn't able to infer the type, so you have to instead (in this case) write option.None[int]().

Generics is a super cool addition anyway though.

Edit: I just found https://go.googlesource.com/proposal/+/refs/heads/master/des... which has some details on why method type parameters aren't possible.

jamespwilliams··on The growth of command line options, 1979-Present (2020)
On the latter, an example that comes to mind is how to specify field numbers: -f in cut, -k in sort, -j for the most common option in join.

And specifying field delimiters: -d in cut, -t in sort, -F in awk.

jamespwilliams··on Go Replaces Interface{} with 'Any'
I’m not a typescript person, but to be fair to typescript, its type system is still much more expressive than Go’s, even with the generics addition
jamespwilliams··on Go Replaces Interface{} with 'Any'
Loading this commit in safari almost killed my phone
jamespwilliams··on Tictactoe in PyFL, my experimental functional language
I _think_ (but unsure) that it should be read “followed by”, and only makes sense in the context of a while loop, where `x = y fby z` means that x will take the value of y on the first iteration and z on subsequent iterations.
jamespwilliams··on Log4j RCE Found
There is also http://www.dnslog.cn/
jamespwilliams··on Rockstar: a language for programs that are also hair metal power ballads
> Tommy used to work on the docs.

Nice

jamespwilliams··on Ask HN: 1Password Alternatives
Bitwarden. The free tier is sufficient for personal use in my experience, although I choose to pay the small fee for “premium” (I forget what they cal it).

I switched from lastpass after they removed their free tier and have never looked back.

It is free and open-source software, it looks good and works well across all the platforms I use.

jamespwilliams··on Show HN: Get the guitar chords from your Spotify playlists
If anyone knows of a free and open-source guitar tab sharing site, I'd be interested.

I wrote some tabs recently and ended up just putting them on my personal website. Hopefully people will search via Google and find them.

jamespwilliams··on How to use dig
TIL .digrc
jamespwilliams··on Euler’s number pops up in situations that involve optimality
This was probably the result of HN's autocapitalisation of post titles. The title of the article itself uses lowercase e. In any case, the title has been changed now.
jamespwilliams··on How to build a low-tech website? (2018)
The Google SRE book, which I think is a reasonable reflection of SRE culture generally, actually mentions this in the very first chapter.
jamespwilliams··on We memo all the things (2020)
Kind of makes you wonder why React.memo isn't just the default behaviour.

https://github.com/facebook/react/issues/14463#issuecomment-... suggests it was meant to be the default behaviour, but was scrapped because it would "break backwards compatibility". No source is given for that claim though.

jamespwilliams··on New Brunswick’s Mystery Disease
CJD is almost always a clinical diagnosis. MRIs and lumbar punctures give hints, but aren’t conclusive.

The only way to diagnose conclusively is via a brain biopsy, which apparently isn’t worth the risk in most cases. Conclusive diagnosis is often done post-mortem.

(my girlfriend works in this area)

jamespwilliams··on An enormous thread on alleged Google Facebook collusion
https://en.m.wikipedia.org/wiki/Emergence
jamespwilliams··on Why this Website is not, and may never be, HTTPS
Okay, sure, if you don't care about the visitors to your site, don't bother with HTTPS.

Personally, I don't want visitors to my site having adverts injected by their ISPs or public wifi networks they're connected to. I don't want to needlessly expose my visitors to having malicious JS being run on their machines. I don't want a MITM to be able to change the text that a visitor receives on my website, and make the reader believe that I said something I didn't say. Especially when the fix for all of this is incredibly simple and introduces only a miniscule overhead.

https://www.troyhunt.com/heres-why-your-static-website-needs...

jamespwilliams··on Tools to Explore BGP
RIPEStat’s already been mentioned here I see.

I recommend bgp.he.net and bgp.tools too - they are simpler and more lightweight than RIPEStat, so they’re nice to use when you don’t need all the features of RIPEStat.

jamespwilliams··on Facebook-owned sites were down
Is this caused by missing glue records? I can’t resolve any of FB’s nameservers. Anyone know how that could happen?
jamespwilliams··on Show HN: Hacker News client with a twist
Looks good and works well. Browsing with Vimium is good enough for me though, and means I can reuse muscle memory to/from other sites.
jamespwilliams··on It's tough being an Azure fan
Yes. We found a problem with Azure’s IPv6 support a while back.

It took quite literally months to get the issue escalated to someone who could do anything about it, and as far as I know it’s still broken, although it’s scheduled to be fixed this year. We had to pay for this “support” too. We worked around the problem in the end, but still.

jamespwilliams··on HTTP Status 418 – I'm a teapot
http.StatusTeapot in Go: https://pkg.go.dev/net/http#pkg-constants

4k+ results on Github: https://github.com/search?utf8=&q=http.StatusTeapot&type=Cod...; ~600 excluding _test.go files: https://github.com/search?q=http.StatusTeapot+-filename%3A*_...

jamespwilliams··on Go’ing Insane: Endless Error Handling
I haven’t used Rust. Does the ? operator add some kind of stack trace to the error? If not, how do you know where the error has come from?

Having a Result type with statically enforced checking sounds good though.

jamespwilliams··on Go’ing Insane: Endless Error Handling
Maybe it’s just Stockholm Syndrome, but IMO Go’s “verbose” error handling approach is a feature, not a bug. I think the expectation that every single error is handled and (importantly) wrapped explicitly is one of the reasons why Go and the Go ecosystem in general is conducive to writing robust and resilient systems. When writing Go, error handling is at the forefront of my mind, and not an afterthought, as it can be in other languages.
jamespwilliams··on What they don’t tell you when you translate your app
I’ve noticed a few other German-English anomalies in my time around German people. First is “some-” instead of “any-”. Second is the use of “since”, e.g: “I’ve been working here since 8 years”. Present tense confusion - e.g: “I’m having” instead of “I have” - my understanding is that in German there is only one present tense, whereas English has a few subtly different ones, so it’s not surprising that some confusion ensues. “Driving a bike” is always funny. Saying “with X years” instead of “aged X years”.

In all of those cases it’s still obvious what the person means. And to be clear I don’t mean to pick on anyone here, I just find the language differences interesting. Far be it from me to judge - I can barely speak one language, let alone two.

jamespwilliams··on Ok, so you can’t decide
Cunningham’s Law IRL
jamespwilliams··on The mutation that helps Delta spread
See https://www.gov.uk/government/publications/covid-19-variants...
jamespwilliams··on France issues moratorium on prion research after fatal brain disease strikes
The word "prion" is actually a contraction of the words "protein" and "infection". (edit: although I agree it's not what one might conventionally think of as an "infection")
jamespwilliams··on France issues moratorium on prion research after fatal brain disease strikes
Hm:

"long period of uncertainty began on 31 May 2010, when she stabbed her left thumb with a curved forceps while cleaning a cryostat—a machine that can cut tissues at very low temperatures—that she used to slice brain sections from transgenic mice infected with a sheep-adapted form of BSE. She pierced two layers of latex gloves and drew blood"

Later in the article:

""We conduct research only on mouse-adapted sheep prions, which have never been shown to be infectious to humans,” Aguzzi [neuropathologist at the University of Zurich] says."

It sounds like the assumption that mouse-adapted sheep prions can't infect humans may be flawed.

jamespwilliams··on Akamai Edge DNS was down
Back up now by the looks of it
← PreviousPage 4 of 5Next →