Better HN
topnewbestaskshowjobs
Log inSign up

proto_lambda

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

Submissions

comment 4y ago · link · parent

The hosting provider is free to decide who they want to host and who they don't want to host. If they're fine with being known for knowingly hosting the scum of the earth, more power to them; but they are also absolutely allowed to nope out of that.

comment 4y ago · link · parent

HN title mangling strikes again. "NaN Boxing", which is very likely what the OP submitted it as, would've been obvious.

comment 4y ago · link · parent

> - Raw-pointer equivalent to lifetime parameters (`GenericStruct<*>`, converts `&'a T` into `*const T` and `&'a mut T` into `*mut T`)

How would that work? References and pointers are fundamentally different types, and the primary operation on references (`Deref`) isn't available for pointers. Any methods implemented on the struct wouldn't be able to do anything with the "reference" field, since it might actually be a pointer instead - it would be like having a `struct Foo<T>(Vec<T>);`, and then specifying `Foo<boxed T>` (imaginary syntax) if you actually want a `Box<T>` instead of a `Vec<T>`. You can't just treat a `Box` like a `Vec` (or a pointer like a reference).

> - `impl Trait` for associated types. This lets you workaround async trait functions without boxing the returned futures and also return anonymous closures from traits

You're probably already aware, but for the bystanders, that seems to be close to happening: https://github.com/rust-lang/rust/issues/63063

> - Mutability variance: e.g. write `fn index<&a>(&a self, idx: Idx) -> &a T`, instead of needing to write `fn index(&self, idx: Idx) -> &T` and `fn index_mut(&mut self, idx: Idx) -> &mut T`)

I think that's something the Keyword Generics (aka "totally not effects") Initiative[1] is looking into.

> - Built-in unit types (e.g. write `#[unit(ms)] pub struct Milliseconds(usize)`, and then you can write `128ms` => `Milliseconds(128)`)

Making sure that doesn't turn into a name collision nightmare would probably needs some work. It might also make it very hard to figure out what type you're actually dealing with just by looking at such a number. The current solution to this problem, defining an extension trait on integers, produces only moderately more verbose code, with the benefit of not requiring any additional syntax: `128.ms()`.

[1]: https://blog.rust-lang.org/inside-rust/2022/07/27/keyword-ge...

comment 4y ago · link · parent

No idea, but from context, maybe they meant https://en.wikipedia.org/wiki/Multiple_Dwelling_Unit? Really weird phrasing either way.

comment 4y ago · link · parent

https://archive.ph/YjOfv

comment 4y ago · link · parent

That's the wrong repeat(), I was talking about str::repeat(): https://doc.rust-lang.org/std/primitive.str.html#method.repe...

comment 4y ago · link · parent

Rust uses `repeat()`, which sounds much more descriptive to me. The types in the function signature make the "clone" part of the name redundant.

comment 4y ago · link · parent

