forked from gleam-lang/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
173 lines (149 loc) · 5.17 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
layout: top
list_sponsors: true
---
<section class="hero hero-xl">
<div class="hero-homepage-content content">
<img class="hero-logo" src="/images/lucy-charcoal-2.svg" alt="Lucy the star, Gleam's mascot">
<div class="hero-blerb">
<h2>
Gleam is a fast, friendly, and functional language for building type-safe,
scalable systems! ✨
</h2>
<a href="/getting-started" class="button-light">Get Started</a>
</div>
</div>
</section>
<section class="content">
<h2>Why Gleam?</h2>
<h3 data-before-icon="☔">Safe</h3>
<p>
Gleam's powerful static type system helps find and prevent bugs at
compile time, long before it reaches your users. It also serves as a
productive refactoring tool, enabling programmers to confidently make
large changes to unfamiliar code, quickly and with low risk.
</p>
<p>
For problems the type system can't solve (such as your server being hit
by a bolt of lightning) the Erlang virtual machine provides well tested
mechanisms for gracefully handling failure.
</p>
<h3 data-before-icon="💜">Friendly</h3>
<p>
Hunting down bugs can be stressful so Gleam's compiler provides clear
and helpful feedback about any problems. We want to spend more time
developing features and less time looking for bugs or deciphering
cryptic error messages.
</p>
<p>
As a community we want to be friendly too. People of all backgrounds,
genders, and experience levels are welcome and must receive equal
respect. See our <a href="https://github.com/gleam-lang/gleam/blob/main/CODE_OF_CONDUCT.md">community code of conduct</a>
for more.
</p>
<h3 data-before-icon="🧵">Performant</h3>
<p>
Gleam builds on top of the Erlang virtual machine, a best-in-class
runtime that has enabled companies such as
<a href="https://www.whatsapp.com/">WhatsApp</a>,
<a href="https://www.ericsson.com/en">Ericsson</a>,
<a href="https://www.heroku.com">Heroku</a>, and
<a href="https://www.klarna.com/">Klarna</a> to provide low-latency
services at a global scale. Gleam takes full advantage of the Erlang
runtime and adds no overhead of its own, so all Gleam programs are as
blazingly fast as their Erlang counterpart.
</p>
<h3 data-before-icon="🧩">Erlang compatible</h3>
<p>
Gleam makes it easy to use code written in other BEAM languages such as
Erlang, Elixir and LFE, so there's a rich ecosystem of
<a href="https://hex.pm/">thousands of open source libraries </a>
for Gleam users to make use of.
</p>
<p>
In return Gleam code can be easily used by programmers of other BEAM
languages, either by transparently making use of libraries written in
Gleam, or by adding Gleam modules to their existing project with minimal
fuss.
</p>
</section>
<section class="content">
<h2>Features</h2>
<ul>
<li>Actor based multi-core concurrency
<li>Algebraic data types
<li>Erlang style fault tolerance
<li>Fast compilation
<li>Full type inference
<li>Generics
<li>Helpful error messages
<li>Immutable data structures
<li>No exceptions by default
<li>No null
<li>No undefined behaviour
<li>Reliable package management
<li>Small and consistent language design
<li>Zero cost interop with Erlang, Elixir, etc
</ul>
</section>
<section class="content">
<h2>Examples</h2>
<details class="openable-example" open>
<summary>Hello, world!</summary>
The classic example program that prints "Hello, world!" to the console.
{% highlight rust %}
import gleam/io
pub fn main() {
io.println("Hello, world!")
}
{% endhighlight %}
</details>
<details class="openable-example">
<summary>A basic web server</summary>
This little web server responds with the text "Hello, world!" to any
HTTP request made to it.
{% highlight rust %}
import gleam/bit_builder
import gleam/http/elli
import gleam/http
pub fn my_service(_req) {
let body = bit_builder.from_string("Hello, world!")
http.response(200)
|> http.set_resp_body(body)
}
pub fn start() {
elli.start(my_service, on_port: 3000)
}
{% endhighlight %}
The web server created by this code is fully asynchronous and
multi-threaded, seamlessly making use of all the cores of your computer
without tricky locks, callbacks, or promises.
</details>
<details class="openable-example">
<summary>Multi-threaded hello world</summary>
Thanks to the powerful Erlang virtual machine Gleam programs can spin up
hundreds of thousands of threads (called processes) without any trouble.
Here's "Hello, World!" being printed by a thousand processes
concurrently.
{% highlight rust %}
import gleam/io
import gleam/int
import gleam/list
import gleam/string
import gleam/otp/process
pub fn main() {
list.range(0, 1000)
|> list.each(start_process)
}
fn start_process(i) {
process.start(fn() {
let message = string.append("Hello world: ", int.to_string(i))
io.println(message)
})
}
{% endhighlight %}
In addition to this low-level process abstraction Gleam has helpful
libraries full of building blocks for writing type safe and fault
tolerant multi-core programs as quickly as possible.
</details>
</section>