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?

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.

原文链接:What Happened When I Learned Java and Python at the Same Time

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
People are not just to love and live.
人不是仅仅为了爱而生存的
评论 抢沙发

请登录后发表评论

    暂无评论内容