Erlang For Mac



  • Erlang Tutorial
  • Erlang Useful Resources

3.5 Setup on Windows. To set up the Erlang Emacs mode on a Windows systems, edit/create the file.emacs, the location of the file depends on the configuration of the system.If the HOME environment variable is set, Emacs will look for the.emacs file in the directory indicated by the HOME variable. If HOME is not set, Emacs will look for the.emacs file in C:. Alternatives to Erlang for Windows, Linux, Mac, BSD, Web and more. Filter by license to discover only free or Open Source alternatives. This list contains a total of 25 apps similar to Erlang. Aug 19, 2020 To learn Erlang, we recommend that you start by reading the official Erlang user guide, and of course the Learn You Some Erlang for Great Good tutorial by Fred Hebert. Learning IntelliJ IDEA IntelliJ IDEA is a Java IDE in the first place, however it’s also a platform and IDE for other languages, such as Erlang, Python, Ruby, PHP, and many other. Using a standard Erlang installation from brew anything that calls crypto crashes on 10.13 because dynamic linking is hitting Apples modified version of BoringSSL instead of LibreSSL or OpenSSL. I have tried compiling with the following flags:-disable-dynamic-ssl-lib -with-ssl=#Formula.

  • Selected Reading

In Erlang there are 2 types of numeric literals which are integers and floats. Following are some examples which show how integers and floats can be used in Erlang.

Integer − An example of how the number data type can be used as an integer is shown in the following program. This program shows the addition of 2 Integers.

Example

The output of the above program will be as follows −

Output

Float − An example of how the number data type can be used as a float is shown in the following program. This program shows the addition of 2 Integers.

Example

For

The output of the above program will be as follows −

Output

Displaying Float and Exponential Numbers

When using the fwrite method to output values to the console, there are formatting parameters available which can be used to output numbers as float or exponential numbers. Let’s look at how we can achieve this.

Example

The output of the above program will be as follows −

Output

The following key things need to be noted about the above program −

  • When the ~f option is specified it means that the argument is a float which is written as [-]ddd.ddd, where the precision is the number of digits after the decimal point. The default precision is 6.

  • When the ~e option is specified it means that the argument is a float which is written as [-]d.ddde+-ddd, where the precision is the number of digits written. The default precision is 6.

Mathematical Functions for Numbers

The following mathematical functions are available in Erlang for numbers. Note that all the mathematical functions for Erlang are present in the math library. So all of the below examples will use the import statement to import all the methods in the math library.

Sr.No.Mathematical Functions & Description
1

This method returns the sine of the specified value.

2

This method returns the cosine of the specified value.

3

This method returns the tangent of the specified value.

4

The method returns the arcsine of the specified value.

5

The method returns the arccosine of the specified value.

6

The method returns the arctangent of the specified value.

7exp

The method returns the exponential of the specified value.

8

The method returns the logarithmic of the specified value.

9

The method returns the absolute value of the specified number.

10

The method converts a number to a float value.

11

The method checks if a number is a float value.

12

The method checks if a number is a Integer value.

Erlang is a great language that lets you build highly concurrent applications. This tutorial will teach you how to quickly get started with it.

Preliminary steps

Installing Erlang OTP

The first thing for setting up an Erlang environment is installing Erlang OTP, a set of Erlang libraries essential for development.

Windows

If you are a Windows user, download the Erlang OTP package and run the installation wizard. Once the installation is over, add the installation path plus bin to the PATH environment variable.

macOS

If you are an macOS user, to install Erlang OTP, type the following at the Terminal prompt (make sure you have Homebrew installed on your machine):

If you prefer MacPorts to Homebrew, your command line should be different:

port install erlang +ssl

Linux

The installation process for Linux is similar to macOS, except that instead of brew or port you have to use apt-get (a Linux package management utility):

You can always download the latest version of Erlang OTP package for any OS.

Verifying Erlang OTP installation

To verify that Erlang OTP is installed correctly, run the Erlang shell by typing erl in a Terminal prompt:

To learn more about the Erlang shell, read its user guide.

Installing Rebar

In addition to Erlang OTP, you’ll also need Rebar, a build tool that helps compile and test Erlang applications. The easiest way to install it on your machine is to download its sources and build it locally:

git clone git://github.com/rebar/rebar.git$ cd rebar$ ./bootstrapRecompile: src/getopt...Recompile: src/rebar_utils> rebar (compile)

Congratulations! You now have a self-contained script called 'rebar' in your current working directory. Place this script anywhere in your path and you can use rebar to build OTP-compliant apps.

Setting up IntelliJ IDEA

