4 ms·
> Another thing is strict typing and debugging: since Python is an interpreted language, finding bugs wasn’t as easy Wait, what? How is its interpreter remotel
by technomancy 10y ago
> Another thing is strict typing and debugging: since Python is an interpreted language, finding bugs wasn’t as easy
Wait, what? How is its interpreter remotely relevant to its semantics?
> if you have a syntax error in C, the program will simply not compile, on the other hand, in interpreted languages, the problem might go unnoticed for quite some time
Hang on--Python allows you to run code that has syntax errors? I'm so confused.
- forkerenok 10y agoTo my knowledge syntax within a file is completely checked when that file is loaded. I think the OP referred more to errors in method and other reference names.
- michaelt 10y agoIf you write this: #!/usr/bin/python import time time.sleep(5) fdafadsfadsf It'll take 5 seconds to crash with a "NameError: name 'fdafadsfadsf' is not defined". Likewise, if you do this: #!/usr/bin/python import time x = 1 time.sleep(5) print "x is "+x It'll take 5 seconds to crash with "TypeError: cannot concatenate 'str' and 'int' objects" In a language like Java, these would be syntax errors, and they'd be picked up at compile time as they're illegal in Java's syntax. I assume they're legal in Python's syntax, because for all the syntax checker knows, time.sleep() might define fdafadsfadsf and convert x into a string. So they're runtime errors in Python. Of course, Java still has runtime exceptions - null pointer exceptions, for example.
- jasonpeacock 10y agoJava and Python are apples and oranges - one is a compiled language, the other is interpreted. Better to look at other interpreted languages like Ruby & Perl...and they have the same issue. It's a side-effect of using an interpreted language, but it also allows such languages to be self-modifying which can be very powerful when you need it.
- mmagin 10y agoPerl actually has a 'compilation' phase where some types of syntax errors are actually detected before it goes executing the code.
- technomancy 10y agoPython and Java are both compiled to bytecode and both interpreted as bytecode. It has absolutely nothing to do with compilers.
- mmagin 10y agoYep. What drives me even more crazy is things which are purely syntactically wrong, e.g. an else: clause with no if before it are only detected when the interpreter gets to that line.