Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What a weird thing to complain about. The Rust code in TFA are purely arithmetic and imperative function calls. Any C developer that is good enough to care about the algorithm mentioned will have no issue reading such Rust code, heck, they could even throw the code to chatgpt to translate for them no problem.

Such a good and detailed article that packed with techniques that are applicable everywhere yet the complaints are: “but rust”.

Regarding Python, how could such optimizations be implemented in Python? Generating LLVM bytecodes directly aside.



Fluent in C and C++ among others, know nothing about Rust. It's mostly easy to follow, but I'm having trouble with notation like `&[u32]` and `&[u32; P]`. Arrays that hold unsigned 32 bit integers? But there's `Vec<u32>` which also seems like an array type? Is it like the difference between C++ primitive arrays and std::vector?


`&[u32]` is essentially `std::span<const uint32_t>`.

`&[u32; P]` is similarly something like `std::span<const uint32_t, P>`.

`[u32; P]` (no `&`) is essentially `std::array<uint32_t, P>`.

`Vec<u32>` is essentially `std::vector<uint32_t>`, yes.


Thanks


For `&[u32]` and `&[u32; P]`, those are both references to an array of unsigned 32 but integers, however the former is to an array of any size (and carries its size at runtime), whereas the latter is to an array with an explicitly known size at compile time. It's unusual in C, I think you can express it as `int[24] *` (or possibly some other permutation, I'm away from a compiler).

Vec<u32> is pretty much like std::vector compared to them, yeah.


I have not studied Rust and find its syntax alien. It looks like a cross between a functional language and C++. Trying to read it is like forcing myself to read Italian. I don’t know Italian, but have studied Spanish and Latin. I can sort of figure things out if I put in effort, but there is always uncertainty when I do. That is the problem with reading Rust.

This could be addressed if I just learned Rust (much like my difficulty with Italian could be addressed by studying Italian). However, I already know at least 10 programming languages. I am unwilling to learn the latest fashionable language unless it can promise me that the language will not change and there will never be another fashionable language for me to learn. Given that Rust rejected the standardization process that C and C++ embraced, and Zig is expected to replace Rust one day, I doubt Rust can make such assurances.

As for Python, it is often used for teaching CS and everything except the assembly code is doable in it. Using low level assembly from Python would require using the FFI. Also, Python has nothing to do with LLVM.


Suck to be you, I guess? If you don’t care enough then you don’t care. You wouldn’t bitch when there’s an article written in Italian with good knowledge inside: “but Italian”. You either trying to read using translation tool or ignore it entirely.

I didn’t say python has anything to do with LLVM, it’s just a technique, read about it, or not.


> Zig is expected to replace Rust one day

That's a bold prediction considering that Zig is unsafe and Rust is safe.

If Zig's idioms make it safe, then modern C++ is safe too.


Zig replacing Rust is not my prediction. It is what I am hearing from the Zig enthusiast I know. I have also seen others express the sentiment that the next fashionable language after Rust will be Zig. Regardless of whether it is Zig, there will be another. Rust is just one part of a never ending cycle of people trying to reinvent programming.


There's approximately a 0% chance of Zig seeing non-trivial adoption anywhere other than maybe the embedded world.

It otherwise solves basically nobodies problems in the real world and is just a love letter to C. It's cute, kinda, but that's about it.


Zig is like the Vulcan Centaur next to Starship.


> Rust is just one part of a never ending cycle of people trying to reinvent programming.

This is true of every single programming language.


That is my complaint against the next fashionable language. Once you have some level of proficiency in around 10 languages, adding more to the list is a chore. It lacks the enjoyment that came from the first few. At least, that is my experience. That is why I am resistant to learning new languages unless software I want to modify is already written in it. Then, I am forced to learn and time spent on it is time that actually needed to be spent, unlike my brief time spent teaching myself FORTRAN in college, which was largely a waste of time.


> Zig enthusiasts

Yeah, don’t you think they might be perhaps just slightly biased? I have some news for you about your average technology enthusiast…

Anyone who claims Zig is going to replace Rust knows nothing about either Zig, Rust, or both. Zig is designed to solve none of the problems that Rust solves. Trillion-dollar corporations are rewriting things in Rust because it solves problems that really matter to them.

The US government strongly recommends writing all new mission-critical code in memory-safe languages. Guess which one of Rust and Zig is memory-safe?

I have nothing against Zig, it looks like a very nice better C, and the comptime stuff is both cool and useful. But its priorities are not Rust’s priorities.


Of course, Rust evangelists are also more than slightly biased.


Of course.


> Rust is just one part of a never ending cycle of people trying to reinvent programming.

Which is good. Programming is an open field, ideas are constantly popping in and out and you sometimes need to reinvent things to prove that they are worth it. More languages is a good thing, the bizarre tribalism around them is dangerous, but it is not possible to prevent it, people gotta be people.


Both are unsafe, just zig is usually safer than rust.

And also so more readable, ie. maintainable


That’s one crazy claim to make.


> Regarding Python, how could such optimizations be implemented in Python? Generating LLVM bytecodes directly aside.

You don't. You instead use your favorite Python extension system (regular Python modules, Cython, Numba, whatever) to implement this tree algorithm and expose it to Python already shaped into a container.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: