v0.3.0 of Gleam, the statically typed language for the Erlang VM, is out
source link: https://www.tuicool.com/articles/byQrmyF
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Gleam has reached v0.3! Let’s take a look at some of the new features introduced since v0.1.
Module namespaces
Modules can now be namespaced, allowing use of short, convenient module names without the risk of collisions with other Gleam or Erlang modules.
To use a namespace create a directory with the name of your namespace inside
the src/
directory and put your modules in there. As an example, if I’m
making the hot new food delivery app snackr
I might choose to have a
directory structure like this:
src/ └── snackr ├── customer.gleam ├── payment.gleam └── food ├── falafel.gleam ├── pizza.gleam └── salad.gleam
Once created these modules can be brought into scope using the import
statement.
import snackr/customer import snackr/food/falafel fn eat_lunch(louis) { customer:eat(louis, falafel:new()) }
It’s now possible to use multiple modules with the same name, so for convenience modules can be given a name when imported.
import space/rocket as spaceship import salad/rocket as leafy_green
Type annotations
Gleam’s type inference doesn’t require any annotations to understand the types of all your code and provide full type safety, but we might still want to add some for documentation, or to specify more restrictive types then Gleam might otherwise infer.
It looks a little something like this:
fn is_empty(list: List(a)) -> Bool { list == [] }
Easier installation
Precompiled Gleam binaries for Linux and OSX can now be downloaded from the Gleam GitHub release page so it’s no longer required to install Rust on your machine and build the compiler from source.
Victor Borja has kindly created an asdf
version manager plugin for
Gleam
, so for asdf users installing Gleam
is as easy as asdf install gleam v0.3.0
.
For Docker fans the Gleam compiler has been packaged as a Docker image tagged
as
lpil/gleam
.
Easier project creation
Previously Gleam projects were created using a rebar3 plugin. This worked but was one more thing to install, and there was to good way of ensuring that you have an up to date version of the plugin to match your Gleam installation.
Now project creation is handled by the gleam
binary itself, so to get
started with Gleam run gleam new my_cool_project
and it’ll generate all
that’s required.
If you’ve got rebar_gleam
installed it’s safe to delete it from your ~/.config/rebar3/rebar.config
as it’s no longer used.
The rest
In addition to these features there’s been a number of other improvements to the quality of the error messages, the generated code, and a handful of bug fixes. :blush:
If you want to try out the new version of Gleam head over to the installation page . I’d love to hear how you find it and get your feedback so Gleam can continue to improve.
Code BEAM lite Berlin
On the 11th of October 2019 I’ll be speaking at Code BEAM lite Berlin about Gleam. If you’re attending (or are in Berlin but not attending) say Hello!
Recommend
-
26
Most people's first programming language is a dynamically typed, interpreted language - JavaScript, Python or Ruby. These are excellent languages to learn programming with - but there's a separate category of languages in...
-
26
Gleam has reached v0.4! This version has some new features, bug fixes, and some breaking changes. Let’s take a look. Structs Gleam’s map and tuple type has...
-
15
Gleam has reached v0.5! It’s quite a bit larger than any of the previous releases, so let’s take a look. Labelled arguments When functions take severa...
-
24
It has been two months since the last one, so now it’s time for another Gleam release! Let’s see what’s new this time: Improved error messages Since the last release we’ve put a lot of work into the error...
-
14
Thanks to all our new contributors Gleam’s development is faster than ever and it’s time for another release! Let’s take a look. Improved error handling The main way that errors are represented and handle...
-
12
1 month and 10,910 lines of code later it is time for another Gleam release! Let’s see what’s new this time. Module constants Sometimes we want to use a certain fixed value in multiple places in our proje...
-
8
A statically typed language I'd actually want to use Thu, Nov 4, 2010Nearly a year ago I tweeted, and released on github a project I’d been working. It’s called shore, and it’s the...
-
4
Gleam is a type safe, scalable, and productivity focused language for the Erlang virtual machine. Today Gleam v0.21.0 has been released, which includes the first version o...
-
11
The Erg Programming Language
-
5
Praise for Go despite being statically typed language Back to General discussions forum...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK