Lazzyness is not a bad habit! Slothfullness is :)
So what’s the difference?
Hehe… in my world, I classify Laziness as the unwillingness to do more work than you feel you need to do. Slothfulness, in this same world of mine, is the unwillingness to do work that must be done.
You still don’t see the difference? Lemme explain. I’m slothfull about my Laundry (trust me… you don’t want to stick your nose near my laundry bad :) ), but I’m totally Lazy about Programming.
Porting XLib to D, is a case in point. From my limited understanding of the conversion process, I jumped in, took one look at Xlib.h, saw that it included X.h, and Xmd.h, and I decided to start by converting X.h to X.d
All well, and good, till I started doing the actual conversion. I started seriously replacing complex #defines, #ifndefs, etc, with version() statements, etc, and got stomped on a number of them, put TODO: markers on them for a next iteration, and tried to move as fast as I could. In the first two days, I completely had X.h converted to X.d (a whooping 3000+ line file!!!). That proves I’m not slothfull by my definition.
Well, next was Xmd.h to Xmd.d, and I started… full of energy and enthusiasm… and then I realized… heck… at this rate… I’ll NEVER finish this stuff!!! How did I come to that realization? Well, all this files are VERY LARGE. Then my lazy side kicked it… my hands just REFUSED to move on the keyboard again, and I started thinking… there MUST be something I’m not doing correctly. I considered writing a bash or python script to take the drudgery away, but then there were still so many special cases, and my RegEx is not FBI class RegEx (whatever FBI class RegEx is :) ).
It was then I started looking closely at the docs and found that there was a recommended step I was indeed missing out.
There is a recommendation to run the Preprocessor before conversion actually starts.. hmm… how did I ever miss that? Will it simplify my work? I went to find out.
I ran gcc –E on X.h and OMG!!! The result was less than 20 lines of code… I immediately began to suspect the process.
I repeated this on Xmd.h and DAMN! The same thing… all the code was disappearing, and some files like Xosdefs.h turned up totally empty. I popped into irc, asked around a bit, and someone said I may have empty files if I’m not referencing anything from those files.
Keeping that in mind, I reapeted that on Xlib.h, which pulled in code from X.h and Xmd.h, and I compared the sections it pulled in, and they were the same as the ones I got when I ran gcc –E on the independent files. Also, Xlib.h wasn’t empty like the other files, but it was just left with struct defs and typedefs…
Wow!!! That is a whole lot less work than my previous approach. So I’ve already clobbered the old sources, and started again. I’m almost certain I may start afresh at least once more as things get clearer, but it’s a whole lot more clearer. What I want to do is to download digital mars C compiler and use that to run the Preproccessor stage and compare the two outputs.
Currently my work is cut out for me, I’ve written a quick and dirty bash script, that does most of the typedef replacements that are obvious, and the type mappings (unsigned long long -> ulong for instance).
I’m sure I’ll be able to test my example code this weekend, so I’m still shooting for that.
Back to laziness and sloth. I was lazy about continuing, but not slothfull about doing the necessary research. Also, my continuing along with my HARD WORK approach, will seem to prove that I’m not lazy and not slothfull. The truth is, once I refuse to AT LEAST CONFIRM a suspicion, then I’m slothfull. This is probably one of the key factors that separate smart hackers from the regular drone next desk :).
Maybe I’m not your uberKewl smart hacker, but hey…I’m MY UberKewl smart hacker :)