<commit_before>:source-highlighter: coderay

= Writting basic project in Elixir

Let's create a basic project scructure by invoking mix new from the command line. Type:

----
$ mix new greet
----

Where greet is our name project. You should see following out put.

----
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/greet.ex
* creating test
* creating test/test_helper.exs
* creating test/greet_test.exs
----

There is a lib folder which contains all application code. mix.exs holds the metadata and dependencies of your application.

Now edit the file: lib/greet.ex and add this code:

[source, groovy]
----
defmodule Greet do
  def main(_args) do
     IO.puts "Hello World"
  end
end
----

Elixir uses escript to build an executable. At first we need to set the main_module in mix.exs:

[source, groovy]
----
def project do
  [app: :greet,
   version: "0.0.1",
   elixir: "~> 1.0",
   escript: [main_module: Greet], # <- add this line
   build_embedded: Mix.env == :prod,
   start_permanent: Mix.env == :prod,
   deps: deps]
end
----

Then create an executable and run it:

----
$ mix escript.build
$ ./greet
----

'''
Footer
<commit_msg>Adding link to elixir application example<commit_after>:source-highlighter: coderay

= Writting basic project in Elixir

Let's create a basic project scructure by invoking mix new from the command line. Type:

----
$ mix new greet
----

Where greet is our name project. You should see following out put.

----
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/greet.ex
* creating test
* creating test/test_helper.exs
* creating test/greet_test.exs
----

There is a lib folder which contains all application code. mix.exs holds the metadata and dependencies of your application.

Now edit the file: lib/greet.ex and add this code:

[source, groovy]
----
defmodule Greet do
  def main(_args) do
     IO.puts "Hello World"
  end
end
----

Elixir uses escript to build an executable. At first we need to set the main_module in mix.exs:

[source, groovy]
----
def project do
  [app: :greet,
   version: "0.0.1",
   elixir: "~> 1.0",
   escript: [main_module: Greet], # <- add this line
   build_embedded: Mix.env == :prod,
   start_permanent: Mix.env == :prod,
   deps: deps]
end
----

Then create an executable and run it:

----
$ mix escript.build
$ ./greet
----

link:elixir/elixir_application.html[Basic project in elixir]

'''
Footer

{'fraction_non_alphanumeric': 0.11384976525821597, 'fraction_numerical': 0.003912363067292645, 'mean_word_length': 3.2264462809917354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2116823', 'n_tokens_mistral': 868, 'n_tokens_neox': 842, 'n_words': 313}