<?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 Jacob Abraham on Medium]]></title>
        <description><![CDATA[Stories by Jacob Abraham on Medium]]></description>
        <link>https://medium.com/@jacobabraham_11893?source=rss-de3e761e2bd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iJ0neheU0o4IBLvutPUfiw@2x.jpeg</url>
            <title>Stories by Jacob Abraham on Medium</title>
            <link>https://medium.com/@jacobabraham_11893?source=rss-de3e761e2bd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:20:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jacobabraham_11893/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[Ruby vs Java]]></title>
            <link>https://medium.com/@jacobabraham_11893/the-magic-of-ruby-from-an-ex-java-man-63f9df0366f8?source=rss-de3e761e2bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/63f9df0366f8</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jacob Abraham]]></dc:creator>
            <pubDate>Sat, 03 Feb 2018 22:32:49 GMT</pubDate>
            <atom:updated>2018-02-11T07:41:48.172Z</atom:updated>
            <content:encoded><![CDATA[<p>As someone who primarily used Java as his first language, finding out I had to use Ruby for my first full-time job was well…a little nerve-wracking. Five months after, here is what I learned.</p><h4>Printing To Console</h4><p>Java</p><pre>System.out.println(&quot;Hello World!&quot;);</pre><p>Ruby</p><pre>puts “Hello World!”</pre><p>Not much else to say here.</p><h4>Other Cool Things</h4><p>I dont have a problem with Java&#39;s syntax. Its not bad, but its not that great either.</p><pre>public static void main(String[] args) {  <br>  int result = 0;<br>  <br>  for(int i=0;i&lt;5;i++){<br>    result+=i<br>  }</pre><pre>  if(result &gt; 5){<br>    return result;<br>  }<br>  if(result &lt; 50){<br>    return 50;<br>  } </pre><pre>}</pre><p>Nothing too crazy here. Let’s check the ruby version of this.</p><pre>def main<br>  5.times.do |i| <br>    @result+=i<br>  end<br>  return result if result &gt; 5<br>  return 50 if result &lt; 50<br>end</pre><p>This is just easier to read and understand in my opinion.</p><p>Like Java, Ruby is also an OOP (Object Oriented Programming) language. Therefore, efficent class design is crucial to the implementation of robust, maintainable applications. One of the fundamental principles of OOP is <a href="https://www.tutorialspoint.com/java/java_encapsulation.html">Encapsulation</a>. This is implemented in Java through the use of getter and setter methods.</p><pre>public class Student {</pre><pre>  private String name;<br>  <br>  public String getName(){<br>    return name;<br>  }</pre><pre>  public void setName(String name){<br>    this.name = name;<br>  }</pre><pre>}</pre><pre>Student student = new Student(&#39;Jacob&#39;);<br>System.out.println(student.getName());<br>student.setName(&#39;Jake&#39;);</pre><p>Encapsulation is important, so creating these methods are necessary, but cumbersome. Ruby provides us with a much more compact solution</p><pre>class Student<br>  attr_accessor :name</pre><pre>  def initialize(name)<br>    @name = name<br>  end <br>end</pre><pre>student = Student.new(&#39;Jacob&#39;)<br>puts student.name<br>student.name = &#39;Jake&#39;</pre><p>The ‘<em>attr_accessor’ </em>essentially serves as the getter and setter method for the instance variable<em> name.</em> This is much more convienient than taking the time to write seperate methods for each instance variable in the class.</p><p>Method arguments are another area where ruby is able to really shine. One neat feature is hash arguments. Lets say we have a method that creates a Student object, and this method’s arguments will be used to update the fields of the object.</p><p>Java</p><pre>public Student newStudent(String name, int id, String email, String cellNumber){<br>  return new Student(name, id, email, cellNumber);<br>}</pre><p>Ruby</p><pre>def create_student(args)<br>Student.new(args[:name],args[:id],args[:email], args[:cell_number]<br>end</pre><pre>...</pre><pre>create_student(name:&#39;Jacob&#39;,id:1,email:&#39;jacob@email&#39;,cell_number:&#39;000-000-0000&#39;)</pre><p>What’s nice here is that we are able to keep the method compact and more readable. Explicitly having to write out each attribute as a parameter in Java makes the code much more cluttered.</p><p>There are a lot more examples I could write about that highlights ruby’s ease of use, but I’ll stop here.</p><p>So here is my takeaway: Ruby syntax is very clean and concise. Because of this, writing beautiful code is an essential part of being a great ruby programmer.</p><p>So for now, I bid farwell to you Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*sEUQ6OCNLQCtGFo0nb-aVQ.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63f9df0366f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>