Better HN
topnewbestaskshowjobs
Log inSign up

coder543

6,699 karma · joined Jul 18, 2012 (14y ago) · 1,967 submissions

My email is at gmail using my username.

Backend-focused full-stack engineer with 8+ years of experience, mostly focused on Go, Rust, and TypeScript, but open to other options.

Resume: https://drive.google.com/file/d/1VNC272B3n7ZEfppMHkm2wGgaINwYl4Av/view

Submissions

comment 6y ago · link · parent

> Ets is built with shared memory, yes, but interaction with your code is as if you were messaging a table process

To me, this is a distinction without difference.

Shared, mutable memory access without some form of synchronization is a bug and is always invalid.

You either hold a lock the entire time you're using a shared value, or you use a lock to take a copy of the value and then go about your business. With the singular exception of atomic values, the value should never change while you have it without you taking an explicit action to update it, and atomics are rarely used outside of either metric tracking or very specialized code. Besides atomics, everything you described about ETS is the same as any shared memory system.

comment 6y ago · link · parent

I watched that talk just now, and it was basically a retelling of everything I really like about Go. Except, Go is statically typed, and a lot faster than BEAM in benchmarks that I've seen. Go is also a very "normal" language, so it's usually easy to onboard developers into it, no matter what their background is. JetBrains GoLand makes the IDE experience essentially impeccable. I can refactor code with a few clicks, and GoLand precisely updates all references thanks to the static type system.

Go can run massive numbers of Goroutines on a single system, and it preemptively timeslices individual Goroutines, so I'm never worried about any single task preventing other tasks from making progress, which was like 75% of that talk.

Go has a fantastic production runtime debuggability story, which was the other 25% of that talk.

Go's pprof support feels magical: https://golang.org/pkg/net/http/pprof/

You can connect to running systems and see flamegraphs of where CPU time is being spent, you can take traces of the goroutines to understand why the system is idle when you think it shouldn't be, you can see how much memory different parts of the system are using, and so much more. It's not mentioned as prominently as I think it should be, but `go tool pprof` has this `-http=:` option that will open a web browser to let you just see everything graphically and click around, and it's an amazing experience.

There were really only three things in there that Go doesn't offer:

1. Forcefully terminating processes

Go doesn't allow anyone to forcefully terminate a Goroutine except the Goroutine itself. Personally, if I identified a buggy Goroutine, I would just focus on writing a patch and deploying it. Manually terminating a process is cool, but then the user types "-1" again and again, and you're just sitting there playing whack-a-mole instead of fixing the problem and deploying the fix.

2. Patching the running system without restarting it

The advantages of this are difficult to enumerate. It sounds nice and clean conceptually, but I would worry about existing processes / goroutines being in unexpected states because of erroneous code that they had previously run. Having a way to gracefully shut down a system and restart it without abruptly terminating responsive client connections is much more predictable to me.

3. Seamlessly distributed execution

He briefly talks about distributed Erlang towards the end of the talk. but mentions that it has serious problems and that a number of people don't recommend using it in production. Personally, even if it were nearly perfect, I think the benefits of it are limited. It's not difficult to have nodes communicate with each other using any number of other things, including proper RPC libraries all the way down to just raw TCP connections. The hard thing is service discovery, and I don't think distributed erlang meaningfully solves the problem different than other solutions. If everything is running homogeneous code, why bother your nodes with knowing about the existence of other nodes? Just use a load balancer, and then do everything internally on each node. If your systems are heterogeneous, you need a way to send the right messages to the right nodes, and that's where a named load balancer for each type of node can do just fine.

comment 6y ago · link · parent

Yes, I definitely misunderstood the point being made there.

> What, baked into Go not via a library, handles multiple Go programs communicating within the same physical node or across multiple physical nodes?

Go does have an RPC package built into the standard library, for what it's worth, but I know it's not the same thing as the runtime transparently stitching distributed machines together under the hood.

comment 6y ago · link · parent

> Distribution in the sense of distributed computing, not in the sense of giving somebody else binaries to run. That is not something erlang is good at. But you can rather easily join nodes together and not just have them communicate but have them leverage one another e.g. spawn processes on an other node in the cluster.

Ah, I misunderstood, sorry. Personally, I see limited benefits to making things fully distributed at the runtime level. I'm sure it's nice sometimes.

