HNHacker News
TopNewBestAskShowJobs

killercup

940 karma · joined May 12, 2012

I'm @killercup on twitter.
submissionscomments
killercup··on Austria Lobbies EU to Host Anthropic After US Access Curbs
Is this the way forward for the EU? Genuinely curious: Are there any EU providers that host the very good recent Chinese open weight models? Like, an EU-based alternative to DeepSeek's own API offering? To me, that sounds like an easier business to turn profitable, albeit maybe less impressive.
killercup··on A four year plan for async Rust
Because this code block looks quite complex, I want to add that it can also be just

    smol::block_on(async {
        println!("I'm async!");
    });
(I thought tokio had a helper like this too but could only find `tokio::runtime::Runtime::new().unwrap().block_on(async { println!("I'm async!"); });`.)
killercup··on Ripgrep 13.0
Ripgrep includes one of the most prominent algorithms from Hyperscan internally for some expressions.

Longer story: Ripgrep uses Rust's regex library, which uses the Aho-Corasick library. That does not just provide the algorithm it is named after, but also "packed" ones using SIMD, including a Rust rewrite of the [Teddy algorithm][1] from the Hyperscan project.

[1]: https://github.com/BurntSushi/aho-corasick/tree/4499d7fdb41c...

killercup··on && operator chains (and ||, possibly) generates unoptimizable LLVM IR
> If the work is done I expect Rust to be faster than C and C++ for the same reason that C++ can sometimes be faster than C: a more advanced type system can allow better optimization in many cases.

Every now and then I check in on whether LLVM can deal with rustc spamming "noalias" on all references. You can find the latest change in [1]. While in theory this unlocks _a ton_ of optimizations, noalias is used very rarely in C/C++ code so these compiler passes are not exercised a lot by existing LLVM tests and/or not realized in full.

[1] https://github.com/rust-lang/rust/pull/82834

killercup··on California nurse tests positive over a week after receiving Pfizer vaccine
Technically, he only got tested the day after Christmas, so I'm assuming they picked the more dramatic date.
killercup··on California nurse tests positive over a week after receiving Pfizer vaccine
I'm implying they did not read the article.
killercup··on California nurse tests positive over a week after receiving Pfizer vaccine
There's no need to take that bet if you can instead just read the article, however. No idea why you bring up a German statistic.
killercup··on California nurse tests positive over a week after receiving Pfizer vaccine
This is as suprising as the amount of comments assuming the nurse is female.

Edit for those who just comment after reading the headline: The article clearly states the nurse is Matthew W. and uses the he pronoun in the following sentences.

killercup··on Rust 1.48.0
dupe of https://news.ycombinator.com/item?id=25149969
killercup··on Making our own executable packer, part 13, Thread-local storage
> I don’t understand what a ‘packer’ is

You've found the right series of articles then!

killercup··on Making our own executable packer, part 13, Thread-local storage
Start at part 1.

No, he doesn't give you an answer, but you might just find it interesting enough to no longer have the qusstion.

killercup··on Cheap tricks for high-performance Rust
Author here. Please note that the "cheap" in the title refers to the effort needed as well as how sophisticated the tricks are; benchmarking and optimizing your algorithms is still super important! This was discussed quite a bit on the Rust subreddit [1] when it was published.

[1]: https://www.reddit.com/r/rust/comments/fdbszu/cheap_tricks_f...

killercup··on Writing Software to Last 50 Years
Tar was released in '79 iirc, so it's about the same age.
killercup··on Typesafe Error Handling in Kotlin
The RFC for adding `?` to the language might be a good start: https://rust-lang.github.io/rfcs/0243-trait-based-exception-...
killercup··on Command Line Applications in Rust
Hi, author of large parts of this here! This was written in the lead up to the Rust 2018 edition release last year, but it should still be pretty much up-to-date.

There is a lot of more info and discussions on the associated repo [1]. We didn't have a lot of time to quickly respond to everything recently, but: Questions, typo fixes, and additional chapters are very welcome :)

[1]: https://github.com/rust-lang-nursery/cli-wg

killercup··on Show HN: Faster UTF-8 validator
> Anyone have any ideas about which open source codebases UTF-8 validators exist in?

Rust's std library -- the canonical way to read a text file to a string is to (implicitly) use `std::str::from_utf8`. If I remember correctly, the current implementation doesn't use SIMD specificially but will of course contain vectored instructions if the compiler can select them on the platform you target.

I did a comparison with another SIMD based implementation last year. Maybe it's time to update it: https://github.com/killercup/simd-utf8-check

