Friday, May 25, 2007

Why is this global declared...

That surprisingly is the first thing that popped into my head after reading this worse than failure entry...

You might ask "why".  Well, it made me remember this conversation I had with a developer about 15 or 16 years ago:

me: Why is this global declared - it isn't used.

them: because if you remove it, the program will crash.

me: you mean it won't compile because it really is used?

them: no, it compiles cleanly with or without it - but there must be a bug in the compiler because if you remove the global variable - the program segmentation faults and dumps core

me: do you understand what you have really done here?  You have a memory overwrite and you are just hiding it by having this big variable stuck in there - you have a bug in your code.

them: how could it be a bug in my code, my code runs - as long as the variable is defined.  it must be the compiler.


It was not a good day :) We spent the rest of the week removing unused globals and local stack variables - fixing memory overwrite after memory overwrite in the process.  They really blamed the compiler.

I miss my old C programming days, they were fun (really)...



Blogger bill thater said....

remind me to tell you the story of how i learned to code C.;-)

Fri May 25, 05:04:00 PM EDT  

Blogger Peter K said....

Typical. Here at my current employer, there's a programmer (considered to be a power programmer) who, whenever the program doesn't work, blames it on the database. When told that the program was missing error handling, etc, would looked at you as if you are from another planet.

Sat May 26, 12:48:00 AM EDT  

Blogger mjb said....

Ahh, the good old days of C programming....;-)

My favorite was the bug that would disappear when you recompiled the program w/ debug turned on.....;-)

Sat May 26, 02:14:00 AM EDT  

Anonymous Anonymous said....

Hmm, a blog entry but no followups on asktom two days running: dare I hope you're working on your book? Any chance of getting a teensy weensy hint on how it's coming along?

Sat May 26, 05:18:00 AM EDT  

Anonymous Anonymous said....

Tom I have a question for you... I am by no means knowledgeable with oracle but I am having trouble understanding what is going on ...We have an Oracle database at work Version 7 I belive and we have been using Microsoft Access 97 with it for years to run reports and all sorts of neat things... recently we changed to Access 2003... Lately I've been asked to relink alot of the Access Databases and compress them because Our Oracle Admin here says that the Server is peaking out... the # of Processors in use at one time has jumped from 3 to 4 to 6 I belive and that it is acting really slow... and response times are awful at times... Is there anything you have seen in your experience that might be of hand to me in looking at Access or for that matter any database that is connecting to Oracle that could be causing problems...

Sat May 26, 10:07:00 AM EDT  

Blogger Robert Vollman said....

I think this is why Java was invented. Too many people were too dumb for C.

Sat May 26, 11:31:00 AM EDT  

Blogger Thomas Kyte said....

...Too many people were too dumb for C....

No, I don't like the way that is stated.

They are not, were not too dumb. They were just not educated.

And trust me - Java gives you INFINITELY more exciting ways to shoot yourself in the foot without realizing it. Simply because so much "just happens as a side effect of something else"

If anything, I would say writing correct code in Java is more complex and tricky than C.

Sat May 26, 11:50:00 AM EDT  

Anonymous Anonymous said....

Mette says:

I think it was the other way round. That Java/c were too stupid for the programmers. Who in their right mind made Java case sensitive?? Would YOU define a variable called amount and another Amount and a third AMOUNT? No, then why on earth enable yet another possiblity for crappy programming?


PS Long live pl*sql, rexx, cobol (!!) pascal (look alikes) etc.

Sat May 26, 04:42:00 PM EDT  

Anonymous paul said....

Well, if I might just say, Algol60 was my favourite programming language. I love SQL but can anyone forgive me - I've just been on a 5 day ABAP course!

Sat May 26, 05:06:00 PM EDT  

Anonymous Anonymous said....

A google for:

Gene Weingarten SAP

gives a funny column.

Sun May 27, 12:11:00 AM EDT  

Anonymous chris_c said....

Its possible to get into a great deal of trouble in any programing language, I've had to work with a VB programmed who used the names bob and fred for every variable. If you need more than two variables just append a number, bob01, bob02 etc. Made debuging his code lots of fun.

Mon May 28, 12:52:00 PM EDT  

Anonymous RobH said....

If you need more than two variables just append a number, bob01, bob02 etc. Made debuging his code lots of fun.

Don't get me started, I know SO many developers who use un-named variables all the time, x, y, z, etc, or how about cursors named cur1, cur2 etc.

Tue May 29, 08:35:00 AM EDT  

Anonymous Unique Directories said....

Don't worry about the world coming to an end today. It's already tomorrow in Australia. - Charles Schultz

Sat Jun 02, 04:25:00 PM EDT  

Anonymous Anonymous said....

Where are you Tom? May is over your sales in june dont come into play until next year Tom. Why don't you post something?

Thu Jun 07, 08:33:00 AM EDT  

Anonymous Anonymous said....

Hi Tom,

sorry nothing to do with globals BUT

haven't been able to access your site

Just get connection timed out

since Saturday 16th June

Any thoughts ?


Mon Jun 18, 01:23:00 PM EDT  


<< Home