Home > Articles > Programming > General Programming/Other Languages

  • Print
  • + Share This
Like this article? We recommend

First Glances

Anyone who has used Prolog will find Erlang syntax eerily familiar. This is no accident; the first version of Erlang was written as a meta-language on top of Prolog. Some traits inherited from Prolog include atoms (textual identifiers), variables starting with a capital letter, statements being terminated with a full stop, and the list syntax.

There are two data structures in Erlang: lists and tuples. Lists may be of any length, while tuples have a fixed size. Strings are implemented as lists of ASCII characters. As with most Prolog dialects, there is some syntactic sugar for dealing with strings. Compare the following two representations of the same string:

"This is a string"
[84,104,105,115,32,105,115,32,97,32,115,116,114,105,110,103]

One slightly unusual feature of Erlang is that it’s a single-assignment language. Once a variable has been bound to a value, it cannot be modified. This is how a modern compiler works internally (a programmer-visible variable will be represented by a number of variables in an intermediate representation), but it’s relatively unusual for this to be exposed in the language.

  • + Share This
  • 🔖 Save To Your Account