• 0 Posts
  • 74 Comments
Joined 2 years ago
cake
Cake day: June 2nd, 2023

help-circle




  • That’s why I included “do research”. I absolutely agree that reinventing everything is not the way forward, but I also think it’s important to get stuck on a problem before looking up what the possible solutions are, because that is when you are in the best position to understand them and how / why they work to solve the problems.

    If you write nested if after nested if, hopefully at some point you go “hold on, is there a better way?” And then you do research and learn. That is not to say that learning for knowledge’s sake is bad. It isn’t. In fact it’s great. But it might also be a bit dull to just follow tutorials and such.



  • To answer you: no, x += 1 cannot mutate my_var, because it’s a copy. If you wanted something else you would say auto& or auto*.

    And if the type of x is such that even a copy can mutate the original (e.g. maybe it’s a wrapper around an index with an overloaded operator+=() that mutates the original entry in the storage), you are probably working with a specialized system of some kind, since that breaks the semantics of the language, and hopefully you would know from context that you have such cases.

    And yes, in such an environment I would see “never use auto for this wrapper type” as a valid additional strategy to help ensure code correctness.

    But by and large my direct experience is that using auto “almost always”, as Herb Sutter puts it, is beneficial and doesn’t harm readability or understandability.


  • auto doesn’t really hide all type information, but that is besides the point. The point is that in the vast majority of cases you don’t really care about the specific types your code is dealing with, you only care about the properties of the type.

    If I write get_descriptors()[some_idx] what is the type returned by get_descriptors()? You can’t know, because nothing tells you, but you know it must be a type that supports random access indexing. If I put the result of the function call in a for loop, it must support iteration. If I return it by move, it must support being moved.

    99% of code is like this. Then you have specialised code that might be doing bit wrangling and what not, in which case you must know that you are dealing exactly with, say, an uint32_t and not just something that supports left shift.

    For the 99% of cases, auto makes the code simpler, more correct, more robust, more consistent, and shorter to write and read.

    The post I replied to in particular got angry at documentation that uses auto. I have written documentation that looks like this

    auto my_var = MyConcreteType { /* … */ };
    auto const* x = my_var.get<uint32_t>();
    auto const& y = my_var.get_or<uint32_t>(42);
    

    How would such code benefit from not using auto?

    MyConcreteType my_var = MyConcreteType {}; just repeats the type, adds zero useful info.

    MyConcreteType my_var {}; is inconsistent. Where is the equal sign signifying that this is an assignment?

    Similarly, what would you gain by saying uint32_t const* x = my_var.get<uint32_t>();? Nothing, you just doubled your maintenance when you need to change the type passed to the template parameter.





  • My expectation: nothing. At least, nothing on the OS side. I don’t think windows is very important to microsoft strategically.

    Nowadays, the way to capture audiences is not so much via a proprietary OS, but via proprietary apps.

    And in that sense, microsoft is proceeding exactly as expected: more and more of the windows ecosystem either exists on the web, or is available on linux and macos too.

    I can see a future where windows only exists for backwards compatibility, but otherwise:

    • dotnet apps run on linux (via dotnet core)
    • edge runs on linux
    • powershell runs on linux
    • visual studio code runs on linux
    • most of the rest of microsoft’s suite runs in the web

    So what does microsoft need to do once windows collapses in the desktop space? Imo not much, really. Those people and companies that are tied to microsoft products will still be. Only, they might be running them on linux.

    Edit to add: I am gonna place a bet that we’re gonna see an official microsoft linux distribution by the end of 2035



  • ugo@feddit.ittoADHD memes@lemmy.dbzer0.comBrilliant
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    That’s how I feel and I’m somewhat positive I don’t have adhd. I mean do you have any idea how much effort it is to do one thing, when “doing nothing” means (at least according to my girlfriend) at minimum selling 8 hours of my day + commute, walk the dog, clean the cat’s litterbox, filling and / or emptying the dishwasher, and sometimes buying groceries?

    You better believe I feel like fire when I do one thing, that one thing was likely in the works for several days.