On 14-10-2016 1:07, pozz wrote:
> I come from the C language, that is a compiled and strongly typed language. 

C is far from a strongly typed language, IMO...
You can convert (cast) almost anything to anything else without compiler errors.
Have a a float? Ah yes no I mean treat it as a pointer to a function taking a 
instead. Things can blow up majorly at runtime (segfault or worse)
Python is much more strongly typed than this. You can never do something to an 
that is not defined in its interface, and an object is always exactly known to 
be of one
particular type.

Perhaps you're thinking about statically typed versus dynamically typed?

> I learned
> many good tricks to write good code in C: choose a coding style, turn on as 
> many
> warnings as possible, explicitly declare static variables and functions (when 
> needed),
> explicitly declare const variables (if the piece of code will not change 
> them),
> explicitly declare all the functions, and so on.
> All the tricks have a common goal: to discover bugs as soon as possible, 
> mostly during
> compilation process. Indeed I usually find some bugs during compilation (or 
> static
> analysis). It seems to me very important.
> Now I'm learning Python and it appears to me very simple, but at the same 
> time highly
> dangerous. For example, I can write a function that accepts two arguments and 
> call it
> with only one argument. I can execute the script without any problem and I 
> will not
> notice the bug until I test exactly the erroneous line of code (the call with 
> only one
> argument).
> However, I think the language interpreter could emit the error before 
> launching the
> script even without executing the wrong instruction, because it perfectly 
> knows how many
> arguments the function wants and that one instruction calls it with a wrong 
> number of
> arguments.
> Are the things exactly how I understood, or do I miss something in Python?

Python is a *very* dynamic language so static checks are usually extremely hard 
to do.
Recent IDEs and tools (checkers, linters) have made some progress though, and 
type hints
have been added to the language recently to support this.

The biggie I think is that in the Python world the concept of *unit tests* is an
extremely important one. That is (I feel) the major tool being used to not only 
existing bugs, but also to avoid introducing new ones while changing the 

Something which I believe you need everywhere else as well, regardless of 
language. Proper unit testing (and testing in general) is much more powerful 
placing a lot of trust in the compiler.



Reply via email to