Hello everyone. So this is a really tightly talked with a bit ambitious title about a
site project of mine. I will explain a bit what site project is about, two parts of the
title and explain what I plan to do with it later. So I made a toy programming language
for fun, like yeah it's not really original but anyway. I was thinking of it for more than
a year now and I have a lot of ideas about stuff to experiment and I start implementing a lot of
parts of it but at the end I had no programming language at all. So I decided somehow to send
a first-dem talk and to try to do a programming language usable by people. So here I am and I
will, I publish online a version where I have a domain name and so this is something I tried to
write a few past months that is mostly usable and I can explain why. So the idea is I made a
really small programming language and by small I hope it's easy to learn. That helps you to catch a
lot of bugs at build time, what most of programming language try to do and I make it kind of looks
like JavaScript and target JavaScript because it's more easy to target JavaScript when you do a
programming language that targets something else. So it's one of the motivations of it. And so maybe
you know that GS is not the perfect programming language. There's a lot of flow. There is one I
really hate which is shallow code by default which is you pass something to some place of your
program and it's changed behind your back and you don't realize only really after about what's
really happened and it's actually painful. There is really weird behavior with every operator that
everyone know and talk about. It's not really big issue but still annoying when you try to use it
and discover it at the last moment. And there is most painful things about there is a lot of things
that should fail that does not really fail and rather return and define and you will really
discover it really later in your program and there is a lot of work on JavaScript to make it a
better language but the problem is you will still want JavaScript to work with all JavaScript
code so there is a lot of duplication in the language like the same things two times but not
exactly the same thing because we try to fix where we ever so this is really confusing I believe.
And I think JavaScript is actually a good language to have another language
transpiled or compiled because it can work anywhere. It's actually quite fast because there is a lot
of engineer that worked into making JavaScript fast and that's true JavaScript is run fast
on a lot of platform and still there are alternative run times that you have to make
JavaScript easily embeddable in other program or use it for other usage on the web.
And there is that thing that everyone knows about maybe which is WebAssembly which is the
thing that your language should target if you want to go on the web and don't want to work
write JavaScript and it's cool, it's fast, it's also cross-platform, it's even know as the
fact that you don't really have to manage your memory by hand in WebAssembly because there are no
GCs that let you say okay I create object and let's manage the memory like you would do in
JavaScript so it's really nice to have a language that built to WebAssembly but there is still few
reasons to prefer to target JavaScript than WebAssembly. The one is WebAssembly doesn't work
on older browser, it's really nice to have a language when you can do all the hack of the earth
because it's really expressive and you try to do a type project programming language,
really nice to have all this expressive power. You can get more easy to work with any existing API
which is something which is really painful to do in WebAssembly if you already tried WebAssembly you
will be aware that it's really hard to interpret WebAssembly code with any other API because you
have to do JavaScript glue code and this glue code is not really safe, it's really hard to maintain
and this kind of stuff. Having a target language that is familiar and when you can run it into a
step by step debugger if you find bugs in your compiler or I mean mine type project and also you
can build a term JavaScript to see with something called Quick.js which is actually really cool and
so if you have JavaScript you can have native target for free, native backend for free. Maybe you
were aware there is a lot of language that already tried to target JavaScript, there's a few of them
named here. The one in bold are actually functional language and the one in italic are the ones that
try to kind of look like JavaScript and the only one in the list that's really used by a lot of
people is TypeScript because that's the one language that accepts the ideas that most of people want
to write JavaScript or keep using working on JavaScript code base so I don't know a lot of people
that's doing per script for example that look like Askel or Elms that look like to Askel too and
that don't look like at all like JavaScript. So what does that mean to make something smaller than
JavaScript? It means that I have for example one kind of function which all functions are lambda
and an image function, the arrow function. I have one kind of string in the literal not three and
the ones that one support string interpolation like you do in JavaScript but all the strings
support it so it's more easy. So all this kind of detail like you just take the minimum amount of
feature you can implement and try to make a smaller JavaScript and there is kind of the
thing that's normally a rather functional language but I kind of implement which is everything return
a value so every expression you can put it into another expression because everything should return
a value so for example I can assign the result of an if-else branching because the value of an
if-else branching is a branch that was executed so you can just say that which makes sometimes the
code more compact and easy and something you can do easily in JavaScript because you have to define
variables with a default value, reassign the variable in the branch and scan stuff which is painful
and I don't have an undefined and just have an empty object which is empty value like when you do
something that does not return a value it returns an empty value which is the empty object or record
anyway. I have some integration to make it easy to embed into JavaScript and this thing that is that
sorry since every file is kind of an expression and every expression is a value every expression is
convert to the equivalent JavaScript value so every expression could be compiled and using
JavaScript for example I have a function which is compiled to the equivalent JavaScript function
and those equivalent things you would expect the function to do and it's kind of expected and I want
to speak a bit about some things that's often when you use a lot of programming language we take
we start to feel like a lot of behavior are normal and logical but if we really think about it those
behavior are not logical at all and for example there are so many different scope rules in JavaScript
and many language that does at some point there's too many scope rules it's really counterintuitive
for example this is legal in JavaScript you can use a function which is declared later in your
program because function are top-level things that can be used anywhere in your programs or
order don't count but if you do a lambda if you do an anonymous function it's blockscop so you
can't use something before it's defined logical it's not the same mechanism but still we are two
mechanisms it's a bit counterintuitive and if we are in object declaration of course you can't use
an item of an object within an object because you have to wait for the object to be created fully
and you can't call the object within the object because you have to wait the object to be to be
declared you can do that it's obviously is legal it seems logical but if we look at function we
can use function inside function of course and we can even use value that are declared after
function even if function capture the definition site because we set the semantic of JavaScript
because JavaScript without harvesting which is function are actually declared in top of your block
but only assigned later so and it's also true for const on let keyword so this code will actually
work and display a lot of emoji and at some point do a stack overflow of course but this is really
counterintuitive that you can you can access a variable here define here it's working function
it looks so a lot of different variable so I come with the idea of doing something really more
simple which is let's merge the two concept of object and block and say just one thing which is
a block could have side effect a block could have value redefined but a block will return the
object of the element within it so we just have one kind of brackets that do the two things in one
and are one scope rule which is always the same and you don't have to remind four five
scoping different scoping rules there is that rules that works for everything it's more smaller
language like you just have one block to have instruction and that is also the way to define
objects so that kind of one main idea and so other idea it's be is pure and pure it's the world
that is so much used for things so many different things that I will be to explain what I mean by
that in this context of this talk I mean that when you define a variable and call something else
you expect the variable to not have changed because you expect not to have shared mutability like
the you don't expect to functions that implicitly change a value of your program you what you expect
is to have kind of a guarantee with a value of what it it in B of having whatever you do with the
value the value and change and this kind of invariant is kind of things you you you know you
will always have it's really cool because it's a lot of stuff I will show later in the presentation
but kind of kind of nice to know that to know to whatever I do if I don't reassign x explicitly
it cannot be reassigned by another part of the program I can't do that if I want to reassign x I
have to return it as a return value of a function it's the only way to reassign it it's to have it
at return value not to pass it as implicitly like that so I have a kind of immutability by default
so immutability kind of says that when you define a value keeps that value forever but you can
redefine value which work bit like mutation and actually is implemented like mutation can
redefine things and if you redefine something in a different scope it don't touch to the thing in
the upper scope so if you redefine value in sub scope and later call to the value it's the
previous value because you you want some modification to be local to don't propagate and that this idea
of scoping which is always the same that's applied everywhere which is maybe a bit weird but actually
really handy and so the interesting part is about how having a more constrained language makes
allow the ability to spot more bugs and I speak a bit about the fact that tabscript
sadly have exactly the same flows as JavaScript because it's a superset so for example charm
immutability a 4x2 have right correct inference and correct typing here I have an example of bad
inference in typescript which is I it's borrowed from the typescript tutorial I should have typescript
understandings that's if I want something which is left of right and assign a variable
right I should have the right thing but the thing is typescript decide to infer s as a string and not
as a left or right and why typescript does that because here we have a let s equal right and not
a cost s equal right if you change the let by the cost typescript will correctly infer but since
there's shared immutability everywhere typescript can't really know or assume that the value of s
will not be changed so it just say okay it will be a string even if you don't change it if you even
if you use it right after say it's a string because it's mutable it can change so you don't know
it's don't know so so that's kind of among situation where so typescript inference failed
and if you have immutability you don't have this kind of error of course and there is also
bad typing this code is a bit nasty but the idea if you expect something which is a string or a
number and then you check it's a string and then you kind of calling some things that changing the
value behind the back of typescript and typescript can detect that because typescript just choose to
don't keep track of that and assume you don't do it even if you can do it so this code was compiled
it will check with typescript strict typescript strict is hard to say we say there is no
no error everything is fine but if you run it every of course at one time you say that's two
uppercase is not a function which is annoying I would expect typescript to catch it but in
a way I know typescript can't catch it because yeah it's really hard to keep track of every value
and and types then can't do that easily so this question is no how I expect types to work in my
minimal programming language I've not finished yet and there is an idea that's come from
mostly really mathematical language which is called dependent type language which is the idea that
types could be values that could be used like a value you can assign like for example here I just say
types kind of a function they just say if something is true or false and if it's true
it's type and if it falls it don't type it's really natural to understand but
then I could use this in my code in to prefix value and say okay let's check if it's work and everything and
and this is a really expressive way to say that something is a type because every function could
be a type as soon as the function return true or false a boolean value this since there are
functions function can be composed so you can for example do structural typing you can for
example do union types the things you have in typescript you can do interchange type it's just
way to say is it a thing and a thing and a thing or a thing is a thing is a thing and and just
comparing value it's not that hard but the thing is you want to run all that computation at run at
build time not at run time so you kind of all you you will you will succeed to do that what
typically typescript type script can do and the thing is it's more easy because as we see before
the execution flow of the language is more predictable there's no shown metability you
don't know if a value can be shown by something else and there is a technique that's come from
static analysis which is technique which is mostly used to prove that's a language that don't behave
correctly still behave correctly this technique for example used to prove that the C program works as
expected and in a C program you can do whatever you want so you kind of need a powerful technique
so the idea of this technique is typing a program checking a program the build time check
is really like running your program you run your program and you check if it failed or if it worked
but running a program does not scale because if your program has an infinite loop your
check at build time will be infinite or if you do an infinite recursion so you have to change a bit
to be aware of your program you have to change a bit of if else work a function call work and you
have to change a bit the standard library to to not do print not write file not read file and the
idea if you change a bit seems to be fully determined for example random function rather than returning
a random number return the range of possible numbers so you know your number will be between zero and
five because it's expected to be between zero and five but you don't know what value you you you
change value by kind of the what would be the expected value in this case this is really simple
and powerful technique but that does not really scale well because if you have a really big program
you kind of running a really big program at build time which is problematic and there's a solution
to that later in this presentation and I have a little demo of this working yeah so here I have
four file but only two of interest I have something in type script which is I have an array of four
element I pop an element and try to access the previous last element and obviously it failed
and I have the same thing in these that look kind of similar actually parentheses are optional
but I put them because it's more looking like JavaScript yeah so two two can do the same thing so
if I do it in in type script yeah take a while it's really small file but still type script yeah
cool I have an old computer for type script defense and it compile no issue everything
fine and if I run it obviously I got in the fine which is not what I I expect here but if I do it
with my super cool side project toy compiler I have a really nice error that tell me a lot about
what's it is happening here yeah so tell me what's the static value of the array what's
happening where how yeah and I work mostly on that on having kind of user friendly error
and tries next to make this thing scale well and have more expressivity to explain type so
so that's the idea um yeah I'm I'm I'm near the end of the talk so I implement a lot of things
like really funny scoping bugs I use three-seater for my grammar which is what use github for
syntax creation and analysis of everything on github I have all the things we have in
JavaScript like the spread operator or the structuring I have things that does not exist in
JavaScript like implicit function argument, hyper-overloading and I have a small standard
library where with everything you can expect to to write a program and and I have also a
client as I just demonstrate that work without node in your class you don't even need to have
JavaScript installed on your computer to make it work I have build targets so you can customize
your JavaScript with different compile time variable and you can even use or define have
build cache so when you you do yeah it's not a good example because the compilation fail anyway
but if your compilation succeeds if you run it several times you just compile only the files
that change not the new one I have syntax highlighting not the best but still and I have
a lot of things left to do I don't have yet pattern matching I would like to have it for the presentation
but I still don't have it so I try to do it soon because it's really nice to kind of destruct your
things in function if parameter or yeah anyway so this case where my language looks really too
functional like you don't really can't really do while loops you can have forage but you can't have
while and because you need kind of mutability to be able to say okay do that until that thing
it's no longer valid and and I'm kind of thinking about having a bit of mutability constraint because
it solves this problem and there is subtyping because actually with types I as I show them I cannot
say that's a type is of another type and it's not that art you but I didn't did it yet because I
have keep track of all the type declare and can explain that later if there is question about it
and and yeah and there is a lot of things to do and societal is a part-time project but maybe one
day it will no longer be a part-time project it's really nice to have a language server protocol
maybe you are aware of that debug adapter protocol too it's kind of the language was designed the
first place to not compile to JavaScript but to compile to kind of so I made a read me you can
try it if you want and that's basically the end of my talk thank you
are there any questions
yeah so the question was what's programming language parted part theme I use as inspiration
was this just JavaScript or something else for example rest or functional programming and the
answer is I work in for the asset for an ascal company so I am really a functional programmer
indeed and before I was working with rest and I really love rest but I I kind of feeling that
trust is not a language for anyone because rest ergonomic make it sometimes really painful to use
for writing like most of the program tasks you you want to write in your daily program or life
so my first motivation was to try modestly to do a better rest like a rest but that's with maybe
more simple rules and more easy to use but still the same kind of guarantee but it's still the idea
a bit behind this project but I I like what I said in the beginning of the talk I try to
to I try to make something small and hackable in on which I can really experiment if my
semantic work in my syntax is is an ambiguous this kind of stuff and it's more easy to have
something small that work on which you can experiment and see if it's usable rather than
it's a bigger goal I have I had in the beginning which was more inspired by
yeah rest or functional programming overall yeah thanks for the question
so uh one of the
you