• 0 Posts
  • 127 Comments
Joined 1 year ago
cake
Cake day: June 21st, 2023

help-circle
  • Ignoring the rest, just some thoughts about the list of proposed features:

    A capture trait for automatic cheap clones

    Automatic implicit cloning would be useful for high level developers, but not ideal at all for low level or performance-sensitive code. It’s not the case that anyone using a shared pointer wants to clone it all the time. The high level usecase doesn’t justify the cost assumed by the low level users.

    Instead, being able to wrap those types with some kind of custom “clone automatically” type feels like a middle ground. It could be a trait like mentioned, or a special type in the standard library. Suppose we call it Autoclone[T] or something (using brackets because Lemmy nonsense). Autoclone[Rc[T]] could function like the article mentioned.

    Automatic partial borrows for private methods

    Having “private” and non-“private” methods function differently feels like confusing behavior that should be avoided if possible. Also, “private” I assume refers to pub(self) methods (the default if unspecified), which is “module-level” methods (so accessible within the module it’s defined in). Anyway, there are years of discussion around this so I’ll just defer to that as to why it’s not in yet.

    I agree with the urge to make it happen though. Some method of doing partial borrows for methods would be nice.

    Named and optional function parameters

    This is what prompted me to even comment. What “every language” does for complex constructors is different per language. C#, for example, supports both named and optional parameters, but construction usually uses an object initializer:

    var jake = new Person("Jake")
    {
        Age = 30,
        // ...
    };
    

    This is similar to Rust’s initializers:

    let jake = Person {
        age: 30,
        ...Person::new("Jake")
    };
    

    Where it gets tricky is around required parameters. Optional ones don’t really matter since you can use the syntax above if you want, or chain methods like with the builder style.

    As for the overhead of writing builders, there’s already libraries that let you slap #[derive(Builder)] on types and get a builder type automatically.

    As for optional parameters, how those are implemented differs between languages. In C#, default values must be constant values. In Python, default values are basically “global” values and this nonsense is possible:

    def count_calls(count=[]):
        # if unset, count is a global list
        count.push(0)
        return len(count)
    

    Anyway, all this is to say that the value of optional parameters isn’t obvious.

    Named parameters is more of a personal choice thing, but falls apart when your parameter has no name and is actually a pattern:

    async fn get_foo(_: u32) {}
    

    Also, traits often use names prefixed with underscores in their default fn impls to indicate a parameter an implementer has access to, but the trait doesn’t use by default. Do you use that name, or the name the implementer defined? I assume the former since you don’t always know the concrete type.

    Faster unwrap syntax

    We have that, it’s called the try operator.

    Okay I know it’s different, and I know everyone’s use case is different, but I’ve been coding long enough to know that enabling easy unwraps means people will use it everywhere despite proper error handling being pretty dang important in a production environment.

    Thinking of my coworkers alone, if we were to start writing Rust, they’d use that operator everywhere because that’s what they’re familiar with coming from other languages. Then comes the inevitable “how do I add a try-catch block?” caused by later needing to handle an error.

    Anyway, I prefer the extra syntax since it guides devs away from using that method over propagating the error upwards. For the most part, you can just use anyhow::Result and get most error types converted automatically.

    Try trait

    Yes please.

    Specialization

    Yes please.

    Stabilizing async read/write traits to standardize on an executor API

    I’d want input from runtime devs on this, but if possible, yes please.

    Allowing compilation of builds that fail typechecking

    ???

    How is the compiler going to know how to compile the code if it doesn’t know the types? This isn’t Python. The compiler needs to know things like how much memory to allocate, and there’s a ton of potential unsound behavior that can occur from treating one type as another, even if they’re the same size.

    Anyway I’ll save the rest for later since I’m out of time.


  • Speaking as someone with a MTF close friend and NB spouse, but the term used in the article is the term everyone around me used when I was growing up. That term may be obsolete now, and if so, the author simply needs to be informed. There’s no need to assume they meant harm by it.

    If they knowingly used a term that may offend, then that’s of course a separate issue.




  • In addition to 1:many, many:many, and many:1 (which is just 1:many but looking at it in the other direction), you also occasionally see 1:1, for example if you want to augment a table with additional data. This might be done by having your foreign key also be your primary key in the augmenting table, since that would also enforce a uniqueness constraint on the FK as a result.

    Also, probably unnecessary to mention, but you can also have “0 or 1” relationship (meaning one side is optional but capped at 1). These are technically separated from “1” relationships usually when you get into all the theory. An example of this might be a “0:1” relationship using the above augment table, but where the augmenting table isn’t required to have a row for every row in the augmented table. (A 1:1 constraint can be enforced, for example, by having an additional FK in the augmented table pointing to the augmenting table.)





  • If you want to use it in your start menu, there are some options. I know Start11 can use Everything, for example (but isn’t free - there may be free options out there, but I haven’t looked).

    Otherwise, most of what I’ve seen are CLI applications. Is there anything specific about Windows you’re hoping to see a replacement for? For me, search and settings (why the f are you advertising to me in the f-ing settings?) are the worst offenders, but settings is kinda locked in for the most part unfortunately.


  • We have infused AI into every layer of Windows

    I sure hope not. I don’t want Windows to just decide to delete my hard drive because it feels like it.

    We are introducing Windows Semantic Index, a new OS capability which redefines search on Windows and powers new experiences like Recall.

    You could also improve Windows search by contracting with voidtools and integrating Everything. While you’re at it, maybe ditch the bing searches, and other useless search results?

    Anyway, the rest of the article seems to go into actual dev-oriented details, and there’s some interesting bits like enabling certain AI acceleration features on the web (probably only in Edge though…), for what that’s worth.





  • I’ve used GitLab and Azure DevOps professionally, but there are a lot of services out there which host Git repositories. GitLab can also be self-hosted which is nice. They all fundamentally work the same though from my experience - code viewer, issue tracker, pull requests, some way of doing CI/CD, and various collaborative and documentation features (wikis, discussion areas, permission management, etc).

    It may be good to understand also where the separation lies between features that are part of Git vs those which are part of the service you’re using (like GitHub). For example, branches are Git, while pull requests and wikis are GitHub.



  • TehPers@beehaw.orgtoProgramming@programming.dev...
    link
    fedilink
    English
    arrow-up
    5
    ·
    2 months ago

    I’ve been writing Lua off and on for probably close to a decade, and I can’t remember the lack of a round function being an issue. I may have needed it at some point, but it’s not exactly a complicated function to write up in a minute.

    To me, the biggest appeal of Lua is actually the lack of an overbearing standard library. It has just enough to be usable as a scripting language within a larger application, and the larger application can always include its own helper library that gets loaded into the interpreter automatically on initialization. Feature-wise, there is enough to define your own OOP helpers (but no language built-in specific OOP stuff beyond metatables basically), there is enough to build your own async/await and generators using coroutines, etc.

    Not having a huge built-in standard lib comes with the benefit of not needing to distribute a huge standard lib with your larger application.



  • If by parallel you mean across multiple threads in some map-reduce algorithm, the compiler will not do that automatically since that would be both extremely surprising behavior and in most cases, would make performance worse (it’d be interesting to see just how many shapes you’d need to iterate over before you start seeing performance benefits from map-reduce). If you’re referring to vectorization, then the Rust compiler does automatically do that in some cases, and I imagine it depends on how the area is calculated and whether the implementation can be inlined.


  • I agree with the conclusion, and the exploration is interesting enough that I think it was worth sharing. Still, while the author seemingly knows this already based on their conclusion, it’s still worth stressing: these kinds of microbenchmarks rarely reflect real world performance.

    This toy case doesn’t have many (if any) real world performance-sensitive applications. At best, using shapes in games comes to mind, but shapes there are often represented as meshes, and if you really need the area that much, you might find that precalculating the area once is more impactful on the performance than optimizing how fast the area is calculated.

    Still, the author seems aware, and it seems to just be the author sharing their fun experiment.


  • The hourly wage here seems below 1 dollar.

    I’m surprised this is even legal. I mean, of course it’s fine to scam a bunch of desperate people looking to pad their resumes. Why wouldn’t it be?

    Unless you have no other source of income, then I don’t see these making sense. Even then, consider if retail or food industry might be a better use of your time until you can find something better (unironically - they can be great experiences).