Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
For those who just want the link: https://github.com/MystPi/bella
I've been working on a small language off and on over the past weeks, and I'm excited to share it with you all. And yes, I know: another programming language cluttering up the ATs. If that's all you have to say, feel free to move on to something more interesting. Okay then, without further ado, Bella is:
So yeah, if you have any ideas, feel free to share them! Constructive criticism would also be appreciated.
Here are some unnecessary notes:
I've been working on a small language off and on over the past weeks, and I'm excited to share it with you all. And yes, I know: another programming language cluttering up the ATs. If that's all you have to say, feel free to move on to something more interesting. Okay then, without further ado, Bella is:
- A functional language, with some features inspired by Elm. This means it does not have mutability, side-effects (while at times possible, they are mostly discouraged), loops, or statements. Everything is an expression.
- Dynamically typed. I really wanted to make a statically typed language, but I honestly wasn't sure how, and I couldn't find many resources on the subject—at least ones understandable by a high-schooler with little patience. Maybe in the future?
- Written in Gleam, which is an amazing language; you should check it out!
- A work in progress.
; Hello world
print('Hello, world!')
; Factorial
let fact =
n ->
if (n == 0)
1
else
n * fact(n - 1)
in
4 |> fact |> print
; Countdown
let countdown =
n ->
if (n == 0)
print('Liftoff!')
else (
print(n)
countdown(n - 1 )
)
in
countdown(10)
; Records
let
repository =
{ type: 'github'
, user: 'MystPi'
, repo: 'bella'
}
package =
{ name: 'Bella'
, type: 'Programming language'
, repository
, tags:
{ fun: false
, simple: true
}
}
bella =
package + { tags: package.tags + { fun: true } }
in
bella.tags.fun |> print
; Try & throw
let divide =
a -> b ->
if (b == 0)
throw 'Cannot divide by 0'
else
a / b
in (
print('Before try')
try
print(divide(1, 0))
else
msg -> print(msg)
print('After try')
)
So yeah, if you have any ideas, feel free to share them! Constructive criticism would also be appreciated.
Here are some unnecessary notes:
- This was pretty much my first time writing Gleam, so the code might be kinda messy and unorganized. Apparently Louis told me large files aren't a bad thing in the Gleam world?
- There are almost no comments in the code because I'm me and I don't ever remember to comment things.
- If you want a recursion exercise (and a mind bender), then the parser is for you! You can look through it here.
- Syntax highlighting for Gleam on GitHub is kind of broken right now, so you might want to clone the repo locally if you're going to spend time looking through the code. Actually, it got fixed recently!
- Bella is named after a dog that recently died.
She looks a similar to the AI-generated logo on GitHub.
Last edited by NFlex23 (Oct. 25, 2023 13:10:24)
- uwv
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
woah! this is super neat! cool little language
you should totally add a llvm backend to this (for real no joke)
you should totally add a llvm backend to this (for real no joke)
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Thank you! To be honest, a llvm backend sounds like a lot of work, along with the fact that I don't really know what llvm is. woah! this is super neat! cool little language
you should totally add a llvm backend to this (for real no joke)