Now when Erlang OTP and Rebar are set up, it’s time to download and install IntelliJ IDEA. Keep in mind, that for Erlang development you can use IntelliJ IDEA Community Edition (which is free and open-source).

Once the IDE is up and you see its Welcome screen, go to Configure | Plugins, then click Browse repositories, locate the Erlang plugin and install it:

After installing the plugin, restart IntelliJ IDEA.

Configuring an Erlang SDK

One more thing you’ll have to do to configure IntelliJ IDEA is to add an Erlang SDK.

To do that, change the structure of the default project. Open the default project structure in one of the two ways:

  • On the Welcome screen, go to Configure | Project Defaults | Project Structure

  • On the main menu, choose File | New Projects Settings | Structure for New Projects

Then, add an Erlang SDK by specifying the path to the Erlang OTP installation directory.

If you don’t know where Erlang OTP was installed, check the following directories:

  • Windows: C:Program Fileserl<version>

  • Linux: /usr/lib/erlang/<version>

  • MacPorts, macOS: /opt/local/lib/erlang/<version>

  • Homebrew, macOS: /usr/local/Cellar/erlang/<version>

Configuring Rebar

Erlang For Mac Download

The final adjustment you have to do is to specify the path to Rebar, so that IntelliJ IDEA can run Rebar commands from the IDE.

You can do it via Configure | Preferences | Other Settings → Erlang External Tools:

Creating a new project

Creating an Erlang project

There are several ways to create a new Erlang project. The easiest one is to use the Create a new project from the Welcome screen.

Click Create New Project:

Then choose Erlang in the left pane, and click Next.

IntelliJ IDEA prompts you to choose an Erlang SDK (which you've already configured):

After that you’ll be asked to specify the name of your project and its directory. The following image shows the resulting Erlang project with the name ErlangDemo:

Creating a Rebar project

Instead of a pure Erlang project, you might want to create a Rebar project. To do that, type the following code at the Terminal prompt:

Once the project has been created, import it into IntelliJ IDEA to make it possible to open this project in the IDE.

Importing a project into IntelliJ IDEA

You can import a project into IntelliJ IDEA in several ways. Let's explore importing from the Welcome screen.

On the Welcome screen, press Ctrl+Shift+A, type project from existing sources, and click the Import project from existing sources action in the popup.

In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open.

IntelliJ IDEA offers you to either import the project from existing sources, or from an external model (a build file).

If your project uses Rebar, select the corresponding option when asked.

When importing a Rebar project, make sure to enable the option Fetch dependencies with rebar:

Running and debugging an application

To run an application, you have to create a run/debug configuration created against the stub Erlang Application. To do this, on the main menu choose Run | Edit Configurations, select the stub Erlang Application, specify the name (here it is hello.hello_world), and specify the application’s module and function:

Erlang Machine Voluntarily Stopped

After that you’ll be able to run your application via the main menu (Run | Run <run configuration name>, the toolbar , or a even a shortcut Ctrl+Shift+F10.

Once you have a run/debug configuration, you can also debug your application via the main menu (Run | Debug ‘<run configuration name>, the toolbar , or a shortcut Shift+F9:

For more information, refer to the concept of a run/debug configuration and the procedural sections Run applications and Debug code.

Running Eunit tests

Running Eunit tests is similar to running an application, but needs a different run/debug configuration, created against the stub Erlang Eunit:

IntelliJ IDEA provides a handy Test Runner with support for Eunit. It shows test results, lets you rerun tests of you choice, jump to failed tests, etc.:

Running Rebar commands

Running Rebar commands is also possible right from the IDE – with the help of the Erlang Rebar run/debug configuration:

Note that if your Rebar commands run tests, you can use a Erlang Rebar Eunit run/debug configuration to see test results in a Test Runner.

Erlang for machine learning

Additional

Learning Erlang

To learn Erlang, we recommend that you start by reading the official Erlang user guide, and of course the Learn You Some Erlang for Great Good tutorial by Fred Hebert.

Learning IntelliJ IDEA

IntelliJ IDEA is a Java IDE in the first place, however it’s also a platform and IDE for other languages, such as Erlang, Python, Ruby, PHP, and many other. To learn more about IntelliJ IDEA, it’s worth checking out the section IntelliJ IDEA overview and watch the Video Tutorials.

If you have a question, you can always ask it on StackOverflow (probably it’s already answered).

Providing Feedback

In case you’d like to share your feedback about IntelliJ IDEA or its support for Erlang, feel free to submit an issue in Erlang plugin GitHub repository, or to the IntelliJ IDEA issue tracker.

For information about contacting JetBrains support, see Getting started.

Erlang
Last modified: 22 October 2020