Ported to Blogger

There’s a few reasons why, but life’s too short to explain it – I’ve changed to Blogger (and though I still need to port all my old posts) the adress is http://oleksthoughts.blogspot.com/.

Advertisements

A small case on code IDEs

Upper class 3rd-generation programming language frameworks, such as Java and .NET make it impossible to code anything beyond a simple algorithm in a simple text editor. One may even think that these languages were designed to make us use IDEs, but that would probably be an overstatement. So, there exist various IDEs to make our jobs as coders for these frameworks much less of a burden, and oh my do they do a great job! I’m sure, those of you familiar with such coding, won’t object me too much when I say that code-completion in Visual Studio, Eclipse, Netbeans, and so on, probably makes all the difference in the world!

Recently, from a bit of over-coding in Java I’ve noticed a pattern, or rather an itch that I’ve had for while, with all of these big IDEs. The thing is that they do a great job at analyzing the code standing before the cursor, and in other functions and classes, but there seems to be no analysis of the code between the position of the cursor and the end of the current line of code! Let me give you an example:

Assume that I make the novice mistake of using

m.group(1) == "maze";

instead of the built in equals(Object anObject) method in the String class.

So I decide to correct that. Being the cautious user that I rarely am, I decide not to erase “maze”, but rather change the code around it. So I move the cursor to the closing , and put a ):

m.group(1) == "maze");

Then I move the cursor to the opening , delete until, but excluding, the closing ), and putting a . right next to it:

m.group(1)."maze");

This causes my IDE to pop-up a smart auto-completion box with all the available to me fields, properties & methods of the String class. I genuinely type a few of the first letters of the word equals, until it is the only method present, and in desperation hit TAB to autocomplete. The dumb thing is that this results in:

m.group(1).equals(anObject)"zoom");

A totally unusuable peace of code. Thus, I end up doing more work cleaning this up, than I would’ve originally, if I simply decided to delete the intere == “zoom” sequence, and write it all over again. Sadly, sometimes the line to keep is long, and the change in comparison is subtle, which begs for copy/paste, but how irritating is it to have to resort to selecting code when coding!

So, my dear IDE, will you please learn look not only behind, but also ahead when you autocomplete?

P.S. I didn’t include screen-shots to emphasize this goes for any IDE I’ve ever used, but correct me if I’m wrong of course 🙂 Oh and I’m open to suggestions on how to fix this, if such a feature comes built in. I know that Eclipse is open-source so don’t tell me that 😉

With <these things> Do <those actions>

I originally started this blog to discuss code, so I guess it’s time for a comeback of that practice!

While most of us are still struggling with coming to terms with the inherent design failure of the following idea:

Conventional Table of Contents

[Source: Manners for the Millions, 1932]

Namely that the word “Chapter” is repeated 24 times.

I wish to apply the same DRY(Don’t Repeat Yourself) convention to code, or rather extend the one we have today.

Programming abstractions exist to allow us to tackle software problems from different vantage points. Thus a large software system is often more humanly comprehendible if it is written in a higher-, rather than a lower-level language. This is the point of such abstractions, to hide boring(exciting) and complex code behind a compiler, and allow us to code using whichever conventions we find best, given they fit the constraints of our compiler.

Higher-level languages EXIST to overshadow the stupidity of a computer and allow the human being to read, analyze and basically code FASTER. While beauty of code is an art, we are far from having the tools to write intuitive code, in fact, certain (maybe needed) constrains limit us from doing so.

Basically, I’m saying that a media and communications nerd needs to look at the syntax of our code, and tell us computer geeks where we got it wrong. Source-code syntax is after-all meant for human comprehension and construction, not merely computer compilation.

We’ve come a long way from Assembler to Java, but allow me to ask the exact same question as above about this exemplar peace of code:

lblData1 = new JLabel("0");
lblData2 = new JLabel("0");
lblData3 = new JLabel("0");
lblData4 = new JLabel("0");

Again, there’s something inherently wrong with this picture – it’s the fact that we have write  = new JLabel(“0”); four times over and over again. Essentially we are performing the same function, but waste so much time writing that up!

One cannot nest this functionality in a for-loop directly, since the distinct labels will be used for distinct things in the future. One could of course define a custom label that took an enum value of what type of label it was, and then somehow through complex means one COULD put this into a for-loop. While I may be guilty of performing such hacks in my own code, for the sake of DRY or some other convention, it is of course, STUPID.

Ideas of aspect-oriented programming come to mind here, but again, why complicate things any further? All we need is a little syntactic sugar. We already have the idea of With in VB.NET:

