Sup Sup Forums, I've spent 5 years writing a programming language:

Sup Sup Forums, I've spent 5 years writing a programming language:

github.com/jesserayadkins/lily

> Statically-typed, but interpreted
> Speed between Python and Lua
> Automatic memory management through gc + refcounting

I can't sleep right now, so wanna ask me anything?

Other urls found in this thread:

github.com/jesserayadkins/lily/blob/master/src/lily_alloc.c#L6-L7
github.com/corazza/monac-scala
github.com/corazza/monac-scala/blob/90a4afba45f61b27f963ab0cd2bdcc8fa50d9c9a/standard-library/prelude.mona#L43
twitter.com/SFWRedditImages

>Posted 9 minutes ago
>No reply

Aww i feel bad for you OPie

Take a reply

Thank you.

Oh, i was just joking around but it seems pretty cool.
Im fairly new when it comes to programming but it reminds me of python, a lot, and i like the fact that it has a low memory footprint.
Will mess around with it, i just wish you made a sublime text plugin or something.
Well done OPie, keep up the good work.

I spent a lot of time packing everything, so I'm glad to hear that. I personally want to shoot for it being under 5K of memory, but 64-bit pointers make that hard. Eventually, I want to try porting it to Arduino, where I've heard the pointers are 16 bits and that way you'd have a fair amount of room left.

As for plugins, I haven't done anything on that front because I've been hacking away at the core. I'd like to expand support for different stuff, like different ides and such over the next year now that I'm just about done fiddling with the core.

>Eventually, I want to try porting it to Arduino

Shit, do that and you'll have my heart.
Im a fucking tard when it comes to programming software, but im fairly OK when it comes to hardware.
Again, nice job, it's a shame this board gives more attention to meme/shill threads than actual tech ones.

What'd you go to school for?

Computer networking, and then I never pursued it. I don't have a formal CS education: Entirely self-taught.

It's cool and all OP but your frees are unchecked and thus unsafe. Look up Fibersteins lecture on Dynamic Memory System Coherency on the tubes

Some people are actually talking about what I made, even if only for a little while. Things like this don't come around often, and really I'm fine as long as I get some excitement for what I'm doing.

For me, the Arduino is a huge selling point. I'm cramming stuff down harder, and I might reach a limit of what I can reasonably do soon. But I want to be able to say that I have the only interpreted language that works under that small of a situation. It's a huge technical win for me, the best kind of win.

In theory, with 16 bit pointers, you'd have to relinquish about 2K of what I believe is 8K of Arduino's memory. But if you're writing a small sketch then you shouldn't hit the memory ceiling.

I'm glad you're excited about it though, since it makes me feel better that chasing Arduino isn't just some crazy pipe dream of mine, and something possibly useful to another person.

Huh. My understanding was that free of NULL was a no-op, except for very old platforms. I'll see if I can find that.

This isn't smartphones
This isn't linux shitposting
This isn't windows shitposting
This isn't graphics cards
This isn't shilling
This isn't gaming shitposting
This isn't memes
This isn't Maki
This isn't Akari
This isn't e-celebs
This isn't one of the 5 milion generals
This isn't piracy shitposting
This isn't consumerism in general

It is, however, a nice project

Do you like functional programming ? Do Lily has functional tools ?

>static typed
deprecated

What made you want to do this?
Just curious.

They are, he's talking shit.

Also, dunno about the language. It seems to want to throw a bit of everything in the mix, not really a huge fan of that. Why have three ways to construct an object?

Wrong quotation, I meant to say that free(NULL) is in fact a no-op according to the standard.

github.com/jesserayadkins/lily/blob/master/src/lily_alloc.c#L6-L7

absolutely disgusting

Make an Operating System running off of Lily entirely, i'll give you 10 years max. No cheating, write everything from scratch, including a kernel

I like some parts of FP. I like monads insofar as using the type system as your ally. I LOVE the idea of eventually adding rank 2 polymorphism to the language just to say I did. I have a fair idea of how to do it, too, and simply haven't gotten around to it (I can treat forall'd types as unquantified, and restrict rank to 2 since 3+ is supposedly undecideable).

I like being able to map, select, and filter over collections. The collections API is borrowed heavily from Ruby's ideas.

You've got Rust-style enums which support exhaustive pattern matching.

But for the language? There's no monads, and typeclasses/traits are something I plan to get to in a coming 1 or 2 releases. I haven't done them yet because I wanted unify to be done right.

