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 4y ago · link · parent

Not to defend Elon Musk since I generally agree that this whole thing is a dumpster fire of his own making but he couldn't have backed out by paying the contract breaking fee. Twitter was suing him for specific performance, meaning they were asking the courts to force him to close the deal. And everything I read during the saga seemed to be in agreement that Musk had ~0% chance of getting out of the deal.

comment 4y ago · link · parent

No, it doesn't. Pure FP is about pure functions, meaning only that they don't have side-effects (essentially just that you could replace the function call with it's return value without changing the semantics of the program). If a function mutates some global state then that would certainly make it impure but a function which takes an input, mutates it and returns the mutated value is absolutely pure.

comment 4y ago · link · parent

Correctness is important to everyone. Presumably everyone involved would rather software work rather than not work. Time commitments are what they are and sometimes quick and dirty is what you have to do but I don't actually think there is some hard tradeoff between fast and correct. The whole idea of having rigorous foundations is that you have a set of primitives which can compose together in well-understood ways so you can build correct programs quickly without necessarily re-inventing the wheel each time.

comment 4y ago · link · parent

I don't think any paradigm is inherently better at managing complex and messy state. I've worked on several very complicated applications written in a pure FP style which handled complex, shared mutable state really elegantly (and many OO applications where state management was a terrible mess...). And more generally I think that pure FP and specifically effect-oriented pure FP gives you really nice, composable tools to handle complex state safely in concurrent applications.

But yeah, for game development pure FP is probably a bad fit because you need pretty precise control over memory allocation and layout (from what I understand, never actually done any game dev).

comment 4y ago · link · parent

> as a general rule OOP languages seem to make dealing with state much easier

I disagree. One of the most significant benefits of FP (and pure FP in particular) is being able to deal with mutable state safely in concurrent programs. This is essentially the core problem which effect systems try to solve.

comment 4y ago · link · parent

Yeah, the bigger risk is just how insanely pro-ccyclical the housing market is. There are of course ups and downs in the world of software engineering but it's not like if there is a recession, all new software development is halted. Whereas in the housing market, housing starts basically fall off a cliff during a recession.

comment 4y ago · link · parent

It's still a very weird and perplexing phenomenon. Settings aside people living in old shipping containers it just seems like it wouldn't be all that hard to make prefabricated housing that looks more or less identical to houses that actually are built for dramatically cheaper.

comment 4y ago · link · parent

Did that recently change? I had to renew my passport at the office this year and it was very strictly by appointment only.

comment 4y ago · link · parent

Yep, agree wholeheartedly with this. I came to Rust from Scala where writing an explicit for loop is looked at as one step above using goto :) and it took me a while to just give in and write the imperative version.

comment 4y ago · link · parent

The boring (and probably mostly correct) answer is that engineers don't like writing documentation so it is the last thing to get done, if it gets done at all. This is especially true of FOSS projects. You may be motivated to spend your free time hacking on something cool and interesting, but spending your free time writing documentation is another matter.

comment 4y ago · link · parent

Yeah, that's why I can't help but think that some of these dark patterns arise as bugs. Maybe I just have too much faith in humanity, but I can't imagine some PM sitting there thinking this would be a good idea that wouldn't eventually blow up in their faces. But who knows, maybe I'm just naive.

comment 4y ago · link · parent

I have a (not really serious, but kind of) theory that metrics driven organizations stumble into various dark patterns through software bugs. In this case, that would look like:

1. You want to convert people to "pro" users so you try to show them all the money they can save by doing so.

2. Because of a bug in the code somewhere, you end up showing the discounted price in the cart until checkout.

3. Because some number of people don't pay attention and don't realize the switcheroo happens at the end this bug actually increases conversion.

4. Someone eventually notices the bug (after customers like you complain about it!).

5. When they fix it the metrics are adversely impacted.

6. The bug is now a "feature".

This is of course all very shortsighted since you are essentially burning customer trust for a short-term gain in conversion so it's bad for the medium/long term business. But the team has to hit its KPIs, which are tracked on a daily/weekly basis!

comment 4y ago · link · parent

Yeah, I've been stung more than once by the `Fn/FnOnce` distinction

comment 4y ago · link · parent

In general I agree that the difficulty and need to know the "gritty details" is overstated, but there is one aspect where that is true and I have found it confusing at times. Since it has to capture anything in scope of an await point, you will sometimes get somewhat non-obvious compiler errors about how "X is not Send" when it's not really obvious at all why it would need to be. So something like

``` let locked = std::sync::RwLock<Foo> = ...;

let lock = locked.write().unwrap();

bar.doSomethingAsync().await ```

will complain because `std::sync::RwLockWriteGuard` is not send. Just looking at the code it is not really clear why it should need to be. To understand why, you need to understand how the compiler transforms this code into a state machine and capture everything in scope of an await point in Struct that must be send (since it can shift to new thread when resuming). It makes sense when you understand what's happening under the hood but can be a bit baffling when you are starting out.

comment 4y ago · link · parent

Great name!

comment 4y ago · link · parent

You've still got 2 years!

comment 4y ago · link · parent

That makes sense assuming you have already written your backend in JS. In that case, yeah the bar for rewriting in another language should be high (as it should be for any ground-up rewrite). But it's not a "premature optimization" when you are deciding on the tech stack to begin with.

comment 4y ago · link · parent

