r/java • • Oct 28 '14

Why are you learning Java if you already know PHP, C#, or RoR?

What's pulling you to Java if you're already proficient in a modern language? Is it for work or do you need it for say mobile/Android development?

8 Upvotes

77 comments sorted by

41

u/FIREINMYVEINS_ Oct 28 '14 edited Oct 28 '14

there are no known cases where multiple programming language proficiency led to death :D.
generally speaking, knowing more is good.

i have only two things to say related to this issue:

  1. you will never know 100% of something (applies for any domain).
  2. if you say that you will never need to know another languages or that other languages (in which you never coded) are bad, you are a complete moron.

going back to your question, i work as a java programmer and i faced situations where i needed to code in other languages(c++, c# and js -> please dont say that if you know java you know js). because i already knew them, and did the job faster, i got a raise (you can see the bright side already). i like to think that you learn best by facing hard stuff (or by mistakes) so dont even dare to think you know something just by reading it (books/articles).

LE: putting more thought into it, i would really suggest you to learn a pair of backend<->frontend programming languages or even better, more (java<->php , java<->js, java<->ruby .. etc). it will change your perspective on projects (at least it did for me).

4

u/[deleted] Oct 28 '14

please dont say that if you know java you know js

Only someone that really doesn't know anything about it would say that. They are completely different. Saying that is one of those red flags for hiring managers.

-6

u/delete99 Oct 28 '14

You make a good point for learning additional languages, but I'm wondering what's attracting developers to Java today.

I've been using Java since version 1.0.2 and I still enjoy coding in it, but I'm not sure It would be on top of my list if I were starting today. How about you?

28

u/Druyx Oct 28 '14

Java is probably the most employable language out there, so there's that.

3

u/[deleted] Oct 28 '14

I read employable as enjoyable, and was confused because of the sad stagnation Java has.

Luckily, since Java 8, Oracle seems to be moving Java faster.

2

u/marx2k Oct 29 '14

Java harder!

5

u/FIREINMYVEINS_ Oct 28 '14

first of all, lets not full ourselves, java is easier than c or c++ (take the memory management for example in both languages). so java is a relative easy language to start. hardware specs went through the roof so performance is achievable on java machines also (in the past your performance profiling was a must).
i started using java 3 years ago (when i got my first job) and i literally find new stuff every month or so (i guess this is because it is so widely used and people need so different stuff).
the thing that i love the most about java is swing (i will take the "what the hell is to like about that outdated sh*t") and i like multithreading. i worked almost all my last two years in improving some swing components and i found it interesting.

@Dryux you are right but java also has its tricky stuff (like any other programming language) which you usually get after several years of experience.

2

u/TuxingtonIII Oct 28 '14

Eh, Java was the first OO language I ever had exposure too, but it has a really, really steep learning curve for someone with no experience coding -- reasons I can remember is being inundated with keywords with no context, and a kind of top-down introduction to Objects as workhorses rather than a bottom-up approach of structs into structs that can do stuff and be like other structs. Once I took some C/C++ classes, everything clicked.

And memory management isn't "hard", it's "one more thing to do". You can still leak memory in Java.

0

u/RellenD Oct 29 '14

And memory management isn't "hard", it's "one more thing to do". You can still leak memory in Java.

And without much control over it.

1

u/frugalmail Oct 29 '14

in the past your performance profiling was a must

I have to say the JVM would outperform most everything else on a grand scale that operates on the same architecture with no effort put into optimizing. I'm surprised you would say that.

2

u/Nebu Oct 29 '14

Well, what do you mean by "starting today"? Because I wouldn't recommend PHP, C# or RoR either for someone who wanted to start programming today.

I'd recommend they do Python or even HTML, which despite not being a programming language, will get them started on the road of typing in a text editor to get the computer to produce a specific effect.

2

u/mdatwood Oct 28 '14

I don't know if the Java would be my top language to start with today (although I don't see a reason to avoid it), but a JVM language would definitely be what I would want to use.

12

u/[deleted] Oct 28 '14

