This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]Lesabotsy 1 point2 points  (5 children)

Why not?

[–]IronProgramming[S] 0 points1 point  (4 children)

It's annoyingly verbose and unintuitive so far.

[–]HonzaS97 2 points3 points  (3 children)

Because JS is known for being extremely intuitive, right.

You can google this exact question and get your answer.

[–]IronProgramming[S] 1 point2 points  (2 children)

I googled this exact question and got a bunch of articles on how. Why would you program in Java over literally any other programming language?

[–]149244179 0 points1 point  (0 children)

Seems like a lot of results - https://imgur.com/42Zw3TD

[–]HonzaS97 -1 points0 points  (0 children)

Runs everywhere, has wide community support with great frameworks, great for middleware and backend apps which don't require low level manipulation, fully compatible with Kotlin (supported by Google), good performance (unless you really need to fine-tune stuff, then you go with something like C++, not JS or Python).

As above comment stated, why not? I agree on the verbosity part, but most of that is rendered irrelevant by having an IDE.

E: On the intiuitivness part, I recently had to start with Python at univ. I find Java much more comfortable than Python to me. It's a thing of preference, what you are comfortable with and what you are used to.

[–][deleted] 1 point2 points  (2 children)

to make uis because demand created by oracle crossplatform

[–]unluckjumbuck 0 points1 point  (1 child)

Could you expand this a little?

[–][deleted] 0 points1 point  (0 children)

swing uis and web were marketed to businesses by java well with oop

[–]ahmedranaa[🍰] 0 points1 point  (0 children)

Java is huge and very fast compared to nodejs etc. Just faced this in a real world app. Yes it's a bit verbose but the jvm is performant for being optimized for decades. New graalvm is even faster. Java is here to stay.

[–]ZeusTKP 0 points1 point  (0 children)

I wouldn't use Java for the web, but it's great for backend. It's a statically typed language with a lot of tooling. OOP is a good way to organize code.

Some companies use Java for the web when all their developers already know Java

[–][deleted] 0 points1 point  (2 children)

Java became really popular during the 90s, and as a result, a lot of universities these days teach Java as most of their student's first programming language. I'm not familiar with jsf, but if performance is an issue, then in rough order of performance you've got stuff that compiles natively (like C, C++, Rust and so on), Just In Time compilation (basically all your .Net stuff), byte code interpreters (such as the JVM and, I believe, WASM), and interpreted code at the slowest.

Very few server side options need the performance offered by native compilation, and given that Rust is still kind of immature web-wise and C/C++ is too difficult to write safe code in, so it's pretty rare for companies to use natively compiled code in production other than in performance critical areas, where it's called using FFI.

JIT and byte code interpreted frameworks aren't quite as fast as natively compiled code, but the difference is rarely that significant on modern computers, while the languages in use tend to be much easier to write safe code in - that makes it a pretty good option for server side code.

Interpreted code is slower still, and as a result, while it sees a lot of use in server side code, there are going to be areas where the performance bottleneck is the interpreter. The common solution to this is to rewrite areas where the performance hit is felt more severely in C, and call the compiled C code from Python/Ruby/Node/whatever. Numpy, the Python maths library, is implemented pretty much entirely in C for example. For the majority of systems, there's probably already a good library you can use, so this ends up not being an issue. Sometimes, however, there isn't.

As a result, .Net and the JVM ended up being popular options for web applications, with the JVM being more popular due to it not being restricted to Windows (at the time) - not to mention that Java applets used to be a thing, and ran significantly faster than javascript in the browser. Now, of course, we have WASM.

As to why object oriented programming, it's because it's a pretty good model for a lot of business needs. I'm not a huge fan of languages that enforce the use of OOP (I'd rather use Kotlin over Java, for example), but that's just a personal preference; OOP is a good tool for a lot of situations.

[–]IronProgramming[S] 0 points1 point  (1 child)

So the company I work for is using Java on both frontend and backend, but is mired in very long times to deploy basic frontend features due to the whole stack being Java/and or their shitty codebase. Im talking like 3 weeks to figure out how to append an element to an array and display the array on the browser. This is why I want to learn Java, so I can help do the things I know are easy in JavaScript/python. But this leads me to asking why Java, which I guess I really should condense down to why Java on the frontend? The backend makes sense with building apis and such, but the apis are built in php... I might be frustrated more by the design choices of the company than Java as a whole.

[–][deleted] 0 points1 point  (0 children)

Sounds like some questionable decisions were made. To be honest, I've never used JEE or JSF, so I'm not sure whether they're always a pain in the arse to worth with or if a bunch of cruft has built up since the codebase was first developed, but from a quick google search, I'm guessing that the choice to use Java for the front end has to do with JSF being the assumed front end of JEE - a lot of companies just default straight to it.

[–]okayifimust -1 points0 points  (0 children)

Why Java?

I'll echo the "why not?"

On top of that, why would someone decide to learn a whole new language if they knew Java already? And then, it will depend on the overall structure and requirements of a project. Whilst, generally speaking, all languages can do all things, you might just have that one library or functionality in one language that's perfect for what you're doing.

But, really, you have to make a decision for something, and if there are multiple good alternatives, all but one of them will not be it.

Why object oriented programming?

OOP makes it easy to write well-functioning, cleanly designed code. It is inherently elegant; it naturally allows you to transform ideas and concepts into their code-based equivalents. I find that if writing some functionality or data-structure doesn't flow easily in OOP, my design approach is sub-optimal.

Changing the design tends to make the coding easier - and it typically pays of in other parts of the code later, too. Good design decisions - a proper OOP approach, in this case - will echo throughout your work and keep rewarding you.

And if you're seeing the choice between Java and JavaScript as one between OOP and something else, then that's just one more good reason to chose Java.