- lolecksdeehaha
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Woah! I love this neat function syntax, which kinda splits up the arguments. It might've been a limitation so you had to add that (or just because you didn't want to make it work), but it actually looks kinda sick!
Also, is the newline and indent after let required, or just in the general style? And how do I run it?
Also, I really like this language in general, it looks fun to use.
let
add =
a -> b ->
a + b
Also, I really like this language in general, it looks fun to use.
- Marc92020
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
woah a programming language named after my dog thats pretty epic
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Thanks! The reason the lambda (function) syntax is like that is because there are really only 1 and 0 parameter lambdas. The parser actually turns calls like `add(2, 3)` into `add(2)(3)` behind the scenes. So `add` is a lambda that returns Woah! I love this neat function syntax, which kinda splits up the arguments. It might've been a limitation so you had to add that (or just because you didn't want to make it work), but it actually looks kinda sick!another lambda that computes the sum of the two numbers. Phew!Also, is the newline and indent after let required, or just in the general style? And how do I run it?let
add =
a -> b ->
a + b
Also, I really like this language in general, it looks fun to use.
As for whitespace: no, it isn't required. Format to your heart's content! I just like doing it like that since it makes it easier to read.
And for running the language: there are instructions in the GitHub README, but basically you just do `gleam run file.bella`. There isn't a dedicated binary for Bella yet.
Last edited by NFlex23 (May 26, 2023 22:26:58)
- bigspeedfpv
-
500+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
this is super cool i'll have to try it out tbh !!!!! rip bella </3
- MagicCrayon9342
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Add your language to GitHub: https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.md
Add support for your language to vscode: https://code.visualstudio.com/api/language-extensions/overview
Offer a shorthand file extension (Example: .bl, bla, or bll)
Package it for several distributions or make an installer similar to rust
Make a package manager and allow libraries to be packaged and reused.
Add support for your language to vscode: https://code.visualstudio.com/api/language-extensions/overview
Offer a shorthand file extension (Example: .bl, bla, or bll)
Package it for several distributions or make an installer similar to rust
Make a package manager and allow libraries to be packaged and reused.
- ajskateboarder
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Neat syntax
You should make a style guide sometime if you're devoted to this project
You should make a style guide sometime if you're devoted to this project
- DifferentDance8
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Except, if this doesn't even have documentation… and style guides are basically documentations… You should make a style guide sometime if you're devoted to this project
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Nice idea; I'll probably make one eventually. Neat syntax
You should make a style guide sometime if you're devoted to this project
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
You can create an executable if you have Deno & Gleam installed:
Using it is the similar to before:
I'm not sure if the executable I built will work for anyone else, but feel free to try it out (Linux x64): https://ufile.io/sxzyzj4o
gleam clean && gleam build
deno compile --unstable --allow-all ./build/dev/javascript/bella/main.mjs
./bella ./examples/countdown.bella
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.mdAdd your language to GitHub:
We try only to add new extensions once they have some usage on GitHub. In most cases we prefer that each new file extension be in use in at least 200 unique :user/:repo repositories before supporting them in Linguist
- MagicCrayon9342
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Announce it in more places and make it popular.https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.mdAdd your language to GitHub:We try only to add new extensions once they have some usage on GitHub. In most cases we prefer that each new file extension be in use in at least 200 unique :user/:repo repositories before supporting them in Linguist
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
As weird as it sounds, that's not really what I want. Bella is not intended to be widely used, it is more of a hobby project and an exploration in functional programming.Announce it in more places and make it popular.https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.mdAdd your language to GitHub:We try only to add new extensions once they have some usage on GitHub. In most cases we prefer that each new file extension be in use in at least 200 unique :user/:repo repositories before supporting them in Linguist
- MagicCrayon9342
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
That's kind of like what Linus Torvalds said when he made Linux. Look where Linux is now.As weird as it sounds, that's not really what I want. Bella is not intended to be widely used, it is more of a hobby project and an exploration in functional programming.Announce it in more places and make it popular.https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.mdAdd your language to GitHub:We try only to add new extensions once they have some usage on GitHub. In most cases we prefer that each new file extension be in use in at least 200 unique :user/:repo repositories before supporting them in Linguist
- ajskateboarder
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
Style guides are a very specific kind of documentation. You don't really need existing documentation to make oneExcept, if this doesn't even have documentation… and style guides are basically documentations… You should make a style guide sometime if you're devoted to this project
No offense to the language, but I don't think this would reach a point where nearly every developer uses it. Many languages have already been built around functional programming (Lisp, OCaml, Haskell, etc.) That's kind of like what Linus Torvalds said when he made Linux. Look where Linux is now.
- UserFriend-
-
31 posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
I finally got it to work!
Had to dive into code inside bella/build/dev/javascript/bella/*, debug and fix it (Gleam compiled code was broken lol..)
(it was giving errors before, like “I don't know what is ….” or “function is not found …”)


(I hope I'm the first one to use Bella
)
My first program lol

Had to dive into code inside bella/build/dev/javascript/bella/*, debug and fix it (Gleam compiled code was broken lol..)
(it was giving errors before, like “I don't know what is ….” or “function is not found …”)


(I hope I'm the first one to use Bella

My first program lol

Last edited by UserFriend- (May 28, 2023 07:50:08)
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
bella/build/dev/javascript/bella/*, debug and fix it (Gleam compiled code was broken lol..)That's weird. Can you give me the exact errors you got, and your Bella code? The Gleam code works completely fine & typechecks, so it must be your Bella code. Had to dive into code inside
(it was giving errors before, like “I don't know what is ….” or “function is not found …”)
By the way, you can call your `idk` function like this: `idk(30, 40, 35)`
Last edited by NFlex23 (May 28, 2023 11:29:32)
- NFlex23
-
1000+ posts
Bella ⌁ A simple functional programming language ⌁ Written in Gleam!
I'm working on better error messages at the moment.


Edit: now released. Feel free to try it out!
↓ imported from examples/import_errors/a.bella
↓ imported from examples/import_errors/b.bella
✕ error: invalid syntax
┌─ examples/import_errors/c.bella:2:3
│
2 │ , name: 'value'
│ ~~~~
│
? Duplicate record field

↓ imported from examples/import_errors/a.bella
↓ imported from examples/import_errors/b.bella
✕ runtime error in examples/import_errors/c.bella
? Operands of + must be numbers, strings, or records and be the same type; instead got a number and a string

Edit: now released. Feel free to try it out!
Last edited by NFlex23 (May 29, 2023 15:45:57)
- Discussion Forums
- » Advanced Topics
-
» Bella ⌁ A simple functional programming language ⌁ Written in Gleam!