views:

345

answers:

12

I'm a beginning programmer and the I&CS program at our school starts us off learning Java. It seems to me like C and its spin-offs are way more prevalent in the real world. Is this true? How do expert programmers use Java for their work?

To be more precise, I want to know in what situations would a programmer prefer to use Java over other languages. OpenOffice is definitely a prominent example of Java, but couldn't it have been coded using anything else?

+2  A: 

There are tons of JAVA applications out there. Perhaps not as many on the standard Windows desktop, but on mainframes, etc, Java is very heavily used. Also, a lot of sites still use jsp, etc. Java is a very relevant language, and will likely remain so. (Even though, personally, I would rather use .NET.)

In our company, we use Confluence as a content management system for documentation, MAXIMO as an asset tracking software.. both of which run on Java. Most of the internal web apps that we have that interact directly with the mainframe run on JSP. For desktops, probably the most notable Java app is Open Office...

Also, Java is a relatively nice language for learning Object-Oriented programming. A lot of what you learn in Java can be easily carried over into other OO languages (such as C#, VB.Net, C++, etc). It's a heck of a lot easier to learn than C++, so it makes for a good "learning" language. (I still think C# is easier, but that's probably a personal bias.)

David Stratton
A: 

How? I open my editor, swear at Java for being so verbose and low-level (but not as low-level as C!), and then start typing.

Except for slight variations in step 2, it's pretty much the same for all languages I use for work.

Ken
except for an entirely different runtime...
darren
+2  A: 

Java is perhaps second place in use to the more closely C-based languages, but it's a close enough second that I wouldn't worry too much about its applicability. More generally, I wouldn't worry too much about the applicability of the first language you learn - there are so many languages out there, each with their particular domain. Focus on learning concepts, and you won't have a hard time switching to whatever language is appropriate for the current task.

Regarding Java"s problem domain:
Java is often used for cross-platform applications with a graphical user interface, for cell phone applications, and on the server for generating web pages. The code that has already been written in Java in these areas is what makes it attractive for future projects in these areas - but no problem domain belongs explicitly to one language.

Getting a little technical:
Java is a statically typed and garbage collected language. This means that it is slightly more difficult to accidentally do unsafe things, and Integrated Development Environments (like Eclipse) can provide more help to the programmer, so Java is perhaps better suited to larger projects or projects that are likely to have programmers unfamiliar with the code base.

As a garbage collected language, Java is perhaps less well suited for programs with severe resource constraints or speed requirements (where C is generally preferred). As a statically typed language, it is less suited for rapid application development (where dynamically typed languages like Python, Ruby, and PHP are generally preferred).

More broadly, Java is also an imperative language, so its style is more familiar to most programmers, and it is better for telling the computer exactly how to do something, as opposed to, for example, functional languages (like Haskell), which may be better for describing what needs to be done, so that the computer can divide the work up as it needs to (but are not as good at dealing with things that change, like what's on the screen).

T.R.
+ 1 for "I wouldn't worry too much about the applicability of the first language you learn "
David Stratton
+3  A: 

Java is quite prevalent. It's really hard to compare its prevalence with "C and its spin-offs" because no one keeps statistics on how many "real world" problems are solved with each one. Java, however, is quite popular. Some Java applications that you can install and play with on your own desktop machine:

Java also runs on many cell phones and web servers.

As far as your second question -- expert programmers tend to use Java to get things done. (Just like C, C++, perl, Lua, python, Javascript, ruby, Clojure, Pascal, SQL, COBOL, and any other programming language.) As a beginning programmer, don't worry about the real-world applicability of Java. If your school teaches it, use it to learn the computer science concepts that will serve you in whatever language you end up using to solve prevalent real world programs.

RarrRarrRarr
Yeah some of my programmer friends say don't worry about the language just focus on the concept;eventually writing in different languages will just be a matter of learning the syntax. Thanks!
Leebuntu
@Leebuntu: Learning a language is NOT just matter of learning the syntax. Try learning something like Haskell or Lisp and you will realize how wrong your assumption is.
missingfaktor
@Rahul +1 So true, like someone said it's not about the syntax, it's about the philosophy of the language.
Helper Method
@Rahul, in that case the first language should be LISP :) All downhill from there.
Thorbjørn Ravn Andersen
+8  A: 

Unless you're writing games, embedded device software, maintaining legacy software, or writing high performance parallel computation software (eg CUDA), you'll get much more mileage out of Java these days than C/C++. C# is actually more Java-derived than C-derived despite the name, in case you're thinking of that (many would argue that it's better than Java, myself included).

That Java is slower than C/C++ is slowly but steadily becoming a myth (see for instance this benchmark). It's certainly much more programmer-friendly, and there are rapidly emerging more and more enterprise-grade solutions that specifically deal with Java, its development, and its deployment in the real world.

Particularly in server applications, you'll find that Java is gaining enormous ground. In most fields at this point, it's debatable whether it really is second-place to C/C++ in usage.

Clint Tseng
Thanks so much for your through answer! It definitely gave me some perspective on what I'm learning. So often I feel like I'm driving in fog...I think I'll try to get familiar with C.
Leebuntu
I should clarify that C is still a good thing to know. If it's not part of your school's curriculum, I would definitely take some time to learn at least the basics of it. Knowing where we came from and knowing what the low level bits are gives enormous perspective on how to do things right.But, Java on its own is a powerful and oft-used tool.
Clint Tseng
Java most definitely is not "gaining enormous ground" anywhere anymore; that statement was true 10 years ago. Nowadays, Java is *losing* ground to languages like Python and Ruby.
Michael Borgwardt
@Michael Borgwardt - Java has become one of a handful of dominant programming languages, Java has the ground.
igouy
igouy
@igouy: yes, it has a lot of ground - but it's currently losing it slowly. It recenly fell to number 2 in market share (behind C) in the TIOBE survey.
Michael Borgwardt
@Michael Borgwardt: TIOBE is not a survey of "market share" - it's a survey of chatter.
igouy
I'm a Rubyist myself, so I'd love to say that Ruby is winning against Java, but while Python/Ruby may be growing very quickly, they can't hold a candle to Java's marketshare. As far as the benchmark I linked; yes, it is slower. I never said it was as fast, I said it was getting there.
Clint Tseng
A: 

You mean prominent applications that you face as a general member of the public? There aren't many, I can only think of Frostwire for one. Doesn't mean its presence is not there, before I started my programming career I have never heard of Oracle, even though right now its as big as the Coca Cola company.

mglmnc
"There aren't many." There are thousands. Consider websites. Consider amazon.com for a start.
EJP
+7  A: 

Your perception of the "real world" is maybe not accurate because many (most?) big Java applications are not "visible". Sure, there are desktop Java applications but, in my opinion, it's server-side Java that made it so popular, especially in heterogeneous corporate environments (portability brings you vendor independence) and Java is used in almost all industries. And because you asked for an example, mine would be GMail. Is that big enough?

Pascal Thivent
"Python at Google"?? we're talking about java here.
Zaki
Got it, thanks.
Zaki
+2  A: 

Reasons for choosing Java specifically:

  • Your application must run on multiple operating systems - Java makes this easier than most other languages
  • You're planning to use one of the huge number of libraries that are available in Java
  • You want to be able to find developers for your project easily

Also, there are two misconceptions in your question:

  • Java is a spin-off of C. Its syntax and concepts are closer to C and C++ than most other modern languages.
  • OpenOffice is not written completely in Java. Some small parts are, but most of it is C++
Michael Borgwardt
Java is not a spin-of of C. It steals the syntax to make it easier to learn for C programmers, but it is a completely different language.
Thorbjørn Ravn Andersen
@Thorbjørn: what then would you consider a "real" spin-off of C that's *not* a completely different language?
Michael Borgwardt
Depends. I believe the crucial point is whether you have pointers that can be manipulated or not.
Thorbjørn Ravn Andersen
My recollection is that Java (rapidly) evolved from C++. By 1.0 not much survived outside of syntax, notably little C++ that isn't part of C.
Tom Hawtin - tackline
+2  A: 

My personal usage of Java has been on cell phones. I ported an application to Android and BlackBerry. So for real world publicly visible usage, those operating systems and their myriad applications are fair examples.

The more I work with Java the less I like it. That is partly the developer tools (Eclipse), partly the target platform, and partly the language itself. Java is a fine first language, but at some point I hope you try others to see what you are missing.

drawnonward
Personally, I've found Eclipse+Java really enjoyable to work with. So much better than any C++ IDE I've used.
Philippe Beaudoin
@drawnonward, it is a well established fact that all languages suck.
Thorbjørn Ravn Andersen
Yes there is something to dislike about every language and environment. With Java on mobile devices, I have found more daily frustrations than with anything else except coding for multiple web browsers.
drawnonward
+2  A: 

I've been a C/C++ programmer forever, but I've recently started using Java as I write web applications using the very cool Google Web Toolkit (GWT). This little gem will compile your java code to Javascript and, if you write the server code in Java too, it can radically simplify client-server communication. I've written webapps in PHP and Python before, with raw javascript or jQuery, but to me the GWT+Java combo is a much more enjoyable solution.

Granted, it's not the most popular use of Java, but I thought you might be interested to know alternate uses of the language.

Philippe Beaudoin
+1  A: 

"C spin offs" are not in as much use as it seems when you factor in the business world (unless you consider Java a spin off, which I think you definitely should).

If you want to get a high paying job in IT Development (look at job postings), Java is currently the language to know (not second, not even close, unless you combine all alternatives but that means little).

J2EE (web development, server 'middle tier' development) is where Java dominates. Unfortunately, this is not something you will likely learn--or even talk about--in college (most profs don't know J2EE, anyway). Java also does well in situations where you need integration with some technology, database, or software. Of course it's multi-platform (if coded correctly). It also offers more choice (overwhelmingly so) and support for developers than most (if not all) alternatives.

J2EE applications don't "seem" common because they are usually hidden within corporate or government internal networks, or are used on web servers which you obviously don't ever see.

Crusader
+1  A: 

The reason a lot of commercial enterprises use Java (and similar high level languages) is that it (they) make it easier to write complex, robust and relatively efficient applications that are maintainable in the long term. With C or C++, large scale applications of the same level of complexity requires more effort (developer years). The software also tends to be more fragile because programmers with average skills make more mistakes in C / C++ than in Java (et al), and those mistakes tend to be more insidious (e.g. buffer overruns) and to have more serious consequences.

It is claimed that C / C++ is more efficient than Java and other managed languages. While this may be true for small (lines of code) applications, it is rather difficult to demonstrate for large (e.g. 100k+ SLOC) applications ... because nobody writes such applications to the same design in multiple languages.

Besides, in most kinds of software, the speed of an application is less important than things such as cost of development, cost of maintenance, system reliability and so on. Often, the only hard performance criterion is that the software runs fast enough to be tolerable. A lot of young programmers find this hard to grasp, and hard to accept, but the folks who pay our salaries think about these things differently ...

Stephen C