Skip to content

Commit 8e9bb23

Browse files
committed
Simplify crash course
1 parent 25456c1 commit 8e9bb23

File tree

2 files changed

+5
-46
lines changed

2 files changed

+5
-46
lines changed

crash-course.markdown

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Invoking a function from a module uses different syntax. In Erlang, you would wr
167167
lists:last([1, 2]).
168168
```
169169

170-
to invoke the `last` function from the `List` module. In Elixir, use the dot `.` in place of the colon `:`
170+
to invoke the `last` function from the `lists` module. In Elixir, use the dot `.` in place of the colon `:`
171171

172172
```elixir
173173
List.last([1, 2])
@@ -312,7 +312,7 @@ kw[:another_key]
312312

313313
### Maps
314314

315-
Erlang R17 introduced maps, a key-value store, with no ordering. Keys and values can be any term. Creating, updating and matching maps in both languages is shown below:
315+
Maps are key-value pairs with no ordering. Keys and values can be any term. Creating, updating and matching maps in both languages is shown below:
316316

317317
**Erlang**
318318

@@ -361,18 +361,6 @@ Regex.run(~r/abc\s/, "abc ")
361361
#=> ["abc "]
362362
```
363363

364-
Regexes are also supported in heredocs, which is convenient when defining multiline regexes:
365-
366-
```elixir
367-
Regex.regex?(~r"""
368-
This is a regex
369-
spanning several
370-
lines.
371-
""")
372-
#=> true
373-
```
374-
375-
376364
## Modules
377365

378366
Each Erlang module lives in its own file which has the following structure:
@@ -450,10 +438,9 @@ HelloModule.Utils.priv()
450438
#=> ** (UndefinedFunctionError) undefined function: HelloModule.Utils.priv/0
451439
```
452440

453-
454441
## Function syntax
455442

456-
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, I'm briefly covering the main points and provide sample code both in Erlang and Elixir.
443+
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, we briefly cover the main points and provide sample code both in Erlang and Elixir.
457444

458445
[3]: http://learnyousomeerlang.com/syntax-in-functions
459446

@@ -835,7 +822,6 @@ after
835822
end
836823
```
837824

838-
839825
## Adding Elixir to existing Erlang programs
840826

841827
Elixir compiles into BEAM byte code (via Erlang Abstract Format). This means that Elixir code can be called from Erlang and vice versa, without the need to write any bindings. All Elixir modules start with the `Elixir.` prefix followed by the regular Elixir name. For example, here is how to use the UTF-8 aware `String` downcase from Elixir in Erlang:
@@ -848,33 +834,6 @@ downcase(Bin) ->
848834
'Elixir.String':downcase(Bin).
849835
```
850836

851-
### Rebar integration
852-
853-
If you are using rebar, you should be able to include Elixir git repository as a dependency:
854-
855-
https://github.com/elixir-lang/elixir.git
856-
857-
Elixir is structured similar to Erlang's OTP. It is divided into applications that are placed inside the `lib` directory, as seen in its [source code repository](https://github.com/elixir-lang/elixir). Since rebar does not recognize such structure, we need to explicitly add to our `rebar.config` which Elixir apps we want to use, for example:
858-
859-
```erlang
860-
{lib_dirs, [
861-
"deps/elixir/lib"
862-
]}.
863-
```
864-
865-
This should be enough to invoke Elixir functions straight from your Erlang code. If you are also going to write Elixir code, you can [install Elixir's rebar plugin for automatic compilation](https://github.com/yrashk/rebar_elixir_plugin).
866-
867-
### Manual integration
868-
869-
If you are not using rebar, the easiest approach to use Elixir in your existing Erlang software is to install Elixir using one of the different ways specified in the [Getting Started guide](https://hexdocs.pm/elixir/introduction.html) and add the `lib` directory in your checkout to `ERL_LIBS`.
870-
871-
872837
## Further reading
873838

874-
Erlang's official documentation site has a nice [collection][4] of programming examples. It can be a good exercise to translate them into Elixir.
875-
876-
Elixir also provides a [Getting Started guide][6] and has [documentation available online][7].
877-
878-
[4]: http://www.erlang.org/doc/programming_examples/users_guide.html
879-
[6]: https://hexdocs.pm/elixir/introduction.html
880-
[7]: /docs.html
839+
Both programming languages have plenty of resources available to dig deeper. Check out their respective websites ([Elixir](https://elixir-lang.org) and [Erlang](https://www.erlang.org)) for more information.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ <h4>Erlang compatible</h4>
196196
<<192, 223, 75, 115, ...>>
197197
{% endhighlight %}
198198

199-
<p>To learn more about Elixir, check our <a href="https://hexdocs.pm/elixir/introduction.html">Getting Started guide</a>. We also have <a href="/docs.html">online documentation available</a> and a <a href="/crash-course.html">Crash Course for Erlang developers</a>.</p>
199+
<p>To learn more about Elixir, check our <a href="https://hexdocs.pm/elixir/introduction.html">Getting Started guide</a>.</p>
200200
</div>
201201
</div>
202202
</div>

0 commit comments

Comments
 (0)