forked from LordMZTE/pythonlang2
2.7 KiB
2.7 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-dependant scopes make multiple statements on one line look horrible.
- Doc comments
- They go under what they are documenting, which looks wrong and is very unusual.
- The
def
keyword does not imply a function, so one may think it is declaring a variable, or something else. - Strange naming
- Exception handling using
raise
andexcept
instead of the usualthrow
andcatch
. There is literally no point to do this, and it confuses users. - Same goes for
elif
instead ofelse if
. This is just pointless, and again looks like a lazy implementation.
- Exception handling using
- Normal
if
andelse
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.
class Foo(Bar)
looks likeFoo
has a constructor that takes aBar
as an argument, and not likeFoo
extendsBar
. - For some reason, the
pass
keyword exists. Why can't we just leave the block empty or omit the:
? Yet another lazy implementation! True
andFalse
are capitalized which is unconventional.
{{ 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.
- 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 asstatic
. - 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.
{{ sec_header(name="Other Issues") }}
- Operator chaning often works in completely nonsensical ways. For example
False == False in [False]
is treated asFalse == False and False in [False]
and not as something that makes sense such as(False == False) in [False]
orFalse == (False in [False])
.
{{ sec_header(name="Conclusion") }}
Python is a perfectly fine language for beginners and experienced devs alike. There is nothing wrong with using it directly, or programs made with it.