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

Is it harmful to success. It certainly seems like Rust has been wildly successful. Maybe the async fragmentation will change that but I don't see any evidence of that so far.

comment 3y ago · link · parent

And APIs for timers!

comment 3y ago · link · parent

You don't. Anything that can be sent between threads needs to be `Send` and anything shared between threads needs to be `Sync`. This is really important invariant that the rust compiler provides.

comment 3y ago · link · parent

I'm not sure there is any reason in principle but it doesn't work now because the APIs for various things are not really standardized. So for instance timers. If anywhere in my code I do `tokio::time::sleep(Duration::from_millis(100)).await` (which is quite common thing to do) then my code will no longer work with a non-tokio runtime.

comment 3y ago · link · parent

> I mean, maybe you end up integrating splunk or perhaps self-hosting kibana

I think this is the issue. Both Splunk and OpenSearch (even self-hosted OpenSearch) get really pricy as well especially with large volumes of log data. Cloudwatch can also get ludicrously expensive. They charge something like $0.50 per GB (!) and another $0.03 per GB to store. I've seen situations at a previous employer where someone accidentally deployed a lambda function with debug logging and ran up a few thousand $$ in Cloudwatch bills overnight.

You should look at Coralogix (disclaimer: I work there). We've built a platform that allows you to store your observability data in S3 and query it through our infrastructure. It can be dramatically more cost-effective than other providers in this space.

comment 3y ago · link · parent

Sure, and a lot of tools will do this in one way or another. Either instrument code directly or provide annotations/macros to trace a specific method (something like tokio-tracing in the Rust ecosystem).

However, tracing literally every method call would probably be prohibitively expensive so typically you have either:

1. Instrumentation with "understands" common frameworks/libraries and knows what to instrument (eg request handlers in web frameworks)

2. Full opt-in. They make it easy to add a trace for a method invocation with a simple annotation but nothing gets instrumented by default

comment 3y ago · link · parent

