aloso

joined 2 years ago
[–] [email protected] 3 points 2 years ago

Is that Professor McGonagall

[–] [email protected] 1 points 2 years ago (1 children)

That doesn't solve the issue that there are too few contributors. Requiring a review doesn't ensure that someone reviews the code.

[–] [email protected] 9 points 2 years ago

I guess it cannot be done if their IT infrastructure was not designed with that use case in mind. Although I'm not familiar with human resource management software, I don't find this hard to believe at all.

Also, you'll understand what Biron Tchaikovsky meant with "Please believe me" when you look at their email address. They already tried to do it, and probably complained many times before giving up.

[–] [email protected] 90 points 2 years ago (3 children)

Oh, didn't the domain somesoftwarecorp.com give it away?

[–] [email protected] 1 points 2 years ago (3 children)

On GitHub, everybody has the ability to review pull requests, even you. But there still aren't enough volunteers who review PRs.

[–] [email protected] 2 points 2 years ago (7 children)

Discriminant is irrelevant and you’re not supposed to fuck with it

It matters because the conversion between i32 and the Result is only "free" if they have the same layout (which they do not, because of the discriminant). So a more costly conversion method is required.

And there is zero reason to use unsafe/transmute for this.

You are right, because the compiler is able to optimize your code quite well. However, if that optimization were to break at some point (as there is no guarantee that an optimization will continue to work in the future), it would become less efficient.

[–] [email protected] 2 points 2 years ago* (last edited 2 years ago) (10 children)

This is not possible, because Rust still stores a discriminant even when the enum values don't overlap.

As far as I can tell, the only situation where Rust doesn't store a discriminant is when either the Ok or Err variant is zero-sized, and the other variant has a niche. So, Result<(), ErrorEnum> can be represented as an integer, but Result can not.

You can still use enums, and implement simple conversions like this:

#[repr(i8)]
pub enum Error {
    E1 = -1,
    E2 = -2,
    E3 = -3,
    E4 = -4,
}

#[repr(i8)]
pub enum Success {
    S0 = 0,
    S1 = 1,
    S2 = 2,
    S3 = 3,
}

pub type LibResult = Result;

pub fn number_to_result(value: i32) -> Option {
    match value {
        -4 ..= -1 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
        0 ..= 3 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
        _ => return None,
    }
}

pub fn result_to_number(res: LibResult) -> i32 {
    match res {
        Ok(value) => value as i32,
        Err(error) => error as i32,
    }
}

P.S. Sorry that the generics aren't displayed due to Lemmy's bad santiziation.

[–] [email protected] 6 points 2 years ago (1 children)

Lemmy is like Reddit, which is used a lot to ask questions and get help. But StackOverflow fills a different niche, it's meant to be useful to as many people as possible and stay up to date. This is why

  • there's a distinction between "comments" and "answers" (comments can be used to request additional information, and for meta discussion)
  • both questions and answers can be modified by other users, for example to
    • add more information, or remove unnecessary details
    • correct outdated information
    • fix typos and formatting
    • rephrase sentences that are confusing
  • a question can be closed as duplicate, so people always find the oldest thread of the question with the best/most detailed answers
  • before submitting a question, you get a list of related questions to avoid creating a duplicate question
  • questions have tags, making them easier to search for
[–] [email protected] 12 points 2 years ago* (last edited 2 years ago)

Iframes cannot access the main frame's DOM if the iframe is from a different origin than the main frame, and they never share the same JavaScript execution context, so an iframe can't access the main frame's variables etc.

It's not required that iframes run in a different process, but I think they do at least in Chrome and Firefox if they're from a different origin. Also, iframes with the sandbox attribute have a number of additional restrictions, which can be individually disabled when needed.

[–] [email protected] 13 points 2 years ago (2 children)

They still have their place; for example to embed Google Maps or a YouTube video. Generally, whenever you want to embed something from a different website you have no control over, that shouldn't inherit your style sheets, and should be sandboxed to prevent cross site scripting attacks.

[–] [email protected] 17 points 2 years ago* (last edited 2 years ago) (3 children)

I do not use AI to solve programming problems.

First, LLMs like ChatGPT often produce incorrect answers to particularly difficult questions, but still seem completely confident in their answer. I don't trust software that would rather make something up than admit that it doesn't know the answer. People can make mistakes, too, but StackOverflow usually pushes the correct answer to the top through community upvotes.

Second, I rarely ask questions on StackOverflow. Most of the time, if I search for a few related keywords, Google will find an SO thread with the answer. This is much faster than writing a SO question and waiting for people to answer it; and it is also faster than explaining the question to ChatGPT.

Third, I'm familiar enough with the languages I use that I don't need help with simple questions anymore, like "how to iterate over a hashmap" or "how to randomly shuffle an array". The situations where I could use help are often so complicated that an LLM would probably be useless. Especially for large code bases, where the relevant code is spread across many files or even multiple repositories (e.g. a backend and a frontend), debugging the problem myself is more efficient than asking for help, be it an online community or a language model.

[–] [email protected] 4 points 2 years ago (5 children)

True, code for critical IT infrastructure should always be reviewed. But from what I understand, this is difficult because there is one full-time developer (paid by the Rust Foundation) and a small number of volunteers, who don't have the time to review all the employee's changes.

view more: ‹ prev next ›