DEV Community

Cover image for What Happened When I Learned Java and Python at the Same Time
Alli Teration
Alli Teration

Posted on

What Happened When I Learned Java and Python at the Same Time

This is a story of how I learned Python and Java at the same time, and while doing that, learned a few things about myself in the process.

Starting out on a Journey

When I started my current job I'd primarily been a frontend developer. I'd used some PHP in college and dabbled a bit in C#--and I could write a mean SQL query--but that was it. At my current company, we have mostly Java and PHP on the backend. While I still mainly work on our React frontend, I coded in PHP right when I started and then, gradually, began coding in Java.

It started like this: an endpoint wasn't giving me what I wanted. I could wait for someone else to fix it, or I could just take a look in the code and see... yup. There was the part that needed fixing. It wasn't long before I'd created my first Java Pull Request.

Some people were starting up a Python learning group. I'd always wanted to learn Python but never started. Why Python? First of all, the Python developers I knew loved their Python. And secondly, Python just sounds badass. When I tell people I'm a software engineer and they ask what I program in, Python sounds way cooler than JavaScript. So I joined the group.

In the group, we're going through Learn Python the Hard Way by Zed Shaw. I picked that book up and started going through it.

Then I needed to pick a 6-month goal. I thought about Python, but I knew Java would be more relevant. I could fix things here and there but I didn't have a solid grasp of the language basics. I asked a coworker for a book recommendation and he suggested Head First Java by Kathy Sierra and Bert Bates. I made it a 6-month goal to go through the first six chapters.

That's how I ended up with two different programming books learning two different languages at the same time. And I was still coding primarily in JavaScript for my regular job. What was I thinking?

Danger Noodle mug with snake drawing

I have no idea.

What I Know Now

Currently I've finished the first six chapters of the Java book and the Python book only has a few chapters left. (The chapters in the Java book are incredibly long, while the chapters in the Python book are just a few pages.)

I definitely wouldn't call myself an expert at either language, not like I am with JavaScript. (You can't compare a decade of using a language to six months of learning a new one.) I know enough of Python that for my next six month goal I decided to build a Slack bot in the language. I'm proficient enough in Java to build new features in our code base and contribute more to Java code reviews than just syntax nitpicks.

I also know a lot about my learning style and what I like, and don't like, in a programming language.

How I Learn

I learned that I like short, bite-sized chapters better than long ones with a lot of information. I learned that I prefer writing little programs to doing elementary-school-like exercises.

