Do I really have to learn Java?
Mark Oates

:-/

Some software package asks that its plugins be written in Java. And, as far as I am aware it's the most common language, though I've never had to use it apart from the Comp Sci 101 class I took in college.

As a computer programmer, is it weird if you don't know Java? Is it worth it? Is knowing Java going to level up my haxor-ninja insight in any way or is it just ++ for knowing another common language?

CursedTyrant

Eh, depends on what you want to do, really. I'd say it's weird, if only because it's so popular and has been around since forever, but not everyone does, or has to, know it. It has its uses, but I believe it's mostly web apps these days, or at least that's all I ever do at work. :P

I'd say it's good to know Java, but it won't be a life-changing experience for you. If you're not aiming to learn any frameworks (e.g. Spring), the syntax is very similar to C#.

l j

Java isn't too hard to learn if you know C++ or other more modern languages like C#. It probably won't level up your haxor-ninja insight.

There are lots and lots of frameworks out there. Also you might want to take a look at reflection, it's a powerful language feature, but complete overkill for most tasks.

torhu

I learned Java a few months ago, and the main thing that stood out was how simple it was. But it's also inflexible and has a handicapped implementation of generics. As a tool for getting things done, it's probably often better than C++ because of how simple it is, and how good the library support is. But you get what you pay for. I suppose it's mainly for server software or apps that have no competition, like apps that are for in-house use. Cause it's slow and uses a lot of memory.

If you want to know a wide variety of programming languages, a good base would probably be C++/assembly/Python/Scheme. But if you're interested in programming languages, you're going to learn more than that anyway.

If you're talking about what to put on your resume, that's just too boring to talk about here :P

bamccaig

There's a big difference between knowing Java and knowing Java frameworks enough to be useful in Java. :P The language is very easy to learn. The frameworks require a bigger time investment; for the most part, the best way to learn these is probably to actually get employed by a company that uses them and learn by example. Joining an open source project that uses them would be another option, but those are probably not too plentiful, and I would guess harder to get involved with because nobody is paying you to be useful so they don't really care if you ever get past cloning the repository.

Is it useful to know? Yes. Is it necessary? Probably not. Do I know it? The language mostly, the frameworks not at all. The language is quite similar to C#, and C# is probably the better of the languages. Of course, Microsoft is in control of that so I consider Java the better investment (Oracle is certainly no better, but at least Java is properly open source). Obviously if you plan to write a plugin for a software package that needs to be in Java then you have your own motivation to learn it already. Let's just hope that's enough (again, the language is easy, but the framework(s) will probably take some time). :P

Steve Terry

just implement a big giant JNI in C/C++ to interface to a simple Java API call :)

MiquelFire

just implement a big giant JNI in C/C++ to interface to a simple Java API call :)

Ain't that basically what Allegro for Android is?

Steve Terry

Pretty much so :)

Kris Asick

There was a time long ago when using Java for game development was laughable. :P

Nowadays though... more and more people are going Java over other traditional languages like C/C++ that it's making me a bit worried. I don't learn new programming languages very fast and I've been avoiding Java since every time I look at sample code for it, my brain hurts. So long as I can continue to get away with using C++ exclusively, I shall continue to do so. ;)

Edgar Reynaldo

Java is the main programming language my community college teaches. I plan to get certified in it so I can get a job somewhere, but its not my favorite. It's very similar to C++ in many respects which makes learning it easy for me, but a very important point that bamccaig mentioned is the tremendous amount of learning that it takes to use its frameworks properly. And the number of classes it uses is staggering. It's got some decent string handling built in to the language, but its not perfect. Learn it for kicks or learn it for money otherwise I would say avoid it.

Matthew Leverton

the tremendous amount of learning that it takes to use its frameworks properly. And the number of classes it uses is staggering

The truth. :-X

Marco Radaelli

As others said, Java has its fields of application (webapps, most Android, although others languages can be used there aswell).
About being the most common language, I have no idea, but I guess it <a href=http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html>shares the place with at least a couple others</a>.
I'd say, either choose a field you're insterested in and then learn the languages it requires, or make up a knowledge on a handful of not-so-much-overlapping languages like others suggested :)

LennyLen

and has been around since forever

Java hadn't even been released yet when I started taking computer science courses at University.

Mark Oates

Hey, I didn't know Java was open source.