If you want immutable collections, however, you're going to be disappointed. That's one of the parts of FP that I don't like. I've spent a LOT of time making Lily's memory usage really low, and immutable collections go in the opposite direction of that.

why

>I don't have a formal CS education: Entirely self-taught.

Badass. This makes me not give a shit about any of your language's deficiencies. Compared to the vast majority of the people on this board, you're a fucking wizard. Keep at it. I should be going to bed, but this is a rare good thread and I want to be around for it.

I'm writing a post on that that I'll be publishing tomorrow. A few things:

People complain a lot about PHP, but nobody ever writes an alternative that has templating built-in.

Nearly every statically-typed language is slow wrt the compiler and waiting around. I've kept going because Lily has an incredibly fast turn around time. I've tested parsing 2200 ish lines in about .022 of userspace time.

I also don't have a life, so this gives me something to do.

robustness flies out of the window entirely
especially for embeddable languages, you want to report that shit back to your caller
libraries have no business calling abort()

Hey, I think I saw this on HN. Pretty neat, nice work op.

You know, don't listen to all the shit you'll probably get on here. The people criticizing your work are pretty much 100% useless NEETs that simply don't know what five years of work mean.

Really, the kind of consistency and discipline (even if you might not think that way about it) you need to even get a project like that done on your own is absolutely amazing.

Despite that, what I see on first glance looks pretty fucking cool.

Woah, hold on there. I'm no Terry Davis.

Reminds me of swift

One is that the new method is just that, a method.

The second is a shortcut. If you say a(1) and a is a class, then it constructs a class. Done.

The third, piping, is a way of making sure that things flow from left to right.

Suppose you're executing a string. You've got this huge expression you're building up, but you forgot to write a print for it. So you do |> print and you're golden. It's useful for undoing nested parentheses: You can write x |> f |> g instead of g(f(x)). It's a simple trick, and it doesn't cost a lot to implement.

So that last example of piping to a class is just about showing how new really, really is just a method and not some special keyword with magic underneath.

You probably did. I posted it there a few days ago.

I just read thru the readme. This looks cool. And it's awesome you built your own language. So i saw it mentions apache, would I be able to use this with nginx as a php replacement?

wrong board this is the graphics card board

I don't know how nginx works, but I assume the answer is yes.

What's needed is to define a server package to bridge from Lily to nginx. Lily needs to know what POST, GET, ENV, and httpmethod are. It's possible to give Lily through the options, some sort of nginx struct pointer, if that's needed.

Some ancillary functions are needed, like server.write, server.write_literal and maybe one or two others. Later, header/cookie support would be needed.

But if that were done, everything else is in the core of Lily since there's no configuration file like you get with PHP.

Lily doesn't specifically depend on Apache at all, and the scripts get a server-agnostic representation of the important data. This allows a script to be ported from Apache to nginx once the backing mod_lily is done for nginx.

It's almost certainly possible, and the best part is that the script aren't hard-wired to know the internals of the server.

beautiful senpai, does it have a standard lib?

So far, no. The only non-core library is postgres. There's a lot of backend apis that need to be done, and those are going to take a month, two at the earliest.

For the moment, no, and likely not soon. I'm still not sure what I want and I'd rather have nothing right now than to have something I hate and which sucks.

Hey op,
I have been planning out a programming language a bit (something to compile to assembly for gnu as), and was wondering if you have any important tips or resources you might want to share?

It helps if you learn a few languages first, just because that might expand upon what you actually want to do. If I had a chance to do Lily all over again, there's a lot that I would have done different. A lot of the churn that happened was because I learned important ideas like FP, about Option, and bits of Scala/Haskell later on, so I had to rip a bunch of stuff out.

Build your debugging tools early on. Get comfortable with gdb. I wrote an opcode debugger that verified is this an emitter problem or a vm problem. Saved me tons of time. TONS. Make your debugging pretty. Being able to look at something easy and say "that's definitely X" is a cure worth tons of prevention.

Don't avoid writing stuff because you don't feel like it. That's nothing against you, but I didn't write a garbage collector for the longest time, and instead wrote a circle buster as an alternative. What I did was stupid and it cost me a lot of time. The gc took a week to do, and I've pretty much left it alone since.

There's something that I think Drepper wrote out there about struct packing. I might have the name wrong, but if you don't know about struct packing, learn it. It's incredibly useful, and a large part of how Lily boots in 6K instead of Lua's fat 20K.

Be vigilant about not letting crap build up. Once in a while go through your stuff and clean it. I made the mistake of not doing that, and now I've got a bunch of structures with crap in them.