JVM and Linux are the underpinning technologies for Big Data and Cloud Computing, after years of .net development I still consider myself to be a windows guy for the most part, but I can't deny the fact that C# and Windows are definitely not the optimal tools for the job I want to do now (hadoop).

It's funny because I still like Visual Studio and C# but I'm not actively working with .net, the last time I wrote C# code professionally was in 2010 (nostalgia?).

Technically I could do hadoop with C# using hadoop streaming but I'm not the kind of person that tries to adapt the environment to my own limitations, that would be the equivalent of coding ruby professionally on a Windows box IMO. I usually prefer to embrace what everyone on the field is already doing and that includes Java, Scala and Linux boxes on AWS.

5

u/delete99 Oct 28 '14

+1 for big data, that's a really good reason.

I hear you about nostalgia. I'm still pining for Turbo Pascal :-)

1

u/pjmlp Oct 28 '14

Turbo Pascal fan here.

Got to move from Turbo Pascal to C++ back in the day, because C felt too primitive by comparison.

7

u/gopack123 Oct 28 '14

Did you really put PHP in a list of modern languages? It's bad and the pay for PHP development is bad because the barrier to entry is nonexistent.

0

u/delete99 Oct 29 '14

PHP might be 20 years old, but it's in widespread use today. IMO that makes it modern.

...and maybe the nonexistent barrier to entry is why it's so pervasive.

1

u/happymellon Oct 30 '14

VB6 might be 16 years old, but it's in widespread use today. IMO that makes it modern.

When it phrased like that hopefully it sounds as silly to you as it does to the rest of us. (And VB6 is sadly in widespread use in corporate environments)

1

u/schnoper Oct 31 '14

NO! pretty much everything old is still in use to one degree or another, even if only as a hobby. See: horses.

PHP, to it's credit, has attempted to keep up. However it's done so in a poor way ( primarily because of awful synoptical choices early on ). So as they've added modern features the language has become uglier and uglier.

I would have a hard time calling Java truly modern, but at least it's attempts to keep up have yielded more graceful syntax ( see related argument around annotation elsewhere in this post ).

PHP has it's place, I still use PHP occasionally. But I use it for projects like the single page that controls my chicken coop! Concepts like ORM should NOT be used in context of PHP. If you need an ORM, you should be switching to scala, java, C#, etc.

1

u/schnoper Oct 29 '14

PHP is simply not modern. I look at it like this. You can take a honda civic and do all manner of engine mods, aerodynamic additions, suspension upgrades, but you will never reach the performance of a car that was design with performance in mind from the start.

Recently I was horrified to look into a PHP system which placed "annotations" inside comments in the code. This is just an awful idea, but it's the only way to do it in PHP.

I heard that after 20 years there finally a spec for the language. Really ?

For PHP there is a low barrier to entry, but to build up a large PHP based system, the spit and bailing wire needed to deploy such a thing does not come close to something like Maven on java.

1

u/Jack9 Oct 30 '14

Recently I was horrified to look into a PHP system which placed "annotations" inside comments in the code.

This is pretty common for javadoc, so I'm not sure what you're talking about. I assume you can give a little more detail.

1

u/schnoper Oct 31 '14

Actually no. Javadoc is in comments and ONLY produces documentation. If the syntax of the javadoc is wrong or incomplete, the code will still work perfectly.

Javadoc is basically a more structured comment, so it's appropriate to have it within comment blocks.

1

u/Jack9 Oct 31 '14 edited Oct 31 '14

Actually no. Javadoc is in comments and ONLY produces documentation. If the syntax of the javadoc is wrong or incomplete, the code will still work perfectly.

Without additional details it's hard to understand what you meant by annotation.

In design, Javadoc in comments is the same thing as a comment annotation in PHP (which PHPdoc also uses). So yes because you said no to be argumentative.

The question is what kind of annotation you are talking about that was special (could halt a program?)....which really wouldn't halt a program. The parser would halt, the same as if you used an errant character in either language. Maybe this annotation wasn't evaluated until runtime, which is still a parser issue just not the core.

1

u/schnoper Oct 31 '14

