• 23 Posts
  • 178 Comments
Joined 6 months ago
cake
Cake day: December 31st, 2023

help-circle





  • “With respect to content that is already on the open web, the social contract of that content since the 90s has been that it is fair use. Anyone can copy it, recreate with it, reproduce with it. That has been freeware, if you like. That’s been the understanding,” said Suleyman.

    Ugh. Social contract, free use, freeware - those all mean very different things. I don’t think the head of a department like that should be blabbing to the public if they’re going to mix up terms like that. Do they not have PR and legal departments that are versed in anything beyond Microsoft’s historical business methods (lie, steal, and fearmonger about open source)?

    Not to mention that in some places, you cannot give up the IP rights over code you write.

    Not to mention “fair use” is primarily for artistic endeavors.

    Not to mention “freeware” is for programs, not written word blog posts or images.

    etc…




  • 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.








  • I just got back from a trip to a substantially less developed country, and really living in a country, even for a little bit, where I could see how many lives that money could improve, all being poured down the Microsoft Fabric drain, it just grinds my gears like you wouldn’t believe. I swear to God, I am going to study, write, network, and otherwise apply force to the problem until those resources are going to a place where they’ll accomplish something for society instead of some grinning clown’s wallet.

    Amen. We always need more insiders who are ready to take up the cause of not doing stupid shit with the ungodly accumulation of resources our society has permitted, especially when we are currently leaving so much of the world to play catch-up while we continue to leech them dry.