Just a basic programmer living in California

  • 5 Posts
  • 95 Comments
Joined 7 months ago
cake
Cake day: February 23rd, 2024

help-circle
  • I think it depends. Lua is great for scripting - like when X happens do Y. I agree that makes sense for a case like Home Assistant. Sometimes you really want the result to be a data structure, not an interactive program, in which case I think more sophisticated configuration (as opposed to scripting) languages might be better.




  • hallettj@leminal.spacetoProgramming@programming.devWhy YAML sucks?
    link
    fedilink
    English
    arrow-up
    13
    ·
    edit-2
    10 days ago

    I agree - YAML is not suitable for complex cases that people use it in, like Terraform and Home Assistant. My pet peeve is a YAML config in a situation that really calls for more abstraction, like functions and variables. I’d like to see more use of the class of configuration languages that support that stuff, like Dhall, Cue, and Nickel.

    There is another gotcha which is that YAML has more room for ambiguity than, say, JSON. YAML has a lot of ways to say true and false, and it’s implicit quoting is a bit complex. So some values that you expect to be strings might be interpreted as something els.


  • The equation for force of gravity is F = GMm / r² where

    • G is the gravitational constant
    • M is the mass of the planet
    • m is the mass of the object being weighed
    • r is the radius of the planet / distance between the centers of mass of two objects

    The equation shows that gravity scales linearly with mass, and scales inversely with the square of distance. The article says K2-18 b is 8.6 times Earth’s mass, and 2.6 times Earth’s radius. So the weight of a 100 kg mass would be:

    F = 100 × 8.6 / (2.6)²

    which works out to a weight of about 127 kg, or 1.27 times heavier.













  • To expand on why generics are preferred, just in case you haven’t seen these points yet: the performance downsides of Box<dyn MyTrait> are,

    • methods use dynamic dispatch in this case
    • requires heap allocation

    There is also a possible type theory objection which is that normally there is a distinction between types and traits. Traits are not types themselves, but instead define sets of types with shared behavior. (That’s why the same feature in Haskell is called a “type class”, because it defines a class of types that have something in common.) But dyn turns a trait into a type which undermines the type/trait distinction. It’s useful enough to justify being in the language, but a little unsettling from a certain perspective.


  • What helps me most is to find a comfortable rhythm, which is a combination of stride cadence and breathing. I’ve read advice on counting strides, and matching breaths to certain steps. It’s hard for me to coordinate all that so I go by feel. If you’re not feeling comfortable maybe try going slower.

    When your legs don’t want to move it could mean that your muscles aren’t warmed up. You might feel better after taking it easy at the start of the run. Or your muscles might be tired from recent exercise. Either way make sure you’re hydrated.


  • It would make sense for the terminal to handle syntax highlighting since that would match how editors work. But the convention is that the shell handles highlighting, not the terminal. You can check which shell you are running with the command,

    $ echo $SHELL
    

    It’s done that way because the shell is a running program that is capable of telling the terminal which colors to show (by mixing color escape sequences into text). Compare that to code in an editor which is text, not a running program so the only option is for the editor to handle highlighting[1]. Editors need syntax files to configure highlighting for all the different programming languages, while terminals don’t need this because the shell tells them what colors to show.

    [1] setting aside the “semantic highlighting” LSP capability - that was invented long after syntax highlighting conventions were established