Skip to content

Commit dff4932

Browse files
josevalimggVGc
authored andcommitted
Remove explicit mentions to elixirc, as it isn't used in practice
1 parent 3490521 commit dff4932

File tree

3 files changed

+25
-46
lines changed

3 files changed

+25
-46
lines changed

lib/elixir/pages/getting-started/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ $ elixir simple.exs
5757
Hello world from Elixir
5858
```
5959

60-
Later on we will learn [how to compile Elixir code](modules-and-functions.md) and how to create and work within Elixir projects using the Mix build tool. For now, let's move on to learn the basic data types in the language.
60+
`iex` and `elixir` are all we need to learn the main language concepts. There is a separate guide named ["Mix and OTP guide"](../mix-and-otp/introduction-to-mix.md) that explores how to actually create, manage, and test full-blown Elixir projects. For now, let's move on to learn the basic data types in the language.

lib/elixir/pages/getting-started/module-attributes.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In the example above, we are defining the module documentation by using the modu
3232

3333
`@moduledoc` and `@doc` are by far the most used attributes, and we expect you to use them a lot. Elixir treats documentation as first-class and provides many functions to access documentation. We will cover them [in their own chapter](writing-documentation.md).
3434

35-
Let's go back to the `Math` module defined in the previous chapters, add some documentation and save it to the `math.ex` file:
35+
Documentation is only accessible from compiled modules. So in order to give it a try, let's once again define the `Math` module, but this time within a file named `math.ex`:
3636

3737
```elixir
3838
defmodule Math do
@@ -53,23 +53,29 @@ defmodule Math do
5353
end
5454
```
5555

56-
Elixir promotes the use of Markdown with heredocs to write readable documentation. Heredocs are multi-line strings, they start and end with triple double-quotes, keeping the formatting of the inner text. We can access the documentation of any compiled module directly from IEx:
56+
Elixir promotes the use of Markdown with heredocs to write readable documentation. Heredocs are multi-line strings, they start and end with triple double-quotes, keeping the formatting of the inner text.
5757

58-
```console
59-
$ elixirc math.ex
60-
$ iex
58+
Now let's compile it. Start `iex` and then invoke [the `c/2` helper](`IEx.Helpers.c/2`):
59+
60+
```elixir
61+
iex> c("math.ex", ".")
62+
[Math]
6163
```
6264

65+
And now we can access them:
66+
6367
```elixir
64-
iex> h Math # Access the docs for the module Math
68+
iex> h Math # Docs for module Math
6569
...
66-
iex> h Math.sum # Access the docs for the sum function
70+
iex> h Math.sum # Docs for the sum function
6771
...
6872
```
6973

70-
We also provide a tool called [ExDoc](https://github.com/elixir-lang/ex_doc) which is used to generate HTML pages from the documentation.
74+
When we compiled the module, you may have noticed Elixir created a `Elixir.Math.beam` file. That's the bytecode for the module and that's where the documentation is stored.
75+
76+
In our day to day, Elixir developers use the `Mix` build tool to compile code and projects like [ExDoc](https://github.com/elixir-lang/ex_doc) to generate HTML and EPUB pages from the documentation.
7177

72-
You can take a look at the docs for `Module` for a complete list of supported attributes. Elixir also uses attributes to annotate our code with [typespecs](../references/typespecs.md).
78+
Take a look at the docs for `Module` for a complete list of supported attributes.
7379

7480
## As temporary storage
7581

lib/elixir/pages/getting-started/modules-and-functions.md

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,13 @@ iex> Math.sum(1, 2)
2525
3
2626
```
2727

28-
In this chapter we will define our own modules, with different levels of complexity. As our examples get longer in size, it can be tricky to type them all in the shell. It's about time for us to learn how to compile Elixir code and also how to run Elixir scripts.
28+
In this chapter we will define our own modules, with different levels of complexity. As our examples get longer in size, it can be tricky to type them all in the shell, so we will resort more frequently to scripting.
2929

30-
## Compilation
30+
## Scripting
3131

32-
Most of the time it is convenient to write modules into files so they can be compiled and reused. Let's assume we have a file named `math.ex` with the following contents:
32+
Elixir has two file extensions `.ex` (Elixir) and `.exs` (Elixir scripts). Elixir treats both files exactly the same way, the only difference is in intention. `.ex` files are meant to be compiled while `.exs` files are used for scripting.
3333

34-
```elixir
35-
defmodule Math do
36-
def sum(a, b) do
37-
a + b
38-
end
39-
end
40-
```
41-
42-
This file can be compiled using `elixirc`:
43-
44-
```console
45-
$ elixirc math.ex
46-
```
47-
48-
This will generate a file named `Elixir.Math.beam` containing the bytecode for the defined module. If we start `iex` again, our module definition will be available (provided that `iex` is started in the same directory the bytecode file is in):
49-
50-
```elixir
51-
iex> Math.sum(1, 2)
52-
3
53-
```
54-
55-
## Scripting mode
56-
57-
In addition to the Elixir file extension `.ex`, Elixir also supports `.exs` files for scripting. Elixir treats both files exactly the same way, the only difference is in intention. `.ex` files are meant to be compiled while `.exs` files are used for scripting. This convention is followed by projects like `mix`.
58-
59-
For instance, we can create a file called `math.exs`:
34+
Let's create a file named `math.exs`:
6035

6136
```elixir
6237
defmodule Math do
@@ -74,15 +49,13 @@ And execute it as:
7449
$ elixir math.exs
7550
```
7651

77-
Because we used `elixir` instead of `elixirc`, the module was compiled and loaded into memory, but no `.beam` file was written to disk.
78-
79-
Elixir projects are usually organized into three directories:
52+
You can also load the file within `iex` by running:
8053

81-
* `_build` - contains compilation artifacts
82-
* `lib` - contains Elixir code (usually `.ex` files)
83-
* `test` - contains tests (usually `.exs` files)
54+
```console
55+
$ iex math.exs
56+
```
8457

85-
When working on actual projects, the build tool called `mix` will be responsible for compiling and setting up the proper paths for you. For learning and convenience purposes, we recommend you to write the following code into script files and execute them as shown above.
58+
And then have direct access to the `Math` module.
8659

8760
## Function definition
8861

0 commit comments

Comments
 (0)