pythonlang2/content/_index.md

4.2 KiB

+++ title = "Why python is a bad language" +++

{{ sec_header(name="Weird Syntax") }}

  • It is hard to read, because it is missing semicolons and braces.
  • Indentation as a syntactical element is just silly. This takes away freedom from the developer and makes the code less readable without any benefit.
  • Indentation-dependant scopes make multiple statements on one line look horrible.
  • Doc comments
    • They use triple quotes which doesn't make sense for a comment.
    • They go under what they are documenting, which looks wrong and is very unusual.
    • They are technically not comments, which is a terrible idea.
    • They are accessible at runtime, but shouldn't since this encourages spaghetti code.
  • The def keyword does not imply a function, so one may think it is declaring a variable, or something else.
  • Strange naming
    • __init__ or __add__ looks like an internal function. That these define operators looks like someone was too lazy to do this properly (yet again!).
    • Exception handling using raise and except instead of the usual throw and catch. There is literally no point to do this, and it confuses users.
    • Same goes for elif instead of else if. This is just pointless, and again looks like a lazy implementation.
  • Strange symbols
    • not, and and or instead of the more conventional and cleaner looking !, && and ||.
  • Normal if and else statements are not expressions. If they were, the additional ternary operator syntax would be completely redundant, and the code would be cleaner.
  • The syntax for inheritance looks really confusing. Foo(Bar) looks like Foo has a constructor that takes a Bar as an argument, and not like Foo extends Bar.
  • For some reason, the pass keyword exists. Why can't we just leave the block empty or omit the :? Yet another lazy implementation!
  • The recently added := (assignment expression) operator exists, instead of simply making the normal assignment (=) an expression.

{{ sec_header(name="Lacking Features") }}

  • Lambdas are a poorly implemented afterthought.
  • There is absolutely no switch statement or anything along those lines, leading to absolutely HUGE elif blocks!

{{ sec_header(name="Intepreter") }}

  • Intepreters lead to runtime errors which could otherwise be detected at compile time. This often causes bad errors to make it into production due to untested edge cases.
  • Very bad performance.
  • Python is hard to package. Of course tools exist that can do it, but they are slow and large as they always include the interpreter as opposed to compiling the code or using some sort of faster intermediate language. Packaged python also includes the source code, which may be undesirable.

{{ sec_header(name="Dynamic Typing") }}

  • Passing an invalid type into a function may cause unpredictable behaviour. Manual type checks are annoying, and type hints are still just hints.
  • It is often unclear what type a function is expecting, thus it can be hard to know how to call it, especially if it is undocumented.
  • A function can return whatever type it wants, so it is hard to work with and unpredictable.
  • Variables don't need to be declared. This leads to many issues, such as accidentally overwriting other variables with the same name, or typos going undetected.
  • A variable's type may be changed after its assignment, making it harder to work with.

{{ sec_header(name="Poorly done Classes") }}

  • The self parameter being passed into functions explicitly is pointless boilerplate. Instead it should just be there implicitly, and static functions should be declared with a keyword such as static.
  • Fields do not need to be declared. This leads to issues mentioned before. It also makes the data a class stores undefined, making it harder to work with. It is recommended to declare fields, but unfortunately not enforced.
  • Enums are basically just classes, and are yet another lazy afterthought.

{{ sec_header(name="Other Issues") }}

  • Strings can be evaluated as code, encouraging spaghetti.
  • Doc comments are available at runtime using help(element). This also encourages spaghetti
  • The command line REPL prints Use exit() or Ctrl-Z plus Return to exit for no reason, instead of simply exiting.