Nothing really, but they are mainstream languages and OCaml is (currently) not. So if you really need one of those then there is already a more widely adopted option that gives it to you. It's not that OCaml is bad (I like it a lot) it's that to adopt it you need a really compelling reason to do so.

comment 4y ago · link · parent

I think to gain adoption any general purpose language needs a clear niche to gain a foothold. If you are choosing a tech stack then choosing a language that is not already widely adopted is always a risk. The tooling is usually inferior, there are not necessarily high-quality libraries in domains you care about and you pay a cost in training new employees in a new tech stack.

Java was an OO, garbage collected language that supported (sort of...) hot swapping code. Go was a reasonably performant, garbage collected language that compiled to static binaries and has great cross-platform support. Some grad student decided to write Spark in Scala so you had to use it for Spark jobs Rust is a systems programming language with zero-cost abstractions and no GC that allow you to write mostly memory-safe code.

What is the killer feature of OCaml that makes it worth the investment?

comment 4y ago · link · parent

I'm genuinely curious, does the work you are hiring for really require a PhD? To put it a different way, if you and the current employees in your job all started immediately after finishing your undergrad degree would you be any worse at your job?

comment 4y ago · link · parent

Everything is a risky bet and there is always subjectivity involved in prices, but what I mean by "intrinsic value" is that the the asset has so tangible use that is valuable to people directly. Oil has intrinsic value because people can use it to generate electricity. As you say, equities have (theoretically) some cash flow associated with them so you are buying a cut of future profits.

But what is the theoretically correct price of Bitcoin? In some sense it's just like every other asset, the right price is what someone else will pay for it. But what you actually care about is what someone will pay for it 1/5/10 years from now (especially if you plan to use it as a store of value). And how do you even begin to model that?

comment 4y ago · link · parent

Because it doesn't seem like Crypto is a good inflation hedge. If you're worried about inflation from unwise increases in the fiat money supply, then it seems like you want something with intrinsic value (real estate, other tangible assets, inflation protected bonds, etc), but crypto is the opposite of that. It's too volatile to be an actual currency so what is it exactly other than a purely speculative asset?

comment 4y ago · link · parent

Is it? I though that work stealing was a basic requirement for maintaining some semblance of cache locality.

comment 4y ago · link · parent

Was Bezos an engineer? I thought he was a hedge fund guy before founding Amazon.

comment 4y ago · link · parent

Wouldn't that just be a vector of pointers?

comment 4y ago · link · parent

gRPC and JSON are not really alternatives. gRPC is an RPC framework that typically uses protocol buffers as a serialization format but is perfectly capable of using JSON.

When you would use JSON over HTTP vs gRPC? I can think of a couple cases:

1. Your infrastructure doesn't support HTTP/2 with trailers.

2. You need to send/receive payloads that aren't well-defined. The nice thing about JSON vs protocol buffers is that JSON is self-describing and flexible. In most languages you have libraries which can deal with JSON as essentially a Map<String,Object>, with maybe a nice cursor API that allows you to pick/update specific fields without knowing anything else about the object structure. You can encode the JSON AST in protocol buffers but it will not be very nice I don't think.

3. You want your wire-format to be human readable for some reason. You can technically do this with gRPC as it is not strictly tied to protocol buffers as the wire format for messages, but in practice it is kind of a pain and language support for doing it can be spotty. At the very least you have to figure out how to do it as protocol buffers is very much the default.

4. The code-generated classes/structs from gRPC IDL are often quite bad to work with. If you've ever used the case classes generated by scalapb (Scala) or the structs generated by Prost (Rust) then you know what I mean. You end up having to create a parallel set of data structures for your protobuf message types to keep yourself sane. With JSON on the other hand, you can typically create classes/structs which are nice to work with internally but also directly serializable to JSON.

All that said, gRPC is really nice. If I am bootstrapping a project, gRPC is definitely the default and I need a good reason to use anything else.

comment 4y ago · link · parent

gRPC streaming is too complicated so you should ... deploy Kafka?

comment 4y ago · link · parent

Fair enough, maybe tautology is the wrong word, but I do think everyone agrees with it. Who ever says "we need to have more complicated code"? The question is how do you define simplicity, because it is not always obvious. Every overly-abstracted mess I've ever seen was done in the name of "simplicity". Basically, let's add an abstraction so we can "simply" swap in another database in the future, or handle X hypothetical use case by only changing configurations. Likewise, I've seen 1500 line methods with dizzying, incomprehensible control flow that was nevertheless composed entirely of "simple" if/then/else statements. And a well chosen abstraction or two made things much simpler to read, understand and modify.

comment 4y ago · link · parent

Thousands of classes with indirection is not clean code and write code as simply as possible is tautology. Of course it should be as simple as possible. The interesting question is what counts as simple.

Setting that aside though, the author seemed to mostly be talking about architectural simplicity in the article. He specifically called out "premature move to microservices, architectures that relied on distributed computing, and messaging-heavy designs" which I think is spot on. Distributed systems are fundamentally hard and involve a lot of difficult tradeoffs. But somehow we have convinced ourselves as a profession that distributed systems are somehow easier.

comment 4y ago · link · parent

I came to Rust from Scala and I think it actually really helped. My first non-trivial Rust project was a straight port of a Scala library and it was actually pretty uncanny how straightforward the translation was. I'm sure the Rust code could have been optimized to avoid a few clones here and there but in general I've found that you can avoid a lot of the really tricky edges of Rust by just using clone/Arc/Box/etc. In non performance-critical code sections it's probably not even worth avoiding those things.
1
8910
24