DEV Community

Cover image for I'm Learning Java s̶c̶r̶i̶p̶t̶?
Manish Mehra
Manish Mehra

Posted on • Updated on

I'm Learning Java s̶c̶r̶i̶p̶t̶?

Around two and a half years ago, I started my programming journey with Javascript. Ever since then, it has been my de-facto, go-to language. Because I can achieve anything with it, I never felt compelled to learn a new language. Until I realized my thinking was confined to Javascript alone.

This realization does not reveal itself outright but is the consequence of two years of somewhat developed understanding of computer systems and software. While I can build applications with Javascript, it became clear to me that I was operating at the top level of abstraction.

With this perspective in mind, I began visiting the fundamentals and decided to learn a new programming language.

Java came to mind.

In my previous company, a startup, I served as a React intern. The backend was written in Java(Spring). The team members admired Java and continually used it in their careers. Despite that, I was skeptical and unwilling to learn it. I regarded the senior developers, who speak so fondly of Java oldies and unfashionable.

This dismissive attitude prevented me from learning a new language and further making any contributions to the backend.

My reasoning was simple: Java is not as shiny/trendy as Python or Go or Rust. I have no intention of using it in the future, so why bother learning it in the first place?

The hated language

In my research, I've found that people are avoiding Java like a plague. It's not an enjoyable language to work with; it's dull and verbose, burdened with a copious amount of boilerplate code. This sentiment has spread widely on the internet.

My two-week experience learning Java confirms that you need to write extensive code for straightforward tasks, which indeed feels unnecessary and time-consuming.

For those coming from Javascript, they might not find Java appealing due to its verbosity. In contrast, Javascript has seen the addition of new features over the past few years. Such as, arrow functions, template literals, object/array destructuring, and array methods like map, filter, reduce, and so on. These syntactic sugars have led to an overall reduction in the number of lines of code and have made writing JavaScript a more pleasant experience.

The syntax has become both concise and elegant; however, I won't debate its readability in certain cases.

Another reason not learning Java would be that Google called Kotlin—the official language of Android a few years ago. Of course, this might not be relevant if you have no plans to delve into Android development.

And still, Java is everywhere.

There are a lot of job openings out there, and significant portion of enterprises hanging on Java. Major players in the tech industry utilizes Java. And it is extensively used in computer science academia.

If you know Java, you will get hired.

It is not going anywhere anytime soon, that is for sure.

The Lesson Learned

Ultimately languages are languages. A new language has its appeal with playful syntax, stylish cool logo, and fresh features, but its true worth unfolds with time.

Although Java may not have the allure of novelty, it remains a well-tested, reliable language. If it has stayed relevant over the years, there must be good reasons to spend time learning it.

I was hesitant to learn Java because I feared stepping into unfamiliar, scorned territory. However, after two weeks of working with it, I discovered the learning process was fruitful. It's easier since you have prior knowledge, yet it's also new, introducing unknown elements. There are plenty of surprises along the way.

Being exclusively familiarity with one language limits your understanding and narrows your perspective. You can only think in, for instance, "The Javascript Way", of approaching things if you restrain yourself to this language.

Another pitfall is that you become more susceptible to imposter syndrome. Whenever I come across code that isn't written in JavaScript or doesn't resemble JavaScript, I'm afflicted by a constant sense of uncertainty. Simply looking at that unfamiliar code is distressing.

If something makes you uncomfortable, the optimal strategy for the longer run is to confront what induces discomfort.

So, I figured I must learn JAVA.

End Note

While I've begun learning Java, I can’t guarantee I'll develop a fondness for it as my previous colleagues did. Additionally, Java might not be my primary choice for projects. Nonetheless, I've committed to understand what this language has to offer and how it operates and learn its way of composing programs.


Update

August 25th

This post was meant as my reflection on what I believe is a good way of growing as a developer. Learning and exploring a new language is a part of the process. The core idea behind learning a new language is becoming more adaptable and expanding your worldview. The question of whether you should learn Java, or if you should master every language, remains irrelevant here. Reflecting on this post after a week, I feel that I did not succeed in effectively conveying my point.

Thanks for all the thoughtful responses. Much appreciated.
Meanwhile, I need to work on my communication skills 😓

Top comments (32)

Collapse
 
skyjur profile image
Ski • Edited

