??? 11/12/11 12:42 Read: times |
#184676 - You can't Responding to: ???'s previous message |
Jan Waclawek said:
Even in compiled languages I am able to write - and have written, on uncountable occasions - errors which revealed themselves only later.
If this bothers you, you should adopt the same technique as with any other language - test what you've written immediately after you've written it. There are of course so many variants of the "interpreted language" paradigm, with various minor points for and against them in various settings. The world is just not black and white. JW Compiled languages prunes down the number of combinations of errors you need to test for in a way that doesn't happen for a truly interpreted language. Real programs aren't written fully and then tested fully. They are incremental pieces of work. With a compiled language, you can focus on what to test based on what additions you have made. With interpreted languages, you have a much harder time to figure out how the changes may break older, pre-tested code. It is a well-known fact that functions can normally be subjected to full testing whenever they are modified. You can have a test harness that tests all if statements, all limits for all variables etc. When combinting 500 functions into a complete program, the combinatorial math tells us that we can not perform such a complete test. It could take billions of years. So we have to settle for testing what is possible to test. And the compiler (or static analyzers like lint) will be part of that testing environment. And they will test huge amounts of combinations that you will not be able to test with the interpreted language. The compiler might drop the number of needed tests from 2^20 to 2^10. But that means that it will catch a large number of errors that you just can not set up test cases to catch for the interpreted language. You wouldn't even have the thousand years it would take just to write the test cases. Remember also that most interpreted languages have weak type handling. So they can have a string "15" and allow that to be multipled by 2 and end up with the result 30. Weak type checking sometimes helps. But sometimes, it makes the program create a result even when the code was wrong and we sent the wrong variable to the function. With weak type checking, you get into troubles like is "" same as NULL or the value zero? Is "15hello" the number 15 or invalid? Should "hello " + "world" concatenate two strings or be a failed attempt to add two numbers from text input boxes on a web form? But there are many other things that can go wrong with an interpreted language. For example the upload of a PHP-based web application to a server accidentally make one of the source files not readable by the web server. The application can run fine for a long time, until a web visitor does something that requires this file to be included for parsing. Interpreted languages that gets bad data from a text input and doesn't guard about it, could accidentally try to run the text input data as if it was code. A common example is SQL injection, where people enter text data that looks like the end of a text string, and then follows this with a semicolon and some dangerous SQL statement. The programmer thought he performed a single SQL query in the database, but his query ended early and after that followed a SQL statement requesting the database to be dropped (i.e. thrown away). |
Topic | Author | Date |
Interpreted Languages? | 01/01/70 00:00 | |
Sometimes it's hidden | 01/01/70 00:00 | |
p-code | 01/01/70 00:00 | |
P-code and others | 01/01/70 00:00 | |
interpreter/compiler | 01/01/70 00:00 | |
Debatable | 01/01/70 00:00 | |
Not necessarily machine code | 01/01/70 00:00 | |
Definitely debatable | 01/01/70 00:00 | |
Ofcourse not | 01/01/70 00:00 | |
runtime errors | 01/01/70 00:00 | |
You can't | 01/01/70 00:00 | |
You missed the point! | 01/01/70 00:00 | |
Not always worth it with interpreted languaes | 01/01/70 00:00 | |
I like your thinking | 01/01/70 00:00 | |
Many FORTH implementations are interpreted, aren't they? | 01/01/70 00:00 | |
Forth | 01/01/70 00:00 | |
Maybe a comparison? | 01/01/70 00:00 |