• 1 Post
  • 9 Comments
Joined 3 months ago
cake
Cake day: August 16th, 2024

help-circle

  • I have advice that you didn’t ask for at all!

    SQL’s declarative ordering annoys me too. In most languages you order things based on when you want them to happen, SQL doesn’t work like that- you need to order query dyntax based on where that bit goes according to the rules of SQL. It’s meant to aid readability, some people like it a lot,but for me it’s just a bunch of extra rules to remember.

    Anyway, for nested expressions, I think CTEs make stuff a lot easier, and SQL query optimisers mean you probably shouldn’t have to worry about performance.

    I.e. instead of:

    SELECT
      one.col_a,
      two.col_b
    FROM one
    LEFT JOIN
        (SELECT * FROM somewhere WHERE something) as two
        ON one.x = two.x
    

    you can do this:

    WITH two as (
         SELECT * FROM somewhere
         WHERE something
    )
    
    SELECT
      one.col_a,
      two.col_b
    FROM one
    LEFT JOIN two
    ON one.x = two.x
    

    Especially when things are a little gnarly with lots of nested CTEs, this style makes stuff a tonne easier to reason with.





  • It’s not easier to do getters or setters but especially in python there’s a big culture of just not having getters or setters and accessing object variables directly. Which makes code bases smaller.

    Same with the types (although most languages for instance doesn’t consider None a valid value for an int type) Javascript has sooo many dynamic options, but I don’t see people checking much.

    I think it boils down to, java has a lot of ceremony, which is designed to improve stability. I think this makes code bases more complex, and gives it the reputation it has.



  • houseofleft@slrpnk.nettoProgrammer Humor@programming.devLanguages
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    1 month ago

    I think a lot of it is “ceremony”, so it’s pretty common in java to:

    • create a get method for every object variable
    • create a set method for every object variable

    Then add on top that you have the increased code of type annotations PLUS the increased code of having to check if a value is null all the time because all types are nullable.

    None of that is hugely complicated compared to sone of the concepts in say Rust, but it does lead to a codebase with a lot more lines of code than you’d see in other similar languages.



  • I feel like in a lot of ways, most languages are great candidates for this, for lots of different reasons!

    • Rust: Great choice because it produces a small, very well optimised binary. If you just care about the output binary being small and non-memory intensive, then this is probably a good call.

    Buuuuut, Rust’s compilation can be pretty resource intensive, so if you’re actually developing on limited hardware:

    • C (or curveball option, Hare): produces a small, well optimised binary, with faster compilation. But less framework type things to help you on your way to apis/servers/etc.

    Then there’s the fact that it’s a home server, so always on, meaning you actually have generous resources in some ways, because any available CPU is kinda just there to use so:

    • Python: has a runtime and can be pretty heavy CPU wise, but lots of frameworks, and in all honesty, would wind up being a lot faster to put stuff together in than Rust or C. Probably a great default option until you hit resource issues.

    And then why not go whole hog into the world of experimental languages:

    • Roc: Doesn’t have versions yet, so super new, but should produce a pretty small binary and give you higher level ergonomics than something like Rust or C, especially if you’re into FP.

    And then we’re forgetting about:

    • Haskell: Haskell is the only true programming language, and any time there’s a selection of programming languages, picking the one that isn’t Haskell is the wrong choice. Just ask anyone who programs in Haskell.

    But that doesn’t factor in:

    • Javascript: Sooner or later, everything is just javascript anyway, why even try to resit?

    Plus:

    • Assembly: Can you even trust that it’s well optimised unless you’re writing the assembly yourself?

    Edit: My actual serious answer is that Rust + Rocket would be great fun if you’re interested in learning something new, and you’d get very optimised code. If you just want it to use less memory that java and don’t want to spend too much time learning new things then python is probably fine and very quick to learn. Go is a nice halfway point.