I don't quite get where this myth of java being verbose and dull is coming from. Infact if you compare Nest.js and Spring application overall Spring applications often will be less verbose achieving similar tasks at hand.

Collapse
 
manishmehra profile image
Manish Mehra • Edited

The belief is quite prevalent. Personally, not sure about dullness, but verbose, why not if you compare it with something like python or javascript.

I have not worked with spring or nest js. Both are frameworks and I think the general dislike is toward the language fundamentally. To print a hello world, you have to start with setting up main class and all these keywords like public, static, void are confusing and intimidating to beginners.

Collapse
 
skyjur profile image
Ski • Edited

Actually in python to print hello world if you follow good practice you do

def main():
     print("hello world")

if __module__ == __main__:
    main()
Enter fullscreen mode Exit fullscreen mode

And same pattern is suggested to follow in node.js too. This is to ensure that it doesn't run if it's imported and so that main() can be unit tested. In the end by the time when application reaches hundred thousands lines of code and when size of application demands adopting either mypy or typescript - there is very little difference in verbosity - and in fact because mypy and typescript are stripped on top of fundamentaly untyped code it often demands writing even more code so that untyped code is wrapped in typr safe manner.

Thread Thread
 
manishmehra profile image
Manish Mehra

Thanks @skyjur for the insights. I see, why Java is often preference for medium-large scale apps.

Collapse
 
stainlessray profile image
stainlessray

I have. And if you implement any Python with OOP you may find that verbosity is pretty universal.

Anyone can write a Python script. Very few people seem to use it in an OOP way.

FWIW, I frequently write scripts in both. I can bootstrap either in minutes and deploy a jar wherever I need to run it. No VM required.

Collapse
 
joshuaamaju profile image
Joshua Amaju

We use Spring at work. You get some speed with Spring boot and the whole JPA shit. But at what cost.

You get unnecessary constraints that impact feature development cause developers are beholden to what Spring provides and can't break out of the norm. You get less verbosity but your hands get tied

Collapse
 
muralivp profile image
Murali

spot on, too much magic in the name of making it easy, in reality devs just are fooled, are discouraged to think and be smart

Thread Thread
 
skyjur profile image
Ski • Edited

I don't disagree with that. But point being is that Nest.js is attempting to do very similar thing what Spring does, basically following similar patterns of handling lifecycle of your instances and inject dependencies for yoy. And point is that it's even more verbose than Java code for very similar thing.

Verbosity usually come due to fact that TypeScript - even though I find it necesssary in larger applications - in the end isn't that perfect.

Here is one commonly annoying example. Let's say I have an interface X, I have class XImpl, and I register XImpl in provider

interface X {}
class XImpl implements X {}
provider.register(X, new XImpl)
Enter fullscreen mode Exit fullscreen mode

in TypeScript however you can't reference X as it's interface thus can't be used as value. So additionally a reference needs to be declared

interface X {}
const XRef = new Symbol('XInterface')
class XImpl implements X {}
provider.provide<X>(XRef, new XImpl())
Enter fullscreen mode Exit fullscreen mode

Another annoying case, is catch() construct, in JavaScript if you want to catch only one type of error

try {
   ...
} catch(e) {
   if(e instance of X) {
     ...
   } else {
      throw e
  }
}
Enter fullscreen mode Exit fullscreen mode

in Java same thing is cleaner as catch can be narrowed down to type

try {
   ...
} catch(X e) {
   ....
}
Enter fullscreen mode Exit fullscreen mode

and there are really many examples as such where same thing in Java is cleaner than JavaScript+TypeScript.

Now sometimes JavaScript alone could be shorter than Java, but it's often just not the same thing, as you don't get any kind of static validation. If static validation and linting are added to JavaScript and Python - which it is often the case in larger projects - then these languages are more verbose as they had not been designed with this idea first hand.

Collapse
 
muralivp profile image
Murali

it is not at all a myth, Java is verbose and dull.

Collapse
 
tracygjg profile image
Tracy Gilmore

Hi Manish,

Go for it, I applaud your choice.

I have been a JS developer for over 20 years, and C/C++ developer for 10 years before that and only touch Java a couple of times in my career. I don't hate Java (only those who confuse it with JS), C#, Python or any other programming language, but JS is my thing.
If you think Java is what you want to invest in, dive right in. We need Java/C#/Python & JS/TS developers in the industry. JS is not the all-purpose language. I don't think there really is one yet, although WASM makes some a close contenter.