Dim myButton = New System.Windows.Forms.Button()
With myButton
   BackColor = Colors.Black
   ForeColor = Colors.Red
   Text = "Go!"
End With

[Some smart-guy should now come along and say that I can push these along in C# as well via the constructor of a WinForms Button, the beauty of the With statement however, is that it can be used in any place with any thing!]

I’m sure other languages have similar implementations, and, while this may be a common feature to use, for some reason this is not a two way street!

Often, especially in cases of user interfaces you will end up doing the same things to different objects, and sometimes it just simply doesn’t make sense to abstract those elements in a way described above. So here is my suggestion for a bit of new syntactic sugar:

with {} do {}

or perhaps

do {} with {}

Where the latter is far easier to pronounce, but the former makes more grammatical sense when reading the code (I’m guessing).  In the do code-block we of course define a set of actions to perform, and in the with code-block the objects to perform those actions on, which all have a common super-type that implements all the methods requested in the do statement.

So let’s take a quick example, how might rewrite the aforementioned bit of Java code?

with { lblData1 , lblData2 , lblData3 , lblData4 }
do { #1= new JLabel("0") }

Or something like that, I’m open to suggestions for a better syntax! Specifically the task becomes more complex with something like:

lblData1 .setText(datastore.data1.toString());
lblData2 .setText(datastore.data2.toString());
lblData3 .setText(datastore.data3.toString());
lblData4 .setText(datastore.data4.toString());

One could imagine the need to introduce numbered or even tagged elements! Here’s a thought:

with { “name”:{ lblData1 , lblData2 , lblData3 , lblData4 },
  “value”:{ datastore.data1, datastore.data2, datastore.data3, datastore.data4 } }
do { #name.setText(datastore.#value.toString()) }

But wait, we are still rather not DRY, we still repeat lblData. and datastore. in our with block. Remember, this is syntactic sugar, so anything is possible! So instead, how about having the do-block as a form of a eval-statement block, and the with a list of arguments(perhaps as strings, but who wants to write the “” all the time?) . The idea is probably best illustrated with an example:

with { 1, 2, 3, 4 }
do { lblData#1.setText(datastore.data#1.toString()) }

Which is where a loop(1 to 4) would fit perfectly! And actually, a do with makes great grammatical sense as well, just look:

do { lblData#1.setText(datastore.data#1.toString()) }
with { 1 to 4 }

BEAUtiful isn’t it?

Of course, one could stack statements into both do and with, thus, this ought to be a many-to-many relation, but maybe that would decrease readability if used extensively, but then again, which language feature does not?

Unfortunately, our compilers can’t understand things like these(yet), and I don’t understand why, as long as the arguments in the with block are immutable of course! Maybe you have a valid reason?

P.S. Here use of static variables is actually practical, where as the constraint to static variables in a Java switch-statement is far less so! Which is why I often end up replacing such none-sense with an if-elseif 🙂

Why Ubuntu still sucks, and I am back to Windows 7

I’ll try to be short and precise here.

So I tried Ubuntu 9.10, right? Well, it’s faster than 9.04, and I like the software installer, although they simply seem to have hacked around the original package installer, it is a breeze installing stuff now, THANK YOU :). However, having a Skype conversation right after the install, I noticed that I could do NOTHING except talk on Skype, because doing ANYTHING, i.e. loading a web-page, seemed to get the conversation to lag, irrefutably. Sure my hardware and network specs were lousy with my 1.6 Intel atom, 2 gigs of RAM and probably a 4 mbit connection, but COME ON, how lousy is that operating system at multi-tasking? Some may argue I might’ve been missing some drivers, but hey a CLEAN Windows 7 install can do better than that, COME ON Ubuntu! You SUCK!

So I took a few days on Windows, gave myself a bit of space, and fired it up again tonight, hoping for a happy ending! I turned on a flash video, as I often do while checking the mail, reading the news etc, and guess what? It LAGGED! I’ve had enough, a system so lousy isn’t worth taking up space on my hard drive!

All of this is making me more and more convinced that Bill Gates was right saying that software you don’t pay for can only really be able to do so much for you. So, now I’m going to give Mac OS X a shot on my netbook, although I do have a feeling that it won’t be too happy about my specs either, since it is oh so well in play with Apple’s hardware.

Oh, what is the world coming to, when Windows 7 is the only decent operating system around? That you can format throw around as you wish, and it still works. Hey, it ACTUALLY lets me to talk on Skype, watch a video and do something PRODUCTIVE while I’m at it! It’s magic!

Killing the netbook

Few of you know that I’ve been practicing my thumb-typing skills on that killer iPhone multitouch screen of mine, and I don’t mean simple SMS and mail, but more specifically notes on the go, for which I’ve primarily been using a netbook up till this point. Few also know that for the past few weeks I’ve been practicing using the Gentoo terminals at DIKU for most of my academical work, and I’ve had relative success doing it, I may say! Even fewer know that I’ve recently taken up a part-time job at Safiri.dk making web-crawlers, which I’m pretty happy doing so far 🙂 Here I’ve managed to pull off a 2,6 GHz quad-core Dell, which I’m even happier about than the coffee!

Most of you know, however, that this spring I had abandoned the notion of a lap-top entirely, and haven’t had a desktop PC since the ancient year of, well, 2004 or something. For all this time, I’ve been netbook ONLY and I’ve been perfectly happy about it(even though some say that they may cause back-problems). Since around this time last year I’ve also started moving my stuff to the cloud, i.e. ALL of my music, pictures and documents, and since about August moving all that data to operating-system independent services such as f.x. Dropbox.

Thus, my life is no longer centered around my computer, but rather around every single computer out there, mua-ha-ha!

Recently I’ve also been reminded of the old-days in middle-school, where from time to time I’d take nothing but a pen with me!

Thus, I decided to trim down that fat and get rid of the netbook as well! Or rather keep it at home as a “desktop”, with occasional dates in public places.

So for the next few weeks I’m going to try out travelling without a nerdy bag, and merely an iPhone in my pocket!

However, the iPhone is a terrible mobile device for needs of my scale, and I predict an Android phone would do much better here! And if it doesn’t, I can always code the software myself, right? Right….

Unfortunately, none of the Danish cell phone companies offer a decent Android phone, if there at all is at a decent Android phone out there! Ironically, I’m looking for something of an iPhone killer, something that doesn’t exist, but a mere BIG WIDE screen and fewer buttons would suffice, is that so hard HTC? I want a device that I can use in land-scape mode, something that seems awfully awkward doing on a Hero or Tatoo.

Another very important thing is of course – running the code! Now that I’m a computer science sophomore, it is an irrefutable part of my everyday life(not that it wasn’t before). I need something in the cloud, that I can store and ruuuun my code!

Well, I guess that’s what Google is missing in their monopoly, so I guess I must build something myself!

P.S. I’m still working on establishing a polyphasic sleep-pattern.

An open letter to Steve Jobs

Sometimes I get frustrated with software and I have to get it out. This time, instead of complaining to a friend completely unrelated to the lousiness of the software, I decided to throw up an official letter right to the head of this rewolt. Whether he answers it or not, doesn’t matter, I’ve gotten my thoughts out, and I believe it’s a reasonable point that I’m making here. I’ve of course written it in my true fashion – 6972 characters(without spaces), which by danish gymnasium standards is about a 5½ page letter, and I still think it’s too short. Anyways, here it is:

Dear Mr. Steve Jobs.
Firstly, I cannot help but admire the way you are changing the world one great product at a time. YOU are the reason we’re all running GUI shells and keep a mouse on the desktop. YOU are the reason we can have a few times the 1000 songs in our pocket. YOU are the reason the whole mobile hardware and software industry is moving towards a far more intuitive interface of touch. YOU are the reason we all can today browse the web and run 3D games on mobile devices that can lie in the palms of our hands. YOU are the reason for many great things in modern-day client computing, and YOU are probably the one that has contributed most to shaping the gestalt of that industry. By YOU, I of course mean the brilliant team of engineers at Apple, a group which sometimes also includes yourself.

You do all this, while maintaining, and expanding, a cool image, as the relaxed, but confident and more competent brother of Microsoft. I’m sure that you will disagree given your areas of interest today, but this is where you started, where you fought your first, great battle. While having lost that desktop battle to Microsoft on you’ve retreated, rearmed and stroke again, this time with greater power and elegance within the depth of our pockets, first with the iPod, and then with the iPhone.

This created a well-desired halo effect to your advantage, that today is slowly eating up Microsoft’s market-share on the desktop of our homes and offices as well as the lap’s of students, businessmen and others. However, it is of course not only the halo effect that has caused this. Your new generations of MacBooks and iMacs are great in exterior hardware design, as well as the interior software design. I understand that the very fact that you do both allows you to do things, unimaginable to Microsoft employees. Furthermore, you’ve kept telling us again and again that your products are better than Microsoft’s for years, and I think that strategy might finally be gaining ground with the prominent failure of Windows Vista. Today, I fall witness to more and more of my fellow human beings falling to your knees and going down the MacBook road, not having returned from it yet.

However, if this was a mere letter of admiration, it would, somewhere along the line, be pointless. In the paradise that you sell to us at prices not understandable to a hardware vendor, there is a flaw. I’m convinced that you are long aware of the fact that the idea that great design and intuitive interface costs money, is an idea harder to sell than the idea that good software does, which is Microsoft’s thing. This is something you’ve been battling with for the past 30 years, and therefore is least of my worries, because you are doing a great job so far.

Where my worries arise is in your lack of respect for great products other than your own, and how that disrespect is most definitely hurting your sales, or at the very least slowing them down én masse. This problem is best ascribed with the fact that I have not met a human being happy with the way iTunes, QuickTime or Safari run on a Windows-powered machine. While for the latter two there are perfectly fine alternatives, the first one we as consumers have to put up with, and it’s a demanding process. A product so essential to your core products, the iPod and the iPhone, and that is supposed to give us, aliens, an idea of how great and flowing Mac OS X is, is among the slowest peaces of software I’ve ever had to deal with, and I’m not at all alone in this view. And I’m even lucky! If I was running a Linux system, things would be a whole lot worse if I were to keep it legal. You only care about creating software for your own hardware, and everyone else is left barely hanging on the wings of your flight, presumably destined for usability heaven.

My daily use of iTunes can be described as follows. I connect my iPhone, which automatically fires up iTunes, sync it and close iTunes to not see it again until the next time I have to charge my device. I keep it open for as short a period as possible, and not a second longer. I guess I would liken it to having to visit a public bathroom in a mid-size Eastern European city – you do the deed and try to forget it ever happened. Ergo, I do not use the iTunes Store, except for iTunes U(a service which I’m greatly thankful for both to you, and the universities that provide the content), and have ABSOLUTELY no intention of running Mac OS X. Even if I do eventually buy a MacBook for it’s hardware and exterior design ingenuity, my choice would be to run Windows or Linux on it.

There is of course no real reason to why I seem like such a Windows fan-boy or Apple hater, and personally, I do not like to be characterized as either. I dual-boot Windows and Ubuntu(with the WMII dekstop manager) on my netbook, use VIM for small code snippets and Visual Studio for large projects, use LaTeX instead of Microsoft Office and Google Docs, use Google as the default search engine for the mere fact of being used to it, use Google Chrome as my default browser for the sheer minimalism and speed it stands for, and in my pocket I’ve got an iPhone 3G. All of that while I try to expand my programming skills in all the programming languages and environments out there. I love all those products, and not that much for what they can, but for my ability to interchange and not blindly follow you, Microsoft or Google.

The products that I use for the diverse tasks I might encounter, I pick depending on the ability of those products to perform those very tasks, both in terms of hardware and software capabilities. It should therefore come across to you very clearly, why, I wish for inter-connectivity between all of that hardware and software, a game which your company is NOT winning.

I cannot possibly know the true reason why Apple software is so terrible on Windows and absent on Linux, but if it is done so on purpose, in order to show how terrible or incompetent those underlying operating systems are in your sheer opinion, then you are far in the wrong here, because for me, and everyone else I’ve asked, you are creating nothing but the idea that Apple software engineers are TERRIBLE, or at the very least, the Windows team. However, if the Windows team is so terrible, then why should any other software team be any better? So you are either mismanaging the Windows team, and therefore all-in-all your software engineers, or on purpose releasing terrible software, in either case, it is the wrong path to follow. Take example of the Microsoft Office team for the Mac, and how greatly their software is working on the Mac. As far as I know it is the most popular software for the every-day office tasks of people uninvolved in academia.

Thus, while you are promising a paradise to the dedicated users of Apple products, you are enslaving all the rest of us, that still have a critical view of the of the efficiency of systems that we use for specific tasks. I will not use a Mac for the mere reason that the software I must have to use a great product of yours is incompetent in Windows and absent on Linux. These systems, each in their own way deserve respect for the mountains of great software already written for them, be that Visual Studio, VIM or any other. It is precisely for that reason that I’m in fact today, considering strongly to switch to an Android mobile device.

And to finish off.

All of this would’ve been a common letter from one engineer to another, merely filling up your inbox. However, allow me to mention something that I witnessed recently. My mother is a database administrator with most years of experience in Oracle database system, and therefore also Linux systems, but recently also Microsoft enterprise systems. She has never used an Apple product of a generation newer than something in the late 90’s.

I, the technology enthusiast of the family, decided to give her the new iPod Nano for her recent birthday, and she loved the device, but like I, hated iTunes before we even got it installed on her Windows machine.

The download is terribly large for a substantially simple peace of of software, and the experience that we had to go through setting up iTunes and the iPod, copying music showing off the iTunes Store was horrible to say the least. It was slow, laggy, unresponsive, and I could come up with many adjectives inappropriate for such a letter to describe it, but the point is, that such an experience is unworthy of your company’s name.

Eksperiment med sovetider

Efter at have sovet gode runde 12 timer både fredag og lørdag nat, kom jeg i tanke at jeg burde måske optimere mine sovetider. Det er et eksperiment jeg delvist startede på allerede på ITC, men som endte i hegnet da der var alt for lidt organisation, og dermed formål eller balance mellem sove- og arbejdstimer.

Søndag morgen faldt jeg over dette søde link, og blev helt vildt inspireret af de store idealer en del af anvendte begrebbet power-napping til at beskrive deres søvn, her er en lille revision:

  • Leonardo Da Vinci som sov 20-30 minutter flere gange i døgnet i stedet for at sove flere timer om natten.
  • Thomas Edison sov ofte i sin stol med et sæt kugler(he-he) i hånden, som ville vække ham hvis han tabte dem på gulvet (under dybere søvn).
  • Yoshiro Nakamatsu tror på at det kan være skadeligt at sove mere end 4 timer i døgnet.

Jeg tænkte mig lidt om og fandt på følgende eksperiment:

Jeg vil prøve at optimere migselv til at sove blot 4 timer i døgnet, og bruge dermed de resterende 20 til diverse arbejdsopgaver som jeg som sædvanligt har en del af.

Hvordan har jeg tænkt mig at opnå det så?

Jeg vil fordele et døgns søvn på 4 power-naps. Det mest optimale ville selvfølgelig være at tage en times power-nap efter hver 5 timer af hårdt arbejde, men eftersom jeg har vænnet mig til det almene menneskelige døgnrytme i løbet af sommerferien, så forventer jeg ikke at kunne nøjes med 2 adskilte timer i løbet af det mørke halvdel af døgnet. Derfor regner jeg med at starte med 7-8 timer istedet for, med ca. følgende plan:

  • 0.00 – 1.00/3.00 => Power-nap: (jeg vil altså starte med 3/4 timer fra kl. 12 til tidig morgen)
  • 1.00 – 5.00 Blog/Nyheder/Diverse personlige opgaver/Kræver ikke så meget hjernekraft
  • 5.00 – 6.00 Løbetur/Træning
  • 6.00 – 7.00 Power-nap
  • 7.00 – 12.00 Første forelæsning/produktiv del af dagen
  • 12.00 – 13.00 Power-nap (dog et mindre en da der ikke rigtig er et sted at gøre det pga. manglende sofaer på DIKU)
  • 13.00 – 18.00 Anden forelæsning/produktiv del af dagen
  • 18.00 – 19.00 Power-nap
  • 19.00 – 00.00 Sidste produktiv del af dagen – lektier, kode, osv.

Det burde dog bemærkes at perioden 01.00-05.00 forventer jeg med tiden at forvandle til endnu en produktiv del af dagen, men det bliver selvfølgelig svært i starten.

For at komme godt i gang efter hvert power-nap vil jeg gøre en del mad klar, så jeg spiser “stor morgenmad” 4 gange i døgnet istedet for de nødvnedige 4 måltider. Jeg dropper dernæst tilfældig kaffe-drikning så jeg kan til en hver tid falde i søvn når tiden kommer til et power-nap, altså jeg vil ikke lade kaffen påvirke min rytme på noget som helst måde, jeg skal nemlig være naturligt frisk, ikke blot have en opfattelse af friskhed.

Jeg prøver at køre det her i den her uge, og det hele bliver selvfølgelig dokumenteret i følgende excel-ark. Dataen er struktureret sådan at under 0 har jeg en karakter mellem 0 og 1 hvor meget af tiden jeg rent faktisk sov. Under 1-5 har jeg karakterer for hvor effektiv jeg var i de timer på en skala fra 0 til 10, hvor 0 betyder at jeg sov og 10 betyder at jeg er nok tilfreds med mit arbejdsindsats.  Jeg forventer at sovetiden bliver forholdsvist lav i starten og der forekommer en del 0’er her og der, men med tiden kan jeg måske blive vandt til døgnrytmen 🙂

Så arken kører i produktivitet/power-nap rytmer istedet for i hele døgn, selvom disse er adskilt med en tyk streg, som burde komme efter hvert 4. 5-sæt, medmindre tiden går i kage.

Lad os se hvad der sker 🙂