• 2 Posts
  • 363 Comments
Joined 1 year ago
cake
Cake day: September 24th, 2023

help-circle


  • Well I’m no fan of Python either but it doesn’t describe itself as a scripting language (and neither does Ruby) so I think you’re way off there.

    And I dunno about Ruby being a better Python. It looks way worse to me. In particular the story for static type annotation seems pretty dire. The syntax is worse, it’s less popular, and even slower!

    I can believe the tooling is better though. Python’s is abysmal (unless they officially adopt uv - ray of hope there but I have zero faith the Python Devs would make such an obvious decision).





  • Some suggestions:

    1. Declare input in the loop. That limits scope which is basically always a good idea.
    2. Trim the newline like
    let input = input.trim();
    

    This is better in several ways:

    1. Simpler
    2. Doesn’t allocate a new string.
    3. Removes all whitespace at the start and end.
    4. It makes input immutable after that line.

    Also attempts is never read - you should have got a compiler warning about that.

    Otherwise, good work.





  • Very good points. A codebase that gets this VERY wrong is Gitlab. I think it might be a dumb characteristic of Ruby programs, but they generate identifiers all over the place. I once had to literally give up following some code because I could not find what it was calling anywhere. Insanity.

    Another point: don’t use - in names. Eventually you’ll have to write them down in a programming language, at which point you have to change the name. CSS made this mistake. foo-bar in CSS maps to fooBar in Javascript. Rust also made this mistake with crate names. A crate called foo-bar magically becomes foo_bar in Rust code.









  • Have a go on your free time and see if you like it. There is an absolute ton of free learning material online. You don’t need to pay anyone.

    Most programming jobs (e.g. making web sites) are easy enough for the average person to do, but I think most people would find programming far too tedious and boring to learn.

    It’s like law - there’s nothing particularly difficult about it but most people find it incredibly mind numbing to read legal documents.

    So I would have a go in your free time first to make sure it is something you could do.