Okay, please welcome our next speaker, Ivan, to talk about contracts for free.
Hi everyone.
It's a really quick talk about the Akitoi project and some unpopular opinion about
using runtime types.
So the thing is, there is an old issue, maybe you know it, in NICS, which was closed since
because it will never be implemented, which is a bit embarrassing about the fact that
NICS have no any static type system, and the thing is, I changed my mindset relatively
recently about that, but I will talk about it later, because what's the issue about the
type system?
It's the lack of a static type system, it's the error you'll get, you'll get them at
the last moment.
It's really inconsistent regarding where the mistakes were made, and when you read your
stack trace, you get out time to find what was the actual error, and that is really not
helpless for, for example, beginners trying to work on NICS expression or people trying
to debug NICS expression right then by other person.
So I changed my mindset because NICS is a really simple language, and it should be a
simple language, and it invites us to build construct in library space, and if you look
at NICS built-ins, for example, it's really few built-ins, and a lot of things that could
be built-ins are actually implemented as NICS by Quage, LibSync, and there is a NICS by
Quage, LibTypes, maybe without NNES, which is what you use when you define NICS option
to say the option could be that or that and everything, and so I changed my mindset because
NICS is made in two steps, you know, so it's the first step that you evaluate the language
and produce things in NICS to review, symbols in NICS store, and after you build, you made
your Quage, but the instantiate part is guaranteed to terminate, you know, you will, the computation
will always terminate, which is what you expect for a type system actually, and which is not
the case of some type system or most of macro systems that are not expected to terminate,
so actually it's a good guarantee, and that's why we could do a lot of things in NICS, you
can see it as, I changed my mind because I see that NICS is not really about the runtime
and programming language, so we could do a check at runtime, and I wrote a thing while
a vacation and realized later that other folks already did it, which is Tajjin, maybe you
know him, he works on Twix, Twix right now, and he also writes NICS OnePager, one of the
best NICS starting guide at some point, and the thing is, it's really simple, you define
the data you want, just validate your function, so you say, I want something like that, and
you check at this point of your NICS expression what it evaluates, that's its respect to a
contract, a validator function, and that's help actually there to fail early where you
want it to fail, there is differences in implementation, I will not talk really about, but I really
simply didn't rely on NICS package, and it's fully compatible with NICS exception, so you
can define a thing, and the last thing is, those composes, I go back inside, you can
define types, you can define validator, instruct, that became validator, and you can compose
really complex things, because it's really expressive, and also the nice things with
runtime types is you can produce recoverable error, which is the case for types errors that
exist in NICS itself, so for example, this will be unrecoverable, but if you use the
runtime type, you would recover this situation. Last thing is, I try to advertise this kind
of technique, because it helps a lot to debugs your application and to have assertion about
this, respect that and everything, it doesn't really solve the problem, because it's not
a real type system actually, but if you're not starting something from scratch, if you
actually working on an existing NICS expression, NICS expression could be actually really large,
I think personally it helps, if you're starting a new thing from scratch, there's really cool
things like Q, dial, NICL, generate JSON, and you use that live in NICS package, so you
can use it really easily, and there is also, I like personally plural NICS, because it
generates NICS output results and JSON, okay, I think I said most of what I would say, so
don't hesitate if you have a question or want to share it with you. You don't have time?
Thank you, it was really good presentation.