Convert Figma logo to code with AI

gleam-lang logogleam

⭐️ A friendly language for building type-safe, scalable systems!

17,363
721
17,363
168

Top Related Projects

24,265

Elixir is a dynamic, functional language for building scalable and maintainable applications

11,297

Erlang/OTP

19,321

The Crystal Programming Language

33,640

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

  1. Hello World example:
pub fn main() {
  io.println("Hello, World!")
}
  1. Pattern matching and recursion:
pub fn factorial(n: Int) -> Int {
  case n {
    0 -> 1
    _ -> n * factorial(n - 1)
  }
}
  1. Working with lists:
import gleam/list

pub fn double_list(numbers: List(Int)) -> List(Int) {
  list.map(numbers, fn(x) { x * 2 })
}
  1. 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

  1. Install Gleam (assuming you have Erlang installed):

    $ curl -sSL https://gleam.run/install.sh | sh
    
  2. Create a new Gleam project:

    $ gleam new my_project
    $ cd my_project
    
  3. Add your code to src/my_project.gleam and run it:

    $ gleam run
    
  4. Build and test your project:

    $ gleam build
    $ gleam test
    

Competitor Comparisons

24,265

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.

11,297

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.

19,321

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.

33,640

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Lucy, Gleam's mascot

GitHub release Discord chat

 

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 - Adi Iyengar - Adi Salimgereyev - Adrian Mouat - Ajit Krishna - Alembic - Alex - Alex Houseago - Alex Manning - Alex Viscreanu - Alexander Koutmos - Alexander Stensrud - Alexandre Del Vecchio - Aliaksiej Maroz - Ameen Radwan - AndreHogberg - andrew - Andrew Brown - András B Nagy - Andy Aylward - Antharuu - Anthony Khong - Anthony Maxwell - Anthony Scotti - Arnaud Berthomier - Arthur Weagel - Azure Flash - Barry Moore - Bartek Górny - Ben Martin - Ben Marx - Ben Myles - Benjamin Peinhardt - Benjamin Thomas - bgw - Bill Nunney - brettkolodny - Brian Dawn - Brian Glusman - Bruno Michel - bucsi - Carlo Gilmar - Carlo Munguia - Carlos Saltos - Chad Selph - Charlie Govea - Chaz Watkins - Chew Choon Keat - Chris Donnelly - Chris Haynes - Chris King - Chris Lloyd - Chris Ohk - Chris Rybicki - Christopher De Vries - Christopher Dieringer - Christopher Keele - clangley - Claudio - CodeCrafters - Coder - Cole Lawrence - Colin - Comamoca - Constantin (Cleo) Winkler - Daigo Shitara - Damir Vandic - Dan Dresselhaus - Daniel - Danielle Maywood - Danny Arnold - Danny Martini - Darshak Parikh - Dave Lucia - David Bernheisel - David Cornu - David Sancho - Dennis Dang - dennistruemper - Dillon Mulroy - Dima Utkin - Dmitry Poroh - Donnie Flood - ds2600 - ducdetronquito - Dylan Carlson - Edon Gashi - Eileen Noonan - eli - Emma - EMR Technical Solutions - Eric Koslow - Erik Terpstra - erikareads - ErikML - Ernesto Malave - Evaldo Bratti - Evan Johnson - evanasse - Fede Esteban - Felix Mayer - Fernando Farias - Filip Figiel - Florian Kraft - fly.io - frankwang - G-J van Rooyen - Georg H. Ekeberg - Giacomo Cavalieri - Giovanni Kock Bonetti - Graeme Coupar - grotto - Guilherme de Maio - Guillaume Hivert - Hammad Javed - Hannes Nevalainen - Hannes Schnaitter - Hans Fjällemark - 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 - inoas - Isaac - Isaac Harris-Holt - Isaac McQueen - Ismael Abreu - Ivar Vong - J. Rinaldi - Jacob Lamb - Jake Cleary - James Birtles - James MacAulay - Jan Skriver Sørensen - Jean-Luc Geering - Jen Stehlik - Jenkin Schibel - Jesse Tham - jiangplus - Jimpjorps™ - Joey Kilpatrick - Johan Strand - John Björk - John Gallagher - John Pavlick - Jon Lambert - Jonas E. P - Jonas Hedman Engström - jooaf - Jorge Martí Marín - Joseph Lozano - Joshua Steele - Julian Lukwata - Julian Schurhammer - Justin Lubin - Kero van Gelder - Kevin Schweikert - kodumbeats - Kramer Hampton - Kryštof Řezáč - Krzysztof G. - Leandro Ostera - Leon Qadirie - Leonardo Donelli - lidashuang - LighghtEeloo - Lily Rose - Loïc Tosser - Lucas Pellegrinelli - Lucian Petic - Lukas Meihsner - Luke Amdor - Luna - Manuel Rubio - Marcus André - Marcøs - Mariano Uvalle - Marius Iversen - Marius Kalvø - Mark Holmes - Mark Markaryan - Markéta Lisová - Martin Janiczek - Martin Rechsteiner - martonkaufmann - Matt Champagne - Matt Robinson - Matt Savoia - Matt Van Horn - Matthias Benkort - Max McDonnell - max-tern - Michael Duffy - Michael Jones - Michael Kieran O'Reilly - Michael Kumm - Michael Mazurczak - Michał Hodur - Mihlali Jordan - Mike - Mike Nyola - Mike Roach - Mikey J - MoeDev - Moritz Böhme - MzRyuKa - Måns Östman - n8n - Workflow Automation - Natanael Sirqueira - Nathaniel Johnson - Nathaniel Knight - NFIBrokerage - Nick Chapman - Nick Reynolds - Nicklas Sindlev Andersen - NicoVIII - Niket Shah - Ninaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - NineFX - Nomio - Ocean - OldhamMade - Oliver Medhurst - optizio - Osman Cea - PastMoments - Patrick Wheeler - Paul Gideon Dann - Paul Guse - Paulo Vidal - Pawel Biernacki - Pete Jodo - Peter Rice - Petri-Johan Last - Philip Giuliani - Pierrot - Piotr Szlachciak - porkbrain - Pushpendra Jaiswal - Qdentity - qingliangcn - Race Williams - Rahul Butani - Ray - Raúl Chouza - re.natillas - Redmar Kerkhoff - Reilly Tucker Siemens - Renovator - Richard Viney - Rico Leuthold - Ripta Pasay - Rob - Robert Attard - Robert Ellen - Robert Malko - Rodrigo Heinzen de Moraes - Rupus Reinefjord - Ruslan Ustitc - Sam Aaron - sambit - Sammy Isseyegh - Samu Kumpulainen - Santi Lertsumran - Savva - Saša Jurić - Scott Trinh - Scott Wey - Sean Jensen-Grey - Sebastian Porto - sekun - Seve Salazar - Shane Poppleton - Shuqian Hon - Simone Vittori - Spec - star-szr - Stefan - Stephen Belanger - Steve Powers - Strandinator - Sunil Pai - syhner - Sławomir Ehlert - Theo Harris - Thomas - Thomas Coopman - Thomas Ernst - Tim Brown - Timo Sulg - Tom Schuster - Tomasz Kowal - tommaisey - Tristan de Cacqueray - Tristan Sloughter - upsidedowncake - Valerio Viperino - Vassiliy Kuzenkov - Vic Valenzuela - Victor Rodrigues - Vincent Costa - Viv Verner - Volker Rabe - Weizheng Liu - Wesley Moore - Willyboar - Wilson Silva - Yamen Sader - Yasuo Higano - yoshi~ - Zhomart Mukhamejanov - Zsombor Gasparin - ~1847917