Having some basic algorithms knowledge is going to help, but you don't need a lot. I don't have a lot myself.

Write a test harness like my pre-commit-hook that runs all of your tests once you can. Don't allow regressions, and you'll notice you're almost always stepping forward in quality. You fix it? You write a test for it, if you can.

This sounds cool. I'll definitely play around with it. So as a php replacement would I be correct in assuming that lily would use less memory, be more secure, and perform faster than php?

I'm not a fan of the |> syntax but this is pretty impressive.

> Less memory
Lily's memory usage is a speck compared to PHP.

php -r '', an empty script, takes 3megs of dynamic memory to even get started.

I can literally import every passing test in Lily (creating a bunch of classes, closures!, types, and so on) and use less memory than PHP even uses to boot (it's about 500K to import almost all of the passing tests).

So in terms of memory usage, you absolutely will not find a better interpreted language. It beats even Lua by a landslide.


For security, Lily represents ENV, POST, and GET variables as being Tainted[String]. It's possible to do bad things in Lily, but the type system makes it very hard to do them.

Performance-wise, I can't say for sure since I haven't done many benchmarks. But it seems that when I do comparisons here and there, it's between Lua and Python.

Right now, I'm working on optimizations that are low-hanging. Once I'm done, I'll be able to have a recursive fibonacci that's faster than Lua's.

So YES, yeah, and probably.

Would you prefer this syntax :^)

OP let me piggyback off your thread since I'm not that far to start my own, but I'm creating a programming language as well:

github.com/corazza/monac-scala

In short:
>compiled, low-level
>no garbage control, statically proven safe
>functional style
>expressive type system

Hey, I love looking at other languages, so I don't ind at all. In fact, I think I'll take a peek, and tell you what I think.

Forgot to add, it's a mix between Rust and Haskell, which should earn me maximal meme points here

>using the smiley with a carat nose

Nice. This is so cool. A language I heard about in a Sup Forums thread that i'm going to try to use as a php replacement in some web dev projects i'm working on. If I get lily working for some of my use cases i'll hit you up on github with links and/or some documentation for other users like "how to do x with lily" etc.

So like, what are you trying to do with this? Are you hoping for a serious language, or more just trying to make something for fun?

So far it seems like bits of Haskell and Scala, with borrowing from Rust. So it's interesting.

I would really like that. Any experience you have with the language, for good or bad, would be interesting to hear about.

>So like, what are you trying to do with this? Are you hoping for a serious language, or more just trying to make something for fun?

Well it's really interesting to work on the project alone and I'm learning quite a bit, but once I'm over some threshold, I would definitely like to see the language used and get other contributors.

But I'm pretty far from that point at the moment.

>So far it seems like bits of Haskell and Scala, with borrowing from Rust. So it's interesting.

I'm curious, which bits of Scala do you see?

I mean the compiler is programmed in Scala, but the language didn't take much influence from it.

Expression blocks, the braces, println, Some and None versus Just and Nothing.

For printing, are you having things derive a show-like entity, or is it just a toString/automatic and internal?

I think if you're wanting to get serious adoption, regardless, you'll need some niche where your language really, really excels. For Lily, that's memory usage, wherein it beats everyone else hands down.

But really, the journey alone can be an amazing thing. I certainly feel like I'm better for having made Lily since I've learn and grown a lot from it.

>Expression blocks, the braces, println, Some and None versus Just and Nothing.
Shit I forgot about the features of my own language

But yeah, on anything other than syntax and some naming conventions (which are think are superior in Scala), not that much influence.

The syntax is a combination of the good bits from Scala and good bits from Haskell, that's true, but the semantics is Haskell+Rust.

>For printing, are you having things derive a show-like entity, or is it just a toString/automatic and internal?

The show way: github.com/corazza/monac-scala/blob/90a4afba45f61b27f963ab0cd2bdcc8fa50d9c9a/standard-library/prelude.mona#L43

>you'll need some niche where your language really, really excels

Well that's certainly one way. But I think making an interesting-enough language that people want to use because of its general features is another.

But I would prefer Mona to be low-footprint and performant, it's another pipe-dream about a C++ replacement really.

Except it's functional. So that could be my niche: Rust users who would like an actually functional programming-style language.

>For Lily, that's memory usage, wherein it beats everyone else hands down.

I mean, really? That sounds pretty fucking amazing

>But really, the journey alone can be an amazing thing. I certainly feel like I'm better for having made Lily since I've learn and grown a lot from it.

