2015-07-23

Java vs .net/C#

Visual Basic Classic was my primary programming language for many years. A pretty amount of years ago when Microsoft announced the end-of-life of Visual Basic Classic (one of the last statements regarding VB6 see http://msdn.microsoft.com/en-us/vstudio/ms788708.aspx) I took a first look at .net and C# as it seemed to be the most logical next step. I was deeply disappointed by the first versions of .net and C# (it was v1.1 if I remember correctly - it was so full of bugs and terrible slow). The next shock for me was the absence of any migration path for the existing VB classic projects. So switching to .net would have been a total restart. I really wondered about that step of Microsoft because pretty every software vendor knows that a hard cut in backward compatibility of software comes with the danger that customers start taking a broader look around to competitors.

Due to the fact that I already had switched from Windows to Linux at home at that time, I thought by myself, that this would be the opportunity to learn a completely new langauge which is platform agnostic and enables me to write applications that run on both environments. Using a computer I can't program (the Linux box at home) was a horrible situation for me.

About a year later, after several evaluation phases and another attempt with C# to give it a second chance, I decided to go for Java with two core advantages (apart from the language specific reasons):
  1. Develop once and run the binary anywhere - on Windows, Linux or even Mac.
    Yes, I know the critics, that Java or other attempts following the "write once, run anywhere" paradigm do not deliver this promise (see comments on Wikipedia to cross-plattform development for example). Now, years later and after a few applications developed (commandline, server, Swing rich clients) my experience is very good. Of course if your development machine runs Windows and you use Windows API exits or use com4j, J-Interop or JACOB to interact with a Windows-only COM component then you will have problems running it on Linux or Mac. For example: I have developed a Swing application that worked flawlessly on Mac even although I did not have any possibility to test it (I do not have a Mac). I was used to get problems with windows only applications just trying them on a new version of Windows! Of course I also had some compatibility issues e.g. when stripping invalid characters from filenames (different characters are allowed and not allowed on the two systems) or checking if a file is still accessed (there is no windows-like file locking on Linux) - but these are differences in architecture of the operating systems and that can be handled. You can develop for many platforms also using C++ for example but then you need at least one instance of each operating system at your fingertips to do the compiling work.
     
  2. Reduce dependencies
    You already run a risk choosing a programming language. You have a learning curve and invest into know-how, library development and maybe also buy some external components - not to speak about the related tools you learn to master (IDE, packaging, deployment, ...). But this is mainly your own risk. The even bigger risk is for the customer using your application when it is not plattform agnostic. I have seen companies trying to migrate a few servers to Linux and were stuck because of software running on Windows only. You don't know which operating system survive for the longer time. With a platform agnostic solution you just don't care. It's a matter of flexibility.
I can see further advantages, like choice of IDE or missing licensing issues (Visual Studio license usually provided by the employer and when you leave you have to find a new sponsor).

Having now the choice between several IDEs I first used Eclipse (free) and moved to NetBeans later on (also free). The book, which was most helpful for me in learning Java (Javainsel) was and is very good (sorry folks, it's german).

The biggest advantage of Java - being platform independent - also is the biggest obstacle in a (still) Windows centric (business) world: To ensure plattform independency (as I explained above) means, that you should only use and do stuff that is available everywhere - or you need to implement to different solutions. The resulting problem is: How to deal with the Windows specific stuff?

My solution to this problem is in the first place to not use OS specific exists or use calls to Windows-only stuff. For applications that need to integrate with Windows stuff I try to keep the OS dependent part small (e.g. a VBScript) and let it communicate with the Java program via commandline, over the net or by saving files to watched folders. For example: To get the active window title under Windows the Windows API is a possible way to go while on Linux there is a commandline tool called wmctrl which can do the same. So under Windows you would write a small Windows program that uses Windows API to to get the title of the current window. Probably the easiest way is to write an AutoIt script which has a prepared function for this and let it return the Window information in the same way as the wmctrl program does on stdout. Your program then - depending on the OS it is running (you can find that out during runtime) - calls either the one or the other commandline tool grabbing stdout of the called program. So it is recommended, that you try to reduce the OS dependent parts to a minimum and split your application into components - and the smaller OS specific part finally needs to be developed twice or three times.

It was and is one of the core arguments of those developers on Microsoft (.net and C#) that they are bound to Windows anyway because they deal with so many other Windows-components. Yes, this is partly true and I do still a lot of Windows-specific VB scripting. But I always think in components and so there are several opportunities to write parts in a platform agnostic way. Even if it is not yet totally platform independent - later there is less work when an OS migration is needed. If you look at the trends of the last years, you can see one big related trend: decoupling or "loose coupling" of components (from COM and DCOM to SOAP and REST). Lately I read more and more about "Micro services" which - frankly spoken - is just a form of component oriented design. Anyway, that nowadays makes it possible to have processes on different operating systems written in totally different programming languages talking to each other.

In the meantime I also improved my C# knowledge a little and developed a few smaller things in C# where it did not really made sense to do it in Java. There are a few people dealing with both languages. Interestingly those people criticizing Java most are usually those who don't know Java and have never ever looked into something else but the Windows world.

Although Microsoft had the chance to create a "better" Java by learning from it, they did many things worse in my opinion. Many say that the .net libraries are better organized than the Java ones. I do not know the .net libraries very well yet, but I tend to agree. On the other hand there are a many characteristics where I prefer the Java way, for example:
  • Properties (C#) vs Getter and Setter methods (Java)
  • Delegates (C#) vs Passing interface implementations (Java)
  • sealed methods+readonly variables (C#) vs final - one word that says it all in both cases (Java)
  • Missing checked exceptions in C# - a Microsoft guy once told me that checked exceptions produce just bloated code and therefore something like this does not exist in .net. Well folks, it is about error handling - something, Microsoft may not care a lot about ;-).
  • Ă„hem, want to talk about GUI development? - Windows forms or WPF? - Both seem to be unfinished I did not figure out yet, which of those will remain unsupported sooner. At least silverlight is dead... - I went for Windows forms so far and even for a quite simple GUI I was stuck with the shitty TreeView and a double-click-issue - bug report from 2009 and not fixed yet...
In general Java is easier and simpler (less language constructs - not the libraries) in my opinion, but sometimes there might be more code for the same thing, but who cares? - It is important at the end, that you don't refuse touching again your code from a year ago (not to speak about the code of others ;-) ).

I will continue to do a increase my C# knowhow, but I'll be always more confident when I can open up NetBeans again and working on a component in Java.

See also: The programming language, Choosing a programming language, Popular Java myths.

2014-09-25

IT ball and chain

After a very intensive year (which means a lot of work and a minor amount of sleep) at least I have been on vacation a few weeks this summer (in chunks). For two weeks I totally abstained to use a computer. I only used the smart phone from time to time for a phone call or checking mail / searching something in the internet (in total not more than approximately 2 hours) or reading the news. That has (again) increased my awareness that a computer does not always increase the quality of your life. Coming home I experienced some of the biggest annoyances of IT:
  • Maintenance work
    • System and application updates - they take a lot of time and attention (e.g. permission check on Android during application updates).
    • Declutter and free space on drives (to download pictures from the camera to the computer in my case) or on Dropbox to get the pictures uploaded that my wife took with the smart phone.
    • Delete spam or less interesting emails.
    • Make secondary manual backups.
    • Fix hardware defects (change old-age harddisks etc).
       
  • Trouble-Shooting
    Be it end-user support or administrative support. Errors may happen during updates, some passwords might be expired while you have been away for too long without logging in, some features (after an update) suddenly not working any more as you expected or - after not using for a while - you might not remember well how to accomplish a task seldom needed.
     
  • React to changes in IT world
    In my case during the updates on my mobile devices I have seen that many applications do want new permissions regarding device ids and call information. So the first action was abort a lot of updates and search the internet for possible reasons and for options to restrict this alarming trend against privacy. Lately there were plenty of news causing administrators to take action, like the SSL heartbleed bug or other alarming information, e.g. leaked by whistle blowers (like Edward Snowden). Not to speak of more long-term changes like technology shifts (those do not happen just during a single vacation, but while reviewing the past year you might notice a trend that needs to be evaluated).
The longest-running tasks during my vacation were washing dishes (no dishwasher in the rented appartment), sweeping and disemboweling fish (take out guts) as well as brushing away the fish scales (adhesive bonded onto the wall), but none of them took longer than 45 minutes. Last weekend I tydied up the storage room in about an hour. In my IT work I can be very happy if something can be done under an hour.

And now take the annoyances mentioned above and multiply with the amount of devices you have... - I fear the time, when even my washing maschine needs to download updates and doing reboots before it can start washing - super annoying...

As a child, one of the main reasons why I got fascinated by the computers, was the fact, that it can help you making a lot of tasks faster and more efficient. Nowadays you have to pay attention that the total cost of ownership with maintenance work together with the velocity of change does not outweigh the benefit of the automation.

Related post: The truth about software.

2014-06-20

Dropbox Icon missing in Ubuntu

On Ubuntu 12.04 as well as 14.04 with recent versions of compiz, dropbox or whatever other module the Dropbox icon may be missing in the upper right corner (system tray) after login.

This is in general just an annoyance because Dropbox is still running in background (you can check this by opening your Dropbox folder and you will see the checkmark icons and the dropbox context menu entry when right-clicking a file - which are only visible when Dropbox is running).

However, I found several forum and blog posts mentioning that
sudo apt-get install libappindicator1
solves the issue or
sudo apt-get install nautilus-dropbox
solves it. I already had libappindicator1 However in reality the latter is obsolete as the nautilus integration is no separate thing any more. So both did not solve the issue for me.

I solved it permanently only by writing a short shell script (which i put into /opt directory):
 #!/bin/bash  
 sleep 60s  
 dropbox stop && dropbox start -i &  
(mark as executable) and then click on the Ubuntu button on the left upper corner, type "startup" and there add an entry to call that start that shell script /opt/dropboxrestart.sh.

2014-01-07

Reinventing the wheel

There are three kind of developers when it comes to library use:
  1. Those who extensively use existing stuff to avoid reinventing the wheel,
  2. those who do code the stuff on their own and try to reduce as many of the  external dependencies as possible and
  3. those who do the easy stuff on their own and only for big topics (like PDF or MS Office file handling etc) they use existing libraries.
If you want to avoid reinventing the wheel completely then you will end up with a lot of library dependencies which often even do not fit well together (just think of the many different java logger frameworks available).

Neither the first nor the second extreme will bring the optimum result - at least not when you think long-term.

For example I was using ini4j to load inifiles (because I was under pressure) but later I noticed that the sections are internally stored in a way that you can not rely on getting them loaded back in the proper order. For the project where I was using it, order of the sections previously wasn't really relevant (that's why I didn't either recognize that ini4j was mixing them up occassionally), but then things changed and now order of some sections is relevant. So I had to change the underlying library. I took the chance to implement the inifile handling on my own. Why? Would I have been the developer of that library I could have changed the internal implementation who the sections are loaded in an instant. Without being really involved into the project I would have needed to read into the foreign source code (which unfortunately is always more difficult than reading your own code - if you did it well) and doing code changes that hopefully will not be rejected by the project owner (loosing it again with the next patch). I would have done this probably, if it wasn't urgent and if inifile handling wouldn't be such a core thing for me (I deal a lot with inifile style files).

And here it comes to a related topic:
You can get your code being written almost everywhere around the world, but the important questions are: If you need a fix or an enhancement,
  • do you have a chance for direct communication with the developers (or how many levels of communication are in between)?
  • how fast can you get what you need?
Of course, when using a big library that is widely used you may get a very good and stable code base, but bigger changes will not be easy to get quickly.

I have seen it plenty of times, that having the full source code available at hand is the only guarantee to get fixes or enhancements in time when you need them!

And there is another related topic: Progress
Sometimes it makes pretty good sense to reinvent the wheel - and indeed if you look at the wheel itself, it has been reinvented (or at least adapted) many times and looks very different depending on the core usage and environment. For IT or source code this means that for instance the same stuff must be programmed again and again when you change programming language or when newer and better technologies can only bring benefit when you partly rewrite the application.

I write this because often the thought of reinventing the wheel is labeled so negatively. Rewriting code parts or writing them yourself instead of using an external foreign library can make really good sense!

Related post: Bronze age of IT.

2013-10-15

IT Dependencies

Lately at a customer I got introduced to an application written by an employee which should be replaced. There were some special features that have been implemented for the exact needs of the company. After a while I began to wonder why they want to replace it. I thought by myself: "What could be better than an application written exactly for their needs by a person who is actually in that company for a long time now?"

Finally at the end of the meeting after the others left, I asked the project manager at the company what the real reason is that they want to replace that program. The answer was: They want to get rid of dependency of that piece of individual software development and dependency of a particular person. They want to use a standard software.

While this sounds quite reasonable, I want to clear-up potential misunderstandings:
  1. Even betting on the biggest companies and their products does not save you from the risk of software being discontinued or services shutting down.
    For example here is a list of software products discontinued by Microsoft. And this does not seem to be a complete list because from the first look I already miss the Visual Basic Classic which is also dead (and I have A LOT of experience with that which will be dead know-how in a few years).
     
  2. Even the largest company-group sends you individuals that do the work and guess what: In most bigger IT projects (even when using standard-software) you usually end up with an individually customized piece of software and often with several project specific extensions. And who knows best your system? - The one who has done it! Change the person and the person needs time to analyse and get into it.
     
  3. As time goes by most companies, when they start to buy external know-how or services, they begin to loose control. To reduce dependency you would need the source code, the know-how and the access. One effect of extreme outsourcing often comes with loosing your privacy and security.
So by switching to a standard product it is not very likely that you are reducing dependency. Often you save internal IT manpower for other things but you trade it for dependency or for privacy. Paying a developer for permanently being ready for implementing your business needs may not be the cheapest solution but you get flexibility and often reduce communication flows.

For many very tiny companies it might be perfectly ok, accepting the dependency from external services when they don't have to bother about their server-backup etc then. And so privacy is also traded (e.g. free web service for providing your personal data).

It is a matter of your values, your priorities, your time and budget etc. if you better have a server in-house or use some online-service in the web.

So what can you do?
  • Be aware of your values
  • Be aware of your business focus
  • Be aware of your (human) resources
  • Remove resolvable dependencies
    which means: Prefer forward-looking software products and plattform-agnostic open-source software over more limited alternatives.
  • Distribute work and risk (e.g. have an external partner helping you but also have an internal administrator/developer who can do the work).
Related posts:  Priceless Developers, Surveillance, Privacy (NSA, PRISM, ...) and encryption, The truth about software.

2013-10-12

LibreOffice v4.1.* and Ubuntu 12.04 Unity-Integration

As I use Ubuntu on my productive work+private machine, I prefer to use stable versions - so I switched to use LTS versions only. However, for LibreOffice I have enabled the LibreOffice repository using

# Adding repository for getting most current LibreOffice # (taken from https://wiki.ubuntu.com/LibreOffice) add-apt-repository -y ppa:libreoffice/ppa
 That slurps the current LibreOffice release into my Ubuntu 12.04 LTS stream of updates (the poor Windows users don't have an idea of such a comfort).

The reason for this was mainly to get the latest additions for Microsoft Office formats support (Microsoft is still good in their attempt to squeeze people into staying with MS Office).

Unfortunately with LibreOffice v4.1.* a unity-related problem (users of other flavors of Ubuntu can stop reading here) was introduced that has not been addressed yet by the Ubuntu folks - at least not for 12.04 LTS:

When opening several documents in Writer, Calc etc the windows are not grouped to a single Unity icon.

As you might know from earlier posts I like the Unity desktop very much (and it also has become very stable) and so I am very glad for the workaround that has been posted to the according bug report at https://bugs.launchpad.net/bamf/+bug/1026426 (comment #166 by Marco Trevisan) which is just one command in the terminal window:
sudo sed '/StartupWMClas
s=.*/d' -i /usr/share/applications/libreoffice-*.desktop
(all one line).

Problem solved, thank you very much, Marco!

Related posts: Open Office and Libre Office starts slow, Normal.dot in OpenOffice or LibreOffice, Default Paper Size in Open Office.

2013-10-04

Maintaining multiple Calendars

While I have to put the Outlook Calendar entries into the office calendar I do have my own private calender on Google that I share with my wife and vice versa. I want my wife to know when I am at customers or in foreign countries. That enables her to make appointments for us without the need to call me several times a day.

There are two problems:
  1. And this is a general problem of the crappy Outlook*): With version 2007 or 2010 they changed the style how invitations are sent and this means: When on an Android phone for example or you do not allow HTML display in your mails due to security reasons you don't see the Outlook appointment information on your phone or mail-client. Both is given in my case.
     
  2. I need to create each work-related calendar entry twice - once in the Outlook Office 2010 calendar and one on my Google calendar.

Solution for problem 1: Install Invitation Processor Pro on your Android device as unfortunately by default Microsoft Outlook inviations cannot be processed by Android (while gmail invitations and those sent with Thunderbird+Lightning which are also distributed as .ics file are displayed fine so this is not a general problem with event invitation mails). Say thanks to Microsoft.

Solution for problem 2: I thought of several possible solutions, but a) I am not using the Desktop Outlook at all (so all Outlook plugins for syncing calendars are irrelevant for me) and b) I do not want extra hosting for calendar syncing. You might be in a similar annoying situation so here is another still a little annoying, but acceptable way:
  1. Create two rules via Outlook web access 2010:
    a) Forward all mails of type meeting request to your private gmail address:
    Rule Name: Forward event invitation
    After the message arrives and...
    the message is Meeting Request.
    And my name is in the To or Cc box
    Do the following...
    forward the message to 'you@gmail.com'
    and
    b) Delete your own meeting responses from yourself (confirming events on GMail side):
    Rule Name: Meeting response from Google Calendar
    After the message arrives and...
    the message was received from 'calendar-notification@google.com'
    And the message is Meeting Response.
    And the message includes specific words in the subject '(YourFirstName YourLastName)'
    Do the following...
    delete the message
    And stop processing more rules on this message
  2. Use Outlook (web-access) 2010 to confirm appointment requests (at work for me the 90% case). When creating appointments on your own then invite yourself (your private or your work email address).
And the good thing when solving problem 2 this way: You also solve problem 1 as GMail is able to display the invitation details (date and time) even for the .ics files originating from Outlook. I installed the Invitation Processor Pro anyway to see the event details also when currently in K-9 Mail on Android.

There are four different use cases:
  1. Co-Worker sends me a meeting request:
    => I confirm in the same way using Outlook web access 2010 and GMail. This way I have to confirm two times, but don't have to recreate the appointment twice manually (and using wrong dates or times) so I can be sure they match. And just to see it in GMail I don't even have to respond to the meeting request because on arrival in GMail I can see it in Google Calendar.
     
  2. I have to create a private appointment:
    => I simply create this event in my private Google Calendar.
     
  3. I have to create a work appointment that is completely irrelevant to my private time planning (maybe just a time blocker or reminder):
    => Just create this event in my office Calendar (using Outlook Web access).
     
  4. I have to create a work related appointment:
    => Create the appointment in my private calendar and invite myself (send invitation to my work/office email address) and
    => confirm the incoming message with the Outlook web access.
    OR
    => Create the calendar entry in Outlook web access calendar and invite myself (send invitation to private email-address) and
    => Confirm invitation in GMail.
The remaining little annoyance with this solution is: As I usually use Thunderbird to access my Microsoft Exchange Mail account from the office, I need to switch to Outlook web access for confirming meeting requests.

Related posts: Outlook Calendar Meetings, Outlook 2010 Meeting Requests, Thunderbird and the Outlook global address book.