- published
- reading time
- 3 minutes
fener
fener
is a interpreted ruby/lua-like language. It is a object-oriented programming language with first-class functions.
This is fener
. A easy language written in Golang.
It’s a dynamicaly typed language with object-oriented features.
It is designed similar to languages like Ruby
or Python
.
Here’s the FizzBuzz
program written in fener
1fn fizzbuzz(n)
2 if n % 5 == 0 && n % 3 == 0 then
3 print("FizzBuzz")
4 elif n % 3 == 0 then
5 print("Fizz")
6 elif n % 5 == 0 then
7 print("Buzz")
8 else
9 print(n)
10 end
11end
Status
This language is a hobby project under heavy development. It’s versatile and capable enough for small programs.
It’s designed for reading and experimenting.
Getting Started
To use fener, you need the single binary.
Go
You can get fener by using the Go
compiler.
go install github.com/pspiagicw/fener@main
Or if you use gox.
gox install github.com/pspiagicw/fener@main
Compile
To compile the project, you only need the Go
compiler.
git clone https://github.com/pspiagicw/fener
cd fener
go build .
Testing
fener has a extensive suite of tests. It’s written in Go’s native test runner.
Which depends on the fener binary being compiled inside the project directory.
go build .
go test ./...
You can run specific tests or get information about all subtests.
Contribution
This project is under heavy development and contributions are highly appreciated. A lot of decisions are yet to be taken, and you can be part of them.
Semantics
fener
is a expression based language.
Every valid statmeent/expression returns a value.
You can interact with fener
using the REPL.
Run the repl using
fener repl
.
Arithmetic
You can run arithmetic expresions.
>>> 1 + 2
int(3)
>>> 1 + 2 * 6 / 7 - 1
int(1)
fener has 3 fundamental data types.
>>> 10
int(10)
>>> true
bool(true)
>>> false
bool(false)
>>> "this is a string"
str(this is a string)
Complex data types include classes
, list
and maps
.
lists
andmaps
are not implemented yet.
- Lists
>>> [1 2 3 4 5]
[int(1) int(2) int(3) int(4) int(5)]
- Maps
>>> { "name" = "Chris" "surname" = "Pratt" }
{ str(name)->str(Chris) str(surname)->str(Pratt)}
Classes are covered later.
There is a bonus type null
, which is returned by builtin functions and some statements.
It can’t be used by the user.
Variables
Variables don’t have any type, they can hold value of any type.
The assignment expression <name> = <variables>
returns the value.
>>> a = 20
int(20)
>>> b = 10
int(10)
>>> a + b
int(30)
>>> a = "something"
str(something)
>>> a
str(something)
Comments
;; these are comments.
;; Comments are marked by 2 consecutive semicolons.
Flow
fener
supports if-expressions and while-statements.
Functions
You can declare functions using the fn
keyword.