> Go is a shared-memory concurrency language, with no restrictions on the sharing.

Sharing is the critical word there. You don't have to give access to that shared memory to anything, but the point I was making is that nothing can take shared access to your stuff without you handing it to them. It's not the wild west of interpreted languages where any piece of code can access all of your code and variables and edit them just for fun without you realizing.

Go also supports channels. How you design your system is up to you, and doesn't BEAM also support shared memory concurrency? A little thing called ETS? I would guess that there are other escape hatches as well, but I'm not familiar enough with Erlang or the BEAM to say for sure.

If you want to make a poorly designed system, I'm sure that Erlang won't stop you, but it will obviously try to guide you into certain accepted patterns by making other things harder.

comment 6y ago · link · parent

> * Erlang is a much simpler language

Go is widely considered to be a very simple language, often too simple, so I find this claim interesting.

> * Despite lacking a static type system, Erlang's functional bend, immutability, SSA and pattern matching makes for a rather safe language

This is fine stuff, but I would rather have a type system, so this is just making up for a deficiency with some other stuff, so it's really just a sidegrade, not so much an upgrade or a downgrade.

> * Erlang has always been fully preempted, it didn't have to wait until 2020 for that to happen

With extremely rare exceptions, Go has always been fully preempted from a developer experience point of view. The fact that the underlying implementation was using function calls as yield points simply didn't matter. The fact that it is fully preempted now means it's kind of weird to still hold it against Go that they are doing the same thing as BEAM now.

It is done, this is no longer a bullet point.

> * Erlang also builds distribution in, though it's "trusted distribution" so probably of fairly limited use at large

Go has always "built distribution in" by offering to build single static binaries. If anything, BEAM languages are harder to deploy.

> * Erlang uses shared-nothing concurrency, greatly limiting side-effects across processes, which again helps with reliability: there is no action at a distance in sequential erlang, no third-party can come in and mess with your state

I agree that immutability is an advantage. In general, third parties can't come in and unexpectedly mess with your state in Go either, as long as you're either maintaining your state local to a function or keeping your global variables private to each package.

Keep in mind that Go's package imports must form a tree with no loops. Third party packages literally cannot see your code or any of the exported global variables, since you are importing them, and not the other way around.

Go does not offer any way for packages to reflect over the whole program's state in memory, so there's no way for third party packages to go hunting around in memory and playing with your values, which would be stupid, unless they use "unsafe" to start poking at random memory addresses, and I'm certain you can do something equally dumb in Erlang with a sufficient amount of effort. It's just as crazy to think of doing something useful that way in Go as it is in Erlang.

> * Erlang builds reliability into the language and runtime through concepts of liking, supervision, …

This is literally the only compelling talking point I've seen for Erlang/BEAM vs Go.

However, I've written large Go applications with distinct services running within the same binary, and it is possible to make extremely reliable systems. Go's context package allows you to build trees of processes that you want to be able to cancel, including cancelling specific sub-trees without affecting adjacent trees or parent trees.

