Better HN
topnewbestaskshowjobs
Log inSign up

proto_lambda

1,156 karma · joined Jan 11, 2022 (4y ago) · 205 submissions

Submissions

comment 3y ago · link · parent

Maybe not much better, but that's hardly the only alternative

comment 3y ago · link · parent

This gets posted again and again, and every time I look at it, the code quality is absolutely terrible. Remote access software is by design a complete internet-accessible backdoor to your system, I will never use one that is written as shoddily as this one.

comment 3y ago · link · parent

> That means that buildings are built with the expectation of being warmed...

That doesn't seem strange to me. At even lower temperatures, water pipes will burst, so you have to heat it at least a little in winter. Waste heat from humans might be enough to avoid freezing temperatures, but then humans also produce a lot of humidity, causing mold.

comment 3y ago · link · parent

Some examples of commit messages it generates would be useful, especially compared to good commit messages like the ones usually found in the Linux kernel.

comment 3y ago · link · parent

(2020): https://www.csiro.au/en/News/News-releases/2020/Australian-t...

comment 3y ago · link · parent

> Because usize has a platform-dependent size and generally the logic of the program should be platform-agnostic.

Fair point, but it really only matters if the overflow is handled gracefully. If it's handled as an unrecoverable error condition, it often 1. doesn't happen during normal operation and 2. can be invoked by a determined attacker, regardless of the exact size. Sure, the exact characteristics might be different, but in the end it doesn't make much of a difference.

Petgraph has a great API, and in general using newtypes over integers for collection indices is a great way to avoid another logic bug: mixing up indices for different collections.

comment 3y ago · link · parent

Some of these comparisons are a little lackluster - sure, the issues may be relatively easy to reproduce if you translate the C code 1:1 to (unsafe) Rust, but you wouldn't even have such code in the first place if you wrote idiomatic Rust:

- Confusing different integer types is much harder not only because the type checker will complain, but also because you don't really come across anything other than usize/isize unless it's a field in a protocol or something.

- Strings in rust are not zero-terminated, so that specific example might not even happen at all.

- Integers, pointers and references are not implicitly cast to booleans, so you can't accidentally mix up comparing a pointer to NULL (which is only ever required for FFI calls) and comparing an integer to 0.

- You have proper types to indicate that a function encountered an error, so all the issues stemming from checking the integer return code the wrong way (e.g. interpreting an error value as a return value) don't exist.

- You simply don't have to invoke potentially dangerous functions like `memcpy` because there are abstractions that take care of this safely and more intuitively.

That's not to say that idiomatic Rust code wouldn't come with its own problems, but they tend to be much more concentrated to fundamental logic bugs rather than silly avoidable things like overflows or misinterpreting values.

comment 3y ago · link · parent

> long range EV

That's called a train.

comment 3y ago · link · parent

In headlinese, your sentence would be short for "Person holds excessively strict ideas about English grammar and English posts". Not a great example to make your point.

comment 3y ago · link · parent

I have a feeling to author doesn't know what "parsing" means.

comment 3y ago · link · parent

I don't think this project specifically is the work of Espressif, but rather a community effort. Not sure about the other things you mentioned.

comment 3y ago · link · parent

Interesting that all its Haikus are 5-7-6, even if it can correctly tell you that it's supposed to be 5-7-5.

comment 3y ago · link · parent

You must've misunderstood, your statement looks like both x and y are `int *`, but in fact only x is an `int *`, while y is an `int`.

comment 3y ago · link · parent

Lying requires intent. This was a mistake, something that humans are well-known for making, and if the compiler is designed to assume otherwise, it borders on useless in the real world.

comment 3y ago · link · parent

It's just an artifact of decompilation. It's the same operation in machine code (checking the MSB), there's no way to tell which one was used in the original source code.

comment 3y ago · link · parent

The problem here is that the thing that "can't happen" isn't actually something that can't happen, it's something that isn't allowed to happen according to a many-hundred-page document that approximately nobody reads. It's not something that can be optimised because the compiler can prove it cannot happen, it is allowed to be optimised because the standard says "dear programmer, if you ever make this happen, god help you".

comment 3y ago · link · parent

It's not a bug. This is perfectly acceptable behaviour according to the language standard. If anything, it's a standard bug.

comment 4y ago · link · parent

Incorrect. Library features like the fallible allocation API are available to all editions, for better or worse - it also means you can't make breaking changes to the standard library ever, not even with a new edition.

New language features may require a new edition, though the vast majority of them don't - here's the list of all the changes in Edition 2021 (a new one is released every 3 years): https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html

comment 4y ago · link · parent

> You can obviously only call common methods

That sounds like trait objects/dynamic dispatch/`dyn`, which comes with runtime costs.

> or have to pattern match later and have a way to tell them apart.

That "way to tell them apart" is a tag, which would make it a tagged union/enum, not an untagged union. Those already exist, though not in an anonymous flavour.

comment 4y ago · link · parent

How would that work in a memory safe language? Rust does have (named) untagged unions already (using the `union` keyword), but they are unsafe to use because there is no way to know statically which of the possible variants a given value contains.

comment 4y ago · link · parent

`NonNull` is actually a wrapper around the pointer type, with the added invariant that the pointer cannot be null. The compiler is made aware of this, which allows `Option<NonNull<T>>` to be just a plain pointer, where the `None` variant of the option corresponds to a null pointer and the `Some(ptr)` case corresponds to a non-null pointer.

comment 4y ago · link · parent

It's definitely not a data structure that makes the borrow checker happy. Luckily it's also not a data structure that's required or desirable in 99% of cases, but the standard library still offers an implementation for those 1% so people don't try to write their own (turns out getting a doubly linked list correct isn't quite as trivial as it may seem).

143.

Generic associated types to be stable in Rust 1.65(blog.rust-lang.org ↗)

39 points · by proto_lambda · 4y ago · discuss

comment 4y ago · link · parent

> I feel like the author must know this

The author does know this, it's a reference to a couple paragraphs above:

> [...] and the HTTP protocol version, which is a fixed string which is always set to HTTP/1.1 and nothing else.

> (cool bear) But what ab-

> IT'S SET TO HTTP/1.1 AND NOTHING ELSE.

comment 4y ago · link · parent

cargo is not a binary distribution.

146.

Compiler optimizations are hard because they forget(faultlore.com ↗)

44 points · by proto_lambda · 4y ago · 4 comments

comment 4y ago · link · parent

> - Don't forget to send reminder messages to everyone who RSVP'd leading up to your event. I like sending my reminder messages 1 week prior, 4 days before, and then on the morning of.

I'd perceive that as too many. Leave out the one 4 days before and it'd be fine IMO.

comment 4y ago · link · parent

You need to communicate clearly that you are doing these things as a learning exercise, not just because they're a requirement for something bigger that you're actually trying to do. People try to be helpful by saving you unnecessary work, not realizing that the work is your actual goal.

comment 4y ago · link · parent

Neonazis are not a protected class (or equivalent in your jurisdiction).
1234567