Total Posts:6|Showing Posts:1-6
Jump to topic:

Compile time errors vs runtime errors

F-16_Fighting_Falcon
Posts: 18,324
Add as Friend
Challenge to a Debate
Send a Message
3/19/2013 11:17:31 PM
Posted: 3 years ago
I was reading an interesting article on a blog linked here: http://www.pgbovine.net...

It has a lot of great advice and in general seems like an overall awesome blog. Yet this one article, I couldn't disagree more with. The author advocates the use of Python as a great language for teaching beginners in introductory programming classes. I won't copy-paste the entire article as it would take up many posts but I wanted to highlight the parts I disagreed with to see the response of people on a debate site. I suggest reading the article to understand the context of my arguments.

Why Python is a great language for teaching beginners in introductory programming classes

(The article writes)
Run-time type errors rather than compile-time type errors
Compile-time type errors annoy students to no end. It's better to at least let their program run and do SOMETHING rather than fail to compile and do NOTHING. In production-quality mission-critical code, a compiler with strict static type checking is vital in order to reduce the incidence of run-time type errors, but students aren't writing code for nuclear reactors, they're writing 20-line toy programs. At least let their programs run and have them figure out what went wrong at run-time! Sometimes execution can get pretty far before a run-time type error occurs, and the student is likely to have a decent intuition about the source of the error.

It's demoralizing to be a beginner who just wants his code to run and do something (even if it doesn't behave perfectly), only to find out that this mysterious tyrant called a 'compiler' refuses to turn his code into an executable program. Ideally, students should be able to run their programs as frequently as possible"the more iterations of the edit-debug cycle they can squeeze in during a programming session, the more motivated they will be to learn.

The best way to understand what is wrong with your code is to read the compiler messages and correct your code before runtime. It doesn't make sense to me to have to correct faulty code at runtime because it is much more difficult to do so due to not even knowing whether there is an error. Perhaps there could be a runtime error but everything compiles fine and you are lulled into a false sense of security. With compile-time errors, you are solving the problems as they occur and can have peace of mind that all errors are accounted for when the compiler finally lets you run the program.

Just the fact that the author says that execution can get pretty far before runtime errors is scary because I don't want execution to get very far furthering the false sense of security the program is running fine. Runtime errors are also more difficult to locate because many test cases need to be tested before you are certain that the program is running fine whereas with compile time errors, the compiler does the job for you.
malcolmxy
Posts: 2,855
Add as Friend
Challenge to a Debate
Send a Message
3/20/2013 4:25:46 AM
Posted: 3 years ago
It works well with XML and it's good in terms of its simplicity of syntax.

You're more in the intermediate to advanced aspects of coding.

I learned on Visual Basic. I'm pretty sure that's not the one to use, anyway (actually, I learned on BASIC and LOGO...LOGO was neat. BASIC was everything that is wrong with computer languages.)

