Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Java

Journal dthable's Journal: Java Is Dead. Long Live The Queen. 7

...or something like that. I read the following front page article on Java being a dead language. While I won't go as far to kill anything this afternoon, I do have to agree with Mr. Eckel that Java is unpleasant to C#. After working for 5 years in a Java environment, I actually found C# fun to program and always wondered why Java didn't have the same features.

I found myself envying three C#isms - type safe generic support, the "all data types are objects" mentality and C++ style code orginization.

The first to features do away with a lot of casting syntax. The damn java.util classes always manipulated elements as Object and for good reason. A list is generic. Give the list something to hold on to and it will. Yet, the lack of generics made this more error prone and just messy code. Cast an element coming out of a list and you get an exception. Type the expression into an IDE and it will tell you that you're getting an object, not a Widget.

I know Java added generics with Java 5, but it looked like it was more of a preprocessor than a fundamental design decision built into the type system. This creates a new issue where I have a SuperWidget and only want to create a list that can hold SuperItems. If I want to use generics I end up opening the list up for everything. If I pass things around as a SuperItem, I still have casting hell. This might seem too picky but think about how many times you have some generic process that should only be applied to a certain class of items. C# ends up implementing generics and keeps them type safe.

I also don't know how many times I've butted up against code that uses the primitive int type versus the class Integer type. Did you ever try to work with a Map using a primitive data type? I just hate having to type Integer.getInt(foo) into my code all the time.

Ok, the last one is a personal preference. I like to combine lots of stuff into one file. It just makes sense that I add a few loosely related classes into a single source file. Not close enough for an inner class but not separate enough for a new source file.

Just remember, opinions on programming languages are like a$$holes. Every one has one and they all stink.

This discussion has been archived. No new comments can be posted.

Java Is Dead. Long Live The Queen.

Comments Filter:
  • I'll agree that C# is nice but:

    1. If you are coding in C# professionally you are coding for Microsoft's platforms.
    2. Not as many spiffy server-side frameworks exist for C#, what exists is tied again to Microsoft platforms.

    OK so the browser doesn't really give a flying rip what OS the server is running, but there are perfectly valid reasons someone might not want to run their webserver or application server on Windows using Microsoft server products.
  • You can put wildcards on generics and even say the wildcard must be a subclass (or super class) of another class. I don't have time to work up examples on a Friday afternoon, but this is good reading:

    http://java.sun.com/j2se/1.5/pdf/generics-tutorial .pdf [sun.com]

    Also, autoboxing in 1.5 will take care of your need to never type Integer.getInt(foo) into your code again. If Java finds that it needs to do that for you, it will.
    • by dthable ( 163749 )
      I think I left the Java game too early. I might pick it up again, but right now my company wants me to develop stuff in PHP.
  • With the new generics (and new foreach loop associated with them), along with auto-boxing (Integer works just like int now), and cool new features, like annotations, I'm sure you'd be happy back in the java environment...
    • by dthable ( 163749 )
      I feel dirty saying this, but I'm actually starting to take a liking to python. Yes, it has that crazy tab blocking and you need to pass self around like a whore, but I like the lack of decoration syntax (; and { }). As I start to get older, I hate looking and typing those funny things.

      Just got a PHP assignment so it will be another year or so until I get to touch java again.
  • I prefer 1 class per file.

    Why?

    So I know where my class is at!

    I have seen .cs files with nearly a dozen classes in them. I shouldn't have to do a full textual search of a directory to find a class definition! (Ok so VS helps solve this by letting me rightclick on a class and select "goto definition" but still...)
    • by dthable ( 163749 )
      12 might be a bit excessive but there are times when you need a helper class that shouldn't be used by anyone else or even an interface that should get a base implementation. That's where I see the use of this feature.

An Ada exception is when a routine gets in trouble and says 'Beam me up, Scotty'.

Working...