News for hackers. Stuff that matters.

killercup

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.
Re:A four year plan for async Rust on Tuesday November 07, 2023 @12:05PM (#38179447)
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!"); });`.)
Re:Ripgrep 13.0 on Monday June 14, 2021 @03:20PM (#27506992)
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...

> 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

Technically, he only got tested the day after Christmas, so I'm assuming they picked the more dramatic date.
I'm implying they did not read the article.
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.
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.

Re:Rust 1.48.0 on Thursday November 19, 2020 @11:00AM (#25150785)
> I don’t understand what a ‘packer’ is

You've found the right series of articles then!

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.

Re:Cheap tricks for high-performance Rust on Tuesday June 23, 2020 @03:57AM (#23611056)
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...

Re:Writing Software to Last 50 Years on Tuesday January 14, 2020 @01:45PM (#22047906)
Tar was released in '79 iirc, so it's about the same age.
Re:Typesafe Error Handling in Kotlin on Tuesday December 17, 2019 @03:32PM (#21818460)
The RFC for adding `?` to the language might be a good start: https://rust-lang.github.io/rfcs/0243-trait-based-exception-...
Re:Command Line Applications in Rust on Saturday November 23, 2019 @07:44AM (#21613834)
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

Re:Show HN: Faster UTF-8 validator on Saturday November 16, 2019 @08:37AM (#21552549)
> 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

(2017)
Not sure. Having the ability to abstract over tuples (using a similar mechanism as HLists for example) would help.
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...
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.

Re:The Phantom Builder in Rust on Thursday March 28, 2019 @04:09PM (#19516085)
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`)

Re:Rust 1.32 released on Friday January 18, 2019 @05:48PM (#18943854)
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).
Re:Inter UI, a typeface designed for user interfaces on Saturday December 29, 2018 @05:14PM (#18786032)
Scroll down: You can use the cv04 font feature to change the style of the lowercase l!
Re:How to speed up the Rust compiler in 2018: NLL edition on Tuesday November 06, 2018 @10:51AM (#18392041)
This also makes incremental compilation faster, doesn't it?
Re:How to speed up the Rust compiler in 2018: NLL edition on Tuesday November 06, 2018 @10:47AM (#18392014)
> 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.

Re:Rust Traits Deep Dive, Part 2 on Wednesday June 20, 2018 @04:14AM (#17353471)
> 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 :)

Waiting to see an example with footnotes and auto references ;)
Re:Go gets preliminary WebAssembly support on Saturday April 14, 2018 @06:27AM (#16836743)
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).

Older »