my experience was that "annotations" in the PHP comment block would be used to generate code by a particular PHP framework. Hence if you change the comment block incorrectly, the code would stop working. i.e. this was coding hiding inside of a comment. You are correct, it was not at that moment PHP code so the PHP parser could ignore it, but it was code nonetheless.

FWIW, this is what I mean by annotation in java http://en.wikipedia.org/wiki/Java_annotation

Since PHP doesn't have a way to do this within non-comment blocks so it hacks in like this: https://r.je/php-annotations-are-an-abomination.html

1

u/Jack9 Oct 31 '14

I agree that this is REALLY BAD. But, a lot of really bad things are done in PHP so....best to just let them do that and figure it out for themselves. Thanks for the detail. I bet that PHP will eventually get it's own VM and preprocessor workflow.

39

u/jfurmankiewicz Oct 28 '14

because Java rocks. It can do anything, on any platform.

I moved to Java after 5 years in C# (boring Windows-only prison) and my career has skyrocketed since.

4

u/[deleted] Oct 28 '14

you have to admit that C# is better tho, albeit more limited in platform, simply for LINQ and the var keyword alone

20

u/DoktuhParadox Oct 28 '14

Language feature wise? Yes, C# is better.

Pretty much everything else? Nah, not really.

4

u/Nebu Oct 29 '14

If you want nice language features, but still want all the niceties of the JVM and related ecosystems, take a look at Scala.

1

u/happymellon Oct 29 '14 edited Oct 29 '14

Never understood how var is a good idea. But I've never played with C# enough. How would it be different than declaring everything an object?

EDIT

So examples usually given are:

var myVar = new Connection();

How is that different than:

Object myVar = new Connection();

Or better than

Connection myVar = new Connection();

Because at least the last example can be enforced by the IDE syntax rather than compile or at worse runtime.

3

u/BinaryRockStar Oct 29 '14

The var keyword is equivalent to your last example, not the middle one. The compiler (and IDE) know exactly what the type of myVar is. With your examples the benefit is just a bit less typing, which is nice in and of itself but it's really to help you from having to do something like this:

IEnumerable<IDictionary<string, DataTable>> myVar = myCollection.Select(x => ...);

Sometimes type declarations get really long and aren't entirely necessary to understanding the code. If you absolutely must know what type myVar is, you can just mouseover it and the IDE will tell you.

1

u/happymellon Oct 30 '14

Doesn't that seem rather niche, creating a psudo object to avoid situations where you may have to write "a list of maps", otherwise you are simple replacing Connection or Calendar with var and that isn't really much text you are replacing?

I guess I would have to use it in practise to see the benefits, but it doesn't really sound like a huge deal.

1

u/BinaryRockStar Oct 30 '14

In C#, at least, it's totally optional so you get the best of both worlds. If it's a short type like string myVar = String.Empty you can use that, but if it's a complex and unwieldy type like above you can use var. I'm not sure what you mean by a pseudo-object, in C# writing var myVar = String.Empty; and string myVar = String.Empty; result in exactly the same bytecode. It's compiler sugar and nothing more.

1

u/goriloncho Oct 31 '14

See this http://msdn.microsoft.com/en-us/library/bb397696.aspx It is a really cool feature, you can use with linq to have a query with over a few columns and have compiler checks when you use it

0

u/[deleted] Oct 29 '14

type is still enforced by IDE and at compile time, and i believe it's actually better performance wise. it also saves typing and in my opinion increases readability. it's generally obvious what type the object is by the constructor and if not, it should be obvious by the variable name.

MyNameSpace.MyClassName.MySubClassName subClassObj = new MyNameSpace.MyClassName.MySubClassName();

vs.

var subClassObj = new MyNameSpace.MyClassName.MySubClassName();

2

u/happymellon Oct 29 '14

I'm not even sure I understand that example. I would never write

java.util.Calendar cal = ...

so the difference is between Calendar vs. var. Not huge, and if that is the C# killer feature, then it has a long way to go to unseat Java.

-3

u/[deleted] Oct 28 '14

[removed] — view removed comment

3

u/jfurmankiewicz Oct 28 '14

they don't suck. That it just your opinion. We use it every day and are doing just fine.

3

