Very often, we get involved in using one language to solve all of our business problems. It’s easy for us, as we know a lot about the language and can conjure up different solutions quickly. However, a solution in a different language may require fewer lines of code and be delivered faster.
Learning a new language opens up new ways of thinking and thus helps to have a flexible mindset. Add another bow on our arrow to solve a business problem. It also helps you get a raise if you play your cards right.
This post provides a step-by-step approach to help you learn new technologies. I used these steps to go from Java to Python about 2 years ago.
Step 0: get an IDE
IDEs have come a long way in improving developer productivity by making coding easier. When I started, one among my colleagues said, “If you would like to find out Java, you’ve got to find out to write down code during a notepad and not in Eclipse.” Years of experience tell me it was bad advice. The goal of a developer is to solve a business problem and the IDE is a useful tool in its box.
We can start using Python on the command line itself. But we cannot build complex logic on the instruction. So I decided on an IDE.
I used IntelliJ IDEA for Java development. So using the community version of PyCharm was almost a no-brainer. I did my research and the next best tool was VS Code. But any of the IDEs is good. The benefit of PyCharm for me was that I could still use the same shortcuts and therefore I followed it.
Step 1: Learn Philosophy And Rationale For Python
It is vital to know the philosophy of the new language. This gives me an idea of what I’m getting into. Python has it set to Zen of Python. I have provided it below for reference.
The beautiful is better than the ugly.
Explicit is better than implicit.
Better is simple than complex.
The complex is better than the complicated one.
The flat is better than nested.
It is better sparse than dense.
Special cases aren’t special enough to interrupt the principles.
Although practicality beats purity.
Errors should never happen silently.
Unless it’s explicitly muted.
In the face of ambiguity, refuse the temptation to guess.
There should be one, and preferably only one, obvious way to do it.
Although that form may not be obvious at first unless you are Dutch.
Now is better than ever.
Although it’s often never better than * right now *.
If the implementation is difficult to elucidate, it’s a nasty idea.
If the implementation is straightforward to elucidate, it’s going to be an honest idea.
Namespaces are a great idea, let’s do more of that!
Zen of Python is beautiful and all the code I write in Python tries to follow these principles. This also helps with code reviews.
Step 2: Write A “Hello World” Program.
After all the reading, the first program we need to write is the “Hello World” program. It is the simplest and fastest thanks to starting. The advantages of the key things are:
A practical view of the code structure
Write code instead of copy and paste
A little ego boost and an affirmation that I can do this.
Step 3: Write Simple Programs With Control Structures And Data Types
This is where the skills learned in Java come in handy. For any code we write, we need to have below:
Type of data
Write simple programs to use the learnings from reading all the documentation. This can range from printing the Fibonacci series to writing simple APIs. It will expose us to the nuts and bolts of writing real code.
The idea is to learn how I can do “this” in Python, what I could do in Java.
Step 4: Confirm Departures Quickly
Learning is challenging as we go through uncertainty. It tests our existing mental patterns. Dripping small hits into the process makes the journey a little easier.
Instead of writing entire programs in one go, I build small incremental pieces. Then I run the code to check for problems. So even if I have to go to the bathroom, I know that I have completed x% of the task and it works. This provides us with feedback on progress and thus helps us stay on track.
Incremental progress validation will establish new pathways in the brain.
Step 5: Learn To Write Code Tests
Writing tests are one of the easiest ways to learn to code. Having tests will help you test different solutions and get better solutions than the first job program.
I started by writing tests in PyTest. Now I know of an additional library and understand my code better.
Step 6: Use Sample Examples From The Planet
Google has all the solutions. The trick is to understand which solution best suits your problem.
Using tests from the last step, we can test different solutions. This provides a deeper understanding of the complexities of the language.
Ingrained concepts in working with Java help to analyze different solutions. Some solutions may be good but are better suited for later use.
In rare cases, some solutions may cause you to rewrite the existing Java code. This is the unexpected advantage of learning something new.
Researching many solutions improves understanding of new technology. Create a library of new patterns that we can use later.