My best wishes for your journey in the wondrous world of Java.
Tracy

Collapse
 
manishmehra profile image
Manish Mehra • Edited

@tracygjg Thank you sir!
While Javascript will still be my primary language and have to learn a lot in it. I'll steal some of my time to explore Java this year.

Collapse
 
camouflagedname profile image
camouflagedName

In my research, I've found that people are avoiding Java like a plague. It's not an enjoyable language to work with; it's dull and verbose, burdened with a copious amount of boilerplate code. This sentiment has spread widely on the internet.

Do you have references or sources for this? I'm curious, because my experience has been the opposite.

Plus, you later state:

There are a lot of job openings out there, and significant portion of enterprises hanging on Java. Major players in the tech industry utilizes Java. And it is extensively used in computer science academia.

These paragraphs you wrote seem to contradict one another.

Collapse
 
manishmehra profile image
Manish Mehra • Edited

Hi, thanks for writing your thoughts down. Its good to know your experience has been positive.

I don't think wide adoption of any technology is strictly translated to good developers experience. Rust, for instance, is most beloved language according to stack-overflow developer survey, but the adoption is slow. A lot of legacy systems are written in Java, so I presume these enterprises and big tech won't find the need to move to new language. After all, Java is still a good language, with active community and tooling around it.

Regarding Java and it's verbosity and people's disinterest in it. It has been my speculation after visiting lot of forums on internet. So, citing anything wouldn't make sense. But if you look at the 2022 and 2023 stackoverflow-surveys(supposing this survey provides a precise, if not entirely accurate, picture), Java is not performing well. In 2022 survey, Java is loved 45% & dreaded 54%. Compared to top loved language Rust, loved 86% & dreaded 13%.
2022
2023

While I tried to make the case that Java is a hated language in my article, I intended to make this post a counter to the idea of loved or hated language. If you have any more thoughts or observations, I'd be interested in continuing this discussion.

Collapse
 
konaduakwasiakuoko profile image
Konadu Akwasi Akuoko

Good response 💯

Collapse
 
baduit profile image
Lena

I totally agree with you that "exclusively familiarity with one language limits your understanding and narrows your perspective". Learning Python made me a better C++ developer, same now that I'm learning rust, because it made me see how differently some stuff can be done and how I could apply some of this concepts in my first language.

Also knowing several tools make it easier to use the more adapter one and the more you know, easier it is to learn knew stuff.

Good luck learning java, I didn't like it when I tried it at school and didn't see the appeal coming from modern C++ but that's me, but as you said, java is used a lot and knowing it can get you a job quite easily.

Collapse
 
manishmehra profile image
Manish Mehra

Thanks for commenting out @baduit
I intend to learn all the language you mentioned in future but for this year, my theme is Java. As I wrote in my endnote, I may not like it. The main idea to familiarize myself with a new language language, learn what it has to offer and move on. Use case at the end of the day depends on market and personal preference.

Collapse
 
danielrendox profile image
Daniel Rendox

Java was my first language and I liked it from the beginning. I like how unambiguous its syntax is. I was curious to break down what each word in public static void main(String[] args) means.

One might say I liked it because I didn't know how much better other languages are. Nope! I recently switched to Kotlin and I wouldn't say that it's that much better. It's not better enough for many companies to switch. Why would they? Java works.

Kotlin is my second programming language now and I'm not propagating how bad Java is, like it was popular to do several years ago. Instead, learning another language taught me so many new things about how technologies work, and allowed me to see some things from a different angle.

However, if one is targeting Android, it's a lot better to go with Kotlin simply because all the new learning resources are now adapted to Kotlin. On the other hand, I think I'd struggle to understand Kotlin if I learned it as my first language.

So, it's a great idea to expand your knowledge, Manish. By learning Java or whatever other language you want. Guys are still coding in C, let alone one of the most popular programming languages. Java will probably be here until AI takes over the world. 😁

Collapse
 
manishmehra profile image
Manish Mehra

Thanks for writing out @danielrendox
Yes, if one want to learn Android, it's better to go with Kotlin. However, I heard that 90% of knowledge is transferrable and if you know Java, switching to Kotlin will be easy. Some even advice to learn Java first, so they would know what Kotlin has to offer.

Collapse
 
danielrendox profile image
Daniel Rendox