Totally feeling you here! Learned so much, this is my largest project yet.

This is amazing! Keep spreading it. I surely will!

Will check this later, bumping for now.
What made you decide on a name?

>Rust users who would like an actually functional programming-style language.
for doing shit on the web? you got me hooked

are you ready for SJW's to start doing find+replace on your code hunting and pecking for "problematic" language?

Hm well Mona is a general-purpose language with useful abstraction facilities, so you could certainly do some web dev with it in theory. But it's aimed at systems/application programming.

>I'm glad you're excited about it though, since it makes me feel better that chasing Arduino isn't just some crazy pipe dream of mine, and something possibly useful to another person.
+1 on that

pretend to be illiterate please

i just told 20 friends about the language though. these are guys who write compression software for a hobby, not sjw posers.

was just asking

and yeah, Lilly looks awesome, stay based op

I don't think there's anything offensive in there.

?

My original ideas were things like Meteor, Hurricane, Tornado, etc. I didn't have any good ideas for a name.

My mom mentioned that she liked the name Lily a few times. I figured, "Yeah, why not?"

I've grown to like it.

Lily sounds graceful.

Heh I have a story about my name as well. I was blazed af in a wax figure museum in Amsterdam, thinking about how I needed a name for a language. And wham, right before me there is a wax sculpture of Mona Lisa. So Mona it was!:D

how does it feel to have wasted 5 years of your life making something that has no value to anyone and never will

I've built a garbage collector from scratch, I built a working register-based vm, I build a whole language, I made a type system comparable to Scala and Rust wrt inference, I've beaten every language hands down wrt memory usage, and I made something cool called scoop types to allow creating a tuple merge and tuple push function.

So maybe it never gets seriously used. I still learned a lot from it.

Bumping for potential.

Also, I might get a lot of flack for this but try posting this to Reddit.

Looks really cool OP, especially as there aren't too many interpreted but statically typed languages out there.

If possible, please make it as embeddable as possible, meaning:

- allow multiple vm instances
- allow to only include the parts of the standard library that has no harmful IO to allow untrusted macros
- separated compilation and run functions

Ur wrong fagget, I'll possibly use this or Wren in a project about half a year from now.

I've got an article already written down, I just need to hit publish and shoot it off to /r/programming and HN. I'm waiting until about 8 o'clock my time, so it'll get more traction. I'll probably do a casual ama this week too. Reddit gets a lot of hate here sometimes (some valid, some not), but /r/programming has been pretty good about feedback in the past.

HN has been good at getting traffic, but maybe I just haven't posted there enough to get interest in the language.

But I'm posting here because there's a different crowd here versus HN or Reddit. Some of you guys are pretty cool, and I got some interest in the language. I like writing about what I've done because I've done some neat things.

I hate the captcha here though.

> allow multiple vm instances
Already done.

> no harmful io
I've thought of moving files to sys, and allowing runners to say they don't want sys. But I'm scratching my head as to what that brings. My intended use cases are game dev, microcontroller dev, server side scripting, and standalone scripting.

> sepaarated compile and run
Still working on the api, and agreed. Internally it's possible, it's just not exposed. There's a definite use to it: Someone might want to run multiple chunks to build them up, and then send it all at once.

This is cool as fuck
How much does formal language theory come into this? OP says he's self taught

(op) I've never written code in production, and I taught myself everything. I don't know anything about language theory. It's more of what I like, and stuff that doesn't fit what I want.

I just read what everyone else does, and figure out what makes sense to me.

The only time I had to read theory kind of stuff was when I added generics. I went to Scala school of generics and crammed hard. I later went to wikipedia and found out about quantification.

I'll occasionally read more theory kind of stuff, like about bivariance. I understand the typing behind it, but I can't read the math for the life of me.

I just do whatever.

>using the syntax with a carat nose

>Speed between Python and Lua
why

There are two optimizations that need to be employed:

One I call exit blasting. It's this idea that when a function exits, it derefs every register that needs it, and only those ones. Certain functions, like fibonacci, can skip it entirely. Currently, functions that are entered blast all of the registers they may need, and that's both slow and unnecessary.

Registers are not being reused, as they should be. It's an easy fix that I've never gotten around to, as I've never done that much benchmarking. Fibonacci (recursive) uses 8 registers, but should really use I think 3 or 4. That makes a difference.

I've done basic tests with what would happen if both were done. On fibonacci, at least, Lily can beat Lua in performance.

The performance is really a rough, pessimistic estimate. I fully expect that, post optimization, Lily can beat Lua all around in performance.

