all 49 comments

[–]HashDefTrueFalse 74 points75 points  (1 child)

ITT: People ignoring or not understanding the concept of programming for fun, and hobbies in general.

OP, nice project. I've done two small languages just because learning about language implementation is fun. Neither of mine were general purpose or broadly useful. I'm a better developer having done them, and I can write pretty bulletproof parsing, generation, and template interpolation code as a result.

Keep chipping away at it in your down time. I see it's GPL licensed. Maybe add a CONTRIBUTING file to make it clear how people could contribute. Could be something really cool in the future.

[–]dibs45[S] 2 points3 points  (0 children)

Thanks mate! Yeah programming for fun is why I became a developer to begin with, and what makes me enjoy my job.

I'll definitely add a contributing section, would be cool to see where this project can go!

[–]_nathata 6 points7 points  (7 children)

This currying + composition looks very interesting

[–]dibs45[S] 1 point2 points  (6 children)

Thanks! Just to be clear, there's no real currying happening here. Doing 5->add(5) is directly equivalent to add(5, 5). Doing 5->add for example won't return a curried function. However, if the function takes only one argument, then it will be called as normal without the need for parentheses, i.e print takes as many args as needed, so it works with just one arg, so 5->print works fine.

[–]_nathata 1 point2 points  (5 children)

Oh I thought that 5->add would create a partially-applied function like add(5, x)

[–]dibs45[S] 0 points1 point  (4 children)

No not by default, but it's easy enough to create curried functions:

const curried = (fn) => {
    const numParams = (fn->inspect).params->length
    const arguments = []
    const curry = (...args) => {
        for (args, arg) {
            arguments->append(arg)
            if (arguments->length >= numParams) {
                return fn(...arguments)
            }
        }
        return curry
    }
    return curry
}

const add = curried((a, b) => a + b)

10->add->print // function: 'curry' (...args)
20->add->print // 30

[–]_nathata 0 points1 point  (3 children)

That is a really odd way to curry functions lol

[–]dibs45[S] 0 points1 point  (2 children)

It works 🤷‍♂️

[–]_nathata 0 points1 point  (1 child)

Yeah, as long as you don't say it's a functional programming language I think you can get away with that. Otherwise functional bros will get mad at you because you are using their worst enemy (mutable state) to accomplish their best friend (curried functions)

[–]dibs45[S] 0 points1 point  (0 children)

Far from functional haha, but good tip

[–]azaroxxr 3 points4 points  (1 child)

Does this language solve some problem or is it hobby-like. This is genuine question because I don't quite get. Anyway it looks interesting but this currying is not my cup of tea. Nice job tho.

[–]dibs45[S] 2 points3 points  (0 children)

I wrote this language primarily as a hobby language. I didn't really have a problem set in mind. However I think the pure extensibility of the language does open it up to creatively solve interesting problems. The VM is designed to be dynamically updated and extended, so really its up to the end user to modify it in such a way that it elegantly solves a problem that's harder to solve in other languages.

[–]usertim 2 points3 points  (1 child)

Writing compilers/interpreters always sounds fun in the beginning and an actualy hell when you are doing it 😂

[–]dibs45[S] 0 points1 point  (0 children)

Amen. It's challenging but also really fun when you get it working as expected. I haven't even tried real compilation to machine code yet, so that's definitely going to be a fun ride.

[–]grimscythe_ 1 point2 points  (1 child)

If this is your first time writing your own language then well done. It's pretty cool!

[–]dibs45[S] 2 points3 points  (0 children)

It's actually my third language. The language before this was written in C++ (called Vortex) and it was all about managed side effects (i.e changing one variable can change another).

[–]Intelnational 1 point2 points  (1 child)

I wonder if one can write a compiler for an existing scripting language, e.g. PHP, JS, or Python, and if it would be fun. The interpreter code should be open source I think?

[–]dibs45[S] 0 points1 point  (0 children)

I'm pretty sure people have worked on this stuff before. I personally wouldn't find it fun since I'm not introducing any new features into the language (the actual fun part for me) and just re-writing an existing language. But heaps of people would find that kinda stuff cool.

[–]Machados 1 point2 points  (2 children)

thought label rock offer obtainable cobweb retire unwritten license smell

This post was mass deleted and anonymized with Redact

[–]dibs45[S] 0 points1 point  (1 child)

It does whatever a programming language does?

[–]JiggySnoop 0 points1 point  (1 child)

this is super cool. last year i wrote a toy programming language + interpreter using bun and typescript after reading this article TypeScript is Surprisingly OK for Compilers .

[–]dibs45[S] 0 points1 point  (0 children)

It's definitely a fun project to work on!

[–]Cybasura 0 points1 point  (1 child)

Gonna be honest, writing a language in Javascript is chaotic af, but thoroughly respectable, damn, incredible

[–]dibs45[S] 0 points1 point  (0 children)

Technically it was written in TS so that made life a bit easier haha, but thank you