6,699 karma · joined Jul 18, 2012 (14y ago) · 1,967 submissions
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
comment 6y ago · link · parent
I’ve never used either library, so I don’t care which one is faster, but I would generally trust the author of the library to have tested the performance at some point more than I would trust someone who isn’t the author to comment on the performance of code they’ve never tested.
The author of that library isn’t present to make their case, so you’re the only one of the two who could provide evidence right now.
EDIT: the author is present now: https://news.ycombinator.com/item?id=23738512
comment 6y ago · link · parent
> No official benchmarks are available but in informal tests Oj is 30% faster that [sic] simdjson.
Source: https://github.com/ohler55/ojc/blob/master/README.md#benchma...
If you have benchmarks that show otherwise, that would be great for the discussion here, but your point appears to have already been addressed?
comment 6y ago · link · parent
To clarify this one point, Go allows you to attach a destructor (finalizer) to an object, but since the language is garbage collected, there’s no guarantee of when the destructor will be called, if ever, since disabling the garbage collector is entirely possible, even if not advisable.
The File object will Close the file when the Finalizer runs, since the standard library attaches a finalizer to it, but you should defer the Close to deterministically ensure that the file is closed when you expect it to be closed, and to free that OS resource of a file handle as soon as possible, since some OSes limit how many you can have at a given time. Finalizers also won’t be run when the program exits, which is fine for most things, but you’ll want to have ensured any buffers were flushed before then, and defer can guarantee that.
Languages like Rust and C++ have deterministic destruction at the end of a given scope thanks to RAII, so it makes sense for them to lean more heavily on destructors there.
Java File*Stream objects should have “close()” called on them, from what I’m seeing on a Google search, so this doesn’t seem to be a surprising pattern for a garbage collected language. I know in Python you’re encouraged to use a “with” block to ensure that file objects get closed.
comment 6y ago · link · parent
The point I’m making is that C# and C++ enums are not exhaustive, and not guaranteed to be any particular predefined value. They’re just integers. (unlike Rust: https://play.rust-lang.org/?gist=c9e499ba8d3abe08e5e54c74f54...)
C#, C++, and Go all share the same flawed enum representation strategy. Use Rust if you want to get better enums... those other languages aren't any better for enums. C#, C++, and Go enums are all type safe, and they're all perfectly capable of holding completely unexpected values. (Although, C++ in the older permissive mode was not type safe period when it came to enums, if I remember correctly. I admit it's been long enough that I could be misremembering.)
I already addressed your point in detail with you elsewhere.
Please, by all means review the final 3 lines I wrote in this comment for more info: https://news.ycombinator.com/item?id=23715897
I agree that being allowed to write any type of integer as a literal is theoretically an ergonomic issue when it comes to enums, but it’s one issue I’ve literally never seen happen even once in practice. I point out that there are linters available to address the issue if it’s one you feel so strongly about. Surely you use linters in every language?
I have been paid professionally for years to work in both Rust and Go codebases. Linters are essential for both languages, and CI is where you guarantee that no lint-failing code is allowed to pass.
I’m well aware of Go’s flaws, but people throughout this thread (yourself included) have made tons of baseless claims about Go. Just because it’s popular to hate on a given language doesn’t make it okay to use incorrect statements for that purpose, such as saying that Go’s enums aren’t type safe. They are a separate type. The language does allow you to write integer literals of any integer type. It also does this with untyped float and untyped string literals as well, as a fun fact.
Go has a number of legitimate flaws, including the absence of both generics and sum types. You could even legitimately complain about untyped literals —- they are really nice in some ways, but they do have some trade offs.
comment 6y ago · link · parent
Your statement implies that errors for using invalid values are guaranteed at runtime as a feature of the language. That entire statement is incorrect.
You really don't get errors... I literally pasted a link to a working, non-erroring example in the comment that you responded to. You clearly saw the code. Did you click "run"?
You only get an error at runtime if you add "-fsanitize=undefined" (or "-fsanitize=enum"), where the compiler will inject some code into your binary.
But the error doesn't actually stop code execution: it just prints a warning!
Here is a link with the sanitizer enabled, and no warning is even printed for using an invalid value: https://godbolt.org/z/NA7FNQ
So, not only is the sanitizer not even comprehensive, it's not actually a feature of C++. It's a best-effort feature from the compiler to add a non-standard runtime code sanitizer to your binary. Warnings for using invalid values are not guaranteed.
comment 6y ago · link · parent
What do you mean by this?
C#: https://repl.it/repls/ExhaustedDisgustingRam
C++: https://repl.it/repls/BackGroundedRobot
C# and C++ offer exactly the same thing that Go offers... enums that are really just integers.
You can assign arbitrary values to those C# and C++ enums, even though you're not supposed to, just like in Go.
Rust offers something truly better, where the enum abstraction doesn't leak at all.
comment 6y ago · link · parent
"Enums" here are just another type of integer, exactly like in C# and C++. They're not a separate concept. I wish Go had Sum Types or even just exhaustive, non-integer (as far as the programmer knows) enums, but neither of those are requirements to have a type safe enum. The only difference vs C++ and C# is that Go has untyped literals, which are quickly handed a type based on where they're used.
Enums in Go have type safety, which is the point you disagreed with. You can't assign values of the wrong type to an enum-typed value without explicit conversion in Go. That's type safety.
There are linters that can be used if you want to enforce more restrictions: https://github.com/THE108/enumlinter
Linters that fit your team's expectations are a good thing to use in any language, and Go is no exception here.
Would this linter be unnecessary in other languages? Sure. I would argue it's still unnecessary, because I've never even once seen anyone accidentally type a literal value in Go where they meant to use one of the predefined enum values. It's certainly possible, but it hasn't caused me any lost sleep.
comment 6y ago · link · parent
No, it doesn't. Go's enums are type safe. You can't accidentally mix two different kinds of enum values, or accidentally use some random value of type "int" where an enum value is expected. The type system protects you from values of the wrong type being used. This was demonstrated by that Go Playground link.
Literals in Go are untyped until they're used. How they're used determines the type, and then they have a very real type, with very real type safety being enforced. So, if you're using a literal "3" where an integer of type "state" is expected, the Go language specifies that the type of "3" is "state". This is an ergonomic issue when you're expecting exhaustive Sum Types, but not a type safety issue.
Should all literal integers just always be a specific type? Let's decide that all literals should be of type "int". Great. Now you can't type a large, 64-bit integer literal to pass as a value to a function, because that would overflow the "int" type, even though the argument is desired to be "int64".
There are trade-offs to every approach.
> In C++ or Haskell, implicitly assigning integer literals like that isn't valid.
I can't comment on how Haskell does things, but C++ is more complicated than you seem to think.
https://en.cppreference.com/w/cpp/language/integer_literal#T...
"The type of the integer literal is the first type in which the value can fit, from the list of types which depends on which numeric base and which integer-suffix was used."
Go's approach is equally type safe here. It assigns the type to the literal based on the expression the literal is used in.
As I said before: I really wish Go had proper Sum Types. But enums in Go are type safe, contrary to what you have claimed in several comments here.
comment 6y ago · link · parent
Type safety does not guarantee exhaustive matching, unfortunately, because the underlying type is still an integer, but that's a separate issue.
https://play.golang.org/p/K0m4hfmw8C1
I wish Go had proper, exhaustive enums too (sum types preferably), but you're incorrect when you say that they don't have type safety.
comment 6y ago · link · parent
I've had good luck with modd: https://github.com/cortesi/modd/
I just tested exactly what you described, did not see any errors, and it ran my commands exactly the way I wanted.
comment 6y ago · link · parent
The profit margins on the Mac Pro are just incredible. (Yes, I'm sure that equivalent professional workstation brands also have huge profit margins... no, that doesn't make me want to pay those lofty prices more.)
The only real value the Mac Pro provides is that it's the most powerful computer you're allowed to run macOS on legitimately. If you can do your work from Windows (with WSL) or Linux, you can save upwards of tens of thousands of dollars by building your own workstation, and that workstation can be significantly more powerful than any current Mac Pro at the same time.
For video professionals who rely on FCPX or similar macOS-only software, they don't really have a choice, and they get the opportunity to essentially pay $10k to $20k just for a license of macOS, which is fun.
comment 6y ago · link · parent
Also, energy density is not nearly as important as you seem to fundamentally believe. It’s pretty much all about cost and availability.
In countries that use very little energy per capita, even just a single solar panel (with a small inverter and a lead acid battery) per person (or even per family) is life changing, giving them enough energy to run a small refrigerator, a light bulb, and a place to recharge their smartphone without having to go into town and pay someone.
In deep urban environments, space is definitely at a premium, but I struggle to imagine that many people are excited to set up a dirty diesel plant in the town square when air quality is already bad enough due to heavily polluting vehicles running in the city center, let alone set up a small nuclear plant, even if wealthier countries would allow such a proliferation of nuclear technology and fuels. Once the nuclear fuel is spent, then you have this extremely toxic, dangerous waste that has to be put somewhere, and those people probably have a lot of other things on their minds, so you could just be rad poisoning their town by giving them nuclear if they don’t dispose of the waste properly.
On the other hand, the rooftops are prime locations for solar panels and solar water heaters, and because 175W/m^2 of solar converted electricity is actually a ton of energy, it’s still plenty of power.
Unfortunately, cost and availability are king. Wealthy countries are happy to sell old assets at a steep discount, and so shiny new solar panels have to compete with second hand fossil fuel plants / generators that don’t lend themselves to great air quality.
Solar is an extremely sensible solution. Nuclear is not a clear answer at all for developing countries, unless you happen to have the design for a clean, portable cold fusion reactor in your pocket. Fission has a lot of problems that are manageable, but managing those problems takes significant money.
comment 6y ago · link · parent
The main point was that the 2010 iPad was being given the most favorable conditions, and it still lost horribly, because even compared to contemporaneous devices, it was very underpowered, unlike current iPads:
- your claim is that websites are substantially heavier now (which I agree), putting the 2018 iPad at a disadvantage
- the 2010 iPad was browsing early 2010 websites in that video, so we've had 10 years of bloatification since then
- the 2018 iPad Pro is browsing 2020 websites, websites built years after it was released, so surely more "bloated" than they were in 2018
- being 2010 websites, they were probably much simpler to render
- the 2010 iPad's screen had 5x fewer pixels to contend with
Nowhere was I saying that the 2010 iPad was super slow to render 2020 webpages in all their bloaty goodness. That would be an obvious conclusion. If the 2010 iPad's performance was so good at the time, but only became slower as the web became much more bloated, why was it still so much slower at browsing 2010 websites than my 2018 iPad is at browsing 2020 websites?
The 2010 iPad was actually slow from the beginning, as the video proves. Since it was slow back then, it shouldn't be surprising that it's slower and more painful now that websites want to support higher resolution experiences by default. Yes, they could put effort into giving old devices a lower res experience, but why? That old browser is one giant security vulnerability at this point, and no one should be browsing any websites they don't control on that thing.
Even with all those advantages being in the 2010 iPad's court, it was still 3x to 5x slower than a 2018 iPad browsing 2020 websites at 5x the resolution. This is not even a 2020 iPad Pro -- this is a 2018 iPad Pro. Imagine how much worse a 2008 iPad would have been at browsing 2010 websites, if it had existed.
You say that it's "not shocking" that they ramped up the power so it can browse better, but the point is that we're loading substantially heavier websites today significantly faster.
How is that possible? Because the 2010 iPad was severely underpowered. If it had been running on a chip that was equivalent to laptop processors of the era (as my iPad Pro's chip is), then it would likely have loaded the 2010 websites about as quickly as my iPad is loading 2020 websites.
> Once a page was loaded and rendered the scrolling, tapping links, and interacting with forms was all usable fast. Even while the content was loading you could interact with the page.
Yes, it's very impressive how much interactivity Apple was able to give the 2010 iPad with its really terrible processor, once the loading finished.
That interactivity isn't because the chip was any good. I remember very clearly that it was because you were basically scaling a 1024x768 PNG while you zoomed in and out. Once you let go, the iPad would take a second to re-render the page at the new zoom level, but you were stuck staring at a blurry image for a second after zooming in. The GPU was really good at scaling a small image up and down. The CPU was not so good at rendering websites.
It was also very easy at the time to scroll past the end of the pre-rendered image buffer, and you would just stare at a checkerboard while you waited on the iPad to catch up and render the missing content. iOS actually drastically limited the scrolling speed in Safari for many years to make it harder for you to get to the checkerboard, but it was still easy enough.
> Look at Reddit versus old.reddit.com. The "modern" Reddit page has poor interactivity even on my current iPad. The old.reddit.com site, which is similar in complexity to 2010's Reddit, renders damn near instantly and has no interactivity issues.
New Reddit is one of the worst websites on the entire internet right now, if not actually the worst popular website in existence. I really don't understand how that hasn't been scrapped at this point. It's not representative of modern web experiences, except possibly in your mind. YouTube, The NY Times, Facebook, Amazon... these are all modern web experiences that work great on anything approaching reasonable hardware.
comment 6y ago · link · parent
Those are some rose colored glasses. The first page (technobuffalo) loaded in this video takes 10 to 15 seconds:
Based on what was said, that page had already been loaded once, and it still took that long.
Loading a Google Search took only about two seconds, because of how extremely minimal and optimized the search page was back then.
Loading The NY Times took about 8 to 12 seconds, depending on where you draw the line.
So, at the time, maybe we were used to webpages taking a while to load on mobile devices, and it seemed very reasonable. I’m sure there were some extremely simple websites that loaded quickly, but The NY Times was one that Apple promoted heavily at the time (apparently) as demonstrating what a good experience the iPad browser was.
Nowadays, we hold the web and our devices to much higher performance standards.
It’s not an apples to apples comparison because the content is entirely different, but the context of this thread is that modern websites are significantly harder to load and render.
Even though content is supposedly much more resource intensive today, my 2018 iPad Pro loaded the technobuffalo home page initially in less than 3 seconds, and subsequent page clicks are even faster.
This iPad loads google search results even faster than the original iPad.
This iPad loads the New York Times in under 3 seconds, with subsequent page clicks taking the same or less time.
Based on the numbers, a contemporaneous 2010 iPad was 3x to 5x slower at browsing the 2010 web than my 2018 iPad is when it comes to browsing the 2020 web, and that’s a roughly two year old iPad design, so it should be even more at a disadvantage. My iPad is also rendering more than 5x as many pixels while doing that.
In conclusion, the original iPad was severely underpowered.
> A blog post, news article, or a tweet shouldn't require a quad core CPU and gigabytes of RAM to be readable.
Conceptually, I agree, but every image and video we use for content in websites now is significantly higher resolution and quality than they were back then. If you just want to read text, then you’re correct.
comment 6y ago · link · parent
It just seems very idealistic to expect most websites to cater to a browser that hasn’t received an update in 8 years running on a processor that has a fraction of the power of any Raspberry Pi 2 or above.
Modern iPads are served the “real” web by default, further emphasizing why you would benefit from upgrading at least once a decade.
comment 6y ago · link · parent
My point was that “comparable” is not universally used in place of the “Ordered” term that the Go team is using, as you were seemingly implying. Ordered is a perfectly fine term for it.
You said:
> Using comparable here closes the door for adding that later.
But the door is not closed in any way. It’s just called “constraints.Ordered”, which is perfectly reasonable.
comment 6y ago · link · parent
The design draft refers to “constraints.Ordered”, so they’re definitely thinking about having both “comparable” and “constraints.Ordered”. Although, for consistency with “comparable”, I think it should be called “constraints.Orderable”.
comment 6y ago · link · parent
Alternatively, use the bool values and rely on the zero value for missing elements: https://go2goplay.golang.org/p/E7yHQqAPseG
comment 6y ago · link · parent
I can't find the actual code review for this. It seems to be hidden/private still?
This was the previous code review: https://go-review.googlesource.com/c/go/+/187317
The comment at the end is where I got the link to the new branch, but as an outsider, I don't have any good way to ask where the new code review is, so I'm leaving this comment here in hopes that a googler will see it and point me in the right direction.
Based on a link that's on the new branch's page, it might be CL 771577, but it says I don't have permission to view it, so I'm not sure.
comment 6y ago · link · parent
> AMD also re-confirmed that we are set to see Zen 3 processors in 2020.
So, as of last month, Zen 3 was again confirmed to be coming this year.
It's absolutely still just a rumor that Zen 3 is delayed until 2021. There has been no official confirmation of any change to the schedule, and attempting to read way too much into some slides doesn't change that.
comment 6y ago · link · parent
Because of this, working with Ruby is actually substantially slower than working with a similarly sized Go project, in my experience, even though Go theoretically has the disadvantage of needing to compile things before running them.
Plus, Go's type system will catch tons of bugs that Ruby optimistically treats as "maybe you meant to do this". Obviously Rust's type system is really awesome, but Go's is still really helpful, while compiling much faster than Rust.
Since Rust and Crystal are both LLVM-based, I would guess that Crystal's compile times also tend to be a bit painful on medium-sized projects, like Rust, but I've never actually used Crystal for anything more than "Hello, World".
(I've been paid to work full time with Ruby, Rust, and Go over the years, and they each have pros and cons, but I just don't think I would ever personally choose Ruby for any new project in 2020, if I had a say in it, given how great Go is for web development.)
comment 6y ago · link · parent
You didn’t respond to anything I wrote. Why should I continue this discussion? It wasn’t a supply chain inefficiency issue. Period.
Nationwide chains are perfectly capable of recalling stock from stores that aren’t selling much of something, and moving it to stores that are running low on those supplies.
Local chains are capable of selling those products online, but there’s no need for them to massively mark up the prices to be incentivized to do so. Unless the product is intended to be a loss leader, they already have a profit margin factored in.
Hoarders create an artificial shortage, often in hopes of jacking up the price.
comment 6y ago · link · parent
It’s much more likely that anti-hoarding laws are passed in order to prosecute people who are planning to price gouge but haven’t been caught in the act.
Would you care to explain why lots of people would hoard when it’s both unprofitable and unnecessary to do so?
Once you have a supply of toilet paper, most people are not going to buy a ten year supply of toilet paper just because it isn’t exorbitantly priced.
People who think they can make a profit absolutely will buy a ten year supply of toilet paper.
comment 6y ago · link · parent
> On March 1, the day after the first coronavirus death in the United States, brothers Matt and Noah Colvin set out in a silver SUV to pick up some hand sanitizer. Driving around Chattanooga, Tennessee, they hit a Dollar Tree, then a Walmart, a Staples and a Home Depot. At each store, they cleaned out the shelves.
These people did not buy hand sanitizer in an area with high supply with an intention of getting it to people in need. They recognized that the value of hand sanitizer was about to go up, so they acted faster than everyone else to scoop up as much stock as they could, with the intention of charging people much more than they paid for it.
This had nothing to do with supply chain inefficiency, where supply is sometimes available in the wrong geographic location. They acted before the pandemic was a major national issue, in anticipation that it would become such a thing, in order that they would stand to profit from it without actually bringing any additional value to anyone.