WEBVTT 00:00.000 --> 00:14.000 So, hello everyone, today I'm going to talk about that on the M, but before that I will briefly introduce myself. 00:14.000 --> 00:22.000 I'm David Beteo, I've been tinkering with hardware and the baddest systems for quite a long time. 00:22.000 --> 00:27.000 And also I, since always been very passionate about open source software. 00:27.000 --> 00:34.000 And in 2017 I discovered the Lixir and they fell in love with it. 00:34.000 --> 00:39.000 And the same year later I created the Atom Vian project. 00:39.000 --> 00:51.000 And before starting with Lixir and Langa and Glenn, I would like to briefly talk the user experience with C++. 00:51.000 --> 01:00.000 And first of all I would like to talk about, for example, multiple cores on microcontrollers. 01:00.000 --> 01:07.000 As soon as you realize that recent microcontrollers have two cores, you want to use concurrency, for example. 01:07.000 --> 01:12.000 But concurrency, if you know C, it can be very tricky. 01:12.000 --> 01:14.000 And it's easy to get it wrong. 01:14.000 --> 01:17.000 And there is a lot of manual stuff that has to be done. 01:18.000 --> 01:33.000 And also, if we think about something different, like parsing banners that are coming from some kind of wire format, or maybe some kind of remote services, you hand doing binary parsing by hand. 01:33.000 --> 01:39.000 That in the best situation is just boring, but it can be also security concern. 01:39.000 --> 01:51.000 And also, as soon as you interact with some kind of remote service, you hand making some multiple cores, so you have to wait one rapidly before making another call or whatever. 01:51.000 --> 01:58.000 So you hand having a synchronous code that turns pretty quickly into maybe some kind of call back health. 01:58.000 --> 02:02.000 And let's not even talk about memory management. 02:02.000 --> 02:09.000 And you hand pretty easily asking yourself, did I free that memory and transfer is usually no. 02:09.000 --> 02:14.000 So I will talk about Elixir Langangling. 02:14.000 --> 02:17.000 And those are functional languages. 02:17.000 --> 02:26.000 They are functional languages that have been designed to run on the beam that is the reference Erlang VM. 02:26.000 --> 02:37.000 And those languages have been designed for writing that highly testable software to write software for distributed system and reliable system. 02:37.000 --> 02:44.000 And the first of those languages that appeared is pretty ancient actually that is Erlang. 02:44.000 --> 02:55.000 It has some kind of prologue syntax, but actually is very good at writing software for distributed systems or reliable system. 02:55.000 --> 03:00.000 And that there was some kind of modern twist and Elixir appear. 03:00.000 --> 03:06.000 Elixir has a ruby-like syntax, and it is a highly productive language. 03:06.000 --> 03:10.000 And the last one that appeared is the Glim language. 03:10.000 --> 03:20.000 The Glim language has a modern take to types, and so it introduces static typing to the beam ward. 03:20.000 --> 03:26.000 All these languages, as you can understand, they have different strengths. 03:26.000 --> 03:33.000 But at the end of the day, they share the same kind of basic infrastructure that is the Erlang VM. 03:33.000 --> 03:36.000 And they share a lot of features together. 03:36.000 --> 03:42.000 So the first thing I would like to talk about is the actor model. 03:42.000 --> 03:46.000 And when you talk about actor model, you end talking about processes. 03:46.000 --> 03:55.000 And the question is, what I can do with processes, how they work on the Erlang VM. 03:55.000 --> 04:01.000 Basically, on the Erlang VM, you can spawn as many processes as you like. 04:01.000 --> 04:08.000 You can end having on an old like million of processes for free, nearly for free, 04:08.000 --> 04:12.000 because processes on the Erlang VM are very cheap. 04:12.000 --> 04:19.000 And actually, you can do that, because processes are VM processes. 04:19.000 --> 04:22.000 They are not threats, they are not operating system processes. 04:22.000 --> 04:25.000 They are just virtual machine processes. 04:25.000 --> 04:30.000 And the other interesting thing is that you don't have shared memory. 04:30.000 --> 04:36.000 If processes want to talk together, they have to resort to message passing. 04:36.000 --> 04:44.000 So since you don't have shared memory, also all the concurrent stuff gets simplified, of course. 04:44.000 --> 04:55.000 And this works also very well with functional languages, because basically a process is an infinite recursion that consumers messages and produces other messages. 04:55.000 --> 05:02.000 And as you can see, as you can understand, making a synchronous software is very natural. 05:02.000 --> 05:07.000 So this is definitely something we want to have in our IoT stack. 05:07.000 --> 05:15.000 And another feature that I would like to talk about, that is very deeply rooted in the Erlang VM, 05:15.000 --> 05:18.000 is the fault tolerance by the fault. 05:18.000 --> 05:24.000 That means that we have to get back a little bit to the beginning of Erlang. 05:24.000 --> 05:29.000 Erlang has been created from Ericsson for telephony switches. 05:29.000 --> 05:39.000 And if you think about telephony switch, when you have to handle an emergency call, any kind of downtime is unacceptable. 05:39.000 --> 05:46.000 So the point is that you cannot completely remove crashes or avoid all errors. 05:46.000 --> 05:48.000 They can happen anyway. 05:48.000 --> 05:53.000 So the idea is to deal with crashes, to deal with errors. 05:53.000 --> 05:59.000 And that is what the Erlang VM and the old Erlang ecosystem is doing. 05:59.000 --> 06:09.000 What it offers you is a very solid set of paradigms, set of APIs and pools for dealing, for example, with crashes. 06:09.000 --> 06:18.000 And for instance, you have, for example, supervised or module that allows you to respond any process in a very controlled way. 06:18.000 --> 06:23.000 As soon as you have a crash, you can even set policies. 06:23.000 --> 06:29.000 So you can decide how to restart them, how when not to restart them in which way. 06:29.000 --> 06:38.000 And this is something that also would like to have in our embedded projects because we want them to be very solid. 06:39.000 --> 06:49.000 And something else that really I would really like to show you is pattern matching is another feature shared across all those languages. 06:49.000 --> 06:51.000 And it is provided by the VM. 06:52.000 --> 06:59.000 Basically, when you do pattern matching, you don't care about manual checking each value. 06:59.000 --> 07:04.000 What you do is designing, deciding to shape of the data you expect. 07:04.000 --> 07:13.000 For example, if we think about our factorial example, you will notice that we are defining the same function two times. 07:13.000 --> 07:17.000 But which actual function we are going to execute is not up to us. 07:17.000 --> 07:21.000 The virtual machine will pick up the right definition. 07:21.000 --> 07:28.000 So for example, for the factorial one, we do a function definition for zero that always returns one. 07:28.000 --> 07:32.000 And then we define the function again for any other value. 07:32.000 --> 07:37.000 So the VM for us will decide the right version that will be executed. 07:37.000 --> 07:40.000 We can even have more complex stuff. 07:40.000 --> 07:48.000 In this kind of example, I handle replies and replies are mean we have several options. 07:48.000 --> 07:51.000 And all those options are picked by priority. 07:51.000 --> 07:56.000 And we have some kind of routing and the structuring together. 07:56.000 --> 08:00.000 So fields are also extracted when there is a match. 08:00.000 --> 08:04.000 So we can route everything to the right handling logic. 08:04.000 --> 08:07.000 Again, the virtual machine does the job for us. 08:07.000 --> 08:10.000 We don't have to worry about this. 08:10.000 --> 08:17.000 And the interesting thing is that pattern matching applies to all data types, including binaries. 08:17.000 --> 08:26.000 And binary things get very interesting because you can actually design them in memory layout of a binary. 08:26.000 --> 08:30.000 And you can do pattern matching down to the single bit. 08:30.000 --> 08:35.000 You can even decide if you are going to match against a little onion, vegan, 08:35.000 --> 08:43.000 an integer float or maybe also integers with very odd sizes. 08:43.000 --> 08:46.000 And everything is handled again by the VM. 08:46.000 --> 08:52.000 And the interesting thing is that we can add some additional logic on top of them. 08:52.000 --> 08:54.000 So additional constraints. 08:54.000 --> 09:02.000 And we can just focus in writing the handling logic for binaries that matches what we need. 09:02.000 --> 09:09.000 So we don't have to worry about handling any other kind of binary that maybe is not well formed. 09:09.000 --> 09:17.000 So code gets very simple because this prevents us from writing those lines of code. 09:17.000 --> 09:22.000 And this is another feature that definitely we would like to have in our VM. 09:22.000 --> 09:26.000 And let's talk briefly about microcontrollers as well. 09:26.000 --> 09:32.000 And a long time ago we had Arduino with first at the mega ones. 09:32.000 --> 09:39.000 So Arduino was very small powerful but very limited because had few kilobytes of RAM. 09:39.000 --> 09:43.000 Nowadays we have devices that have internet connections. 09:43.000 --> 09:49.000 And they can have like 100 of kilobytes of RAM or even some megabytes. 09:49.000 --> 09:55.000 But still they are quite limited if we compare them to our station. 09:55.000 --> 09:58.000 We don't have the same amount of resources. 09:58.000 --> 10:04.000 So this means that we cannot run the regular Erlang VM on them. 10:04.000 --> 10:07.000 We need to resort to something different. 10:07.000 --> 10:13.000 So the very big question here is, do we have any tool? 10:13.000 --> 10:16.000 Can we in any way use out the feature? 10:16.000 --> 10:23.000 I just described and many others that we love from the Elixir Erlang and Blimeco system on those devices. 10:23.000 --> 10:27.000 And that's unfortunately yes. 10:27.000 --> 10:35.000 For this reason I created that on VM that is lightweight virtual machine that runs on microcontrollers. 10:35.000 --> 10:40.000 And allows you to run unmodified Erlang, Elixir and Blimeco code. 10:40.000 --> 10:52.000 And the idea behind that to VM is that it is a virtual machine written from scratch with some key tradeoffs that has been set. 10:52.000 --> 11:00.000 And the most important one is saving memory and also being very flexible and easy to port. 11:00.000 --> 11:05.000 And so what I'm talking about is not science fiction. 11:05.000 --> 11:08.000 This project is already available on GitHub. 11:08.000 --> 11:10.000 You can already use it. 11:10.000 --> 11:16.000 And I would say that it's production really and you can use it for making your next project. 11:16.000 --> 11:21.000 And it includes also you can run also quite complex application. 11:21.000 --> 11:25.000 And it includes also advanced features. 11:25.000 --> 11:30.000 We have just in time but also we have an Erlang distribution. 11:30.000 --> 11:38.000 So you can even make a cluster of microcontrollers with processes talking together. 11:38.000 --> 11:42.000 Maybe on the same PCB and features like that. 11:42.000 --> 11:44.000 That is pretty crazy. 11:44.000 --> 11:50.000 And personally I later used atom VM for doing some home automation. 11:50.000 --> 11:55.000 And experimenting with the lower nodes that feels very natural. 11:55.000 --> 11:58.000 I mean using a language such as Elixir. 11:58.000 --> 12:09.000 But actually you can do any kind of embedded IoT or automation project using atom VM. 12:09.000 --> 12:19.000 And I think it is a pretty solid alternative to software stacks such as Arduino or maybe micro Python or many other. 12:19.000 --> 12:24.000 And you can even use this project for making. 12:24.000 --> 12:31.000 I mean if you need to embed an virtual machine in some kind of other constraint environment. 12:31.000 --> 12:34.000 Actually it has been done for the browser. 12:34.000 --> 12:38.000 But and it is very interesting because we cannot run Elixir. 12:38.000 --> 12:41.000 For example as on the browser as a frontend. 12:41.000 --> 12:43.000 But this is another story. 12:43.000 --> 12:45.000 This is not this talk. 12:46.000 --> 12:52.000 And if you want to know more about atom VM you can of course visit the website. 12:52.000 --> 12:56.000 But you can also get in touch with us on Telegram and Discord. 12:56.000 --> 13:01.000 And also since this year I am working full time on this project. 13:01.000 --> 13:09.000 So if anyone has any kind of advice about how to make some kind of project that works. 13:09.000 --> 13:12.000 I mean how to say that. 13:12.000 --> 13:14.000 If you have any to make sustainable. 13:14.000 --> 13:17.000 If you have any advice about this please reach me. 13:17.000 --> 13:20.000 Also sponsors are of course welcome. 13:20.000 --> 13:23.000 And thank you for your attention. 13:23.000 --> 13:35.000 Do you have any quick question. 13:35.000 --> 13:44.000 Questions from the audience. 13:44.000 --> 13:48.000 Thanks for your talk and the work that sounds interesting. 13:48.000 --> 13:51.000 If you say you support different mic controllers. 13:51.000 --> 13:55.000 What does it mean in terms of the peripherals that are on the mic controllers. 13:55.000 --> 13:59.000 Do you already have some kind of interface that you can. 13:59.000 --> 14:05.000 Whatever talk to the I2C bus from Elang or Alex here or is that something that still. 14:05.000 --> 14:07.000 Welcome progress. 14:07.000 --> 14:10.000 Okay if and this is correctly. 14:11.000 --> 14:16.000 You have you have a PIs for you talking with SPI experts. 14:16.000 --> 14:21.000 See for handling GPOs all that stuff has been already implemented. 14:21.000 --> 14:27.000 So if you want to to write a device driver for example for. 14:27.000 --> 14:32.000 Temperature sensor you can use just any of the languages I mentioned. 14:32.000 --> 14:35.000 You don't have to resort to the languages. 14:36.000 --> 14:41.000 And the only reason to use in times the language if you want to drive. 14:41.000 --> 14:43.000 Very hyper formats. 14:43.000 --> 14:46.000 Staffware timing is very crucial. 14:46.000 --> 14:51.000 Otherwise Erlang Elixir and Glimma are super fine for this kind of task. 14:51.000 --> 14:55.000 And I can assure you that performances are pretty good. 14:55.000 --> 14:59.000 And if you need more performances just in time. 14:59.000 --> 15:02.000 And I have time compiler is available. 15:02.000 --> 15:11.000 You can even translate everything into native code before shipping it to the device. 15:11.000 --> 15:12.000 Thanks.