In my new job working in mobile development, I am getting know Java more in depth, because native applications for both BlackBerry and Android are typically built with Java. I was excited about Mono for Android as an option for me, but I think it’s a little too new to gather much acceptance for the kinds of clients I am currently dealing with, as well as my colleagues who are mostly Java developers. And now the uncertainty around the Mono project makes this untenable for the near future.
As I continue to dive deeper, I am genuinely surprised at how much Java and C# overlap. There are of course differences, but these are much fewer than the similarities.
Of course this point has nothing to do with the language differences, but it affects how you get there. Getting to know Eclipse has been interesting. Since I was a recent convert to ReSharper with Visual Studio, initially Eclipse seemed like a real step backward. The autocomplete is not as good as VS Intellisense, and the syntax highlighting isn’t as good. I learned about FindBugs, a plug-in for Eclipse that performs code quality inspections similar to ReSharper. It’s not as robust, but for the time being it’s workable. I still haven’t found the productivity tools ReSharper provides. I want to get to know IntelliJ IDEA (assuming it’s as good as ReSharper because it’s also from JetBrains), but I have two problems so far:
- BlackBerry development can only be done with Eclipse
- All the Java devs around me are using Eclipse
I’m going to try IntelliJ IDEA for doing some Android work on the side. If it’s much better I’ll work on swaying my colleagues.
It’s also interesting that most folks have multiple copies of Eclipse installed, each one configured with the plugins dedicated to a certain kind of development, i.e. one for BlackBerry, one for Android, one for back-end web services, etc. Apparently Eclipse doesn’t use the registry, so multiple copies is not an issue. Installing the plugins is a pain. Sometimes you get them from the IDE using a built in feature, other times you download and install them separately. I guess VS is similar, you just need to do it much less often.
Lack of Properties
Right off the bat this was difficult for me. You can make members public, but as in .Net this is frowned upon. So you end up creating getPropertyName() and setPropertyName(value) functions explicitly, and they show up as methods not as members. I guess I am spoiled by the auto-implemented properties in .Net. I needed to change the way I looked at accessing data in a class.
While string objects themselves are very similar (immutable, StringBuilder, etc), formatting them is different. There is a static String.format() function, but it requires a little more stringent parameters than the .Net version, akin to the string formatting you do in .Net during declarative databinding in ASPX pages. Java also has dedicated classes for formatting numbers and dates
While events are built into the Java language, it’s in a much more rudimentary way in comparison to .Net. You have to do all the plumbing yourself. Frameworks like AWT and Swing help with this, but as a mobile developer these aren’t doing me any good. It seems to me there isn’t as much focus on this as there is in .Net.
The kind of functionality you get from Linq is not built into Java directly. You need a 3rd party library to do something similar, like lambdaj. In fact, using 3rd party libraries is more of a pattern in Java than in .Net. There are tons of open source libraries to extend the language, which is not as common in .Net.
Open source continues to be a problem for me. I keep doing work for large corporations, and mostly they will not accept open source in software solutions. Essentially they don’t trust the source from a legal perspective, so unless some third party comes along and indemnifies the source for them (like RedHat or Novell has done for Linux) large corporations just don’t want to use it. Now that I have seen how easily hackers can affect open source, I can see where their paranoia is coming from. Ultimately, they are actively choosing sub-optimal solutions to avoid any risk, instead of managing the risk. I’m sure there is a scaling factor here for the largest companies. This is another hidden contributor to the costs and failures of software development.
Null Pointer Exception
Null Pointer Exception == Object Reference not set to an instance of an object. Which one is a clearer message describing the actual problem? Neither one.
The naming conventions in Java differ somewhat from what is accepted in .Net. Methods start with lowercase letters. I’ve seen a bunch recent code written by other Java developers and am deeply disturbed that Hungarian notation is alive and well. It’s down but not out in the .Net world, I hope I don’t find it thriving in Java….
I’m finding with all the different namespaces and open source projects available, that lots of open source developers adopt the “not invented here” attitude and create their own version of a class, ranging from slightly to wildly different. Classes for handling JSON are a great example of this. I have found at least half a dozen implementations of the JSONArray class. Uncle Google is no help for this newcomer. Which one should I be using? Will I need to build a façade into my designs so I can use more than one? Do I now need to build time into my estimation to research all the possible implementations of a concept. How do Java teams manage that?
As I continue delving into the differences I’ll likely have more posts.