I think Java is an excellent all-around-language. It is truly ubiqitous, well specified, highly performant and well accepted by the industry.
But there's a big difference between those credentials, and the credentials of the first language a developer learns. Regardless, James Gosling feels obligated to recommend Java as the first language anyone learns.
Java as a first language? Please! Yes, Java is simpler than C++, C, Lisp, assembler and all the languages that seasoned veterans, such as James Gosling, are familiar with. But the fact that Java shields you from pointers, malloc() and zero-terminated strings does not make it a good first language!
Java is extremely monolithic: in order to understand how to run a simple Hello World program, you'll be exposed to:
- Java packages
- Static vs. instance methods
- Source files vs. compiled classes
- Editing vs. Execution
- Using a compiler or an IDE
- Method return types and method parameter types
- The magic (for newbies) that is "System.out.println()"
... in fact, this list is far from exhaustive. A lot of that has fallen off our collective radar ... we're blind to it from seeing it so much over the last ten years or more.
I'm rarely in a position to teach people how to program, but when I think about it, only two languages make sense to me: Ruby and Inform.
Ruby, because it is interactive yet fully object oriented. You can start with an interactive
puts "Hello World" and quickly work up from there. You get to interact with the Ruby world as objects before you have to define your own objects. There's a nice clean slope from one-off quickies to eventual discipline as a true developer, without any huge leaps in the middle.
Inform, used to create interactive text adventures, is also intriguing. It's specifically designed for non-programmers, and has a laser-focused UI. It is interactive: you type a little bit about your world and hit Run to play it. Again, you experience an object oriented environment in an incredibly intuitive way long before you have to define to yourself, or to the language, what an object is.
Inform is truly some amazing software, given that advanced Inform games will make use of not just object oriented features, but also aspect oriented. Here's a little example I brewed up about a room built on top of a powerful magnet:
"Magnet Room" by Howard Lewis Ship A thing is either magnetic or non-ferrous. Things are normally non-ferrous. The Test Lab is a room. "A great circular space with lit by a vast array of ugly flourescent lights. In the center of the room is a white circular pedestal with a great red switch on top. Your feet echo against the cold steel floor." The red switch is a device in the test lab. It is scenery. The double-sided coin is in the test lab. "Your lucky double sided half dollar rests on the floor." The coin is magnetic. Understand "dollar" as the coin. A rabbits foot is in the test lab. "Your moth-eaten rabbits foot lies nearby." Magnet Active is a scene. Magnet Active begins when the red switch is switched on. When Magnet Active begins: say "A menacing hum begins to surge from beneath the floor." Magnet Active ends when the red switch is switched off. When Magnet Active ends: say "The menacing hum fades off to nothing." Instead of taking a thing that is magnetic during Magnet Active: say "[The noun] is firmly fixed to the floor."
That's not a description of my program; that's the actual program. It's literate; meaning equally readable, more or less, by the compiler and the author. It's still a formal language with all that wonderful lexical and BNF stuff, it's just a bit richer than a typical programming language.
What I like about Inform is that you get a complete little game from this:
Magnet Room An Interactive Fiction by Howard Lewis Ship Release 1 / Serial number 070831 / Inform 7 build 4W37 (I6/v6.31 lib 6/11N) SD Test Lab A great circular space with lit by a vast array of ugly flourescent lights. In the center of the room is a white circular pedestal with a great red switch on top. Your feet echo against the cold steel floor. Your lucky double sided half dollar rests on the floor. Your moth-eaten rabbits foot lies nearby. >take dollar Taken. >drop it Dropped. >turn switch on You switch the red switch on. A menacing hum begins to surge from beneath the floor. >take dollar The double-sided coin is firmly fixed to the floor. >take foot Taken. >turn switch off You switch the red switch off. The menacing hum fades off to nothing. >take dollar Taken. >
The way rules work, especially in the context of scenes, is very much an aspect oriented approach. It is a pattern-based way to apply similar rules to a variety of objects. I've seen this kind of thing with aspect oriented programming in Java, but also with pattern based languages such as Haskell and Erlang.
The point is, using Ruby or Inform, you can learn the practices of a programmer ... dividing a complex problem into small manageable pieces, without being faced with a huge amount of a-priori knowledge and experience in order to get started. Both Ruby and Inform are self-contained environments designed for quick and easy adoption. That's something Java missed the boat on long, long ago!