The single biggest footgun with building reliable systems in Go is that it prefers to crash early. So, every Goroutine that you launch, you must make sure that the first thing it does is catch any panics to avoid taking down the entire program, including unrelated Goroutines. When correctly written, a human will be immediately alerted to the bug that caused this panic (which shouldn't ever happen anyways), and the program will continue operating normally in the mean time until a human gets a chance to push out an update to fix that bug.

In practice, enforcing just one rule (Goroutines must catch panics) in code reviews is not that hard, and it isn't common in my experience for most code to arbitrarily launch Goroutines -- Goroutines should be managed.

In return, Go offers much better performance than BEAM, as well as most of the practical benefits of BEAM that I've seen discussed online.

I think Rust is a better language than either Go or any BEAM language, but the absence of a preemptive concurrency model like Go and Erlang offer just makes it hard for me to enjoy the prospect of using Rust for general purpose network services.

Once Go adds generics in the next year-ish, that should solve my biggest real annoyances with the language. I really look forward to being able to package up a number of the concurrent patterns I write into reusable packages, which will largely eliminate once and for all the need for me manually spin up a new Goroutine in the code that I'm writing and potentially forget to catch any panics.

comment 6y ago · link · parent

I literally mentioned Fargate in the same comment:

>> It would hopefully feel more similar to using Fargate than not, except without paying the higher price for Fargate, and having access to the wider variety of hardware configurations available to regular ECS.

If you're using an ECS Fargate Cluster or EKS Fargate Cluster, I don't consider those the same as an ECS Cluster or EKS Cluster. Unfortunately, there's no specific term commonly used for non-Fargate Clusters that I know of. AWS offers ECS Clusters and ECS Fargate Clusters.

If you were legitimately confused by my comment, I’m sorry. I could have said "non-Fargate" repeatedly, if it would have helped, but I thought the context made things clear, especially with the additional explicit mention of Fargate as a separate thing.

comment 6y ago · link · parent

>>> I'm not entirely sure who they built it for, except as a foundational component for AWS's managed offerings.

>> <snip>

> If a community forms to support Bottlerocket off of AWS, then that's one thing, but until then, it basically just seems like a better option for ECS or EKS.

I'm failing to see why that's a problem or a source of confusion. There's a clearly defined market of "who they built it for", and there's a community option to expand Bottlerocket's target market.

The code is open source, so anyone could fork Bottlerocket and modify it to suit their needs immediately. Will Bottlerocket see success beyond ECS and EKS? Only time will tell... literally no one knows yet.

comment 6y ago · link · parent

If you're using an ECS or EKS Cluster, you still have to run some operating system on the ECS Container Instances. The containers have to run somewhere.

There are a variety of options currently, including one from Amazon, but Bottlerocket seems designed to be a next-generation OS for container instances. It's extremely minimal, and designed to be as secure as possible, with transactional automatic updates.

Ideally, I would just deploy Bottlerocket as the underlying OS on my ECS Cluster, and then never have to actually do any management of the Instance OSes whatsoever. I would deploy containers on top of my ECS Cluster, Bottlerocket would keep itself up to date and secure, and my containers would live happily ever after. It would hopefully feel more similar to using Fargate than not, except without paying the higher price for Fargate, and having access to the wider variety of hardware configurations available to regular ECS.

Amazon has specifically said this in the Bottlerocket repo:

> Bottlerocket is architected such that different cloud environments and container orchestrators can be supported in the future.

It's mainly useful in concert with ECS or EKS right now, but it is architected to be useful in other places as well.

I'm excited about Bottlerocket as a project, and I'm glad it's open source instead of just an opaque AMI that you can use on ECS or EKS.

comment 6y ago · link · parent

Airplay is limited to 1080p, and I don't think it includes HDR. Definitely not what I would call the pinnacle of quality.

I'm surprised that Apple TV apps don't allow you to download content, considering it is based on essentially iOS, but it is clearly a conscious choice.

comment 6y ago · link · parent

You're basically admitting that you don't know much about these parts of the datacenter industry, but you keep posting comments authoritatively like you do.

Why can't you just ask questions instead of misleading people?

comment 6y ago · link · parent

That’s an implementation detail — an optimization on Intel’s side of things. It’s the same effect either way, and I can’t just ask Intel to customize their processors for me.

AWS operates at a large enough scale that they do exactly that, and AWS already purchases directly from Intel, both of which are my main points. Baybal2 doesn’t seem to be aware of either of these facts based on their comment.

comment 6y ago · link · parent

> And they buy them in servers from OEMs who volume buy even bigger number of chip than any of them individually.

No, they build their own servers. They definitely aren't racking Dell or HP servers.

Even Amazon's x86 based servers are extremely custom. That whole "Nitro" system isn't exactly a USB stick, and AWS is often using customized variants of Intel processors in their servers.

Let me repeat that: Intel literally makes custom processors specifically for AWS.

> If they were buying directly, Intel would have even more leverage to milk them, than if they stood behind the back of some beefy OEM.

That's not how bulk buying works... at all.

The scale of AWS is so much larger than you seem to think it is.

comment 6y ago · link · parent

Yes, but good luck getting that through any form of code review. The unsafe block and the raw pointers or the call to transmute make it pretty obvious that something fishy is going on that’s worth reading carefully. ¯\_/(ツ)\_/¯

Unlike C or C++, where it can sometimes be harder to tell what the lifetime of something should be, or whether you’re extending the lifetime of a reference beyond the point that it is safe.

Unsafe definitely gives you loaded footguns... which for the umpteenth time is why it is considered a code smell. Sometimes you have to write smelly code, but it’s something to be avoided.

comment 6y ago · link · parent

> All of the things you say about C++ code also apply to unsafe Rust code.

Which is why unsafe is considered a code smell, and why people in the Rust community get upset when unsafe is used unnecessarily. That's why some people might find it controversial to hide the unsafety of the C++ code being used here. I've used Rust professionally for years, and I don't remember ever having to write any unsafe code in a professional context apart from FFI, and even then... the glue code to wrap around that unsafe FFI was very strictly written to make things as comfortable as possible for the FFI code and minimize the chance of bad things happening on the other side of the FFI barrier.

However, even then, your statement is not entirely correct. Unsafe Rust is extremely similar to safe Rust, enforcing the vast majority of safety requirements automatically. Unsafe code is very limited in what bad things it can do compared to C++ code.

https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#unsa...

- Dereference a raw pointer

- Call an unsafe function or method

- Access or modify a mutable static variable

- Implement an unsafe trait

- Access fields of unions

Those are the only things unsafe Rust can do that safe Rust can't. It doesn't turn off the borrow checker or anything else. There are a lot of mistakes that can be made in normal C++ code that you can't make in regular, safe Rust.

> All this document says is that the C++/Rust boundary should be considered another place where you are asserting "I promise this code is actually being used in a safe way".

The problem is that C++ compilers are much less capable of enforcing safety (inherently, due to legacy design decisions and backwards compatibility), so you often want a layer of glue code that only allows you to use C++ code in ways that are known to be safe, not just any arbitrary way that the function might be callable.

I already said I agree Chromium's team seems to be making the right call for this specific situation. It's not the right call most of the time. C++ code isn't fungible as being "just as good" as safe Rust code. The unsafety needs to be obvious, just like it is with unsafe Rust, so that you can recognize that the external C++ code (or unsafe Rsut) is a loaded footgun, and to treat it with appropriate care.

To be clear: Rust isn't a perfect language, and you can get the vast majority of the safety benefits by using almost any garbage collected language. What makes Rust awesome is that you can bring the memory safety of garbage collected languages into the realm of consistent performance requirements that previously was inhabited mostly by C and C++. Rust is a nice language, but so are a lot of other languages.

comment 6y ago · link · parent

> I think that’s the reason that doc discusses using cxx, right?

cxx can only really do as much as the C++ compiler can. It's certainly better than nothing. In my experience, a non-trivial amount of C++ code will have additional requirements on how and when you're allowed to call various functions; requirements that aren't enforced by the compiler.

>> It might be the right call for this specific case, though.

> I agree with you, but at the same time, I think in this context, single codebase, abstractions built by the teams making the guarantees at the FFI boundaries... it feels like they would meet the requirements here? It definitely is less strict than Rust, but the way I interpret it is that they are saying they will guarantee the C++ is safe behind the abstractions (maybe they can mark the C++ In some way to state this), and that’s not all that different than what we say in general in Rust when we claim an unsafe call is in fact safe when we wrap it in unsafe.

That's why I said it might be the right call in this specific situation. Normally, I don't think this is the right approach, but it's probably the sensible thing to do here, especially since it's likely the same team of people on both sides of the FFI boundary.

comment 6y ago · link · parent

Really, your text macro substitution is missing the broader point.

Hiding the word "unsafe" doesn't make it any less unsafe.

The Rust compiler can't guarantee that the C++ code being called doesn't have use-after-free bugs or buffer overflows.

The Rust compiler can't guarantee that pointers being returned from C++ code aren't just wild pointers that point in the middle of nowhere.

The Rust compiler can't guarantee that the C++ code isn't mutating into an immutable reference.

The Rust compiler can't guarantee that the C++ code isn't holding onto a reference to an object that it will later mutate when Rust thinks it is now the sole owner of that object.

The Rust compiler can't guarantee that the C++ code isn't sending un-Send objects across threads, or that it isn't deallocating objects that it isn't supposed to deallocate.

Rust makes a lot of guarantees about code written in Rust, which is why people are so passionate about it. The Rust compiler feels like having the world's best static code analyzer at your fingertips. It's really nice.

C and C++, on the other hand, are each full of an assortment of powerful footguns. Well-written C or C++ code interops very nicely with Rust, but the problem is that programmers are only human, and humans have been repeatedly shown to make mistakes.

So, calling C++ code is unsafe, and unsafe is a code smell because it is an opportunity for guarantees to be violated, which is undefined behavior.

Ideally, you build an abstraction around the unsafe interop layer that rigorously enforces every requirement that the C or C++ code expects (but that the C and C++ compilers cannot enforce), so that the external code will behave as well as it can.

The Chromium document is right to call their idea controversial. Hiding the unsafety of the C++ code without actually doing anything to protect against malformed calls to that C++ code is a loaded footgun. It might be the right call for this specific case, though.

comment 6y ago · link · parent

It’s “done” because the numbers around it leave no option to move its mines around. Since the mine locations have been fixed in that particular part of the game board, you’re guaranteed that the square at 3,0 is safe. Instead, you clicked on a square you couldn’t possibly know was safe (in the middle of nowhere) when there was at least one square that was definitely known to be safe, so the game punished you for it, exactly as promised.

I played a few rounds on an iPad, so I had no way to mark mines, and the game works just fine. Marking mines has always been for your benefit, to make it easier to remember where the mines are.

comment 6y ago · link · parent

WebAssembly is not JavaScript. This code does not transpile to JavaScript. There might be some JavaScript glue code to call the WASM that's bundled into the website, but that's not what your comment is claiming.

comment 6y ago · link · parent

> I actually started using C for my side projects since two years precisely because I want very long term backward compatibility (that is, being able to leave a program for years without maintaining it, then make a small edit in it and build it with minimum pain).

Rust actually takes a very strong stance on maintaining backwards compatibility, and Go's stance is arguably even stronger in most cases. You're implying incorrectly that these languages are just breaking things left and right for no reason other than "innovation!", which isn't true.

The overwhelming majority of Rust and Go code from years ago will compile without problems today. Any code from post-1.0 that doesn't compile today was (inadvertently) relying on buggy, incorrect behaviors that have since been fixed... and even then, not all incorrect behaviors get fixed because compatibility is considered so important.

C is fine for certain applications, but no one should choose it for side projects based on some notion of backwards compatibility, in my opinion. If some company is building a business application that needs "backwards compatibility" in the sense that it can run on all sorts of arcane microarchitectures and operating systems, then sure... C is still a really painful* choice, but it might be the right choice then, or if there's an existing C code base, then it probably doesn't make business sense to rewrite it any time soon.

* yes, having no protection from footguns, no real standard library, no built-in concept of asynchronous code, and very little of anything useful is definitely painful. If C is the only valid choice for a project, then it's the only valid choice, and that's what you have to do. The number of projects where you simply can't use something other than C is diminishing by the day.

comment 6y ago · link · parent

> Of course, this comment will get downvoted, which just proves the point.

No, it really doesn't "prove the point." Your entire comment is violating HN guidelines[1] left and right, so of course it is getting downvoted (and flagged), but not because you've uncovered some grand conspiracy.

The cloudflare posts that get upvoted are just actually interesting to the HN target audience, myself included.

[1]: https://news.ycombinator.com/newsguidelines.html

comment 6y ago · link · parent

> No mention of go-bindata which was one of the originals :(

There’s literally an entire section in the appendix dedicated to `go-bindata` and explaining what it generates. It was also first in the list of libraries mentioned.

I also disagree with you entirely. The document does a great job explaining the problems with having this “solved by a library”. I’m excited about this draft design.

comment 6y ago · link · parent

If you're so happy with Azure, why aren't you using Azure CDN? https://azure.microsoft.com/en-us/services/cdn/

Obviously, AWS and GCP offer their own CDN systems as well. (CloudFront and Cloud CDN, respectively)

There are tons of third party CDNs as well.

Unless by "good alternative" you mean that you're on Cloudflare's free plan, and hoping to find someone else who will willingly soak up huge amounts of bandwidth for free?

Cloudflare is one of the only services I know of that offers this, but it's hard to complain about a short outage every once in awhile when you're paying nothing or very little. The Cloudflare customers who are paying quite a bit are surely upset.

comment 6y ago · link · parent

Or by using a U2F device, which is designed to prevent spoofing.

comment 6y ago · link · parent

Ah, thanks for pointing this out. You're entirely correct.

I'm not sure how I got confused with the special case around string comparisons, and forgot that it didn't apply to regular struct pointers. It was late in the evening, so I guess that's my excuse?

    BenchmarkSameRef-12    620150179                 1.92 ns/op
    BenchmarkDiffRef-12      6102709               204    ns/op
Source: https://play.golang.org/p/DbjkstOCZ-Y (although you can't actually run it on the Go playground)

Go will check whether two strings have the same underlying pointer first. If the pointers are different, then it compares the contents.

I stand by my earlier statement that I think pure reference equality is just a bad idea 99.9% of the time. I would prefer if Go did deep equality with every comparison when needed the way it does with strings. If you have to use some clunky syntax or built-in function to do just a reference comparison, that would be perfectly fine with me. Unfortunately, Go does exactly what you described.

With a quick google, I didn't immediately find a linter to complain about comparing struct pointers rather than struct values, so maybe I'll write a linter like that sometime if I can find the time and motivation.

comment 6y ago · link · parent

> I.e. I'm not sure we should be dinging a language based on SEO.

I completely agree that one google search is not enough to ding a language. I’m trying to indirectly make a larger point there, which is that of approachability, especially for people who haven’t been doing all of this for forever. I didn’t want to make that comment significantly longer than it already was, so I’ll expand on that idea in this comment.

> the second link, while still a little deeper than one may like, hopefully is enough to realize that ASP.NET is the library to use and puts you just a click or two away from the proper tutorials.

The second link (for me, at least) appears to be a blog post comparing Kestrel vs HTTP.sys within ASP.NET Core, which wouldn’t be very enlightening to someone who isn’t already familiar with the term “ASP.NET” and how that is basically the standard .NET web framework.

Literally none of the links on the first page for that ill-fated (and arguably slightly wrong) search query, as far as I can tell, are a tutorial that involves serving a web page without writing your own socket code.

From experience trying to help a friend transition from Python to C#, a lot of tutorials I expected to find either weren’t at the right level for a beginner, were way out of date, or didn’t exist at all.

With how rapidly C# and the surrounding tooling and frameworks have been evolving over the last 5 to 10 years (.NET Framework to .NET Core, ASP.NET 4 to ASP.NET Core, etc.), my experience is that there’s a lot of so called “inside baseball” in the C# world, partially due to how out of date a lot of the materials that Google is likely to surface are.

I’ve used C# enough over the years that I don’t think I would have much of a problem finding what I needed if I chose C# for a project, but the language itself has a large amount of complexity, and developers have to make a lot of choices. They have to first figure out .NET Framework versus .NET Core, then they need to figure out that ASP.NET is the very intuitively named web framework that most people use. Also, do I need HTTP.sys or Kestrel? I really don’t know without doing some research, but luckily there’s an article diving right into that topic on link #2 on Google.

To give an even more concrete example, the official ASP.NET tutorial on creating a Web API[0] involves a ton of autogenerated code that is either generated through clicking around all over Visual Studio, or running a bunch of `dotnet` commands on the command line. All of that autogenerated code is brushed over as if the reader must already be an expert in the world of C# but has just somehow never used ASP.NET before. (That seems like an unlikely combination to me.) Even if you’re used to other statically typed languages, you see this exciting code[1]:

    // POST: api/TodoItems
    [HttpPost]
    public async Task<ActionResult<TodoItem>> PostTodoItem(TodoItem todoItem)
    {
        _context.TodoItems.Add(todoItem);
        await _context.SaveChangesAsync();
    
        //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
        return CreatedAtAction(nameof(GetTodoItem), new { id = todoItem.Id }, todoItem);
    }
First of all, what is a Task? What is an ActionResult? Where did `_context` come from and why does it start with an underscore? The tutorial literally does not even attempt to address the magical appearance of `_context`, or its ability to hold TodoItems. Ok, thinking for just a second, I remember we added a database context, but how would I know it’s going to be called `_context`? Registering our TodoContext object also felt super magical. We just had to “know” to put it in ConfigureServices, and does it matter that the tutorial puts it before `services.AddControllers`? Does the `//POST: api/TodoItems` line actually control anything, or is it just documentation for us? Why do we want to “Replace the return statement in the PostTodoItem to use the nameof operator” anyways? The code seems to do the same thing either way. (I know most of the answers, but these are the questions I would expect someone else to ask as a beginner being confronted with this tutorial.)

I think approachability is not currently where I would want it to be with C#.

Compare that tutorial to this Go tutorial.[2] It walks the reader gently through the entire process with only an assumption that the reader has some programming experience, a little knowledge of HTML and HTTP, and the know-how to run a few commands on the command line. The tutorial explains most of the Go-specific stuff you encounter, and it iteratively builds up the project code from scratch, rather than just telling you to “insert a line here in this autogenerated file”, and “swap this one random piece of an already functional piece of code with another piece of code that yields exactly the same result.”

Go “includes the batteries” with its standard library that gives you easy defaults for many things, and the standard library docs often give you great examples for many situations. Goroutines make it so that you just write normal synchronous code, but it still scales extremely well. Tutorials are plentiful, and rarely feel out of date. There are no magically-appearing, unexplained variables like `_context`, and there isn’t a ton of scaffolding that you just have to figure out. All of this makes Go feel like a very approachable language to me.

Is approachability super important to everyone? No, and that’s fine. There are lots of C# developers out there already, and there are lots of people who will figure it all out on their own anyways.

I want to point out that I really do like C# and .NET Core. I would personally much rather use C# than Java, although I tend to think Kotlin is better than either of those. The last time I used C#, it had really great developer tooling, and it really did get a lot of things right. I think I would also prefer to use use C# with ASP.NET Core rather than Ruby on Rails or most Python frameworks these days. I’ve just had a lot of great experiences with Go (and Rust too!) in professional projects over the last several years, and those experiences make it hard for me to want to reach for anything else these days, C# included.

[0]: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first...

[1]: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first...

[2]: https://golang.org/doc/articles/wiki/

comment 6y ago · link · parent

Definitely good to know.

Not a critical feature these days with CI being as good as it is, but can you run that command from macOS or Windows and get a Linux binary?

comment 6y ago · link · parent

Since this article seems to be written from the point of view of someone who primarily knows C#, I'll provide some counterpoints from the Go side, which I'm familiar with. I have some C# experience, but it's a few years out of date.

> The comparison there was done before against .NET Core 2.1, and I plan to share the update for the most current state (.NET Core 3.1 vs Go 1.13.6) next week. But preliminarily, the distance became even larger:

For starters, "the current state" is Go 1.14.4. Updating one and not the other seems unkind.

Go 1.14 also introduced this change:

"The page allocator is more efficient and incurs significantly less lock contention at high values of GOMAXPROCS. This is most noticeable as lower latency and higher throughput for large allocations being done in parallel and at a high rate."

Whether it improved single threaded burst allocation performance or not, I don't know, but it seems likely that such an invasive change would have affected it one way or another.

I also don't find it very compelling to talk about single threaded burst allocation performance... aren't most allocations usually being done across multiple threads, and not in a very bursty (not gigabytes all at once) manner?

I think that Go also stack allocates things more frequently than C#, which makes allocation throughput generally less interesting.

> Isn’t this per-call “extra” (16 bytes on call stack + two comparisons) a bit too expensive?

No? I'm not sure why you think it is. Most local comparisons are extremely cheap on modern processors. Values on the call stack do not have any contention from other threads. Contention would lead to caches being evicted, and the instruction pipeline would be more likely to be thrown out and restarted because of a branch prediction failure. Local values on the call stack should be really easy for the branch predictor to guess, especially if you're repeatedly calling a function. I wouldn't go so far as to say prediction and pipelining make such comparisons free... but it really almost does, from everything I've seen over the years.

> btw, pay attention to an unusual “prologue” of every call that checks for the potential need for stack expansion. That’s the price Go pays for goroutines — most of other static languages don’t do this extra check per every call.

Again, these kinds of checks are rather inexpensive. The cost of growing the stack is amortized over the lifetime of the goroutine, so unless you are constantly creating very short lived goroutines that need large stacks, there really isn't much cost to this. Years ago, Go used to have split stacks, and those were expensive, especially if a hot path was straddling one of the splits between stacks.

> There is seemingly no way to make e.g. a map to rely on your own equality comparer (sometimes you need this), and honestly, I don’t know how to implement a workaround assuming equality is always structural — e.g. even if you start substituting the keys with your own wrappers, wrappers still can’t override their own equality/hashing, so…

Depending on exactly what you're looking for, there are some easy solutions. You can have the "key" be embedded into the larger struct, or you can have a function that returns a key struct. This is an example of using embedding for this purpose, which I think would be a reasonable solution: https://play.golang.org/p/mkHyLZiAYOa

The problem is if you're hoping to later get the key back and have access to the other fields of the struct. In my opinion, that's an antipattern. You should be storing those fields in the value of the map if you want the map to hold them but not use them as part of the key. I've never once (in any programming language) wanted to store an entire key in the key part of a map, but only use part of the key for comparison purposes.

There's no great quote to pull from the article, but there's a strong implication that Go has to compare every field in order to determine equality... but this simply isn't true. Go only has to do this to determine inequality. If you have two pointers, Go will first check whether the pointers are equal. If they are equal, its job is done. Otherwise, it dives into the fields to see whether those are equal or not. Unless you want "reference equality" to mean that you can just cheaply compare the pointers without falling back to structural equality, but... why would you want to do that? You can certainly hack something together with `unsafe`, but I don't recommend worrying about this until you have a benchmark pointing at a specific problematic comparison. (which I've also never seen) Reference equality in the sense that it doesn't fall back to structural (or some other form of) equality is a gigantic footgun that I've seen trip people up in numerous languages. I would rather not have that as a language feature. A lot of people end up accidentally comparing two different pointers that contain the same structural value, and they can't figure out why the two values aren't being treated as equal.

There are a lot of other statements throughout this article that I find questionable, but I feel like I've already written too long of a comment at this point. Yes, "language I know" is a lot easier to like than "language I don't really know", but the conclusion was even more one-sided than I expected, given the level of effort the author seemed to be putting into the article. The absence of generics and sum types are real issues with Go... and even C# doesn't have sum types either, so that's a real problem there too. Almost everything else mentioned in the "C# features missing in Go" section is just completely unnecessary. More is not always better, especially when it comes to language features.

When I google "c# web server", the first thing that pops up is a tutorial for how to write your own from the ground up with sockets. When I do the same thing with Go, I get a practical tutorial for how to use the standard library web server to build an interactive wiki application.

Go's standard library is a huge component of the language's success.

Being able to make an easy-to-deploy binary just by typing "go build" is huge, and the compile times are great. Sure, .NET supports some form of AOT compilation, but it's not the default, and when I google ".net core aot", the first thing that pops up is the CoreRT repo that says "This is an experimental project. We have no plans to productize it in its current form" which is not super encouraging.

There are a lot of things to like about Go, but it is different from many other popular languages, so it's easy for it to make people feel uncomfortable. I'm eager for Go to have generics, because that really is my biggest complaint about it.

If you want a cohesive, awesome type system, Rust is built on a decade or two of research that didn't exist when C# was designed, so C# has to live with a lot of baggage as it expands to include other, newer ideas. Go has avoided most baggage simply by avoiding most features, for better or worse.

comment 6y ago · link · parent

I think it’s worth clarifying that I said I would “generally trust {author} more than {random internet person who hasn’t even tested author’s library}”. Are you saying that you trust random internet person more by default?

Trusting one more than the other is not the same as blindly trusting one and never running my own tests. The author who put in the effort to develop and benchmark their library deserves more benefit of the doubt than some drive-by commenter, in my opinion.

If I needed a high performance JSON parsing library, I would definitely set up a benchmark representative of my use case, and test a few different libraries. JSON libraries are usually pretty ergonomic and easy to swap between, so it shouldn’t be an arduous task.

Your very first two comments in this thread were far more insightful than {random internet person} just saying over and over that simdjson can’t possibly be slower, and those comments of yours on their own merit would have removed the need for me to leave any comments whatsoever to defend the original HN post, even without needing to observe that you’re an expert in this field, which just lends further credibility to your comments.

I think the rest of the discussion that occurred was really interesting to watch!

comment 6y ago · link · parent

I was iterating on the comment rapidly after posting to try to make my point in the most neutral way possible, so I’m not sure which “last sentence” you saw, but hopefully it is better now.
1
555657
66