Right, you need essentially a week to learn most of the Kotlin knowing Java (if you don't create shitty tutorials like I did). So even if you don't find Java useful, you'll be able to easily switch to Kotlin. AFAIK, C# is also very similar.

That's another reason why learning Java is definitely not a waste of time.

Thread Thread
 
manishmehra profile image
Manish Mehra

My reasoning was same. Learning Java will make me adaptable to two other widely used languages: C# and Kotlin. So even if I don't use it in future, I would become better at grasping other languages. That was actually the whole of point of my post. I failed to convey this point effectively.
I'm Java from here

Thread Thread
 
danielrendox profile image
Daniel Rendox • Edited

I failed to convey this point effectively.

You're good, Manish

Collapse
 
stainlessray profile image
stainlessray

Just wanted to share my 2c. Java is a wonderful language. WRT capability, it is pretty well unmatched because of wide support from frameworks. It's among the fastest high level languages, and can do almost anything while running almost anywhere.

And it's very friendly to multi stage container builds to reduce build time and footprint size.

I would avoid people who speak in absolutes about a language. They may not understand the underlying need for Java, or not be proficient in its use. Seems everyone has an opinion.

Collapse
 
manishmehra profile image
Manish Mehra

Much appreciated. Your technical insight gave me confident to move forward with this langauge. So thanks you!

Collapse
 
sahilverma_dev profile image
Sahil Verma

best of luck buddy!

Collapse
 
sentinelaeux profile image
sentinelae

Good luck, you will certainly need it.
It's like announcing you're leaving cars behind for elephants, because elephants are everyhere.
Every problem you think you see in webdev is multiple times worse in Java, in every way.
You probably will end up getting a smaller salary, for more work and more stress, but hey, in the end what really matters is making corporations happier and richer.
JavaScript FTW.

Collapse
 
manishmehra profile image
Manish Mehra • Edited

As I wrote in my endnote. Javascript remains my primary langauge, I'm learning java to expand my skills, adding it as a tool to my toolbox. I'm fairly new to programming with only javascript on my side.

Thank you for wishes!

Collapse
 
tsolan profile image
Eugene

Actually, I don’t think comparison is relevant. Both these language serve different purposes. If we are talking about backend, js will match only simple tasks. JS developers are either frontend or fullstack (funny word, that means “you’re frontend one with basic knowledge of backend who saves our money”). And Java (Spring boot) is for backend. So, if you’re frontend UI/UX designer why should you bother yourself with things you’re never gonna do? I bet there are tons of appropriate technologies for frontend , useful for you, you can learn them instead to really improve your capabilities and experience, not just touch something different and unrelated.

Collapse
 
manishmehra profile image
Manish Mehra

I agree, comparison doesn't makes sense here. I wrote an update at the end of this post, where I cleared this.
While I've been on frontend side and there's many things I need to learn. I'm spending a tiny amount of time to just explore other things and see what's there.

Collapse
 
docculprit profile image
Doc Guinness

Author - “ it's dull and verbose, burdened with a copious amount of boilerplate code...”.

COBOL Programmer - “Hold my beer… “

Collapse
 
deathwaiting profile image
ahmed galal

My 2c as well here as a java developer: I think developers who are learning new language should know a bit about its design philosophy.

Understanding the design decisions of the language developers makes the one understand more ,instead of the : "This all dump" attitude.

So, yes, java is verbose, and it is slow to adopt new features, and AFAIK, this is by design.

Python for example was created to be a simple, friendly language, that was a main target, so simple clean syntax was the priority, performance was not even on the table.

Java was created as an "industrial language" to replace C++, and solve its problems in large systems with large number of developers and teams.
So, Java care less about making the developer happy, and care more about keeping the big system working.

Being cross-platform means the company have wider options of hardware, being verbose means less problems switching developers, the slow modernizations fits large projects where the pace is slow, but reliability is a must and so on.

That's probably why it is popular with senior developers instead of juniors. Juniors want to enjoy programming, seniors want the project to keep going several years ahead.

Collapse
 
manishmehra profile image
Manish Mehra

I agree. I have the same notion that Java is not appealing to junior or new to programming, because as you said, it's about keeping the system working instead of making developer happy.

Thank you for the sound advice. I appreciate it.

Collapse
 
artydev profile image
artydev

Give you another chance :-) Languages