Top Related Projects
Elixir is a dynamic, functional language for building scalable and maintainable applications
Erlang/OTP
The Crystal Programming Language
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
A strongly-typed language that compiles to JavaScript
Compiler for Elm, a functional language for reliable webapps.
Quick Overview
Gleam is a statically typed functional programming language for building scalable concurrent systems. It compiles to Erlang and runs on the BEAM virtual machine, offering type safety, friendly error messages, and seamless interoperability with Erlang and Elixir.
Pros
- Strong static typing with type inference, enhancing code reliability and maintainability
- Friendly compiler with clear error messages, improving developer experience
- Seamless interoperability with Erlang and Elixir ecosystems
- Built on the battle-tested BEAM virtual machine, providing excellent concurrency and fault tolerance
Cons
- Relatively new language with a smaller community compared to more established languages
- Limited ecosystem and fewer libraries compared to Erlang or Elixir
- Learning curve for developers not familiar with functional programming concepts
- Still evolving, which may lead to breaking changes in future versions
Code Examples
- Hello World example:
pub fn main() {
io.println("Hello, World!")
}
- Pattern matching and recursion:
pub fn factorial(n: Int) -> Int {
case n {
0 -> 1
_ -> n * factorial(n - 1)
}
}
- Working with lists:
import gleam/list
pub fn double_list(numbers: List(Int)) -> List(Int) {
list.map(numbers, fn(x) { x * 2 })
}
- Defining a custom type:
pub type Shape {
Circle(Float)
Rectangle(Float, Float)
}
pub fn area(shape: Shape) -> Float {
case shape {
Circle(radius) -> 3.14 *. radius *. radius
Rectangle(width, height) -> width *. height
}
}
Getting Started
-
Install Gleam (assuming you have Erlang installed):
$ curl -sSL https://gleam.run/install.sh | sh
-
Create a new Gleam project:
$ gleam new my_project $ cd my_project
-
Add your code to
src/my_project.gleam
and run it:$ gleam run
-
Build and test your project:
$ gleam build $ gleam test
Competitor Comparisons
Elixir is a dynamic, functional language for building scalable and maintainable applications
Pros of Elixir
- Mature ecosystem with extensive libraries and frameworks
- Strong support for concurrent and distributed systems
- Dynamic typing allows for rapid prototyping and flexibility
Cons of Elixir
- Lack of static type checking can lead to runtime errors
- Steeper learning curve for developers new to functional programming
- Performance overhead compared to statically typed languages
Code Comparison
Elixir:
defmodule Greeting do
def hello(name) do
"Hello, #{name}!"
end
end
Gleam:
pub fn hello(name: String) -> String {
"Hello, " <> name <> "!"
}
Elixir uses dynamic typing and a more Ruby-like syntax, while Gleam employs static typing and a syntax reminiscent of Rust or Swift. Gleam's type system provides additional safety at compile-time, potentially catching errors earlier in the development process. However, Elixir's dynamic nature allows for more flexible metaprogramming and runtime code generation.
Both languages run on the Erlang VM, benefiting from its robust concurrency and distribution capabilities. Gleam aims to provide a more familiar syntax for developers coming from other statically typed languages, potentially easing the transition to the Erlang ecosystem.
Erlang/OTP
Pros of OTP
- Mature and battle-tested ecosystem with decades of development
- Extensive libraries and tools for building distributed, fault-tolerant systems
- Strong support for concurrency and scalability through the actor model
Cons of OTP
- Steep learning curve due to unique syntax and paradigms
- Less familiar to developers coming from mainstream programming languages
- Limited ecosystem outside of telecom and specific industrial applications
Code Comparison
OTP (Erlang):
-module(hello).
-export([hello_world/0]).
hello_world() ->
io:format("Hello, World!~n").
Gleam:
pub fn main() {
io.println("Hello, World!")
}
Key Differences
- Gleam offers a more modern and familiar syntax, similar to Rust or Elm
- OTP provides a more comprehensive set of tools for building distributed systems
- Gleam aims to improve type safety and developer experience on the BEAM
- OTP has a larger community and more extensive documentation
- Gleam is designed to interoperate seamlessly with Erlang and Elixir projects
Both Gleam and OTP run on the BEAM virtual machine, allowing for excellent concurrency and fault tolerance. Gleam focuses on bringing a more approachable, statically-typed language to the Erlang ecosystem, while OTP remains the go-to choice for large-scale, distributed systems with its proven track record and extensive tooling.
The Crystal Programming Language
Pros of Crystal
- Mature ecosystem with a larger community and more libraries
- Syntax familiar to Ruby developers, easing transition
- Compiled language with C-like performance
Cons of Crystal
- Longer compile times compared to Gleam
- Less emphasis on type safety and functional programming paradigms
- Steeper learning curve for developers not familiar with Ruby
Code Comparison
Crystal:
class Person
property name : String
property age : Int32
def initialize(@name, @age)
end
end
person = Person.new("Alice", 30)
puts "#{person.name} is #{person.age} years old"
Gleam:
pub type Person {
Person(name: String, age: Int)
}
pub fn main() {
let person = Person("Alice", 30)
io.println(person.name <> " is " <> int.to_string(person.age) <> " years old")
}
Crystal offers a more object-oriented approach with class definitions, while Gleam focuses on functional programming with immutable data structures. Crystal's syntax is more Ruby-like, whereas Gleam's syntax is influenced by languages like Elm and Rust. Both languages provide strong typing, but Gleam's type system is generally considered more robust and central to the language design.
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Pros of Zig
- Lower-level language with manual memory management, offering more control and potential for better performance
- Comptime feature allows for powerful compile-time code generation and metaprogramming
- Supports cross-compilation out of the box, making it easier to target multiple platforms
Cons of Zig
- Steeper learning curve due to its low-level nature and unique features
- Smaller ecosystem and fewer libraries compared to more established languages
- Still in development, with potential for breaking changes in future releases
Code Comparison
Zig:
const std = @import("std");
pub fn main() !void {
std.debug.print("Hello, World!\n", .{});
}
Gleam:
import gleam/io
pub fn main() {
io.println("Hello, World!")
}
Summary
Zig is a low-level systems programming language focusing on performance and control, while Gleam is a functional language targeting the Erlang VM with a focus on type safety and readability. Zig offers more fine-grained control over memory and system resources, making it suitable for systems programming and performance-critical applications. Gleam, on the other hand, provides a more high-level, functional approach with strong type inference, making it well-suited for building concurrent and distributed systems on the BEAM ecosystem.
A strongly-typed language that compiles to JavaScript
Pros of PureScript
- More mature ecosystem with a larger community and more libraries
- Advanced type system with features like higher-kinded types and type classes
- Closer to Haskell, making it easier for Haskell developers to transition
Cons of PureScript
- Steeper learning curve, especially for developers new to functional programming
- Slower compilation times compared to Gleam
- More complex syntax and language features, which can be overwhelming for beginners
Code Comparison
PureScript:
module Main where
import Effect.Console (log)
main :: Effect Unit
main = log "Hello, World!"
Gleam:
import gleam/io
pub fn main() {
io.println("Hello, World!")
}
Summary
PureScript offers a more advanced type system and a mature ecosystem, making it suitable for complex projects and experienced functional programmers. Gleam, on the other hand, provides a simpler syntax and faster compilation, making it more accessible to beginners and better suited for rapid development. The choice between the two depends on the project requirements, team expertise, and development priorities.
Compiler for Elm, a functional language for reliable webapps.
Pros of Elm compiler
- More mature and established project with a larger community
- Extensive documentation and learning resources available
- Strong focus on web development and browser-based applications
Cons of Elm compiler
- Limited interoperability with JavaScript compared to Gleam's Erlang/OTP ecosystem integration
- Slower compilation times for large projects
- Less flexibility in terms of backend and systems programming capabilities
Code comparison
Elm:
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
main =
Browser.sandbox { init = 0, update = update, view = view }
Gleam:
import gleam/io
import gleam/int
pub fn main() {
io.println("Hello, World!")
let x = int.add(5, 3)
io.debug(x)
}
The Elm code showcases its focus on web development with a simple counter application structure, while the Gleam code demonstrates its general-purpose nature with a basic console output and arithmetic operation.
Elm compiler is better suited for frontend web development, offering a more opinionated and structured approach. Gleam, on the other hand, provides greater flexibility for various types of applications, including backend and systems programming, with its Erlang/OTP integration.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Gleam is a friendly language for building type-safe systems that scale! For more information see the website.
Sponsors
Gleam is kindly supported by its sponsors. If you would like to support Gleam please consider sponsoring its development on GitHub.
Thank you to our sponsors! Gleam would not be possible without you.
00bpa - Aaron Gunderson - Abdulrhman Alkhodiry - ad-ops - Adam Brodzinski - Adam Johnston - Adam WyÅuda - Adi Iyengar - Adi Salimgereyev - Adrian Mouat - Agustinus Kristiadi - Ajit Krishna - Aleksei Gurianov - Alembic - Alex - Alex Houseago - Alex Manning - Alex Viscreanu - Alexander Koutmos - Alexander Stensrud - Alexandre Del Vecchio - Ameen Radwan - Andrea Bueide - AndreHogberg - Antharuu - Anthony Khong - Anthony Maxwell - Anthony Scotti - Arthur Weagel - Arya Irani - Azure Flash - Barry Moore - Bartek Górny - Ben Martin - Ben Marx - Ben Myles - Benjamin Kane - Benjamin Peinhardt - Benjamin Thomas - Berkan Teber - bgw - Bill Nunney - Bjarte Aarmo Lund - Brad Mehder - brettkolodny - Brian Dawn - Brian Glusman - Bruno Michel - bucsi - Cameron Presley - Carlo Gilmar - Carlo Munguia - Carlos Saltos - Chad Selph - Charlie Duong - Charlie Govea - Chaz Watkins - Chew Choon Keat - Chris Donnelly - Chris Haynes - Chris King - Chris Lloyd - Chris Ohk - Chris Rybicki - Christopher David Shirk - Christopher De Vries - Christopher Dieringer - Christopher Jung - Christopher Keele - CJ Salem - clangley - CodeCrafters - Coder - Cole Lawrence - Colin - Comamoca - Constantin (Cleo) Winkler - Corentin J. - Cristiano Carvalho - Daigo Shitara - Damir Vandic - Dan Dresselhaus - Danielle Maywood - Danny Arnold - Danny Martini - Dave Lucia - David Bernheisel - David Cornu - David Sancho - Dennis Dang - dennistruemper - Diemo Gebhardt - Dillon Mulroy - Dima Utkin - Dmitry Poroh - Donnie Flood - ds2600 - ducdetronquito - Dylan Carlson - Edon Gashi - eeeli24 - Eileen Noonan - eli - Emma - EMR Technical Solutions - Endo Shogo - Eric Koslow - Erik Terpstra - erikareads - ErikML - erlend-axelsson - Ernesto Malave - Ethan Olpin - Evaldo Bratti - Evan Johnson - evanasse - Fabrizio Damicelli - Fede Esteban - Felix Mayer - Fernando Farias - Filip Figiel - Florian Kraft - Francis Hamel - frankwang - G-J van Rooyen - Gabriel Vincent - Geir Arne Hjelle - Georg H. Ekeberg - Georg Hartmann - George - ggobbe - Giacomo Cavalieri - Giovanni Kock Bonetti - glippert - Graeme Coupar - grotto - Guilherme de Maio - Guillaume Heu - Guillaume Hivert - Hammad Javed - Hannes Nevalainen - Hannes Schnaitter - Hans Fjällemark - Hans Raaf - Hayes Hundman - Hayleigh Thompson - Hazel Bachrach - Henning Dahlheim - Henry Firth - Henry Warren - Heyang Zhou - human154 - Humberto Piaia - Iain H - Ian González - Ian M. Jones - Igor Montagner - Igor Rumiha - ILLIA NEGOVORA - Ingrid - inoas - Isaac - Isaac Harris-Holt - Isaac McQueen - Ismael Abreu - Ivar Vong - J. Rinaldi - Jacob Lamb - Jake Cleary - James Birtles - James MacAulay - Jan Pieper - Jan Skriver Sørensen - Jean-Luc Geering - Jen Stehlik - jiangplus - Jimpjorps⢠- Joey Kilpatrick - Joey Trapp - Johan Strand - John Björk - John Gallagher - John Pavlick - Jojor - Jon Lambert - Jonas E. P - Jonas Hedman Engström - jooaf - Joseph Lozano - Joseph T. Lyons - Joshua Steele - Julian Lukwata - Julian Schurhammer - Justin Lubin - Jérôme Schaeffer - Kaan Keskin - Karl - Kemp Brinson - Kero van Gelder - Kevin Schweikert - kodumbeats - Kramer Hampton - Kritsada Sunthornwutthikrai - KryÅ¡tof ÅezÃ¡Ä - Krzysztof G. - Leandro Ostera - Lee Jarvis - Leon Qadirie - Leonardo Donelli - lidashuang - LighghtEeloo - Lily Rose - Loïc Tosser - Lucas Pellegrinelli - Lukas Bjarre - Lukas Meihsner - Luke Amdor - Luna - Manuel Rubio - Marcus André - Marcøs - Mariano Uvalle - Marius Kalvø - Mark Holmes - Mark Markaryan - Markéta Lisová - Martin Janiczek - Martin Rechsteiner - martonkaufmann - Matt Champagne - Matt Heise - Matt Mullenweg - Matt Robinson - Matt Savoia - Matt Van Horn - Matthew Whitworth - Max McDonnell - max-tern - metame - Metin EmiroÄlu - Michael Duffy - Michael Jones - Michael Mazurczak - Mikael Karlsson - Mike - Mike Roach - Mikey J - MoeDev - Moritz Böhme - MzRyuKa - n8n - Workflow Automation - Natanael Sirqueira - Nathaniel Knight - Nayuki - NFIBrokerage - Nicholas Moen - Nick Chapman - Nick Reynolds - Nicklas Sindlev Andersen - NicoVIII - Niket Shah - Ninaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - NineFX - Nomio - Ocean - Olaf Sebelin - OldhamMade - Oliver Medhurst - Oliver Tosky - optizio - Osman Cea - PastMoments - Patrick Wheeler - Paul Gideon Dann - Paul Guse - Pawel Biernacki - Pedro Correa - Pete Jodo - Peter Rice - Philip Giuliani - Philpax - Pierrot - Piotr Szlachciak - Qdentity - Race Williams - Rasmus - Ray - Raúl Chouza - re.natillas - Redmar Kerkhoff - Reilly Tucker Siemens - Renato Massaro - Renovator - Richard Viney - Rico Leuthold - Ripta Pasay - Rob - Robert Attard - Robert Ellen - Robert Malko - Rodrigo Ãlvarez - Ronan Harris - Rotabull - Rupus Reinefjord - Ruslan Ustitc - Sam Aaron - Sam Zanca - sambit - Sami Fouad - Sammy Isseyegh - Santi Lertsumran - Savva - SaÅ¡a JuriÄ - Scott Trinh - Scott Weber - Scott Wey - Sean Jensen-Grey - Sean Roberts - Sebastian Porto - sekun - Seve Salazar - Shane Poppleton - Shuqian Hon - Simone Vittori - star-szr - Stefan - Stephen Belanger - Steve Powers - Strandinator - Sunil Pai - SÅawomir Ehlert - Theo Harris - Thomas - Thomas Coopman - Thomas Ernst - Tim Brown - Timo Sulg - Tom Calloway - Tom Schuster - Tomasz Kowal - tommaisey - Tristan de Cacqueray - Tristan Sloughter - upsidedowncake - Valerio Viperino - Vic Valenzuela - Victor Rodrigues - Viv Verner - Volker Rabe - Weizheng Liu - Wesley Moore - Willyboar - Wilson Silva - Xucong Zhan - Yamen Sader - Yasuo Higano - yoshi~ - Zsombor Gasparin - ~1814730 - ~1847917 - ~1867501 - Ãber Freitas Dias
Top Related Projects
Elixir is a dynamic, functional language for building scalable and maintainable applications
Erlang/OTP
The Crystal Programming Language
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
A strongly-typed language that compiles to JavaScript
Compiler for Elm, a functional language for reliable webapps.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot