Wednesday, February 4, 2009

C#

Pascal was the first proper language I learned after BASIC, and my IDE of choice was Turbo Pascal, the creation of Anders Hejlsberg, the same man who has now brought us C#. I still rave nostalgically about the brilliant help system built into TP, but when it comes to C#, I have a slightly different view.

I don't hate C#, but I don't love it either. However, that doesn't mean I have a love-hate relation with the language, those emotions are far too strong. Rather, I consider it to be more of a like-dislike relation. Naturally, I focus on the dislikes. Here's the list:

Everything is classes, just like Java, and just like Java, it annoys me. What's wrong with the odd global helper procedure for those pointless-to-classify tasks? The same basic thing can obviously be accomplished by declaring public statics, but it's that much more bureaucratic framework code, just to please the OO fanatics who blindly believe that all globals are evil. The only thing that kind of design accomplishes is an abundance of classes called Library, Framework or System. Suggesting that I use a singleton instead won't improve my mood, either.

Then there's the mollycoddling. Bounds checking? Garbage collection? No pointers? (That last one is a lie of course, but I'll get into that in a bit.) Apparently it's much too deviously difficult or at least much too time consuming for me, a pitiful dev, but I'm pretty sure I can handle the memory management myself, thanks. In fact, I rather prefer to know what's going on under the hood, if I may.

These days, pointers are one of the devil's temptations. Only the most hardened of veterans may use them, and even then only if they incantate the keyword equivalent of a contamination suit, "unsafe". Much easier for the developer, indeed. But does that mean the language is void of pointers (pun not intended)? Au contraire!

In fact, most variables transcending the complexity of an integer that you might want to declare in C# are pointers, or "reference types", as it were. That is, they are pointers to objects. Have a look at this:

  MyClass c = new MyClass();
  someObject.SomeMethod(c);

That method call looks like it takes pass-by-value parameter to me. It does, in fact. It's a pass-by-value of a pointer to the object c. Of course, that means the object can be altered by the called method:

  void SomeMethod(MyClass x) //pass-by-value?
  {
    x.ChangeObjectsInternalState(); //oops
  }

Can someone explain to me how this is more clear than waving the red flag of pointers in order to signal that what's happening is really a pass-by-reference?

  void SomeMethod(MyClass * x); //unmistakable

Also, boxing doesn't improve on any of this.

Something that really has me gritting my teeth is the lack of support for variable shadowing. Googling the matter has informed me that shadowing "is confusing". Huh? I suppose the concept of polymorphism is also confusing for a beginner, but they didn't take THAT out of C#, now did they? How hard can it be to understand that any given variable exists in a, likewise given, scope? Why not skip templates as well? Oh but wait, C# didn't even implement their templates variety "generics" until version 2.0! What was up with that?

Speaking of stuff that's missing from C#, why won't optional parameters with default values be implemented until version 4.0? What is it they're so busy working on instead? Yeah I know, LINQ. As if anyone enjoys SQL so much that they actually want to be able to use it on arrays and linked lists. Get a grip.

There are other things besides LINQ that I fail to appreciate. WCF, for example. Tell me, why is it that I need another layer on top of Berkeley sockets? Maybe connect() is too difficult a concept to grasp? But then again, I don't really care about WSDL or SOAP or anything remotely connected (pun scornfully intended) to "web services".

In the end, I just prefer executables that don't come with a lot of extra luggage. My PC is perfectly able to run software without an extra layer on top of the already installed extra layer that is Windows. In fact, I'm one of those who longingly recall the days when each piece of software came on its own boot disk/tape/cartridge. Who in their right mind forces their users to download and install a virtual machine just to run their software? Sure, soon .NET will have insinuated its way into every Windows machine out there, but that won't stop me from despising the idea in the first place. Unfortunately, it's painfully obvious that bloat isn't exactly high on MS's priority list of concerns.

Tuesday, February 3, 2009

Vista Explorer

There is a single reason I will never install Vista at home (or anywhere, if I have any say about it), and that reason is the horribly disfigured excuse for a file manager the people at MS have decided to force feed us. While there are certainly many other valid reasons to hate Vista, it's really Explorer that takes the cake.

Let me start by stating that Norton Commander for DOS was brilliant. Explorer for Windows 3, not so much. Windows 95 and upwards improved a little on the basic concept, but it seems that Explorer peaked in XP, because now it's not only declining in usability as well as stability, but actually free falling at high speed past their earlier versions, thus managing to render Vista completely useless.

Everybody knows about this first gripe, but let's cross it off the list to begin with.


What on earth were they thinking, when they decided that Explorer should repeatedly and stubbornly assume that every folder on every hard drive must surely be filled with media files that I will want to tag or rate in some addlebrained manner. Easily fixed, yes? Just change view once and apply it to every folder. But no, of course that doesn't work, because that would be too easy. Not only that, but somehow the columns apply even in tiled views. Explorer is out to hurt us.

Have you noticed how sometimes, it's impossible to delete an entire directory structure? Explorer returns with an Access Denied, and you think to yourself, maybe one of the files in there is locked by an application. So you drill down and delete each child directory and their individual files manually, working your way up. At the end, you find the joke was on you - everything was perfectly possible to delete, and no files were locked. You deleted the whole thing, and you're left wondering why Explorer was somehow unable to.

There should really be a switch in Windows. Two modes, selectable from somewhere in the Control Panel. What I want is a way to turn off The Stupid™. Oh please please let me select Advanced Mode, a mode where there is no ridiculous hand holding such as this next dialog, which some might claim to be an improvement over the one found in XP. Guess what - I beg to differ.


If anything, this has just made it that much more difficult to copy files, because now I have to read all that text every time before I can figure out which option is which. More annoyingly, why is the "All" choice suddenly minimized into that check box at the bottom of such a humongous dialog? Let me just press A and be done with it!

While we're on the topic of file moving, why is it that not only is Explorer still unable to properly calculate the time remaining for the operation to be completed, but now it takes that much longer to think it over, or "prepare" as it were, before even beginning to do any actual work. It boggles the mind.

This next dialog is Explorer related, although it doesn't actually display in Explorer itself.


Talk about a downward step in GUI design. This dialog pops up when disconnecting a USB memory or similar. In XP it was just an informative, non intrusive bubble above the system tray, but now it's a full blown dialog, forcing us to dismiss it with a pointless click on a useless OK button in a dialog presenting information I only slightly care about. Barf.

Lastly, the real reason Vista's so called Explorer drives me up the walls. It doesn't synchronize the tree view and the file view properly. When selecting a folder in the tree view, one would expect the file view to display that folder's contents. This still works acceptably for mousers, unless you're used to clicking the little plus and minus icons next to the folders like I am, but apparently there are no keyboard cowboys at MS, because it's horribly broken for those of us, real devs that is, who tend to avoid the mouse when doing any real work. Try stepping around the tree view using the cursor keys, and nothing - NOTHING - happens. You have to press Enter for the folders to sync. Guess where that leaves Vista? BALEETED!

Oh, and it seems Explorer isn't fixed in Windows 7 either. For some mysterious reason MS has apparently and purposely chosen to drive their customers away. Suppose I'll have to start using Linux in earnest then.

(Screens with permission from Martin Rubli's Tech Blog.)

Monday, February 2, 2009

Oracle

Ok, where do I begin?

How about at the beginning? The Oracle installer for Windows is not an MSI. Put another way, the installer for Oracle is a Java application. Do I look like I wanted a JRE installed? This makes for a poor user experience indeed, with one of those really ugly GUI:s one has come to expect from Java. In fact, I have yet to see a pretty Java application. I guess nobody ever had the patience to figure out quite how to use the CrapBagLayout, but I'm getting sidetracked from the rant at hand! Hilariously ill-designed installer in any case.

Secondly, a web application for administration of the database(s). Dudes, how about a proper application? Whatever, I'll just let this one slide, because at least it's a slight improvement over the horrendous installation.

Ah, services. Five of them have been registered at a cursory glance, but as of right now, only three of those are running. So WHY is it then, that my computer's boot time has been at least quadrupled? It's noticeably slower on shutdown as well. Brilliant Oracle, thanks.

Also, and this is more important, why is Oracle continuously running short processes, starting and stopping all the time, in the background? That's not all either, have a look at this screenshot (courtesy Process Explorer) of a sample of the Oracle processes running on my system right now.


What's that now? An exe running a shell command running Perl running a shell command running Java? Seriously? What could it possibly be doing? I shudder lest I were to find out.

Oh, and then there's the database itself of course. No one in their right mind would ever EVER want to be a DBA, but as a dev there are unfortunately times when one has to bite the bullet, so let's create some tables. Oh I need a "tablespace" first? Fine, whatever. CREATE already!

Wait what? There is no auto incrementing ID type? No you heard that right, but obviously there is a way around this, because otherwise the thing would be completely useless, so here's what you have to do: create a "sequence". Meaning, you have to do something like this:

CREATE SEQUENCE supplier_seq
     MINVALUE 1
     MAXVALUE 999999999999999999999999999
     START WITH 1
     INCREMENT BY 1
     CACHE 20;

Then, you finally get to do this:

INSERT INTO suppliers
   (supplier_id, supplier_name)
VALUES
   (supplier_seq.nextval, 'Kraft Foods');

That, boys and girls, is LAME.

And it doesn't end there. There seems to be no way of retrieving a set of records in response to a simple SELECT query, but instead we're forced to use, wait for it, a cursor? That feels like turtle graphics to me. Stone age tech, Lord please have mercy.

I'll leave you with one more laugh. Now, we all know that a column that has not yet been assigned a value should be equal to NULL. If, for example, a string is assigned to a column, it's been assigned a value and should no longer be NULL. If, however, that string were to be the empty string '', Oracle inexplicably inserts NULL, despite the assignment. According to ISO SQL, the non-value NULL is different from the value of an empty string. Oracle, however, stubbornly treats empty strings as NULL. Well done. Maybe zero should be NULL too? That would also be an ISO SQL violation, so why not? At least that would explain the length of an empty string, which in Oracle is NULL, not zero... Scrap UNKNOWN altogether, FALSE is enough to represent NULL, isn't it? Completely defying standardization of ternary logic would probably be the pinnacle of Oracle's achievements. Colour me impressed.
Powered By Blogger