Other than that being a terrible name (it's almost impossible to be sure what it does without consulting documentation), I personally do prefer fewer implicit/overloaded operations.

comment 4y ago · link · parent

Title should be "PAM", not "Pam".

comment 4y ago · link · parent

Qm.n notation is for fixed point numbers, not floating point. As OP said, floating point was not a viable option at the time.

comment 4y ago · link · parent

A typo of "compiler", I'm fairly certain.

comment 4y ago · link · parent

> It basically won’t compile if your code would have runtime errors or memory leaks

While Rust does move a lot of errors from runtime to compile time, there are still a lot of ways to create runtime errors (which must obviously the case if your program handles any input at all).

Rust also does not stop you from creating memory leaks; there's even the `Box::leak()` method[1] that allows you to simply leak a heap allocation.

[1]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.l...

comment 4y ago · link · parent

Wait, what? How could electric resistive heating with its 100% efficiency possibly be less efficient than gas or oil, which are the main alternatives in use at this point?

Heat pumps have >100% efficiency, which makes them stand way out at the top, but they're an exception rather than the rule.

comment 4y ago · link · parent

Not just heat pumps, but also electric water heaters, which are standard issue for older apartment buildings (those without central hot water).

comment 4y ago · link · parent

From Carbon's FAQ[1]:

> Why not Rust? If you can use Rust, ignore Carbon.

So that's probably one reason.

[1]: https://github.com/carbon-language/carbon-lang/blob/trunk/do...

comment 4y ago · link · parent

Of all the examples in this thread, this is the only one that isn't a plain HTML page, but rather a pile of javascript that takes several seconds to load and shows nothing but an "enable javascript" banner without JS. Despicable, but also absolutely typical.

Edit: alright, CZ, UA and RU further down the thread are the same, I just hadn't gotten to those yet. Still, absolutely unacceptable for a government design standard.

comment 4y ago · link · parent

While I think shadowing is great for code readability and I've never encountered a bug caused by it, you can always make sure clippy doesn't let you do it by putting a `#![deny(clippy::shadow_reuse, clippy::shadow_same, clippy::shadow_unrelated)]` at the top level of your crate.

comment 4y ago · link · parent

> I'd rather program fail at compile than runtime, and rather it fail loudly than quietly.

I agree! I was just illustrating the kind of tradeoff that has to be made for that to be possible.

comment 4y ago · link · parent

To expand on your float sorting example, sorting a slice[1] in Rust requires the element type to implement the Ord trait, i.e. be totally ordered. Trying to sort a slice of floats will result in a compiler error, even though it might be totally fine as long as all your floats are "ordinary".

Instead, to sort a slice of floats, you have to explicitly specify what would happen for the non-ordinary cases; e.g. by using `.sort_by(f32::total_cmp)`, where f32::total_cmp()[2] is one possible interpretation of a total ordering of floats. This requires writing more code even for cases where it would be completely unnecessary.

[1]: https://doc.rust-lang.org/std/primitive.slice.html#method.so... [2]: https://doc.rust-lang.org/std/primitive.f32.html#method.tota...

comment 4y ago · link · parent

Not on stable, but you can on nightly (though it's still quite wonky): https://play.rust-lang.org/?version=nightly&mode=debug&editi...

comment 4y ago · link · parent

What kind of primitives are you talking about here? In my experience you don't really have to manually instantiate anything other than a PLL or maybe a multiplier unless you're doing something very specialized.

comment 4y ago · link · parent

I remember them offering a software (or maybe a webpage, though it would've likely been a Java of Flash applet at the time) that allowed users to create official-looking manuals for their own creations by interactively specifying the build steps.

comment 4y ago · link · parent

Quoting from the last time this was posted (https://news.ycombinator.com/item?id=31456007):

I'd proceed with caution. Apparently it doesn't support Wayland, so when you run it under Wayland it offers you a "Fix it!" button that, when clicked, runs sed on some gdm system config files to revert it to X11 (nevermind that gdm is far from the only way to use Wayland): https://github.com/rustdesk/rustdesk/blob/1.1.9/src/platform.... If this is the kind of thing that's considered acceptable by the developer, I'd rather keep their products far away from my machines. A quick glance at the code also reveals an almost complete lack of comments and copious use of unexplained `unsafe`.

comment 4y ago · link · parent

At time of writing, bing translator translates this:

    January 2022
    February 2022
    March 2022
    April 2022
    May 2022
    June 2022
    July 2022
    August 2022
    September 2022
    October 2022
    November 2022
    December 2022
to the following German:

    Januar 2022
    Februar 2022
    März 2022
    März 2022
    Juni 2022
    Juni 2022
    Juli 2022
    Oktober 2022
    Oktober 2022
    Oktober 2022
    Oktober 2022
    Dezember 2022
At least it gets 7/12 right?

175.

Bing translator mixes up month names in dates(bing.com ↗)

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

comment 4y ago · link · parent

We'd need an even more unholy name for `unsafe { foo.unwrap_unchecked() }`!

comment 4y ago · link · parent

There is a problem here - it's verbose and prone to silent-ish breakage if the surrounding context changes e.g. due to refactors (well, probably not with this tiny example, but I hope you know what I mean). Thankfully, there is also a solution to this problem: https://github.com/rust-lang/rust/issues/90091

split_array will eventually allow something like the following, which avoids any explicit indexing and will fail to compile if the sizes don't match up:

    struct IVec2(i32, i32);

    impl IVec2 {
        fn parse(b: [u8; 8]) -> Self {
            let (first, second) = b.split_array();
            IVec2(i32::from_le_bytes(first),
                  i32::from_le_bytes(second))
        }
    }

comment 4y ago · link · parent

> Matrix.org which nobody seems to want to use and I’m not sure why

Lots of people are using it (and probably more every day), but there are also some quite vocal haters. Of course it has its share of problems (availability of non-Electron clients and different servers among then), but many of them constantly improve as the ecosystem grows.

comment 4y ago · link · parent

Oh yeah, that's indeed not great. For messages with up to ~5 lines, the bridge actually just sends several messages, but as soon as the message has more lines than that, it only shows the first line as a preview. I could've sworn it actually sends the first couple lines, then a "(full message at ...)" message, but apparently not (anymore) - would probably be worth opening an issue for :)
1234567