Procedural or OOP programming ?
My impression is that OOP (Object Oriented Programming) is considered the most productive way to program by the mainstream.
So what do I think of OOP ?
I am a procedural style programmer and I find that coding this way is faster and more productive than if I were to use OOP. I use to like Visual Basic when it was in version 1.0 and 2.0, but when I finally purchased VB 5.0 I found it a bit overwhelming. Why ? VB 1.0 and 2.0 had a smaller command set, so it was easy to remember it and so I didn’t have to keep checking the documentation. VB 5.0 started to get a bit bloated with too many commands to remember and I found myself checking the docs more often. Sure, the intellisense feature in the IDE helps, but just because the IDE can display all the properties and methods for you in a quick list, does not mean that you understand what each property or method is for and how best to use them.
Another thing I don’t like about OOP is the need to have multiple lines of code to accomplish what can be done with just one line of code with procedural code. When I write code, I have certain habits such as using as short a name as possible for variables and subs/functions. This means less typing when writing code. For example, I always use variable names with just one character for most loop code (ie. FOR X=1 to 10). The less I have to type the better. OOP tends to require a lot more code to accomplish things.
OOP also requires too much forethought when creating new classes or objects. I tend to code “on the fly” as I need it. Having to design classes or objects would just slow me down. Supposedly OOP produces more code reusability. That may be true, but a good procedural programmer can also build high quality reusable code. In the “old days” we used to call them code “libraries” (emphasis for the sake of humor). Yes, well designed libraries can produce very reusable code. My own EZGUI is extremely integrated internally and I reuse routines a great deal.
Two benefits come up when writing procedural code. First is execution speed. I really do feel that procedural code will always run faster than OOP code. Procedural code has a lot less overhead than does OOP. Also rather than dealing with one property at a time, procedural coders write functions/subs with multiple parameters and the parameters they select are often chosen based on what will work best as a group of parameters. A good example is coordinates for both position and size. Doesn’t it make more sense to pass four parameters X,Y,Width,Height than to set four different properties one at a time. I really do shy away from using any COM at all. While I understand the benefits and reasons for COM, it also adds more overhead (calling functions via vtables, etc.) which makes software bigger and slightly slower.
The next benefit is size of executables. Many laugh at this because harddrives are so big today and most PC’s have a couple gigabytes of RAM, but the interest in more mobile PC’s (netbooks, tablets) has forced some hardware changes which means less memory and less harddrive space and now it does make a difference. When I think about how many features I have packed into EZGUI’s runtimes (DLLs) it still amazes me. While other development tools depend upon huge frameworks, many OCX’s (ie. some of Visual Basics controls), etc. my EZGUI runtime has a huge feature set in a very small size. There are no non-operating system dependencies on OCX’s or the Registry (for the runtime). The DLL’s are small enough so you can install them in the same folder as the application, so there is never a problem with conflicts with versions. EZGUI was written using PowerBasic and I didn’t use any of the OOP features of the compiler.
Now this may change in the future with Windows 8, since it appears a good bit of the new API’s added to Windows are done so using COM instead of just functions. I am not happy about that since it will only add more bloat to even my software. But for now, EZGUI is running fine, even on the Windows 8 Preview and it was written using procedural style coding.
I do find it interesting when I read articles which state that the average programmer only writes a few lines of code per hour. Sure at times I may not write a lot of code in an hours time, but there have been times when I was “on a roll” (as they say) being able to write 50, even 100 lines of code in an hours time. Procedural coding allows my mind to “flow” so the code comes naturally. If I had to think it out too deeply, trying to design a class or an object, it would slow me down terribly. While I may not be able to provide any concrete evidence of whether procedural is better than OOP, I do think the quality of the software I have written and its amazing feature set in such a small form factor speaks volumes about the benefits of procedural coding. Add to this the PowerBasic compiler (BASIC is only language I use) and I have a fast and efficient development system. As the old saying goes, “the proof is in the pudding”!