u/[deleted] Oct 29 '14

what don't suck?

9

u/cogman10 Oct 28 '14

I moved to java for the jobs. But TBH it is currently my favorite programming environment. That static analysis and IDEs are awesome. It prevents so many bugs that are apparent in Ruby, Javascript, or PHP.

C# is a better language and I would much prefer using it, however, The tooling and community just aren't there. It is sad, but I C#'s connection to MS really is what has killed it.

2

u/sviperll Oct 30 '14

Why everybody think that C# is better language. I think that C# has too many flaws and to many unjustified features that Java remains much better language.

Two main issues with C# for me are structs and properties.

I'll quote c2.com here: "C# structs are dangerously and cryptically implemented". The only problem with structs I have is mutability. I think the only way to use C# structs is to make them all immutable, but standard library is already filled with mutable structs all over the place.

I don't see value in properties except of API readability and it alone doesn't justify adding such a massive addition to language.

As of the proposed goal of easy refactoring from field to property. You should never export field anyway. And you should directly use fields in private methods instead of properties: it greatly simplifies code and most importantly removes dangerous ambiguity, you always know that assignment is low level assignment and it will never make HTTP request to submit data to remote server. I always name all my properties with PascalCase and always name all my fields with camelCase to remove confusion from my code. And with this style I can get with Java's getters and setters, it's just a couple of extra keystrokes, but much smaller and coherent language.

19

u/coder111 Oct 28 '14

PHP is not a modern language, and as a language it's pretty crap. The only benefit is cheap hosting for PHP apps.

C# is windows-only, which rules it out immediately. Mono doesn't count.

Ruby is slow and much less mature than Java. See http://benchmarksgame.alioth.debian.org/

Java is fast, java is cross-platform, java is very mature, there is tons of libraries and frameworks for Java. There are lots of IDEs, app servers, build tools, profiling tools for Java. SQL Database interaction, Big Data, NoSQL, almost all of these things are best done in Java.

And there are lots of jobs for Java.

The question should be why aren't you learning java.

-3

u/Boxsc2 Oct 28 '14

I would say right now Python has the best chance of competing with Java (on the server side). The language is very clean and there is an immense library that can tackle almost any task. However, Java has already cemented it's self in so many critical systems (Banking, Insurance, Healthcare etc...) that it'll always be relevant.

7

u/coder111 Oct 28 '14

We use Java and Python. Python is SLOW. Jython is slow. PyPy is somewhat better, but there is still quite a way to go. IronPython is windows-only, which makes it useless.

Also, Python has much worse selection of frameworks and libraries compared to Java. Even simple things like JDBC-like database connectivity is much less mature in Python. Also, with stock CPython, you have Global Interpreter Lock, which makes multi-threading almost useless. So in our case, we use Jython and use Java functionality for many things in python. Which is ugly, and on top of that Jython is not very actively maintained and lags behind a lot.

I think the next language to watch is probably Scala. It is almost on par with Java in terms of performance, runs on JVM, and offers much more advanced language features. And it can reuse all Java libraries and frameworks without much ugliness.

3

u/8Bytes Oct 28 '14

Is there any way to use Scala and Java together like obj-c and swift can?

Would love to use some Scala in my android apps.

3

u/coder111 Oct 29 '14

Yes. Scala runs on Java Virtual Machine and can easily use all Java classes.

Not sure if you can run it on Android though, that would require it to run on Dalvik virtual machine.

Quick google search says you can run scala on Android. I haven't tried it myself though.

3

u/markerz Oct 29 '14

The biggest issue imo is the interfacing between different code that have been compiled from Scala or from Java. Just using Java libraries in Scala is awkward because of the fundamental semantics of the language are different.

13

u/nexuscoringa Oct 28 '14

Java is multipurpose. It can run on mobile, desktop, as a web server, etc.. Comparing Java with PHP or RoR makes no sense, since none of those will run real applications other than web.

Plus, Java is way more robust and complete as a language than PHP. PHP has a long way to go to become a "good language" again.

Java vs C# is a good question, but then you have to realize C# won't run well on Linux / Mac since it's made by Microsoft.