>between Python and Lua
Is Lua faster or slower than Python?

could include a "closed function" notation in the definition that says whether it needs blasting at all
Or rather you could apply the same "closed" principle to all blocks- bscly saying if it's standalone or not

It's going to be faster than Python, but not as fast as Lua quite yet.

Looks uber cool
>too bad you named it after worst girl

BEST GIRL IN THE GAME

>Already done.
Pretty cool!

>I've thought of moving files to sys, and allowing runners to say they don't want sys. But I'm scratching my head as to what that brings. My intended use cases are game dev, microcontroller dev, server side scripting, and standalone scripting.
Generally security, in case an application gets documents with scipts in it. You won't have the whole MS Word macro virus scenario. Regarding your use cases: As an example, you could have a multiplayer game which downloads scripted maps from the server without having to worry that the scripts messes with your computer.

>Still working on the api, and agreed. Internally it's possible, it's just not exposed. There's a definite use to it: Someone might want to run multiple chunks to build them up, and then send it all at once.
It also allows for better error reporting. For the game example, you can compile your scripts at loading a level and should anything break, directly show a warning instead of some hidden, cryptic in-game console message.

That's part of it too. Right now, the -entering- function has to do the blasting. If I swap it around, some of the functions like fibonacci don't have any refcounted values. So they wouldn't need to blast as they exit, they can just exit.

The point of blasting registers is that I can do comparison operations faster. Comparisons can just throw integer values into a register, and not care to check if the register once held something refcounted or not. So the blasting is absolutely necessary. It's more about making it smarter.

You mention blocks though, which is a bit confusing, as I'm thinking of the vm where blocks don't exist.

There's still some neat stuff I can do for optimizations, notably computed gotos which might net me some extra speed.

Stupid and useless.

>Speed between Python and Lua
Mean question: Does that count the important parts, like data structure density, language interop performance, memory handling or are the benchmarks only numerical benchmarks for scenarios that are better covered by languages like Fortran anyway?

Why are you a nu-male?

some code {.......} in whatever form appears as the operation of functions, as a part of if statements, loops and all the rest.
I'm simply suggesting that depending on how you could set up such a indicator- you may be able to include the practice of selective blasting on a block of code regardless of whether it even has a conditional or loop or whatever prefacing it.
Of course that does depend on whether such a structure is permitted to live on it's own.

Ah cool. Haven't looked at it yet but if it can become a higher-level language for arduino/microcontrollers that'd be a cool niche.

>Tainted[String]
I really love when you can express things like that through the type system. It was something divine, expressing such high level concepts, when I first twiddled with Haskell.

Have you posted this on hsckernews? I think its cool Op

someone has, now

>fibonacci
I wonder why that is often used for benchmarking, especially in context of interpreters. It shows nothing about C-API performance and remarkable data structure performance which I'd wager most important in interpreted languages.

I mean, it's sure nice to know that calculations aren't unnecessarily slow, but interpreters can not really come into the range of performance that one would require to write computation intensive stuff anyway.

I can't say, because I haven't done much benchmarking yet. I've always been more focused on just getting the core to work. It's not going to fall over for anything non-numeric though, as the structures are pretty dense, and there's been some optimization wrt say class member access, closure item access, etc.

I think this is a good sign I need to get to doing benchmarks, like, soon.

SO THAT'S WHAT'S HAPPENING.

For the last half an hour or so, the stars have been climbing and I've been kinda wondering what gives.

Whoever did that, thank you.

Looking forward.

what resources did you use to teach yourself?

I go feature by feature. If I need to learn about exceptions, I check(heh) every exception related resource that there is for every language that I know how to read. Generics? Time to read more about the strengths and the pitfalls until something just clicks. I sample everything until I find something that I like or an idea strikes.

I had to google "how do I make a syntax tree" when I first created the ast pool. I had to ask wikipedia how to use linked lists until the first year passed, because I kept screwing those up.

I don't go to Stack Overflow that often, but occasionally it's useful. That's where I found out how to do closures (someone wrote how Scala did it, and I copied the idea. The idea being to write shadowing reads before opcodes, and shadowing writes afterward).

Other times I get weird ideas and roll with it. That's how scoop types came about.

OP. Why aren't you working. Seriously.

I've been trying to get a job, and haven't had much luck at it. I've got more "we don't think you're a good fit" emails than I can count. Don't even get interviews, just "good luck!" over and over.

It seriously hurts.

wth. What are you applying for?