So, we will start another talk about how to improve Python, how to use another language to improve
Python.
For example, we have C, C++, or REST, and here, that will be the case with NIM, another
language, trying to help Python.
Let's go.
Thank you.
I can speak loud, what?
What are you going to speak loud, what are you going to speak loud, what are you going to speak
loud?
This one?
Okay.
Wow.
I'm loud now.
So, thank you for being here.
Very happy to be here.
So, this will be talk about the fact that, let's say seven or more years ago, I was a
Python consumer.
I consumed a part of the ecosystem, and something pushed me to get out there and do stuff
and motivate and be part of the community and even try to contribute to the wider ecosystem.
So, it's actually talk about becoming a better Python instance, and the takeaway for me is
if you get inspired by doing something like that.
For me, that thing has been NIM, but pick your one and do things.
Code for the slides is on GitHub.
So, what is NIM is a programming language, and it's a systems programming language, which
working in the definition is a programming language, which you can write an operating system
for example.
And it's weird one at that, because it doesn't use braces for indentation, and it uses
white space for indentation, which makes it a kind of, not unique, but there are a few
of those.
It's also statically typed and compiled.
So, in these are two ways in which is really different from Python, but it's also good for
everything.
Not have a specific use case, some languages are born with something in mind, NIM a bit
like Python is something that you can use pretty much for any use case.
So, a little bit about me before starting, I met at a scientist, I will use maybe this
is an excuse if you ask me hard, the computer science question.
I work at agile lab, which is a consultant in data engineering, one interesting thing is
that we have a self-management system called holakrasi, that I think is something that
ties well with open source, and I'm also organizer of Python Milano and Python Milano,
if you want to be pass from there, you want to give a talk, we have to, we try to organize
two meetups every month, and I ran into 2018 on Hacker News on this blog post, that
didn't have even the name MIM on the title, and I find it interesting, you know, the romantic
of being an underdog, it was a very nice blog post, and that's how it started.
Good part of the work that I'm presenting here was Donna Drikersenter, which I retreat
for curious and kind of programmers, very nice place.
I did this at Python Italy, and again, please come to Python Italy at the end of May,
we'll be there.
So I will first tell you what is been in a little bit more detail, and then I will try to
explain you why it made me a better Pythonista, and we have blocked the ups for you.
Good.
Thank you.
Really, thank you.
I don't know.
What do I do now?
Okay, yeah, it was just the top.
And then I'll tell you how also you're in the way that I relate to the open source, and it
may be created project and start interacting with the community.
So, MIM, as a first approximation, is an easy to learn and fast complement to Python,
as presented originality, it has very nice interoperability, and the killer feature I would
say is Metaprogramming, and it has another bunch of features.
So the main selling point, at least the beginning, is the fact that it's performance,
so it compiles two native code, and it doesn't add overhead on a runtime or something like
that.
For me, the liberating factor is that you can write nested for loops.
You can write multiplication of metrics with three for loops, and it doesn't give you
a hit in performance.
And you don't need always to reach the reliability to do something performant, and that's
very nice.
And we actually had a debroom when Fosim was online, and there is a talk about this use case,
but we'll not talk a lot about the performant part, because one of the things that I like
a lot is the syntax, so which is also one of the things I like about Python, the readability
part, the fact that you want to show code.
I will start with one thing, which is sometimes a bit of a look, and it's also a bit weird,
not many languages have it, and it's one of the advantages of being statically typed.
So if you have types and a compiler knows about type, you can do something like this, in
which you can define an ink procedure of function, it's equivalent of best.
And when you declare it, to see the compiler knows that something called counter is of type
counter, you can call it in three different ways, the common system, syntax, the function
syntax, and the method syntax.
And it will rearrange it.
And I think this along the fact that you have procedural loading, so you don't have to
come up with a different name for a function that does something when you change the arguments,
which is also something that I appreciate a lot because I have a hard time naming that.
So these things and the procedure of er loading gives you a lot of the advantages of object
or the anti-programming without all the difficult part, the hand in terms of everything.
All the parts that are related, especially to syntax.
And you can always add a function to an object coming from a library and it will look like
a method.
And you don't have print parenthesis, print without parenthesis, Python 2, Python 3,
conversion or anything.
Once you have a compiler, you can ask it to do other things.
So the compiler is something that can reason about your code and give you other stuff.
So in the Python, we are used to have other tools, leaders and checkers and stuff
you like that.
But with a compiler, you can, for example, track side effects.
And the compiler is able to check if something that you now call a funk and not anymore
a proc is something that is without side effects.
So it's a language in this way, which you can get closer to some kind of functional languages.
You can exercise yourself in the style of functional languages,
which is also something that I find very interesting.
And then, as I mentioned, the killer feature is metaprogramming and, for me,
is the equivalent of the magic, of Python, of the important gravity.
And one of the first things I remember is the XKCD comic about that.
And you have this power that you can just import something or something that you look
and you have access to extreme power.
And it's in a sense, this works like that.
So to explain it, the definition is code that generates other code.
Let's start with something we have somehow familiar, which are F string,
which is a great feature.
I guess the feature that made push the move to Python 3.
And an image we look like this, not F, not F, not FnT.
And how this is implemented, it's not actually language feature.
It's something that you implement with metaprogramming,
because in the language you can have that piece of code that is translated to another piece
of code.
Metaprogramming has different sources, but basically you can give
something, static strings, other code, and you can manipulate the ST,
produce something else.
Metaprogramming gives other kind of magic.
And one of this type of magic is interoperability with Python.
And here we are seeing two kinds of magic, one from Niem and one from Python.
On the top, you will see in a light gray, not very visible, something which is called
the pragma, which has this expert pie.
The rest is standard name code, but you import this name pie library.
You annotate the function that you want to use in Python with expert pie.
You put in the same folder a Python file.
And you install the Niemporter library, a Python library.
So you just have these six lines of code, these two files in the library,
and everything is stored, of course.
And if you run Python code, is able to code an Niemcode.
Without anything, in the part of the Python magic is because Niemporter is
hooking the import hook, and it recognizes, and it finds, thank you,
recognizes this and is able to compile and bind anything.
Another thing that I really love about Niemn is the fact that you can do interactivity.
And this is another example of Metaprogramming.
So that kind of BSL is in HTML like the SL used by a library called
Carax, which is sort of a react for Python, that allows you to do interactivity in the front.
And how do you do interactivity in the front and with this language that compiles to native?
Because it does not only compile to see, but as much as boiler in the beginning,
it also compiles to JavaScript.
And I also in the description.
And you have a very easy way to wrap stuff.
So this is how my mind went when I saw this.
Because in a way, as a data scientist, one of the things that I find very important is the user interface,
the way that you interact with this complex algorithm that you look at.
And so I always suffered about not being able to do that in JavaScript,
and maybe not wanting to do that in JavaScript, though.
This is also a result of a rapid, a JavaScript library.
So that was what is named and why it made me into a better Python-ista.
So one very easy way in which you can become in general a better programmer once you
study your first programming language is to study a second programming language.
And do something in other programming language.
Even if you don't plan to use it in production.
This helps you broaden your horizon understanding things.
Maybe do something in another domain.
And so it helped me understand what the type system is.
There are different type systems.
How to go into functional programming.
Reason more about mutability.
Which is also big thing.
And this is one way to change me.
Then one thing I want to tell you is why I was affected by this kind of language.
And there are three things that I think that they share.
One is very accessible.
And this is a really powerful thing with Python.
Because being accessible means being not purely to a really wide audience.
And part of the success of Python, I think, is due to this.
I also find it very playful.
And playfulness is important for creativity, for innovation, for discovering things.
That's why maybe Python has a important role in data science.
And I also like the fact that you can use it because you must try everything.
And once you learn one, you have something accessible and playful.
And you can combine things from embedded to computing whatever.
Three things instead, which are different.
And in front, struggling to read Python are the fact that you have everything happening around time.
So you get errors later.
And the compiler helps you get the errors before.
Then if you want, sometimes you create something with Python,
and you want to give it to your friend.
And it's not that easy.
If you combine alternative code, you have an executable to give.
And the other thing, probably the main thing is that when you work with Python,
you usually work with a high ecosystem, or also reasoning about Python code.
The Python object model is not something too easy to reason about.
And the system's programming language allows you to get to the bottom of the layer of computing.
So you have to cut through the abstraction.
Another very nice thing, very interesting for me, is the fact that the name is a small programming language.
We have a very nice community.
And this I think is something that is a great opportunity to motivate you to contribute to something.
So one other motivation, you can contribute with other bigger project.
But if you find your own niche community of maybe name,
maybe the other programming languages, it's a really a great place to motivate you.
Because it gives you ownership.
Just to give you an example, something that I participated while interacting with the community,
was about picking the color of the language on GitHub.
If you know, but there is a repository which records all the hex codes of the color of the language.
And the name had at some point a different color that did not tie to match the brand.
And in that repository in GitHub, there was a particular algorithm that checked that you didn't pick a color to close for other albums.
So in doing that, we implemented a very specific color distance, so you can read more about the forum.
And so implemented a color distance, and we were able to pick one of the colors that was in here.
That was close to this.
Then the third way, so I mentioned the fact that I improved technically.
I improved in terms of motivation.
And the third way is that also, when you go into another community with all its differences,
with all its issues also, you come back with a different perspective on the Python community,
which I think is a great place, and it gives you a lot of motivation to participate,
and to put in work to keep this community great.
And at some point, I stumbled upon a Kings Day speech of Gators,
which one of the first link on his website, and it's a great blog post,
if you want to get inspired again by a Venetian Python.
So, we open source part, how did it help me to get into open source?
And this, I think, it applies to any other kind of thing,
that any other language that has a niche community.
So, in a niche community, in a way it's easier to do the kind of open source that, as a naive person,
I was many, many years ago, you tend to associate with open source,
to create your own library, to do something,
while then later I realized that many, many ways to contribute to open source.
But let's say you want to contribute your library,
and you have to come up with an idea,
but for example, in a niche language with a small ecosystem,
there are a lot of anti-pidia, and you can start something very easy,
porting something that is another language to that language.
It is useful or fun, another language to that language.
Since I kind of liked the emoji, one of the first things that I did five years ago,
if a library that created was a library to parse, string,
and turn emoji codes into emoji.
And another way, so, a niche community helps with coming up with ideas that you want to do,
because in Python, every idea you say, okay, there's something else that is lying in.
I can contribute to that, but it's not the same thing.
So the other thing you need to code it,
and you just initialize with the package manager,
you code something, and then one of the other things that I like a lot about name,
that the published command is something very, very easy.
You type a command, and it opens a pull request on GitHub repo,
that just adds few lines to a package is done JSON.
Somebody manages that, and it's done.
Compared to how, instead, a little bit more involved,
is publishing a package with Python, I think it's a good bonus.
I haven't yet made the trick to publish a Python package, hopefully soon.
This kind still, kind of scary.
So the bigger project that that was, that,
an emoji thing, by the way, is something that I created that in one day on a Saturday,
and a few days later, the guy who wrote the initial blog post,
that I write on after news, put me star, and that film you with the video,
although that star, that particular important,
but that particular star was very, very important for me.
Another project, instead, that I've worked through other years,
also with friends in this project called Nimi Blunder,
and the first thing is I show you.
I tell you that I like interactivity.
So this is a copy of something that I saw on socials,
of a curve that looks like a firm, that you can change the parameters.
This actually HTML page is something that is done with this Nimi library,
and the source code for this is this many lines.
You put this many lines of code into the library,
and you create an HTML page.
So it's actually, when you look back,
something which is called literate programming.
So interweaving, having code and text code and explanation of the code,
and also output of the code, that are a tool that helps you put the two together
or separate the two.
It started with Donald North.
And Nimi takes advantage of how Nimi syntax is very flexible,
and takes a different approach from the standard literate programming of North,
or even the more modern, interactive programming,
like Jupyter Notebook, which was part of the inspiration of this.
So it is a library that you import,
and you produce an HTML like that.
And you can do slides, then, because then you can add the different template,
and this is also thank you for who the commentator of this library,
and all this project.
And at some point I realized, maybe I can, it also makes sense with Python.
And so I have this project, which I've started working on,
and it's not yet published, but it tries to do the same thing as a Python library.
And it makes much less sense than with Nimi,
but it still makes sense, so it's something that I plan to publish.
And this is something that there is a repo,
and it works like that. It does exactly the same thing.
You have a code, a text cell, and a code block,
and it creates the code block and it captures the output.
And something else I've started experimenting is to integrate it with Python,
because which is also a project I like a lot,
and we will have a talk later this afternoon about that.
And there is a way to interact.
But this is something that APIs not there, there are a lot of problems.
So, I think that sums it up.
I'm very happy to have done this here in this place.
It's my second time at Fossdom, and thank you for your attention.
And she has questions.
Happy to answer here.
Thank you, Pieto, for your demonstration.
Do you have any questions?
Yes.
Thank you.
So, my question is, how good is the support with bindings?
For example, I have a C++ library or a C library,
and I want to be able to interface it with NIMM.
To use it with NIMM.
So, that part is really, really good, the FFI.
So, because it's very, very easy to use a library.
So, I show you the interoperability with Python.
But, basically, for example, you have a C++ library.
You annotate it with something that would be import CPP.
And you can use it basically right away.
Then there are also projects that automate the wrapping,
especially with C++ and has been a lot of work.
One of the most notable projects is,
Juan Gomez was working on a wrapper of the Unreal Engine,
and has really also smoothed out a lot of the experience
of accessing to all kinds of C++ library.
Unreal Engine is a game-changing,
very big C++ project.
And so, lots of projects there to do that.
Performance wise, how does it compare, for example,
GoLank, which assumes it is the same class?
No, LIMM.
Well, it depends about NIMM tends to be in the same class
as last and ZIG.
So, you don't have it, you don't have a floor.
It's starting with the GC.
Now, it has a red counting, so the memory management is something
which injects initializer in the structure.
You can also use it without nothing happening at runtime,
and you'll have to manage pointers for references with the cyclic stuff.
But there is no bottom at the type of performance that you can reach.
And the expressivity makes it so that sometimes you can reach
in an easier way faster speeds.
So, there are projects that Mami Ratsimba has project for tensor libraries
that have the most incredible steep speed,
or crypto libraries that are used in Ethereum space.
And if it fails, we'll get a stack trace or just segmentation fault.
Sorry?
If it fails, do I get a stack trace or segmentation fault?
You should get a stack trace otherwise it's a compiler back.
Another question?
You mentioned portability as an issue with Python,
but if NIMM is compiled, how good is your portability
to different operating systems,
or if you have libraries, are they statically linked in a sense
that you can ship one executable without dependencies?
So, the portability in the sense that you can create an executable.
Yes, you will usually have the choice to statically compile the libraries
or to use dynamic libraries.
So, in that sense, it's portable.
You can compile an executable and you pick whatever you want
in terms of linking with the library.
And in terms of different operating systems,
it's supported all the main ones from scratch.
And since it compiles to, and it's important,
also other back-end targets of different kinds.
But this is probably where I call in the fact that I'm data scientist,
so I'm not supposed to know this kind of stuff.
Okay, thank you. Thank you.
Thank you.
That's me in the theatre.
Hello.