We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Contracts for free!

00:00

Formal Metadata

Title
Contracts for free!
Title of Series
Number of Parts
542
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Nix lacks of a static type system could be really annoying when we want to debug our expression, and understand what's part of code or data is wrong. Dynamic types libraries[1][2] comes to the rescue, giving a simple API to assert that data is valid.
14
15
43
87
Thumbnail
26:29
146
Thumbnail
18:05
199
207
Thumbnail
22:17
264
278
Thumbnail
30:52
293
Thumbnail
15:53
341
Thumbnail
31:01
354
359
410
Design by contractFreewareDiagram
Functional (mathematics)Library (computing)Run time (program lifecycle phase)Type theoryGroup actionCodePhysical systemConsistencyError messageFunction (mathematics)Formal languageConstructor (object-oriented programming)FunktorPairwise comparisonInfinityPerformance appraisalImage resolutionLoop (music)Template (C++)Design by contractInternetworkingSimilarity (geometry)LoginHash functionPasswordEmailField (computer science)Attribute grammarTelephone number mappingUsabilityComputer configurationRegulärer Ausdruck <Textverarbeitung>Configuration spaceLibrary (computing)Error messagePhysical systemComputer configurationMultiplication signFluid staticsValidity (statistics)Function (mathematics)Formal languageProjective planeMacro (computer science)Complex (psychology)Type theoryShared memoryImplementationRun time (program lifecycle phase)CASE <Informatik>NeuroinformatikDifferent (Kate Ryan album)MereologyExpressionReal numberDesign by contractSpacetimePoint (geometry)Right angleGeneric programmingElectronic program guideTypprüfungComputer programmingComputer animation
Program flowchart
Transcript: English(auto-generated)
Okay, please welcome our next speaker, Ivan, to talk about contracts for free. Hi everyone, it's a really quick talk about the Akitoy project and some unpopular opinions about using runtime types.
So, the thing is, there is an old issue, maybe you know it, in Nix, which was closed since because it will never be implemented, which is a bit embarrassing about the fact that Nix 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 get, you get them at the last moment, it's really inconsistent regarding where the mistake were made, and when you read your stack trace, you get hard time to find what was the actual error. And that is really not helpless for, for example, beginners trying to work on Nix expression,
or people trying to debug Nix expression right then by other person. So, I changed my mindset because Nix is a really simple language, and it should be a simple language, and it invites us to build constructs in library space.
And if you look at Nix built-ins, for example, it's really few built-ins, and a lot of things that could be built-ins are actually implemented as Nix package libsing. And there is a Nix package lib types, maybe without an S, which is what you use when you define Nix option,
to say the option could be that or that and everything. And so, I changed my mindset because Nix is made in two steps, you know, so the first step is that you evaluate the language and produce things in Nix, or you symbolize Nix store, and after you build, you made your package,
but the instantiate part is guaranteed to terminate. You know you will, the computation will always terminate, which is what you'll 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 Nix. You can see it as, I changed my mind because I see that Nix is not really about runtime and programming language, so we could do a check at runtime.
And I wrote a thing while vacation and realized later that other folks already did it, which is Tashjian, maybe you know him, he works on Twix right now, and he also writes Nix one-pager, one of the best Nix starting guides at some point.
And the thing is, it's really simple, you define the data you want, just validator functions, so you say, I want something like that, and you check at this point of your expression, what it evaluates, that's its respect to a contract or validator function,
and that helps, actually, the error to fail early, where you want it to fail. There are differences in implementation I will not talk really about, but I, as a really simple liberal, didn't rely on Nix pack-wage, and it's fully compatible with Nix exception, so you can define a thing and share them,
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 Nix itself, so for example, this will be un-recoverable, but if you use the runtime type, you will recover the situation.
Last thing is, I try to advertise this kind of technique, because it helps a lot to debug your prediction, and to have assertion about this respect and everything. This does not really solve the problem, because it's not a real type system, actually,
but if you're not starting something from scratch, if you're actually working on an existing Nix expression, an 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, Dal, Nickel, generic JSON,
and you leave the Nix package so you can use it really easily, and there is also, I like personally ProNix, because it generates Nix output rather than 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 opinion. We don't have time for questions. You don't have time? No, okay. Thank you. Thank you. It was really good.