"The" solution is not macros. The solution is what is provided by the language. If you are calling a bunch of different functions that return different error types then you either have to map them manually (using map_err) or you can create your own error type and implement From<XYZError> to automatically lift into your own error type. I agree that it is a lot of boilerplate which is why there are good libraries for generating the boilerplate with macros. But the underlying mechanism is not really obscure. It is covered quite well in the rust book (https://doc.rust-lang.org/book/ch09-02-recoverable-errors-wi...).

comment 3y ago · link · parent

Ah didn't realized it had been removed. I gave up on it after it became clear it was never going to make it into stable rust. I do hope deref patterns gets some traction though as it could really be a nice feature.

comment 3y ago · link · parent

> using generics for things like RC, ARC

There is an unstable feature for "box syntax" which both allows you to construct a `Box<T>` as let foo = box a (instead of let foo = Box::new(a)) but also to use box as a keyword in pattern matches to deref the box automatically. So struct Foo { value: Box<Bar> };

let Foo { value: box Bar } (in which case value is bound to a &Bar) which was really nice.

It got subsumed into a more generic "deref patterns" project which doesn't seem to be going anywhere but I hope it does because it makes the language much more ergonomic IMO.

comment 3y ago · link · parent

I don't understand what you would include in the std lib exactly. Defining error types is just defining regular types with domain-specific error information. Macros to make that less verbose seems like the exact sort of thing you would want to be implemented in third-party libraries.

comment 3y ago · link · parent

> gun smoke seem from another location, eyewitness reports of Oswald that make it impossible for him to make the shots in those timeframes, or the eyewitness reports of a "police officer" near the grassy knoll that was never accounted for or found

Not sure what specifically you are referring to with all of them, but in general it covers the various eyewitness reports used to establish multiple shooters. In short (and would really recommend reading the book if you are interested in the subject) they are not credible. Often inconsistent (both internally as the stories are told on different occasions) and also mutually inconsistent. There were a lot of people there that day and it was quite chaotic after the assassination. It doesn't seem that implausible to me that there would be a lot of conflicting information from eyewitnesses. But the eyewitness testimony taken as a whole is completely consistent with Oswald firing all three shots from the Book Depository.

> magic bullet

From memory, there was nothing "magical" about the magic bullet. The injuries on both Kennedy and Connelly and the video evidence are completely consistent with the official story that a bullet hit Kennedy in the back of the neck, exited through his throat and then hit Connelly in the the thigh.

> exit wound

I assume you mean the story that there was an exit wound on the back of Kennedy's head. But according to the actual autopsy that was not the case. He had an entry wound on the back of his head and exit wound on the side/front (again consistent with the official story). The story of a rear exit wound is from two doctors who treated Kennedy at the hospital in Dallas. They were not doing an autopsy. They were administering emergency medicine to a man whose head was covered in blood and brain fragments. And there accounts have been directly contradicted by other doctors who were there.

comment 3y ago · link · parent

I didn't read the article but a few months ago I randomly came across https://www.posner.com/case-closed and gave it a read. I haven't really read much else about the Kennedy assassination and the various conspiracy theories (certainly no other 400p books on the subject) but came away from the reading pretty impressed with the thoroughness of the argument. Spoiler alert, the argument is that the official story that Oswald acted alone is almost certainly correct and evidence to the contrary is entirely unconvincing when examined in detail.

comment 3y ago · link · parent

Ha, I had always assumed it meant something on the order of inches.

comment 3y ago · link · parent

They were in the same car

comment 3y ago · link · parent

Yeah. it's bit awkward to make `Option` implement `IntoIterator` and can certainly cause some weird and subtle bugs. But on the other hand it does make a whole lot of things work nicely. For example, you can turn a `Vec<Option<T>>` into a `Vet<T>` trivially with `foo.into_iter().flatten().collect()`. And generally it's nice to have Option and Vec composable.

comment 3y ago · link · parent

Ah yes, I wasn't thinking about the gc. That makes more sense now. Thanks!

comment 3y ago · link · parent

I'm still not sure I follow what the gain is here? I get that it makes it possible to differentiate between an int and pointer, but why is that actually important. The compiler already has type information right? And would know whether a value is a pointer or int?

comment 3y ago · link · parent

Sorry to hear that you had PPD but glad you were able to get help and feel better. I had a child around the same time and I can empathize with your experience. It's a wonderful time but can also be very overwhelming, especially for a first child (which is the case for me). It's like you take a major life change, natural anxiousness about your kid (are they hitting all their development milestones, eating enough, getting enough sleep, sleeping too much, etc, etc, etc) and mix in a big dollop of sleep deprivation.

> New dads: if you feel unusually down, anxious, frustrated, angry, or depressed, consider talking to your PCP about treatment. Taking medication is not an admission of failure. Being a father is tough, but it shouldn't feel impossible.

Amen. Being the internet, people are going to be jerks but I for one appreciate you sharing your experience.

comment 3y ago · link · parent

Interesting. I have the opposite intuition. With a push-based model you end up needing some sort of back-pressure mechanism which gets complicated in a hurry. With a pull-based model you get back pressure "for free"

comment 3y ago · link · parent

It is opt-in. If you're using Tokio then you can specify whether you want to use a single-threaded or multi-threaded runtime. Multi-threaded is "default" in the sense that if you just use `#[tokio::main]` then you get a multi-threaded runtime but you can also just do `#[tokio::main(flavor = "current_thread")]` to get a single threaded executor.

More to the point, even using a multi-threaded runtime won't spawn threads willy-nilly. It will default to using N worker threads (where N is the number of CPU cores available).

comment 3y ago · link · parent

What was the original meaning? When I hear "serverless" I think basically:

1. I don't have to think about or manage any servers

2. Usage is metered at a very fine-grained level (per X requests to the API/per GB of data/etc)

3. No fixed cost. You only pay for usage.

Was there a different meaning originally?

comment 3y ago · link · parent

Indeed. I would add as well that React (for me at least) went a long way towards erasing the difference between "backend" and "frontend" development. When I was a pup, they were very different things and a "frontend" developer meant basically someone who was really good at CSS and HTML and new all the magic incantations you had to do to create a nice UI with them. There were of course precursors such as AngularJS (and others) but React was really the first one for me where I could see frontend dev as just learning another framework the same as I would learn a backend framework.

comment 3y ago · link · parent

async/sync and sequential/parallel are orthogonal concerns. You can write sync code which does work in parallel (on different threads/cores) for something like a numerical algorithm that can be parallelized in some way. Deciding whether something is sync or async is about whether it needs to suspend (in practice, mostly whether it needs to do IO) which is much easier to understand up front. Sometimes it changes of course, in which case you have to do some refactoring. But in a decade of programming professionally in Scala and Rust (both of which have "colored" functions) I can count on one hand the number of times where I had to change something from sync to async and it took more than a few minutes of refactoring to do it.

comment 3y ago · link · parent

That's really cool!

comment 3y ago · link · parent

Really cool. I've spent a lot of time digging through your code in aquatic :) It's a really cool project!

comment 3y ago · link · parent

Oh that's awesome! Thanks!

comment 3y ago · link · parent

I did an echo server with multi-shot here (using the io_uring rust bindings) https://github.com/thinkharderdev/io-uring/blob/ring-mapped-.... My biggest issue with io_uring is figuring out what is available in which kernel version :)

comment 3y ago · link · parent

You can find some hello world level examples here https://github.com/axboe/liburing/tree/master/examples.

Right now, what it can do really well is non-blocking file IO. My (limited) understanding is that as of now, the benefits of io_uring over epoll for network IO is a bit more ambiguous. That said, io_uring is adding new features (already available in linux 6 kernel) that are really promising. See https://github.com/axboe/liburing/wiki/io_uring-and-networki....

comment 3y ago · link · parent

I've tinkered around with io_uring on and off for the last couple years. But I think it's really becoming quite cool (not that it wasn't cool before... :)). This was a really interesting post on what's new https://github.com/axboe/liburing/wiki/io_uring-and-networki.... The combination of ring-mapped buffers and multi-shot operations has some really interesting applications for high-performance networking. Hoping over the next year or two we can start to see really bleeding edge networking perf without having to resort to using DPDK :)

comment 3y ago · link · parent

I took the parent to be saying something like "even if medically assisted suicide were available as an option without restriction, there is no point at which you would decide to do it because the onset of dementia is so gradual." That is, it would be difficult to make the decision (for some/most people at least) while you were still having lucid moments where you could still have some quality of life. And by the point where you have completely lost it, you are no longer of sound mind to consent to a medically assisted suicide.
1
678
24