This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
I've heard about java for a long time, but have yet to run across a java programmer in my almost 30-years of programming experience. Which seems odd. But so be it. So I finally have a need to learn java for a new project I have, and let me tell you, figuring out what one needs, to learn and develop a java app is no easy matter. The Sun web site is absolutely mind numbing. You can't find stuff, you can't figure out what of the umpteen downloads possible you really need. Nothing is intuitive or explained. And try finding documentation. And if you do, try to download it. And worse yet, try to find something in it. For example, You would think a simple built-in function like Math.random() would be fairly easy to find. Why, it must be in the math class, how hard could it be? Go look in the java.math class, 3-methods an no random. What gives. Where else would you put math functions? No other class indicates it would have math functions in it, at least based on the class name. So I start looking in individual classes. After some time I get to the java.util class. Look! a random() function. But I can see that it's a different random function. But at the bottom of the description is a little note with a link that says "math.random() may be simpler to use." So I click on the link and end up in what appears to be the java.lang.Object.math class. And lo-and-behold, there is the random function I've wasted half a day trying to find. I don't know why I didn't think to look there? Seems intuitive to me. NOT! And when I go look at the documentation index, in the list of what is called "All Classes", there is no java.lang.Object.math class listed, nor is there a java.lang.Object class listed. I wonder what "All Classes" really means? So I go back (thank god for the back button, or I could never find it again) to the java.lang.Object.Math class and click on the link to java.lang.Object. One would think that once in this class you would see "Math" listed there. And you would be wrong. So unless one already knows about the java.lang.Object.Math class, how does one find this obscure class? As far as I can tell, you have to stumble around until you stumble across it by accident. But if you don't know what is in it how will you know when you've found it. Ah!, the conundrum. And this is but one small example. I now see why Sun is failing and why I don't run across java programmers. Java RIP.
In my opinion the Java API is fairly easy to navigate and, for the most part, very clearly documented. If you follow the previous link the first thing you should see is a list of packages. The short description should provide some insight as to the kind of classes you will find in a particular package:
java.util Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
One click away the Random class is listed. I wonder what that does? Let's take a look. Why, its purpose is to is to generate a stream of pseudorandom numbers. The Javadoc also contains a reference to the java.lang.Math class (one of the fundamental classes) and its random() method. But wait, there's more! A direct known subclass is also specified here: SecureRandom - the go to class for all your security critical randomness needs.
That's wasn't too difficult, was it? Still it will take anyone unfamiliar with Java time to get familiar with its extensive core API. There's just no way around that. However, in most cases a Google search will provide the necessary clues to get you where you need to go fairly quickly.
With all this in mind, and that fact that you're a programmer with 30 years of experience, I find it hard to believe you stumbled around for half a day looking for this basic feature. [ December 05, 2008: Message edited by: Jelle Klap ]
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Joined: Mar 22, 2005
So how would you have found a random number generator for C (or whatever language you usually work with) ?
(As an aside, the 30 years of experience aren't entirely relevant - Java wasn't released until 1996.)
If you've never had anything to do with Java then I can imagine that it can be difficult and frustrating to get started with it. It looks like you've found out that you need the JDK and you've probably written yout first Java programs already. Here are some links to get you started.
Have a look around in a bookstore. Java is a very popular programming language which is very widely used (despite that you've never met a Java programmer), so there are thousands of books on Java. One popular book is Head First Java, for example. We have a list of book reviews here on JavaRanch.