<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sivarajan on Medium]]></title>
        <description><![CDATA[Stories by Sivarajan on Medium]]></description>
        <link>https://medium.com/@siva.learning2022?source=rss-89a9a43b0434------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*J1ctyXxE3Gr3_PadBjil0A.png</url>
            <title>Stories by Sivarajan on Medium</title>
            <link>https://medium.com/@siva.learning2022?source=rss-89a9a43b0434------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:27:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@siva.learning2022/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Slithering into Java: A Pythonista’s Curious Expedition into the JVM Jungle]]></title>
            <link>https://medium.com/@siva.learning2022/slithering-into-java-a-pythonistas-curious-expedition-into-the-jvm-jungle-ef6c93c16c88?source=rss-89a9a43b0434------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef6c93c16c88</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Sivarajan]]></dc:creator>
            <pubDate>Sun, 11 May 2025 10:48:23 GMT</pubDate>
            <atom:updated>2025-05-11T13:14:31.873Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aUbTYqHT18Ek6BR8" /><figcaption>Photo by <a href="https://unsplash.com/@fahmipaping?utm_source=medium&amp;utm_medium=referral">Fahmi Fakhrudin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It all started on a humble day in December 2018, when I was jumping into JavaScript to ace my front-end development skills. It was the very first time I worked with a dynamically typed language like JavaScript, and my mind was blown by the capabilities it had. By then, I had decided I would become a serious coder and a programmer.</p><p>It is now 2025, and I have explored a variety of tools and technologies. In all these years, I have been a serious Python programmer. If you ask me why, then you really haven’t tasted the Snake Juice that Python has to offer!</p><p>Knowing Python for almost 6 years, I have been inspired by how the language makes everything simple, and there are no strict rules to make things happen. You just write code and it runs. It could be dirty, smelly, and bad — but it still works.</p><p>By this January, I had a very sharp instinct to learn Java. I had been hoarding courses on different technologies to explore them, and Java had been there for almost 3 years. I bought the whole mastery course from <a href="http://www.codewithmosh.com/">www.codewithmosh.com</a>, which is a huge blessing in disguise. I did try to start them a couple of times by 2023, but then I decided I would be a Python programmer for a lifetime. But this January, I started learning Java, and my perspective on understanding coding and programming paradigms has been completely reset.</p><blockquote>“If you really want to master Python, then you need to learn a statically typed, middle-level language like Java”</blockquote><p>I have now completed a three-part course on Java where I dabbled in:</p><ul><li>Classes</li><li>Interfaces</li><li>Generics</li><li>Streams</li><li>Threading and the Execution Framework</li></ul><p>And I have to say, it really makes sense why they built Python the way they did. In Python, all the data structures are built out like generics in Java(though it’s not strictly enforced that way). There are no interfaces in Python, but you can still build classes that are not tightly coupled. Maybe the declarative typing of code (streams) has not been widely adopted in Python, but we do have Pandas, where some of the syntax feels declarative in nature.</p><p>The best part of Java that I liked is how everything is very organized. It means that if you need to build something, you have to create a proper class, add your access specifiers, attributes, and your getters and setters in the correct way. If one of the components of the code is not working, then your code breaks — which really ensures you do the right thing, regardless of your opinion.</p><p>In the course, we learned about a mortgage calculator. Before adapting to object-oriented design, it was chaos. This is how it would have been in Python code if the developer were an amateur. But still, incredibly, it would have worked and could have easily slipped into production.</p><p>By the time I got to learn classes in Java, it made a lot of sense why object-oriented programming is so widely adopted. In Python, we did learn classes and inheritance, but putting it into practice was very questionable due to Python’s duck typing.<br> By applying the classes and syntax, I learned one thing for certain.</p><blockquote>Coding has always been built to facilitate its earlier functionalities and support developers who had adapted to old practices. For any new developer who jumps into Python, it’s easy to miss why things are built the way they are — and this is a huge pitfall.</blockquote><p>Luckily, I completed the course for what it is. But as a tech monk who has been on this incredible spiritual coding journey, I will lay the path for those skeptical Python developers who are choosing Java. Check out my discussion below — it might help you understand why Java could be a great language to learn.</p><h3>Implementing a class — Python vs Java</h3><p>In this section, I am going to share you the same code in Java as well as in python. Look at the below code for making / brewing coffee.</p><pre>from abc import ABC, abstractmethod<br><br>class Coffee(ABC):<br>    def __init__(self, name):<br>        self.name = name<br><br>    @abstractmethod<br>    def brew(self):<br>        pass<br><br># sub classes start here... <br>class Espresso(Coffee):<br>    def __init__(self):<br>        super().__init__(&quot;Espresso&quot;)<br><br>    def brew(self):<br>        return &quot;Brewing a strong shot of espresso!&quot;<br><br>class Latte(Coffee):<br>    def __init__(self):<br>        super().__init__(&quot;Latte&quot;)<br><br>    def brew(self):<br>        return &quot;Steaming milk and adding it to espresso for a latte.&quot;<br><br>class Mochachino(Coffee):<br>    def __init__(self):<br>        super().__init__(&quot;Mochachino&quot;)<br><br>    def brew(self):<br>        return &quot;Mixing chocolate, milk, and espresso for a mochachino.&quot;<br><br>class Cappuccino(Coffee):<br>    def __init__(self):<br>        super().__init__(&quot;Cappuccino&quot;)<br><br>    def brew(self):<br>        return &quot;Creating a cappuccino with frothy milk and espresso.&quot;<br><br># Usage<br>coffees = [Espresso(), Latte(), Mochachino(), Cappuccino()]<br><br>for coffee in coffees:<br>    print(f&quot;{coffee.name}: {coffee.brew()}&quot;)</pre><p>Now a similar code written in Java</p><pre>abstract class Coffee {<br>    protected String name;<br><br>    public Coffee(String name) {<br>        this.name = name;<br>    }<br><br>    public abstract String brew();<br><br>    public String getName() {<br>        return name;<br>    }<br>}<br><br>// sub classes start here.. <br><br>class Espresso extends Coffee {<br>    public Espresso() {<br>        super(&quot;Espresso&quot;);<br>    }<br><br>    @Override<br>    public String brew() {<br>        return &quot;Brewing a strong shot of espresso!&quot;;<br>    }<br>}<br><br>class Latte extends Coffee {<br>    public Latte() {<br>        super(&quot;Latte&quot;);<br>    }<br><br>    @Override<br>    public String brew() {<br>        return &quot;Steaming milk and adding it to espresso for a latte.&quot;;<br>    }<br>}<br><br>class Mochachino extends Coffee {<br>    public Mochachino() {<br>        super(&quot;Mochachino&quot;);<br>    }<br><br>    @Override<br>    public String brew() {<br>        return &quot;Mixing chocolate, milk, and espresso for a mochachino.&quot;;<br>    }<br>}<br><br>class Cappuccino extends Coffee {<br>    public Cappuccino() {<br>        super(&quot;Cappuccino&quot;);<br>    }<br><br>    @Override<br>    public String brew() {<br>        return &quot;Creating a cappuccino with frothy milk and espresso.&quot;;<br>    }<br>}<br><br>public class CoffeeMachine {<br>    public static void main(String[] args) {<br>        Coffee[] coffees = {<br>            new Espresso(),<br>            new Latte(),<br>            new Mochachino(),<br>            new Cappuccino()<br>        };<br><br>        for (Coffee coffee : coffees) {<br>            System.out.println(coffee.getName() + &quot;: &quot; + coffee.brew());<br>        }<br>    }<br>}</pre><p>While python might be looking very clean both the codes are the same. The power you get in java is you control the below aspects compared to python which it manages underneath.</p><ul><li>Abstract class is not inherited from another module, but rather you need to define that class is abstract (which cannot be accessed easily outside)</li><li>@override method is used to over ride the abstract method brew()</li><li>Access specifiers are added in attributes and methods</li><li>extends keyword is used to define the inheritance.</li><li>finally super() in both python and Java, since the class is inheriting from a parent class.</li></ul><p><strong>Final inference :</strong> The only thing you need to learn is the syntactical changes and pretty much the concepts are same. But for any new beginner to python, they might have not taken an initiative to learn this where it might have been over whelming at first. But eventually you will understand</p><ul><li>The extends keyword was explicitly used to inherit attributes and methods</li><li>The @override keyword is used to override a parent method which is inherited</li><li>Constructor are both initialized in Java and python. The super keyword is used in both to utilize the parent constructor.</li><li>Inheriting the brew() method is the core power of this code implementation.</li></ul><h3>Interfaces — Python vs Java</h3><p>While python does not have a formal interface like Java, <strong>it is still very much achievable to implement an interface in Python. In fact you have been doing this, but you just don’t know you have been!</strong></p><p>Check out the below python code where a program is built to simulate a restaurant</p><pre>from abc import ABC, abstractmethod<br><br># Interfaces as abstract base classes<br>class Caterer(ABC):<br>    @abstractmethod<br>    def prepare_food(self):<br>        pass<br><br>class Waiter(ABC):<br>    @abstractmethod<br>    def serve_table(self):<br>        pass<br><br>class EntertainmentCrew(ABC):<br>    @abstractmethod<br>    def perform_show(self):<br>        pass<br><br># Implementations<br>class ItalianCaterer(Caterer):<br>    def prepare_food(self):<br>        return &quot;Preparing pasta, risotto, and tiramisu.&quot;<br><br>class FineDiningWaiter(Waiter):<br>    def serve_table(self):<br>        return &quot;Serving food with silverware and elegance.&quot;<br><br>class JazzBand(EntertainmentCrew):<br>    def perform_show(self):<br>        return &quot;Playing smooth jazz for the guests.&quot;<br><br># Demo<br>if __name__ == &quot;__main__&quot;:<br>    caterer = ItalianCaterer()<br>    waiter = FineDiningWaiter()<br>    crew = JazzBand()<br><br>    print(caterer.prepare_food())<br>    print(waiter.serve_table())<br>    print(crew.perform_show())</pre><p>Now the same implementation in Java</p><pre>// Interfaces<br>interface Caterer {<br>    String prepareFood();<br>}<br><br>interface Waiter {<br>    String serveTable();<br>}<br><br>interface EntertainmentCrew {<br>    String performShow();<br>}<br><br>// Implementations<br>class ItalianCaterer implements Caterer {<br>    public String prepareFood() {<br>        return &quot;Preparing pasta, risotto, and tiramisu.&quot;;<br>    }<br>}<br><br>class FineDiningWaiter implements Waiter {<br>    public String serveTable() {<br>        return &quot;Serving food with silverware and elegance.&quot;;<br>    }<br>}<br><br>class JazzBand implements EntertainmentCrew {<br>    public String performShow() {<br>        return &quot;Playing smooth jazz for the guests.&quot;;<br>    }<br>}<br><br>// Main<br>public class Restaurant {<br>    public static void main(String[] args) {<br>        Caterer caterer = new ItalianCaterer();<br>        Waiter waiter = new FineDiningWaiter();<br>        EntertainmentCrew crew = new JazzBand();<br><br>        System.out.println(caterer.prepareFood());<br>        System.out.println(waiter.serveTable());<br>        System.out.println(crew.performShow());<br>    }<br>}</pre><p>Interfaces define what should exist in a class and both these codes illustrate the same. The only difference which python has it does not use the implements keyword. And that’s a huge miss for any developer who is starting with python. Besides the interfaces in Java are syntactically less compared to the python version where you need to define a @abstractmethod decorator.</p><h3>Final take</h3><p>Plenty of examples like this exist in Java. I am only illustrating this 2 examples. You just have to learn it to understand. Note that this article is specifically for those who are into Python but wish to learn Java. I would say, <em>“Please go ahead and explore!”</em></p><p><strong>To summarize:</strong> the intricacies of coding patterns are not visible to a beginner programmer who is adopting Python as their go-to language. But the cool thing is — they don’t have to. Python was built to overcome such code syntax issues that caused errors. While it’s okay to skip these aspects of the programming paradigm, it’s important to know and learn a standard language like Java, which gives great insight and perspective into coding and learning programming.</p><p>I can now pick up some amazing patterns in my Python code and build on them — and while doing so, I use the @abstractmethod and @staticmethod decorators. But only I know why I really use them. :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef6c93c16c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>