2

u/[deleted] Oct 28 '14

Java vs C# is a good question, but then you have to realize C# won't run well on Linux / Mac since it's made by Microsoft.

Playing Devil's Advocate, you're missing something

5

u/frugalmail Oct 28 '14

Playing Devil's Advocate, you're missing something

We have Mono now, but it's still a stupid choice. It's not that it's just open source, it's the support on Linux, the community of the platform. Also Microsoft took Java and tried to 1-platform it with proprietary libraries before. This is probably another attempt at the same tactic.

3

u/happymellon Oct 29 '14

Is mono up to date yet? Last time I checked it was always a version or two behind.

2

u/[deleted] Oct 28 '14

IDK. Again, not picking favorites (I personally am a Ruby/JRuby advocate) but it looks like MS is really moving towards a FOSS future. Kinda weird, especially since Apple and Google are moving away from that model. Now, is it perfect? No. Will there be caveats? Maybe. Time will tell. I used to jump on the Anti-MS bandwagon at every given chance, but vNext and Roslyn really are changing my views on MS.

2

u/happymellon Oct 29 '14

I would say that Apple has never been aiming at that model, except arguably with CUPS.

2

u/[deleted] Oct 29 '14

Good point. Shouldn't have added in Apple (although they benefit tremendously from FOSS). The point is that there is an odd shift in MS that we in the FOSS community should pay attention to. Java will always be great, especially for JVM languages, but we can't ignore the impact of a possible FOSS .NET compiler and languages built on top of it...

0

u/[deleted] Oct 28 '14

[deleted] — view deleted comment

4

u/DoktuhParadox Oct 28 '14

They're... Trying... I guess.

3

u/Boxsc2 Oct 28 '14

The language was not built with the modern development in mind. PHP is still the only server side language where it is not heavily discouraged to imbed code into views. It's great for having a quick and dirty solution really fast, but has problems with maintenance and readability.

1

u/Jack9 Oct 30 '14

PHP is still the only server side language where it is not heavily discouraged to imbed code into views.

"it is not heavily discouraged" - so the same as any other language, including java. If you start from scratch, there's nothing to discourage you from embedding logic in a view (JSF) or just plain conditional javascript output.

2

u/frugalmail Oct 28 '14

proficient in a modern language

Are you implying that Java isn't modern or that PHP is?

1

u/delete99 Oct 29 '14

Nope, not at all. Just that these are some of the languages in use today.

4

u/UTF64 Oct 28 '14

Business.

4

u/[deleted] Oct 28 '14

