• 19 Posts
  • 74 Comments
Joined 9 months ago
cake
Cake day: December 31st, 2023

help-circle
  • the police say they are targeting the criminals responsible but cannot “arrest their way out of the problem”. They also say manufacturers and tech firms have a bigger role to play.

    Even though I fully expect the police here aren’t doing as much as they could (I mean come on, are they expecting phones to come with wiimote hand straps?) , I’m at least glad their public rhetoric is that they can’t “arrest their way out of the problem”.

    I imagine that’s poor compensation when you’ve just had your phone snatched, however.


  • Having just watched the lecture, the only classified info I can recognize is the capabilities of 80s era satellites.

    Given that, I think it’s quite a shame that the whole thing is only now available. Rear Admiral Hopper seems to have been someone who deeply understood both computers and people. The prescriptions she gives regarding “systems of computers” and “management” vs “leadership”, to name just two, are spot-on. Her lecture is quite grounded in what I’d call “military thinking”, but that’s just because she’s in a room filled with people who are of that life. In my opinion, everything she talks about is applicable to communities and businesses.

    The general gist of the entire ~90mins reminds me of Project Cybersyn in its perspective on how computers could serve society.


  • The idea is neat, and there is a certain precedent for the approach in .htaccess files and webserver path permissions.

    Still, I worry about the added burden to keeping track of filenames when they get used as stringed keys in such a manner. More plainly: if I rename a file, I now have to go change every access declaration that mentions it. Sure, a quick grep will probably do the trick. But I don’t see a way to have tooling automate any part of it, either.


  • The idea & execution are great, I just don’t know that I would ever do this for collecting into Vecs myself.

    When I’m tired of writing turbofish, I usually just annotate the type for the binding of the “result”:

    let d = [1i32, 2, 3];
    let y: Vec<_> = d.iter().map(|x| x + 100).collect();
    

    So often have I collected into a vector then later realized that I really wanted a map or set instead, that I prefer keeping the code “flat” and duplicated (i.e. we don’t “go into” a specific function) so that I can just swap out the Vec for a HashMap or BTreeSet when & where the need arises.







  • Bit of both, I suppose. Along with my own experience trying to deal with prototypes in JavaScript and how Python handles methods vs “bare” functions internally in terms of v-tables and “where” things exist in memory.

    I imagine the fact that both of those are interpreted languages plays somewhat heavily into it.

    With regards to being able to write MyStruct::my_method(&my_var), it’s the one-two punch of “I can use that specific syntax to differentiate between ‘inherited’ methods that have the same name” and that the compiler doesn’t treat .method() calls any differently and just rewrites them as such when doing it’s job.


  • I’m sure there are a bunch of patterns that emerge out of this (anyone with some wisdom here?) …

    The classical one is something that looks like the following:

    struct LoggedOut;
    struct User {name: String};
    struct Admin {name: String};
    
    impl LoggedOut {
      fn login(self, name: String, password: String) -> User {
        User { name }
      }
      fn admin_login(self, name: String) -> Admin {
        Admin { name }
      }
    }
    
    impl User {
      fn log_out(self) -> LoggedOut {
        LoggedOut {}
      }
    }
    
    impl Admin {
      fn log_out(self) -> LoggedOut {
        LoggedOut {}
      }
    }
    
    fn fetch_user_preferences(user: User) { /*...*/ }
    
    fn do_admin_action(admin_account: Admin) { /* ... */ }
    
    fn main() {
      let mut user_session = LoggedOut {};
      /* (get user input) */
      match input {
        "login" => {
            user_session = user_session.login(name, password);
        }
        "admin" => {
           user_session = user_session.admin_login(name);
        }
      }
    }
    

    This would prevent you from writing code that uses the user’s info / session “object” after they have logged out (and/or before they have logged in). On its own it’s naive and a bit encumbering - I expect an enum would make more sense but then you can’t restrict via types which user session values can and can’t be passed to specific functions. In any case, when you are building a whole system around it it can be very useful to have the compiler enforcing these sorts of things “in the background”.

    This is basically what Gary Bernhardt is talking about in the talk you linked.


  • I want to highlight one of the more subtle-yet-important clarifications made in these 2 chapters: associated functions vs methods, and how method calls are just syntactic sugar for function calls.

    Unlike in many other languages, there is no formal distinction (e.g. via separate keywords) between methods vs constructors vs property getters. The first parameter as well as the return type determine if a given associated function is “actually” a constructor or a method (etc.).

    Personally, I find this incredibly elegant; it’s a form of “less is more” that gets out of my way when I’m coding while still allowing me to use all of the existing patterns that I know from elsewhere.













  • The problem is that lemmy.ml hosts too many popular communities. There are people who want them gone from their feeds but also don’t want their Lemmy experience to become empty and boring.

    The solution is to build up more attractive alternatives of those communities elsewhere, not endlessly campaign the existing users to just drop them. I understand that awareness of why people want alternatives is important for those alternatives to have a chance at attracting users, and being discovered in the first place. I just have yet to actually see these alternatives receive the care they (imo) require to justify switching to them.

    The current fedidb stats, to me, state that 488 people is, colloquially speaking, nobody. a screenshot of the first page of stats for lemmy on fedidb.org. The collective stats across all servers is 391,326 total users and 45,189 monthly users. The individual servers shown are (in order): lemmy.world, lemm.ee, sh.itjust.works, hexbear.net, lemmy.dbzer0.com, feddit.de, lemmygrad.ml, programming.dev, lemmyblahaj.zone, and lemmy.ca. The user and "status" counts approximately follow a pareto distribution.  lemmy.world has almost half of the total user count and monthly active user count on its own. The notable outlier is hexbear.net, which has 10% more statuses than lemmy.world made by 10% as many montly active users.

    Maybe it’s too soon to make such a judgement call, we’ll see over the next few days as people get the chance to see this post.