• da_cow (she/her)@feddit.org
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    Hear me out, but whatever lunatics at python decided that brackets and semicolons are unnecessary, have made a catastrophic mistake with it. I start using another editor that uses different amount of spaces for tabs and suddenly my code no longer runs. Its also absolutely horrible when you chase down a bug for an hour just to realise, that one additional/missing tab changed the scope of your code and broke your entire script.

    • (des)mosthenes@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      3 days ago

      python, haskell, lua, typescript, babel, shell (newline), I dunno what else nowadays - the compiler will insert them need be

      • da_cow (she/her)@feddit.org
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        2 days ago

        The reason I dislike the missing of semicolons and brackets is because it causes bugs (that’s more of a problem of missing braces to declare the scope of your code) and also takes away control from the programmer.

        Missing braces:
        I had more than one instance where I accidentally deleted the intendation in a python script that caused undefined behaviour in my code and it took quite a lot of time to track that down. If the programming language would have forced me to properly defined the scope of my code by introducing brackets, that bug would have never been possible.

        Semicolons:
        The main thing I like about semicolons is that it allows you to properly space out your code over multiple lines for visual clarity. E.g.:

        void my_function(int arg1, int arg2, int arg3){
          //some code
        }
        
        int main(){
          my_function(
            1, //arg1
            3, //arg2
            8 //arg3
          );
        }
        

        Python should allow this too, since the arguments are being defined inside brackets, but other languages have no similar functionality (e.g. shell, but that is a little bit unfair, since you can’t even specify arguments) forcing you to put everything into a single line.

        Rust even allows you to leave out the semicolon on the last statement of a code scope in order to return the result of the statement:

        fn main() {
            let condition = true;
            let number = if condition { 5 } else { 6 }; 
            //number turns into 5, since the value is being returned due to the missing semicolon.
        
            println!("The value of number is: {number}");
        
            let number = if condition { 5; } else { 6; }
            // this should return null (if it even compiles)
        }