{"name":"607859","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c57453a0bd962037cc5b95f5523c774.png","w":243,"h":160,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c57453a0bd962037cc5b95f5523c774"}607859

MiquelFire

Yet, even though it is open source, Oracle still sued Google over using Java in Android...

Arthur Kalliokoski

Isn't part of the reason MS came out with C# because Oracle got so upset about the differences of J++?

MiquelFire

Dunno. Never paid attention to that.

Isn't part of the reason MS came out with C# because Sun got so upset about the differences of J++?

FTFY

larienna

I read a book about java lately and it's not so hard to learn. Like mentionned by another user, it's more learning the framework you are going to use that takes time, but that depends on what you want to programm.

I intend to use LibGDX to make video games in java, so in my case, I don't need to learn other frameworks like Java Swing for example.

It also made me realised that my code was not 100% C++. In java, everything MUST be in a class, so you cannot have simple loose procedures. So it forces you to think out of the box.

I think the global aproach was to make things simplier and less annoying to manage. For example, no need to have each class in 2 separate .h and .cpp file. It's now all in 1 file.

The biggest drawback is the garbage collector, which is a plague for video game development. LibGDX seems to have controlled this and it is supplying it's own template classes, to manage vectors for example, that minimise the use of the garbage collector. One of the key is to make for example temporary objects actually static objects of a class instead. This make sure the object does not get instanciated and destroyed all the time.

MiquelFire

I forgot the exact name (it was an article for Javascript, which has the same issue with garbage collection), but using memory pools would be ideal in Java (and other garbage collection languages actually). Basically, if each object takes the same amount of memory, you request memory from the pool, and when you're done, you tell the pool to "release" it, but it keeps it around until it's needed, so to Java, you haven't released it, and it's still in use.

l j

In C++ memory pools are also useful, to minimize dynamic memory allocation and to keep memory closer together.

larienna

So memory pool is actually a chunk of memory managed yourself?

pkrcel

A memory pool is some ancient concept, useful in C C++ Java and I guess a LOT other amenities ;D ;D ;D ;D

Steve++

Unless you are being forced to use it for work or whatever, I wouldn't bother. Java was nice in its day, but those days are long gone. I still use it for some non-work stuff simply because I know how to use it enough to get stuff done, but I certainly wouldn't be inclined to learn it now if I didn't know it.

Some software package asks that its plugins be written in Java.

Unless they require you to provide the source (unlikely), you can use alternative JVM languages such as Jython and JRuby.

In terms of bang for your learning buck, you might be interested in C#. Thanks to Mono, you can pretty much use it everywhere, including Windows, Linux, Mac, iOS and Android. C# is Java done right. Very right.

james_lohr

If you don't know Java or C#, then you should definitely learn one of them. Ideally Java first, as it is essentially a feature subset of C#.

Other than that, pretty much everything bamccaig said was accurate. They are both nice languages to learn. They have a relatively small number of key words, and you don't need to touch a framework, unless the goal is to be employable.

LennyLen

and you don't need to touch a framework, unless the goal is to be employable.

I've used C# for a few projects, but they were all C# with .net. How viable is learning C# without .net?

james_lohr

>>How viable is learning C# without .net?

It's not a question of "viable". It's a bit like asking whether it is viable to learn Java (a cross-platform language) on Windows instead of Linux. Mono is .NET Framework-compatible.

It's exactly as you would expect: the only reason for using .NET is if you want easy access to platform-specific stuff. And a better IDE of course.

You could easily write a complete commercial quality game that compiles fine in Mono and in Microsoft's C# compiler.

LennyLen

I was more referring to your comment about not needing to touch a framework. It seems like C# would be fairly toothless without .net (whether the MS version of .net or mono's).

Thomas Fjellstrom

It's about as toothless as C without libc.

That said, there are a lot of parts to .NET. you don't have to use all of them, especially the higher level components.

Winfield
LennyLen said:

I've used C# for a few projects, but they were all C# with .net. How viable is learning C# without .net?

I'm going to have to go against the grain here and say that it's probably only useful if you're staying glued to Windows. Crossplatform UI for mono is hard to come by - GtkSharp won't compile for Mac right now, and the documentation is so incomplete that GtkSharp wouldn't be that helpful anyway. Qt support in Mono is effectively nonexistent. Managing Mono versions is also unreasonably difficult for nontrivial programs.

It was a wrench for me to stop working in C#, because I really did enjoy the language (and it's a lot like Java, right down to the cartoonishly long namespace resolution chains.) But as my goal was to write code that'd work anywhere, it wasn't a good fit.

Working with the Windows UI is pretty straightforward, though - though that's a .NET component IIRC, so it'd be outside the scope of your question.

james_lohr

It really depends what you are doing. If it is game programming, then you can do everything in Mono.

If it's hacking around with your OS, then it's not the best tool.

BAF

C# runs on the CLR, which is part of .NET. You can't have C# without .NET...

Mark Oates

I predict a monochrome-monitor programming-purist console-loving renaissance. One that strives to abide by the rules of the computers needs, rather than the programmers.

axilmar

I think that since Java is quite easy to learn, then one should learn it, in order to have a more complete view of the state of programming languages.

Mark Oates

Stumbled on

Quote:

Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing"

I guess I'm looking for that language.

axilmar
Quote:

A language that doesn't affect the way you think about programming, is not worth knowing

Is there such a language? I don't think so. All languages are 90% similar and 10% dissimilar, and most mainstream languages are 99% similar.

larienna

From what I know C# was designed to work well with MS stuff like MFC and .net. But its not optimised for doing everything.

Quote:

A language that doesn't affect the way you think about programming, is not worth knowing

That's a nice advice. I could agree that learning Java disturbed my mind a lot and could rethink how I program. The main reasons are:

1- Everything must be an object: That is not always easy to implement, now I understand a bit more the usefulness of Utility classes and Interfaces.

2- All objects are dynamically allocated: Another important issue which is much more problematic is if you want to avoid the garbage collector.

So I think those 2 elements of Java has turned my mind around and it could influence my C++ coding. In my wizardry legacy game, I realised that I now have many design flaws that could have been resolved otherwise.

Thread #613047. Printed from Allegro.cc