Learn Python the Hard Way and Head First Java are two very different books. Head First Java has long chapters that attempt to teach concepts in different ways for different learning styles. My favorite was the bullied list summaries at the end. I found the chapter length overwhelming (I couldn't read a whole chapter and do the exercises all in one sitting) and most of the exercises seemed pointless. Instead of actually writing Java they have you pull together snippets to create programs, do crosswords, and even matching.

I know the book was purposefully trying to get the reader to remember these concepts with the exercises, but I found them tedious, repetitive, and just something to slog through so I could meet my goal. I did like the casual style that the book used. But here's the thing: I'm not going to finish it. I don't think I'm "done" learning Java by any means (I'll never be "done" learning JavaScript), but I'll find some other methods.

Learn Python the Hard Way has one bite-sized concept per chapter and the chapters are usually 2-3 pages long. I could usually get through them in less than an hour, which was perfect for doing them during my lunch break on Python Learning Group meeting days.

The best part, though, was that I was actually writing and running little Python programs, not doing crosswords. Zed has you type out a lot of code from the book, which seems silly but it helped me get used to the syntax. Then Zed has you make changes to the code, break things, make sure you understand what every line is doing, and add your own stuff. At the end, you're building your own text adventure game and learning new concepts as you add onto it.

The tone of Learn Python the Hard Way is much harsher than Head First Java and Zed Shaw can be quite opinionated about things. (I'll admit, we make fun of him in the Python Learning Group sometimes.) It's not enough, though, to turn me away from the book, even when Zed suggests you memorize a list of things and you decide, no, you're not going to do that.

I'm sold on this supposed "hard way." I think there's a second Python the Hard Way book and I'll likely pick that one up. I'm not sure if the group is going to want to do it, but we might need a break first. If I never need to learn another language, I'll probably look for a Hard Way book. There is a Learn Java the Hard Way book. It's by a different author but uses short exercise-based chapters, so I might pick it up.

How I Code

I like Python more than Java.

I really like Python, okay? Not as much as JavaScript, at least not yet, but I could see it being a possibility. At first I was turned off by Python's specific rules about spacing, but now I'm completely on board. Python code looks good. Python code always looks good, because regardless of who wrote it and when you have to try to make it ugly. Eventually you'll stop getting errors about spacing.

You know what I still get errors about though? Types in Java. Less so in practice code than in the actual Java repo we have at work. I understand the reason for strongly typed languages. I've used TypeScript. I worked with a bunch of C# devs for four years. I always use PropTypes in my React components. I get it. But I don't like being forced to use types. I particularly don't like having to decide which number type I want to use. I know that in Java you're concerned about memory allocation and you want to pick the type that uses the least amount of memory possible. I don't want to worry that much about memory allocation, though.* I don't find that fun. Just like I don't enjoy dealing with inventory management in a video game.

Another thing I don't like about Java is all the recompiling. I remember once I kept making changes in our Java codebase and they weren't working. I told it to System.out.print things and nothing printed. Then someone reminded me that I had to stop and restart the application. BLECK. I think I'll write something to automate that so when I save a change it auto-restarts for me. I'll see if I can write it in Python.

Two at a Time

One language at a time is probably the better way to go. I wouldn't recommend it. It did provide the surprise benefit of being able to compare the languages as I learned. I want to give the Java book some credit--it did a better job of explaining some concepts such as Object Oriented design and programming. It was interesting to see how the different languages tackled things such as inheritance.

Learning two languages at once definitely tripped me up. If I was working through the Python book one day and then tried to write some Java code the next, I'd start to do the wrong comment syntax or forget to put in semicolons. It even tripped up my JavaScript: a few times I forgot I wasn't writing Python and neglected to include parenthesis around my if statement conditions and wondered why VS Code was giving me the red squiggles.

Other than finishing the Python book, I'm planning on continuing to practice the language with side projects. I'm coding in Java regularly and hopefully I'll find some resources that suit me a little better.

*I realize this is so much more complicated than I'm making it out to be here. This is not a post about how different languages handle memory allocation. This is just a gut-level dislike I have towards writing Java.

Cover image by Christopher Gower on Unsplash.
Danger Noodle mug image is a mug you can actually buy! I failed to find the python-drinking-coffee image I really wanted to use for this post.

Top comments (18)

silentsudo profile image
Ashish Agre • Edited

similary what happens when i learn Java & Angular at the same time

  • java = String name & angular =name: string
  • java =() -> {} & angular =() => {}
nezam05 profile image
Nezam uddin

You probably meant Typescript instead of Angular

dmahely profile image
Doaa Mahely

Thanks for sharing Alli!

I tried to learn Python and JavaScript at around the same time until I spent 30 minutes wondering why list.push(i) didn't work in Python! 😆
Java was my first language so it will always have a special place in my heart, but now my go-to is definitely Python.

javaarchive profile image

I had a similar experience where the interperter complained about me using list.add(item). To be honest, I think it's good not to stay with one language too long because you'll forget the rest

ivej profile image

Let try list.append(i)

scottshipp profile image

The Java tutorials are pretty good for learning Java, actually, and it's nice that they're free!

If you learn better out of a book, Cay Horstmann's Core Java is considered the benchmark and takes a very different approach than Head First Java.

alli profile image
Alli Teration

Many thanks! I’ll check those out.

andevr profile image

I might be in the minority here, but I love Java, partly because of the static nature, and partly because I've now seen what can be done with it. (I'm still learning, so take what I say with a grain of salt lol.) I struggled on and off for years with JavaScript trying to learn it. I ran into Tim Buchalca's Java masterclass on Udemy and that has been the catalyst for getting me unstuck. It has so many exercises in it, and a lot of them (I think) are useful. It can be had for maybe 10/12 dollars is typical if it's on sale.

Zed is opinionated, but he is a decent guy and wants the best for people who use his books etc. He'sanswered every question I've ever asked (I'm beta testing his javascript book) and for the most part seems pretty mellow and genuine.

Great post, thank you for sharing :)

wrldwzrd89 profile image
Eric Ahnell

As someone who regularly uses Java, JavaScript and Python, electing to self-teach all three... I can confidently say I've been there! More importantly, I've emerged from it a better programmer. Best of luck on your own efforts!

rhymes profile image

Great post Alli!

First of all, the Python developers I knew loved their Python

Ahaha this is so true. If you like Python, it's hard to let it go. It also changed career course, for me personally.

BTW having a Java codebase at your disposal at work should help learning Java with a combination of formal reading and tinkering :D

Zed has you type out a lot of code from the book, which seems silly but it helped me get used to the syntax.

Yeah, even if it's just a tutorial, typing code can help. After all the reason why they used to make you transcribe things at school was also to learn new words, not just practice calligraphy and concentration :D

The tone of Learn Python the Hard Way is much harsher than Head First Java and Zed Shaw can be quite opinionated about things.

Ahaha Zed Shaw is famous for being opinionated. He used to be a Rubyist that exited the community with a famous article: Rails is a ghetto. He then landed in the Python community with strong opinions as well.

I like Python more than Java.

Thank the heavens :P

At first I was turned off by Python's specific rules about spacing, but now I'm completely on board.

I remember that, it lasted only a very short time because I was coming from languages that didn't have spacing as part of the syntax. I was sold on the simplicity of it all, there are ways to complicate it though

I particularly don't like having to decide which number type I want to use

Another thing I don't like about Java is all the recompiling.

I feel you, I think you'll find yourself at home with Python. And if you really want to, you can play with optional type annotations.

Learning two languages at once definitely tripped me up.

Yeah, definitely do not recommend it, but it's doable as you just demonstrated.

Have fun!

zenulabidin profile image
Ali Sherief

If you don't mind, I'm trying to do something crazier and learn 8 (!!) languages all at once. As you can see from my posts I know Python more than the rest, but that's because I started writing with it a few years ago but I haven't kept up with the momentum at programming anything. So my mind could use some oiling for that PyPI library knowledge.

The only resource I'm using to learn all these things is HackerRank, especially their "30 days of code" tutorial, which I almost want to call a bootcamp. It feels rewarding and all but I only have time for one lesson a day for all the languages. Sometimes on particularly unhappy busy days I can only complete one for some languages. And then there's C++, Java, JS, PHP, Ruby, Go, Scala, Rust (yes, I'm weird).

Having said all that, this is a long term action and I expect to finish the tutorial in 6 months, not 30 days. Sometime I don't feel like learning and take a break like I'm doing now.

Now let me tell you about one language that gives me the jeebies: Go. It's not the C-like syntax I've come to be familiar with, all type names go after the variable, and my least favorite pet peeve, there is no implicit type conversion allowed. Don't get me wrong, I have no problem with data types like the ones in Java, it's just that I dislike converting from int32 to int just to use a numeric function or using a counter that I created for a for loop.

But I still like Go, because there is tremendous opportunity in being able to use trending libraries written in the language.

vedgar profile image
Vedran Čačić

you want to pick the type that uses the least amount of memory possible

Not really. Since you're using Java the Behemoth anyway, shaving a few bytes shouldn't be a priority. Much more important is the speed (not to mention correctness;), and on most modern architectures the native 64bit (or 32, sometimes) integer is faster than all the size-restricted ones.

galgreenfield profile image

Great article - thank you for sharing your experience! :)
It was an interesting read.

iamsivav profile image
Sivaraj Velayutham

Thanks for sharing your experience. I am a java developer ( 11+ ) and started learning python in 2016. I agree Python is easy to learn compared to Java. Java may take some more months to learn and acquire proficiency. To master any language is to practice them. The more-hard you practice, the more-easy they become. As you started learning both languages, Keep practicing them. It's one more weapon in your arsenal.

stephvan profile image

Wow... This is incredible. I tried this once and gave up. Cos there wasn't a goal attached to it

alli profile image
Alli Teration

Having a goal in mind really helped motivate me!

rohitshetty profile image
Rohit Shetty

"What Happened When I Learned Java and Python at the Same Time" ?
You took a screenshot.

safisec profile image