Facilis - A Low Level Functional Language
CSharpIsGud (639)

Facilis is a strongly typed functional language that aims to be low level. Facilis uses a hand-written recursive descent parser made with love.

Factorial Example

impure foreign putchar(c of u8) -> void
impure foreign tostr(num of void*) -> string

impure write(str of string, start of i32) -> void {

	if start != str.length() {
		write(str, start + 1)

pure fact(i of i32) -> i32 {
	if i == 1 {
		return i

	return i * fact(i - 1)

impure main() -> i32 {
    write(tostr(fact(6)), 0)

Demo: https://repl.it/@Facilislang/FacilisDemo#README.md
^ Has a user/password login program loaded by default. Read the README!

Source: https://repl.it/@Facilislang/Facilis
^ 2072 lines of C++!

@CSharpIsGud @Subarashi @xxpertHacker

You are viewing a single comment. View All
Jakman (457)

If you want a truely functional language then every function should return a value. void should not exist

xxpertHacker (480)

@Jakman Yeah, look closely and it has more than one problem preventing it from really being an actual FP language.

Jakman (457)

@xxpertHacker yep. That impure keyword

xxpertHacker (480)

@Jakman The language is 100% useless without the impure keyword, although if you wanted a CPU warming program, of course, Facilis is just for you! Even Haskell has some impurity.

Now seriously, there are other problems, the if statement is useless, as there is no way to use it without creating impure code, unless it's followed by an else, in which case it's better, but the only genuine use I could imagine would be an if else in which both statements return a value, besides that there's little to no use.

void only has use in impure code, a void function is automatically impure. There's plenty of other things I can't even begin to think of at the moment. We almost had mutable variables too!

Jakman (457)

@xxpertHacker I have created a paradigm that allows OOP and FP. When you call a method on an object it returns a new object with some modification. This technically follows Fp guidelines and allows you to still use OOP efficiently. for example Instead of

struct Car {tire_count:u32}
impl Car {
   fn lose_tire(&mut self) {
       self.tire_count -= 1;

You could have this

struct Car {tire_count:u32}
impl Car {
    fn lose_tire(&self) -> Self {
        return Car{tire_count:self.tire_count-1};
Subarashi (3)

@Jakman well, the language was never intended to be a pure functional lang.

fuzzyastrocat (1223)

@Jakman That works nicely in theory, but it's absolutely terrible for low-level efficiency. Consider: every time you need to lose_tire, you're allocating a new Car object. And garbage-collecting becomes a must, since calling lose_tire multiple times quickly leaks memory.
So, I'm not saying it's impossible or a bad idea — you could write an efficient compiler to overwrite the old car with the new car, but now you're basically just modifying the original car while wasting time overwriting the non-changed fields.

TL;DR: In theory, that works nicely. In practice, to make it efficient it becomes the same as just modifying the original object.

CSharpIsGud (639)

@fuzzyastrocat Later we could probably secretly modify the original object behind the scenes.

fuzzyastrocat (1223)

@CSharpIsGud True. But now what happens if other functions refer to the original object? You could end up with an impurity leak in pure functions. To do it correctly, you'd pretty much have to create a new object copy every time, but that leads to obvious problems.

So... extremely well-made garbage collector I guess?

xxpertHacker (480)

@Jakman OOP isn't entirely independent of FP, they're not incompatible for any particular reason, it's just how OOP is normally used that affects it. Also, usually OOP is incredibly inefficient.

I was thinking about allowing 100% immutable structs to start with later, possibly developing into some twisted OOP, but who knows.

As of right now, I was preparing to focus on static arrays, destructuring, compile-time JavaScript-like syntax array spreading, and other array-related stuff, etc.

DynamicSquid (4355)


Scratch is not a real programming language.

What has society come to in order for you to say that?

Jakman (457)

@DynamicSquid Some tours through Vietnam

sugarfi (582)

@Jakman that's just fp lmao
haskell internally does that iirc

Camto (8)

@Jakman That's not a new paradigm, those are called lenses! :)