<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jdfolino</title>
    <description>The latest articles on DEV Community by jdfolino (@jdfolino).</description>
    <link>https://dev.to/jdfolino</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F358020%2Ff89ea105-a5f3-4df0-a755-e33aa700c14e.jpeg</url>
      <title>DEV Community: jdfolino</title>
      <link>https://dev.to/jdfolino</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jdfolino"/>
    <language>en</language>
    <item>
      <title>Day 1: Erlang Hello World</title>
      <dc:creator>jdfolino</dc:creator>
      <pubDate>Mon, 30 Mar 2020 23:05:21 +0000</pubDate>
      <link>https://dev.to/jdfolino/erlang-hello-world-82d</link>
      <guid>https://dev.to/jdfolino/erlang-hello-world-82d</guid>
      <description>&lt;p&gt;Ok so after being a Java and Ruby guy for 13 years it is time for me to learn some Erlang for my new job. &lt;/p&gt;

&lt;p&gt;Hello World in Ruby is extremely easy. You just open up the terminal and run the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s1"&gt;'Hello World'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;My initial attempt to do something similar in Erlang found no simple one liner to do so. Below is Hello World in Erlang:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight erlang"&gt;&lt;code&gt;&lt;span class="c"&gt;% hello.erl
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="ni"&gt;module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="ni"&gt;export&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;hello_world&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;

&lt;span class="nf"&gt;hello_world&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nf"&gt;fwrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello, world&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;My inner nerd found a few things to get excited about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You finish each line with a full stop. This is just so logical and makes sense. When I started with java 13 years ago I always wondered why they used a semi colon instead of a full stop.&lt;/li&gt;
&lt;li&gt;You declare the function to export with the arity. This is cool because you can see at glance how many arguments the function will take&lt;/li&gt;
&lt;li&gt;Function declaration on a single line could mean we have nice, concise code &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How do you run this code? You open the Erlang shell, compile the code in the shell (never seen that before) and then you call the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;1&amp;gt; c&lt;span class="o"&gt;(&lt;/span&gt;hello&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;ok,hello&lt;span class="o"&gt;}&lt;/span&gt;

2&amp;gt; hello:hello_world&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
hello, world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;c(hello).&lt;/code&gt; literally compiles the hello.erl file. Another neat thing is how each time you evaluate a line it updates the number in the shell.&lt;/p&gt;

</description>
      <category>erlang</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
