javac -debug vs. -optimize
Alright, another Java whine is up today. This entry is about a discussion I've been having at work about using the debug and optimize flags at compile time for Java programs. My take is that the debug option should ALWAYS be turned ON and optimize should be turned OFF. Now, when I mean ALWAYS I mean ALWAYS! So, I get the "But, Blaine surely not meaning a system in production, right?" and my reply is "you bet your ass I am". It's at this point that I get the puzzled expression that would make you think I have 6 heads. And then, I get a little chuckle about navitity. Next, comes the "But, Blaine the program will run MUCH slower and our infrastructure would never stand for that!" I then counter with "Yes, debug does slow down the program, but not by much...And the gains that you get from being able to see a program running and watch it as it fails are ENORMOUS!" I continue by asking if the production support staff would like this. I always get a "WELL HELL YEAH WE WANT THAT!" from the production support folks. Can you blame them? We as developers always have the luxury of debugging our program and watching things as they happen. It allows us to fix our programs quicker and see the state of the application at run-time. Why wouldn't we want this level of flexiblity for a production system? In production, you want a quick turn around time for bug fixes and it's easier to see the problem if you can watch it the state of the application as it's happening! The time saved in fixing production critical bugs more than makes up for the cost of a few missed milliseconds I think. The production/maintenance support staff should have the same or better tools than we as developers do. Logging, etc are for being able to see what a program is doing when it fails. Surely, writing a log entry is more expensive than leaving debugging on. The argument for speed is starting to make sense isn't it? I like to work on live programs and not dead ones. Working on an application while it's running is way more powerful than looking at logs and finding that the piece of state that you need has not been logged! Grrrrrr....Oh well, some food for thought for the day!