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

help-circle



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











  • Not necessarily cash, but definitely a bit of luck. Some lawyers, if they think a case is guaranteed to go your way, will do the work for free in exchange for receiving a portion of the damages the final judgement will award you. Even rarer, some lawyers care enough about some issues on a personal level that they’ll work for free, or reduced rates, on certain cases.

    In this case, I’m not sure there are any damages whatsoever to award to OP - a “win” is forcing the company to abide by the GPL, not pay up money. The EFF and the FSF, as others have brought up, are probably the best bet to find lawyers that would work on this case for the outcome instead of the pay.







  • According to Our World In Data (which claims to use the Energy Institute’s Statistical Review of World Energy from 2023 as a data source), that waste is from producing around 70 TWh each year:

    That only covers around a third of Switzerland’s energy consumption over those years. Furthermore, Switzerland is a small mountainous country with decent access to hydropower (making up around a third of its needs over the same years). They are not necessarily representative of the waste that would accumulate from a more agressive switch from fossil fuels to nuclear across the world (which is what we’re talking about, if I’m not mistaken).

    France is about 10 times larger in surface area and according to the same source, consumed/produced over 1,000 TWh of nuclear energy each year:

    And officially has still has no place to put the high-energy waste (source - in french), leaving it up to the plant’s owners to deal with it. There is an official project to come up with a “deep” geological storage facility, but no political will seems musterable to make that plan materialize beyond endless promises.

    I should mention that I’m not super anti-nuclear, and I would certainly rather we focus on eliminating coal and oil power plants (and ideally natural gas ones as well) before we start dismantling existing nuclear reactors that are still in functioning order.

    That being said, there are other problems with nuclear moving forwards besides waste management. The main one that worries me is the use of water for the cooling circuits, pumped from rivers or the sea. Not only do open cooling circuits have adverse affects on their surrounding ecosystems, as the planet gets warmer and the temperature swings during the hotter seasons become more pronounced, the power plants will become less efficient. The water going in will be at a higher temperature than it is today, and thus will absorb less energy from the nuclear reaction itself.

    Overall, I don’t trust our current collective responsibility as a species to manage our current forms of nuclear production. Russia sent its own troops into the Chernobyl Exclusion Zone to dig trenches in contaminated soil last year, and they allegedly recognized last week that the Zaporizhzhia power plant is now “unsafe to restart” because of the military activity in the region.

    The world has not experienced generalized warfare with nuclear power plants dotting the countryside; WW2 ended around a decade before the first nuclear power plants were up and running in the USSR, the UK, and the USA.

    Not to mention how few European countries have access to uranium on their own soil/territory. Of course, most of the rare earth metals used in photoelectric panels and windmills aren’t found there either, but as least with “renewables” they are used once to make the machinery, not as literal fuel that is indefinitely consumed to produce power.

    I don’t know enough about thorium-based reactors nor molten salt-based reactors to go to bat for them instead, but they seem like a more promising way for nuclear to remain relevant.