You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
6.0 KiB
159 lines
6.0 KiB
11 months ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||
|
|
||
|
<!-- Enable responsiveness on mobile devices-->
|
||
|
<!-- viewport-fit=cover is to support iPhone X rounded corners and notch in landscape-->
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, viewport-fit=cover">
|
||
|
|
||
|
<title>Julio Biason .Me 4.3</title>
|
||
|
|
||
|
<!-- CSS -->
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/print.css" media="print">
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/poole.css">
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/hyde.css">
|
||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body class=" ">
|
||
|
|
||
|
<div class="sidebar">
|
||
|
<div class="container sidebar-sticky">
|
||
|
<div class="sidebar-about">
|
||
|
|
||
|
<a href="https://blog.juliobiason.me"><h1>Julio Biason .Me 4.3</h1></a>
|
||
|
|
||
|
<p class="lead">Old school dev living in a 2.0 dev world</p>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<ul class="sidebar-nav">
|
||
|
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/">English</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/pt">Português</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/tags">Tags (EN)</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/pt/tags">Tags (PT)</a></li>
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="content container">
|
||
|
|
||
|
<div class="post">
|
||
|
<h1 class="post-title">Introducing Erlang: Getting Started in Functional Programming - Simon St. Laurent</h1>
|
||
|
<span class="post-date">
|
||
|
2020-08-05
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/books/">#books</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/reviews/">#reviews</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/simon-st-laurent/">#simon st laurent</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/erlang/">#erlang</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/it/">#it</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/books-2020/">#books:2020</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/stars-2/">#stars:2</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/published-2012/">#published:2012</a>
|
||
|
|
||
|
</span>
|
||
|
<p><a href="https://www.goodreads.com/book/show/15811999-introducing-erlang">GoodReads Summary</a>:
|
||
|
If you’re new to Erlang, its functional style can seem difficult, but with
|
||
|
help from this hands-on introduction, you’ll scale the learning curve and
|
||
|
discover how enjoyable, powerful, and fun this language can be.</p>
|
||
|
<span id="continue-reading"></span><div>
|
||
|
★★☆☆☆
|
||
|
</div>
|
||
|
<p>Again, an "Introducing" book that one shouldn't expect some deep explanations,
|
||
|
but heck, this felt shallower than <a href="https://blog.juliobiason.me/reviews/books/introducing-elixir/">Introducing
|
||
|
Elixir</a>.</p>
|
||
|
<p>It follows the same path of the "Introducing Elixir" (or maybe it is the other
|
||
|
way around, but hey, that's the order I read both), by creating a "what speed
|
||
|
will something crash if dropped in different planets" library and exploring
|
||
|
changes.</p>
|
||
|
<p>But the biggest drawback is that the book sticks too much into the Erlang
|
||
|
Shell and absolutely nothing (besides "here is one thing you can search for")
|
||
|
outside it. I mean, sure, the language may be nice and fun and all that, but
|
||
|
what's the point if the build tool is a pain and dependency resolution is
|
||
|
inexistent -- and I'm not saying Erlang suffers from that, 'cause as a
|
||
|
learning path, the book says <em>nothing</em> about those things.</p>
|
||
|
<p>For seeing how the language looks like, it's a good book. For something more
|
||
|
<em>real</em>... far away from it.</p>
|
||
|
<h2 id="highlights">Highlights</h2>
|
||
|
<blockquote>
|
||
|
<p>go to the command line and type erl </p>
|
||
|
</blockquote>
|
||
|
<p><em>Note</em>: <code>erl</code> is the Erlang Shell.</p>
|
||
|
<blockquote>
|
||
|
<p>3> 2#1010111. </p>
|
||
|
</blockquote>
|
||
|
<p><em>Note</em>: Binary notation.</p>
|
||
|
<blockquote>
|
||
|
<p>4> 16#cafe </p>
|
||
|
</blockquote>
|
||
|
<p><em>Note</em>: Hex notation.</p>
|
||
|
<blockquote>
|
||
|
<p>FallVelocity = fun(Distance) -> math:sqrt(2 * 9.8 * Distance) end.</p>
|
||
|
</blockquote>
|
||
|
<p><em>Note</em>: <code>fun</code> creates an anonymous function; it is then associated with the
|
||
|
name <code>FallVelocity</code> (all variables need to start with an upcase letter).</p>
|
||
|
<blockquote>
|
||
|
<p>-module(drop).<br>
|
||
|
-export([fall_velocity/1, mps_to_mph/1, mps_to_kph/1]).<br><br>
|
||
|
fall_velocity(Distance) -> math:sqrt(2 * 9.8 * Distance). <br>
|
||
|
mps_to_mph(Mps) -> 2.23693629 * Mps.<br>
|
||
|
mps_to_kph(Mps) -> 3.6 * Mps.</p>
|
||
|
</blockquote>
|
||
|
<blockquote>
|
||
|
<p>-module(combined).<br>
|
||
|
-export([height_to_mph/1]).<br>
|
||
|
-import(drop, [fall_velocity/1]).<br>
|
||
|
-import(convert, [mps_to_mph/1]).<br>
|
||
|
height_to_mph(Meters) -> mps_to_mph(fall_velocity(Meters)). </p>
|
||
|
</blockquote>
|
||
|
<blockquote>
|
||
|
<p>In Erlang, greater-than-or-equal-to is written as >=, and
|
||
|
less-than-or-equal-to as =<. Don’t make them look like arrows. </p>
|
||
|
</blockquote>
|
||
|
<blockquote>
|
||
|
<p>try <br>
|
||
|
math:sqrt(2 * Gravity * Distance) <br>
|
||
|
catch <br>
|
||
|
error:Error -> {error, Error} end.</p>
|
||
|
</blockquote>
|
||
|
<blockquote>
|
||
|
<p>Creating a map requires a different syntax presenting keys and values:<br>
|
||
|
1> Planemos = #{ earth => 9.8, moon => 1.6, mars => 3.71 }.<br>
|
||
|
#{earth => 9.8,mars => 3.71,moon => 1.6} </p>
|
||
|
</blockquote>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|