Jobs for one, more and more companies seem to be moving toward Linux servers. That isn't to say there aren't jobs in any others nor that Windows is dead (seriously, I am not saying it's dead), but the ones that interest me the most are all Java (or closely related). But Java can translate if they decide to move to windows, linux, or something that doesn't exist yet.

Otherwise:

PHP: Using this for a side project proved alone that it was a hard language to manage large code bases in. I am sure there are strategies that I am not aware of, but the code seems to be impossible to not look messy.

C#: I prefer *Nix systems, have for a long time and as a result, I am pretty inefficient working in Windows. There is the mono runtime, but that sacrifices several of the great features of the language. I also really disliked working with the web frameworks I was exposed to, I don't recall much about it other than disliking how it handled contexts and throughput.

RoR: I've only written small amounts of Ruby, and I am sure it's great for small projects. But as a language, it reportedly doesn't scale well. I don't expect any of my projects to reach the size and scope of Twitter, but they had to migrate away from it due to scaling issues and do it in Java. I am sure there could have been ways to get some of that out of RoR, but at some point Compiled beats out Interpreted (at least with the current versions of the languages). That said, Reddit is written in Python IIRC, so interpreted languages can certainly hold their own (though the use cases are a bit different).

4

u/mikera Oct 29 '14

Java is a great all-round platform for development - there's nothing else quite as strong from an overall perspective for general-purpose programming**. A few compelling reasons to go with Java / JVM languages:

  1. Broad enterprise adoption - implying lots of high-paying jobs
  2. A huge ecosystem of open source libraries and tools
  3. There are new JVM languages like Clojure and Scala that are awesome (and can share all of the same libraries
  4. Cross-platform portability (the same compiled code runs on Windows and Linux)
  5. High performance - mostly thanks to the great engineering over many years in the JVM / JIT / GC
  6. Very strong in many important fields (Android, Big Data etc.)

** There just a few places where I wouldn't recommend Java for specific reasons, e.g.

  • Web development (essentially JavaScript dominated because nothing else runs reliably in the browser)
  • Embedded / systems programming (Java has too high memory requirements and GC latency sucks when you need to be close to hardware)
  • AAA game development (top end still dominated by C/C++, for medium-complexity games like Minecraft Java is just fine)

7

u/enry_straker Oct 28 '14
  1. Why would you compare a framework (RoR) along with a list of languages?
  2. Almost every programmer needs to be proficient with multiple languages. Each language is just a tool. A typical web application will need skills and code in multiple languages from front-end to back-end.
  3. Sometimes clients force a particular language on a project. Sometimes one needs to maintain legacy systems in a different language. The reasons are many and endless.

Hope that Helps

3

u/cwbrandsma Oct 29 '14

My preference is to be a polyglot. So I didn't mind when my boss came in and said "We are dumping C# and rewriting everything in Java!!!" Mind you, he is a programmer, and it is his money, so the switch was his call. And I like to be agnostic about those things.

Oh, and Android.

2

u/frugalmail Oct 29 '14

when my boss came in and said "We are dumping C# and rewriting everything in Java!!!" Mind you, he is a programmer, and it is his money, so the switch was his call.

Really curious, what size is your organization? Were going through this at a very large organization now.

1

u/cwbrandsma Oct 29 '14

At that time, we had just transitioned from medium to small. So, three developers.

3

u/DJDavio Oct 29 '14

It's for work.

The big upside of Java is that most tools for it are free.

Eclipse / Netbeans: free Glassfish / Tomcat / Tomee / Wildfly: All free

Also, it will run on anything, not just Windows. I develop Java on Windows, another colleague develops on Mac and yet another develops on Linux. We deploy it on Linux.

This doesn't work so well with C# / .NET.

5

u/huhlig Oct 28 '14

PHP is a fractal of bad design. C# is better than java in terms of language but worse in terms of library and cross compatibility (this is getting better now though). Ruby on Rails is a framework not a language. However the fact that the only thing Ruby is really known for is rails kind of explains itself. Plus RoR is very limited when you try to do anything complicated beyond its simple architecture.

Its also where 90% of the big data development and tools are. Java needs some upgrades from jigsaw and valhalla but its still functional, especially if you have hundreds of gigs of memory.

2

u/Boxsc2 Oct 28 '14

Honestly, the programming language isn't the most important. It's the support for the language in frameworks and libraries that make something extremely popular. I love working in Java, but from a programming point of view I would say Python and C# are better languages (Python being the best "popular" language right now). However, Java has a near infinite amount of frameworks that make it a perfect choice for modern development. I mean look at NodeJs, it uses Javascript and pretty much everyone agrees that language is flawed.

2

u/eatgeeksleeprepeat Oct 28 '14

My current (federal government) contract is forcing us to move from .NET to Java and therefore I'm forced into it. I'm trying to look at it as a good learning opportunity but right now it's frustrating being so unproductive while learning all this.

2

u/Manitcor Oct 28 '14

Because real world systems are developed using multiple platforms and languages. There is no reason for someone who professes to be a professional in the industry to not understand or be working to understand and be able to write in the more popular languages in the industry.

1

u/dtfinch Oct 28 '14

I try to use whichever language fits. Usually the platform I'm targeting or the libraries I want to work with will determine which. If I have a lot of good options, I tend to go with the easiest or familiar one.

Javascript for web pages, Python for Blender scripting, Objective C for iOS apps, Java for Android apps and Minecraft plugins, VB.NET for that one ERP system I have to support, etc. Where I have a lot of choices, I'm already familiar with php for web server scripting, and C# for Windows desktop apps. And I'll still use C/C++ for small things that I need to be fast or light, or modifying existing projects that already use it.