killercup··on Rustgo: Calling Rust from Go with near-zero overhead (2017)
(2017)
killercup··on Actix-web 1.0 – A small, pragmatic, and fast web framework for Rust
Not sure. Having the ability to abstract over tuples (using a similar mechanism as HLists for example) would help.
killercup··on Actix-web 1.0 – A small, pragmatic, and fast web framework for Rust
I can't speak for the actix-web maintainers but I did find this in their examples:

    #[get("/resource1/{name}/index.html")]
    fn index(req: HttpRequest, name: web::Path<String>) -> String {
        println!("REQ: {:?}", req);
        format!("Hello: {}!\r\n", name)
    }
see https://github.com/actix/actix-web/blob/e399e01a22b8a848ecbb...
killercup··on Actix-web 1.0 – A small, pragmatic, and fast web framework for Rust
Correct.

Fun fact: The amount of traits implementations that need to be generated to support tables with 128 columns actually makes diesel an interest benchmark of the Rust compiler.

killercup··on The Phantom Builder in Rust
The simple builder pattern often looks like a lot of boilerplate, I agree. But you can easily crank the coolness of it up a notch by using one of these properties:

- Hide the fields of your struct to not break your users when adding/changing fields

- automatically convert data in your setters (accept a reference to a string even though you want to store a file system path)

- use type parameters to conditionally set and validate values at compile time (by making your data type generic and implementing some setters so that they return a concrete value for that allowing you to write _different_ setters based on that type)

- by using the session type pattern to disallow incorrect method calls at compile times (e.g. calling `set_content` after calling `submit`)

killercup··on Rust 1.32 released
Took me a while to find it, but Rust's iterators have an `.inspect` method that gives you a read-only reference, so println debugging works fine. For more advanced tap-like stuff, use the `tap` crate (which allows you to write `array.tap(|xs| xs.sort())` for example, even though `sort` mutates in place and doesn't return the array).
killercup··on Inter UI, a typeface designed for user interfaces
Scroll down: You can use the cv04 font feature to change the style of the lowercase l!
killercup··on How to speed up the Rust compiler in 2018: NLL edition
This also makes incremental compilation faster, doesn't it?
killercup··on How to speed up the Rust compiler in 2018: NLL edition
> Is there something genuinely computationally harder about compiling Rust?

I'm not sure. Here's what I know: Rust has a complex type system. It also compiles whole packages (crates) at a time, and heavily uses monomorphization for generic code (that is probably less important for the type checking step but is quite heavy on the final compile-with-LLVM/link step).

If it was necessary, I'm sure it'd be possible to trade in some memory usage for CPU time (IIRC, a lot of memory is used for caching/memoization). But aside from outliners like that "10GB less memory usage" fix, rustc doesn't use that much RAM.

killercup··on Show HN: A syntax-diagram generator for rust's macro_rules()
tracked in https://github.com/lukaslueg/macro_railroad/issues/5 if anyone cares
killercup··on Rust Traits Deep Dive, Part 2
> Who determines the output type of "a + b"? "a"? "b"? Both? Are there implicit type conversions?

The Add trait is defined in `std::ops::Add` as:

    pub trait Add<RHS = Self> {
        type Output;
        fn add(self, rhs: RHS) -> Self::Output;
    }
(You can find the documentation on <https://doc.rust-lang.org/1.26.2/std/ops/trait.Add.html>)

Both the type of the `self` parameter and the concrete type of `RHS` determines which trait impl matches. For example: `2 + 2` chooses the `impl Add<i32> for i32 { type Output = i32; ... }` implementation (literal integers are of type `i32`). Something like `2 + &2` would choose `impl<'a> Add<&'a i32> for i32`.

> There's nothing here about what Rust does about conversions, but that may be covered in one of the other many parts of this series.

With operators, there are no implicit conversions involved, AFAIK. So all Rust can do is try and infer the type you want. For literal numbers, it can do so in a limited fashion. As seen above, if you write `let x = 42;` the type is inferred as `i32`. If you write `foo(666)` with `fn foo(x: u64)`, the literal 666 is inferred to be meant as `666u64`.

> The good news is that the Rust programming book is finally coming out in just 6 more days. So there's something better to read than this.

You can already read it here: https://doc.rust-lang.org/book/second-edition/index.html :)

killercup··on Show HN: ReLaXed – High-quality PDFs using web technologies
Waiting to see an example with footnotes and auto references ;)
killercup··on Go gets preliminary WebAssembly support
Please note that upx also compresses your binary contents and decompresses it at runtime.

When downloading a WASM file over HTTP, the server can gzip it transparently. It'd be interesting to compare the effects on the size with what upx does (which is more specialized than gzip).

killercup··on OSS-Fuzz – Continuous Fuzzing for Open Source Software
Or (American) Fuzzy Loop
Page 1 of 7Next →