Better HN
topnewbestaskshowjobs
Log inSign up

thinkharderdev

1,874 karma · joined Jun 12, 2019 (7y ago) · 701 submissions

https://www.thinkharder.dev

[ my public key: https://keybase.io/thinkharder; my proof: https://keybase.io/thinkharder/sigs/Ibpz0COsvz2qYl2K8YfzrhucHf2rcZIxityh5WvYC_k ]

Submissions

comment 1y ago · link · parent

Is it? You know for a fact that there are bugs in some of your dependencies. But how many bugs would the code you wrote from scratch instead of adding a dependency have?

comment 1y ago · link · parent

If there were a multi-billion dollar industry of scammers always trying to trick them into taking the screws out of things so they could steal from them, then no I probably wouldn't buy them anything with visible screws.

comment 1y ago · link · parent

I read the Einstein biography. Highly recommended. But to the parents point, I came way think Einstein was a huge asshole, especially given his pop culture representation as a kindly old grandfather type.

comment 2y ago · link · parent

It's similar but no really the same thing. It has to be done up front by initiating a multi-part upload to start. The parts are still technically accessible as S3 objects but through a different API. But the biggest limitation is that each part has to be >5MB (except for the final part)

comment 2y ago · link · parent

EBS pricing (and by extension anything the effectively bundles EBS) is absolutely insane.

comment 2y ago · link · parent

I don't think it's particularly obvious or necessary. AWS makes its money on big enterprise customers who probably don't want or need this feature. Hobbyists learning AWS in their spare time are a rounding error on AWS revenue.

I would bet that the reason they don't implement it is not that they're being "shady" but because they don't care about the hobbyists and personal projects and implementing hard spending limits would be a huge, complicated feature to implement. And even if they did put in the huge effort to do it, individuals would still manage to not use it and the steady trickle of viral "I accidentally spent X thousands bucks on AWS" stories would continue as usual.

comment 2y ago · link · parent

The chrome browser itself I would think

comment 2y ago · link · parent

Yglesias is just repeating arguments that have been mode over and over by people who do in fact know what they are talking about (Noah Smith makes the argument well here https://www.noahpinion.blog/p/imports-do-not-subtract-from-g...)

The moon base example I think makes the argument very clearly. If you have an economy which produces nothing then it has a GDP of 0. If the increase imports for whatever reason, their GDP is still 0, which means that imports doesn't subtract from GDP, otherwise their GDP would be negative which is nonsensical.

But all this is sort of beside the point because arguments from accounting identities are almost always nonsense.

comment 2y ago · link · parent

> They also correctly stated that the GDP growth in the last quarter was largely driven by government spend, and if you take out the private sector, there was little growth.

The entire article is pointing out quite clearly that this, in fact, not correct.

> They correctly stated that the job numbers always get revised down not up.

This is also demonstrably false with like 5 minutes of research. This is all a matter of public record https://www.bls.gov/web/empsit/cesnaicsrev.htm

comment 2y ago · link · parent

The fact that it's named after Murray Gell-Man, a Nobel prize winning physicist should tell you something. Intelligence doesn't save you from it.

comment 2y ago · link · parent

You linked me to an article that defines an unsafe language as:

"a programming language which, by default, allows code to introduce memory-related vulnerabilities (use after free, buffer over/under flow, use of uninitialized memory, type confusion) and undefined behavior,"

Which was my whole point. The "and undefined behavior" part is absolutely essential to the definition because you can't guarantee the first part without it.

> Go does not, at least not in any non-contrived scenario not involving "unsafe" or FFI.

It absolutely does. You can find examples of code that triggers undefined behavior in this thread. You can hand-wave them away as being "contrived" (which is literally correct) but that doesn't just make the problem go away.

We had a whole collective meltdown (pun intended) over spectre and meltdown a few years back even though AFAICT there have never been any known exploits in the wild. But most people who are knowledgeable in these things still took it seriously because they realized that:

1. Just because you haven't found a specific instance of an in-the-wild exploit doesn't mean there isn't one 2. You don't want to necessarily wait because if something it exploitable in theory is will almost certainly be exploited sooner or later. And it takes time to sort this stuff out

Is this relevant to your average working dev slinging micro-services in go? No, probably not and it's probably not something you should even think about for the most part. But if you're writing a complex, mission critical system with very hard security requirements? Yeah maybe you should worry about little bit about the fact that Go is, by the definition you yourself provided me, not a memory safe language.

comment 2y ago · link · parent

> You'll be using an idiosyncratic definition the rest of the industry does not use, but you do you.

What definition are you using that you seem to think is the one definition of memory safety that is canonical?

> don't have buffer overflows, integer overflows, use-after-frees, double frees, controllable uninitialized pointers, and all the other memory lifecycle vulnerabilities

Any guarantees about this are dependent on the language not having undefined behavior in its safe subset. Once you have undefined behavior any other guarantees made about memory safety are significantly weakened.

> where are the vulnerabilities?

I don't know of any other than code written to demonstrate the concept. But I imagine if you look at any large Golang codebase you will find race condition bugs. So the fact that you have potential undefined behavior resulting from an extremely common coding error seems like it might be something to be concerned about (to me at least). Especially given how little Golang helps you write safe concurrent code.

That's not to say that Go is therefore totally useless and everyone should stop using it now because it's "insecure". But it also seems ... unwise ... to me to just pretend it's nothing because it is hard to exploit or that we don't have any (known) examples of it being exploited.

comment 2y ago · link · parent

Very true, but I do think there is an issue in the margin about how easy it is to ignore errors. For example, in Java you might have something like

``` void checkPermissions() throws AuthException ```

so you have to actively ignore errors by catching the exception. Likewise in Rust you can do

``` fn check_permissions() -> Result<(),AuthError> ```

In that case you can just use the `?` operator to short-circuit (and clippy will warn you if your forget to do that).

In other words, while language design can't fully prevent you from ignoring precondition checks, it can make it harder to forget or even force you to actively ignore precondition failures

comment 2y ago · link · parent

> An example of extraordinary code would be code that interfaces with and/or pulls in non-memory-safe legacy C code.

That's my point though. Of course calling non-memory safe native code over FFI can lead to memory-safety problems in any language. Likewise using the "unsafe" subset that basically every language has. But none of that is required in Go. It is only required that you mutate shared state from different threads, which is something that I would imagine happens in a lot of Go code codebases since it is an extremely easy mistake to make.

To be clear I think:

1. Go is mostly a memory safe language because it does in fact prevent the most common memory safety issues in C/C++ (UAF, buffer overflows, etc)

2. It is LESS memory safe than other modern memory-sage languages (Rust, Java, C#, Python, etc....)

3. The memory safety issues in Go are very difficult to exploit in code that is not specifically crafted to surface them

comment 2y ago · link · parent

> ordinary code is memory-safe by default

What does that mean? What constitutes "ordinary"? I'm not sure there is any official definition of memory safety, but I would consider it to mean that aside from code that is explicitly marked as unsafe it is impossible to write code that has undefined behavior.

comment 2y ago · link · parent

A less cynical view of it is just that diagnosis of engine and dental problems is still pretty subjective so different providers will have different judgements about what constitutes a problem that needs fixing. If one dentist says you have a cavity that needs filling and another doesn't it doesn't automatically mean the first dentist is crooked. It could be the second one is wrong or it could just be that what constitutes a cavity that needs filling is not very well-defined.

comment 2y ago · link · parent

(Un)safe is a bit of an overloaded term but Rust's concurrency model is safe in the sense that it statically guarantees that you won't have data races. Trying to mutate the same memory location concurrently is a compile-time error. Neither C++ nor Golang prevent you from doing this. Aside from that

comment 2y ago · link · parent

> It's caused a lot of trouble so far and for what?

The "for what" seems pretty obvious, no? It's the same reason you would use Rust over C in any other project. Memory safety and more modern PL features.

comment 2y ago · link · parent

Not the OP but the complicated part to me is just that the fd has a global cursor which makes concurrent access require synchronization. The rust std::fs::File API at least makes this clear through mutability requirements but I imagine in other languages this either can cause a lot of bugs or requires a more complicated API to surface the functionality safely.

comment 2y ago · link · parent

Ah yeah, I've implemented LRU caches this way (hash map with an intrusive linked list overlayed on the values) but didn't put 2 and 2 together :)

comment 2y ago · link · parent

Isn't that just a different data structure? How do you preserve insertion order in a hash map?

comment 2y ago · link · parent

Did you stop? If so, why?

comment 2y ago · link · parent

The actual advice from a nutritionist that was quoted was

> focusing less on meal replacements and more on whole fruits and vegetables from local farmers, in addition to occasional animal products from farms where those animals were “raised with sustainable practices.”

Which does strike me as advice for relatively affluent people (although "for the 1%" is a bit of a stretch....). It is indeed not that easy to buy fresh, locally grown fruits and veggies for many people. But I do take your point. I don't think money is really the barrier to people eating a nutritious diet of whole foods. The limiting factor is probably time and discipline. You need to shop for fresh foods every few days (real foods spoil!) and actually prepare meals, when the alternative of cheap, prepared foods that are mostly junk are readily available.

comment 2y ago · link · parent

How exactly? If we take the simplest possible "hello world" service, then protoc generates all the code for a gRPC service without you having to manually type anything

comment 2y ago · link · parent

You need all the same stuff with a REST API only instead of using tooling to codegen all the boilerplate you have to write it by hand (or use janky OpenAPI code generators which, in my experience, rarely work very well).

I am increasingly annoyed by protobuf as a standalone format but given the choice to create a new API using gRPC (where I can spend five minutes writing some proto files and then codegen all the boilerplate I need for both server and client in any mainstream language) and creating it as a REST API where I have to manually code all the boilerplate and decide between a zillion different ways of doing everything I will choose gRPC 100% of the time.

comment 2y ago · link · parent

> Protobuf is intentionally designed to NOT require any parsing at all

This is not true at all. If you have a language-specific class codegen'd by protoc then the in-memory representation of that object is absolutely not the same as the serialized representation. For example:

1. Integer values are varint encoded in the wire format but obviously not in the in-memory format

2. This depends on the language of course but variable length fields are stored inline in the wire format (and length-prefixed) while the in-memory representation will typically use some heap-allocated type (so the in-memory representation has a pointer in that field instead of the data stored inline)

comment 2y ago · link · parent

> The worst part of all is that most people don’t need gRPC, but use it anyway. It’s a net addition of complexity and you’re very likely not getting the actual benefits. I’ve seen countless simple REST APIs built with language-native tooling burned to the ground to be replaced with layers of gRPC trash that requires learning multiple new tools and DSLs, is harder to troubleshoot and debug, and ultimately tends to force API rigidity far sooner than is healthy.

This sounds odd to me because I don't really see how gRPC would cause any of those issues?

> layers of gRPC trash

What layers? Switching from REST (presumably JSON over http) to gRPC shouldn't introduce any new "layers". It's replacing one style of API call with a different one.

> learning multiple new tools and DSLs

New tools sure, you need protoc or buf to build the bindings from the IDL, but what is the new DSL you need to learn?

> ultimately tends to force API rigidity far sooner than is healthy

How does gRPC force API rigidity? It is specifically designed to be evolvable (sometimes to its usability detriment IMO)

There are some definite footguns with gRPC and I am becoming increasingly annoyed with Protobuf in particular as the years go on, but going back to REST APIs still seems like a huge step backwards to me. With gRPC you get a workflow that starts with a well-defined interface and all the language bindings client/server stubs are generated from that with almost zero effort. You can kind of/sort of do that with REST APIs using openapi specs but in my experience it just doesn't work that well and language support is sorely lacking.

comment 2y ago · link · parent

> As I understand it, unsafe pretty much says "what you are doing here may violate memory safety".

I don't think this is true in general. Unsafe is used pretty frequently for things that are themselves memory safe but may violate invariants which can cause memory unsoundness in other places. An example would be `std::str::from_utf8_unchecked` which is not itself memory unsafe. But various safe methods on `str` are memory safe ONLY if the str contains valid UTF8

comment 2y ago · link · parent

Directly from the linked article: "On average, first quarter 2024 earnings results were solid. Four sectors — Communication Services, Utilities, Consumer Discretionary and Information Technology — generated the strongest earnings growth for the quarter"

But that was just a link I came across quickly. You can look at almost any economic statistics you want and see that the economy (at least in the US, you mentioned the S&P 500 so I assume you are US-based) is quite strong right now.

comment 2y ago · link · parent

This is not even remotely true. Corporate earnings are growing strongly across almost all sectors (https://www.usbank.com/investing/financial-perspectives/mark....)
12345
24