Anyway, when you're first starting out, you need some positive feedback and some sort of result to want to go further. I quit after Visual Basic, because we were building a program as the quarter progressed, and any time your part for the week didn't work, the professor would sub in his part (it's object oriented, so its not completely stupid), but if the logic was different, stuff started breaking, and eventually, all you had was a copy of the professor's program.

I wanted my sh!t to work...or break...

I picked up again with SQL, but that's scripting as opposed to programming.

Anyway, I thought everyone learned on Perl these days...
War is over, if you want it.

Meet Dr. Stupid and his assistants - http://www.debate.org...
F-16_Fighting_Falcon
Posts: 18,324
Add as Friend
Challenge to a Debate
Send a Message
3/20/2013 11:12:15 AM
Posted: 3 years ago
The problem with Logo is that it was specifically designed just to teach students programming meaning it isn't a "real" programming language. I think I'd be pretty discouraged if I was introduced to programming with a fake language. For me, the motivation for learning Java and C is partly that they are extremely popular and form the standards on which many real world programs and operating systems are based. Can't have that with Logo.

When you say positive feedback, what level of complexity are you referring to? I am assuming it is more than simple input/output. Are you talking about linked lists or stacks for instance?
drafterman
Posts: 18,870
Add as Friend
Challenge to a Debate
Send a Message
3/20/2013 11:48:17 AM
Posted: 3 years ago
I agree with you, F-16. Compiling errors at least give you feedback and an indication of what's wrong.

Run-time errors, necessarily, are those not found by the compiler. You can't figure out what's going on without debugging the code, which usually requires a lot of advanced modification to see what's going on.

Now, a lot of advanced programs, like the Visual stuff, have debugging integrated into the compiler, but other languages, like perl or python, you basically end up having the program display the values of all the relevant variables just to see what the hell is going on.

I really don't buy the argument that compiler errors are disheartening because having your program run incorrectly, producing unexpected output (or simply producing an error) is not only also disheartening, but you are left with no clue about what the hell happened!
malcolmxy
Posts: 2,855
Add as Friend
Challenge to a Debate
Send a Message
3/20/2013 11:57:46 AM
Posted: 3 years ago
At 3/20/2013 11:12:15 AM, F-16_Fighting_Falcon wrote:
The problem with Logo is that it was specifically designed just to teach students programming meaning it isn't a "real" programming language. I think I'd be pretty discouraged if I was introduced to programming with a fake language. For me, the motivation for learning Java and C is partly that they are extremely popular and form the standards on which many real world programs and operating systems are based. Can't have that with Logo.

When you say positive feedback, what level of complexity are you referring to? I am assuming it is more than simple input/output. Are you talking about linked lists or stacks for instance?

All programs are input - output. You enter some data, or something (press a button, etc) and then the program does something and displays it for you.

The programing I was doing (the parts that were hard) involved algorithms around multiple variables. It can get pretty confusing after a while.

When you say lists and stacks (sorry, it's been a while), do you mean like list boxes? That's what I consider simple.

You must be talking about new terms such that I am out of the loop and don't understand what you mean.
War is over, if you want it.

Meet Dr. Stupid and his assistants - http://www.debate.org...
vbaculum
Posts: 1,274
Add as Friend
Challenge to a Debate
Send a Message
3/20/2013 2:26:04 PM
Posted: 3 years ago
At 3/19/2013 11:17:31 PM, F-16_Fighting_Falcon wrote:
I was reading an interesting article on a blog linked here: http://www.pgbovine.net...

It has a lot of great advice and in general seems like an overall awesome blog. Yet this one article, I couldn't disagree more with. The author advocates the use of Python as a great language for teaching beginners in introductory programming classes. I won't copy-paste the entire article as it would take up many posts but I wanted to highlight the parts I disagreed with to see the response of people on a debate site. I suggest reading the article to understand the context of my arguments.

Why Python is a great language for teaching beginners in introductory programming classes

(The article writes)
Run-time type errors rather than compile-time type errors
Compile-time type errors annoy students to no end. It's better to at least let their program run and do SOMETHING rather than fail to compile and do NOTHING. In production-quality mission-critical code, a compiler with strict static type checking is vital in order to reduce the incidence of run-time type errors, but students aren't writing code for nuclear reactors, they're writing 20-line toy programs. At least let their programs run and have them figure out what went wrong at run-time! Sometimes execution can get pretty far before a run-time type error occurs, and the student is likely to have a decent intuition about the source of the error.

It's demoralizing to be a beginner who just wants his code to run and do something (even if it doesn't behave perfectly), only to find out that this mysterious tyrant called a 'compiler' refuses to turn his code into an executable program. Ideally, students should be able to run their programs as frequently as possible"the more iterations of the edit-debug cycle they can squeeze in during a programming session, the more motivated they will be to learn.

The best way to understand what is wrong with your code is to read the compiler messages and correct your code before runtime. It doesn't make sense to me to have to correct faulty code at runtime because it is much more difficult to do so due to not even knowing whether there is an error. Perhaps there could be a runtime error but everything compiles fine and you are lulled into a false sense of security. With compile-time errors, you are solving the problems as they occur and can have peace of mind that all errors are accounted for when the compiler finally lets you run the program.

Just the fact that the author says that execution can get pretty far before runtime errors is scary because I don't want execution to get very far furthering the false sense of security the program is running fine. Runtime errors are also more difficult to locate because many test cases need to be tested before you are certain that the program is running fine whereas with compile time errors, the compiler does the job for you.

I would use Python as a beginners language (as well as an enders language).

Until you've debugged your program, it will contain numerous problems no matter what language you use. With a staticly typed language, the compiler is able to point out type mismatch errors, which constitute a small minority of the mistakes that you have made. Discovering the error in compile time doesn't teach you something that you wouldn't learn had you discovered the error during runtime.

In the beginning of my career, I used mostly staticly typed languages. I thought dynamic languages were inherently flawed. After I learned PHP, I revised my view; dynamic is almost always better.

The main problem I see with dynamic typing now are two things: difficulty refactoring, which isn't a huge problem, and programmers who code in a style that would simply benefit from type checking. I code in very unambigious way where it's very unlikely for me to use the wrong type. However, it seems to be the case that not everyone writes this way. And despite my preference for Python, I probably would prefer a statically typed languge if I were writting code for a nuclear reactor.
"If you claim to value nonviolence and you consume animal products, you need to rethink your position on nonviolence." - Gary Francione

THE WORLD IS VEGAN! If you want it