Better HN
topnewbestaskshowjobs
Log inSign up

burjui

6 karma · joined Jul 27, 2015 (11y ago) · 46 submissions

Yet another programmer.
Submissions

comment 1y ago · link · parent

> rav1d is transpiled c-to-rust version of dav1d

Sounds like a bad way to port. Completely different languages. It took me some time to learn that one cannot simply write C code in Rust and expect the result to be any good. Should've started from scratch.

comment 1y ago · link · parent

It's more likely they will end up shotgunning sloppy AI PRs.

comment 1y ago · link · parent

... in the way of writing code with undefined behaviour. "You don't tell me how to live! Maybe I want to shoot myself in the foot sometimes! I already shot myself in the head, and it was awesome, instantly made me an old fart that refuses to learn. Ignorance is bliss!"

comment 1y ago · link · parent

I've used the 2013 algorithm, it's fast, simple enough and easy to implement in Rust.

comment 1y ago · link · parent

I wonder what's the point. 8 bits is not enough to store most values for most applications, it's bad for timers and multiplication, it's just a big waste of CPU cycles in general. The more work CPU has to do, the less time it spends sleeping, which is bad for battery-powered embedded devices. Perhaps, it has its place somewhere, but realistically, an 8-bit CPU these days is very niche at best. Imho, it's not going to take off in mainstream embedded.

comment 1y ago · link · parent

One day I needed to parse and generate RISC-V instructions. I wrote a custom bitfield implementation, nothing fancy: no derive macros or any crap like that, only u32 bitfields specified by an array — [(RangeInclusive<u32> /src/, usize /length/, RangeInclusive<u32> /dst/]. One function + a bunch of tests. It worked great. Then I tried the `bitfield` crate, which claims to be as fast as code I would've written by hand. It had dependencies and was two orders of magnitude slower. Basically, it was as fast as code that I would've written by hand in Python.

comment 1y ago · link · parent

At least, we can assume that after a few weeks, he became not quite that depressed.

comment 1y ago · link · parent

Why it's always the borrow checker that bugs the haters? You don't even see it work most of the time, because instead of using references everywhere, like most C++ers are conditioned to do, not only you can move values (doesn't necessarily mean actually performing memory operations), but also the compiler checks that you don't use the variable from which the value has been moved. And even if you do use references everywhere, they don't usually cause any problems, unless you decide to put more than one reference in a often used struct. I often use both shared (RO) and exclusive (RW) references as function arguments and rarely have to specify lifetimes manually, because automatic lifetime elision done by the compiler is sufficient in most cases.

comment 1y ago · link · parent

Exactly the same experience : my toy compiler project has 10477 lines of Rust code, and there is only one line with unsafe:

  let is_tty = unsafe { libc::isatty(libc::STDERR_FILENO) } != 0; 
Here's the source, just in case: https://github.com/burjui/rambo/

In fact, there are exactly two "unsafe" blocks in all of my Rust projects, and the second one is not even needed anymore because of the language and ecosystem improvements, but the project is basically abandoned, so I'm probably not gonna fix it. There's just no need for unsafe in the vast majority of code.

I don't know where Rust critics get their statistics; probably from picking their noses, judging by their arguments. Most don't seem to even have read the official docs, the bare minimum required to form any conclusions at all about the language. I guess they don't read much Rust code and think there is no way we can write even semi-decently performing high-level code without resorting to unsafe hacks or calling C, because that's the way it's done in other languages.

comment 1y ago · link · parent

It's literally THE unsafe part of the code. It's the only part of code that can invoke UB.

  fn do_something() {
      unsafe { ... }
  }

  // Somewhere in the program
  do_something();
Doesn't matter where "do_something" is used and how much. The only possibly problematic part of this code is the unsafe block. You only audit it.

comment 2y ago · link · parent

Even plain C++ is very hard to read, it's one of the reasons I ditched it. Cannot even imagine writing code in this version. C++ is overcomplicated already, imho it's best to leave it to die naturally instead of prolonging the suffering of millions that use it.

comment 2y ago · link · parent

Apply the flame to the sysadmin's hand and get root access. I mean, it's a cool demo, but if you can solder crap to the hardware, might as well do anything that physical access provides normally. Like, you can just install the payload without the exploit.

comment 2y ago · link · parent

C++ & autotools. No, thanks.

comment 2y ago · link · parent

I would like that veey much, but they likely will not go to prison, just pay off the damages, as usual. Capitalism works that way.

comment 2y ago · link · parent

> I think Ada not being very popular shows that the need for a memory safe non-garbage collected language is kind of overstated.

It only shows that Ada is very old and verbose.

comment 2y ago · link · parent

It's not impossible. But if one says "Rust is bad", they better elaborate, unless their goal was to post a meaningless comment.

comment 2y ago · link · parent

It doesn't. Most people complaining about "ugliness" of Rust are either too lazy to read documentation (which is great btw), or just don't like the syntax, because it doesn't resemble their favorite language[s]. Some have valid criticism, but they usually lay it out straight, sometimes in the form of a blog post, instead of vague "Rust is bad" statements.

comment 2y ago · link · parent

How about writing relatively complex things not in Bash? If your shell script requires configuration, it shouldn't be a shell script.

comment 2y ago · link · parent

That's why paths in Rust don't have to be UTF-8. See Path and OsStr documentation.

comment 2y ago · link · parent

The algorithm uses less memory, but more CPU time because of rather frequent deletions, so it's a tradeoff, not just generally better algorithm, as article may suggest.

comment 2y ago · link · parent

My dad is a plumber, and I learned a bit while working with him. I was in software development for about 8 years, intermittently (casual games and microcontrollers in C++, Java/Kotlin for Android), and at the last job (the Android one) I burnt out so bad I got clinical depression which took years to manage. Plumbing to me is a fallback that is going on for too long. Pays the bills and meds until I get fit for demanding mental work. By the way, my lower back is demanding some mental work, for a change, after 3 weeks of carving out grooves for pipes in walls and floors with a big perforator

comment 2y ago · link · parent

5g once a day, standard gym goer protocol.

comment 2y ago · link · parent

Taking creatine cured my lightheadedness that occurs when standing up after squatting for a few minutes, which happens a lot at my job (plumbing). It also reduced other negative effects of sleep deprivation, such as impaired cognition, but to a lesser degree.

comment 2y ago · link · parent

It has a generally simpler syntax, except for function pointers and arrays, but I wouldn't call it "better". Comparing syntaxes of such different languages is pointless anyway. Syntax should serve semantics.

comment 2y ago · link · parent

Lack of carbs supresses appetite, JFYI.

comment 2y ago · link · parent

It's a weak attempt at humor based on the fact that "perdun" means "one who farts" in Russian.

comment 2y ago · link · parent

You're delusional. Humans have not only killed many of them, but also destroyed entire ecosystems without even trying, just a byproduct of expansion. What makes you think AGIs would care at all about preserving ours?

comment 2y ago · link · parent

Simple: attract more people to do it. If everyone ditched their $LANG and started rewriting everything in Rust, we could do it in a month.

comment 2y ago · link · parent

You are. Maybe you just need some additional time to get used to it. After all, even webdev monk... I mean people are used to {} in JS.

comment 2y ago · link · parent

I assume we are talking about LLMs. Optimistically, it could help, given an appropriate, carefully crafted prompt. Realistically, most devs are lazy asses and as soon as AI gives them working code, they would move on to pumping out the next piece of crap that works. If we consider smarter AIs, that can actually understand code and logic, it could be much better. But here we should be more concerned about alignment of such AIs.
12