 Так, давайте початкуємо. Привіт, всі. Дякуємо за цю сесію. У нас є багато великій сесії і багато конфліктів. Я мовив мене багато. Дякуємо за цю сесію. Мене я, Полси Коловський. Я працював для Лінаро, який є консоцієм арм- СПІО-Акітекція Ліценси Нон-Профіт Газир до Декрива фрагментація з арм-ком'юнити і працювати на бейс-лайн-проюджек. Ми ще залишуємо для вендерспіфівських селюцій на село. І всі, без село, спеціалі для арм-платформ і без більше фрагментацій в арм-ком'юнити. Ми працюємо з арм-ком'юнити на бейс-лайн-проюджек. Так. І сьогодні я хотів говорити про скрипт-лайн-проюджек для ООТ. Челленджи в них залишують інші проекти. Так. Нескрипт-лайн-проюджек в нас залишуємо скрипт-лайн-проюджек. Так. У нас є багато знайомих скрипт-лайн-проюджек чи негрішні скрипт-лайн-проюджек як якщо вони говорять так. Так, скрипт-лайн-проюджек в нас залишуємо так, що це має бути також велика спеціаліка It's no longer true and nowadays real big applications can be written in scripting languages and VHL. So the benefits is that they are easy to learn and many people already know at least one, oftentimes more than one scripting languages. They are powerful and concise, like in few lines of code you can do a lot. So it increases productivity. And there are usually well-developed scripting languages that come with really big sub-party library collections, which even more increases productivity. So in some developments and there is classification if it's very high-level languages, there are probably can be defined loosely like medium high-level languages like Java, C sharp, which use, for example, automatic memory management, but still strongly typed and require declaration of all the variables to use, and even lower than that is low-level high-level languages, because even C is probably high-level language by current standard. So in some segments, very high-level languages effectively like hosted those other high-level language groups, for example, like web development. And yes, Java, C sharp, definitely still big contenders, but more and more projects use very high-level languages like Python will be, like Java script and solutions based, for example, on C++ adjust niche solutions. They exist, but they are really used for web development, for example. Yes, so why use scripting languages in IoT specifically? So the idea is try to capitalize on all the features I just talked about, which are used for desktop server development for IoT. And the talk not just about server-side and gateway-side, but also on-for-device, like each devices of IoT, which means deeply embedded development, no real OS, no Linux, just some RTOS, maybe bare metal at all. Yeah, but scripting languages are high-level and do they allow fine control? And can they work in scarce resources, which deeply embedded devices have? And for example, can we run a full scripting language, or like a useful subset of scripting language, which is just a few hundred of kilobytes of ROM, and dozens of kilobytes of RAM? Yeah, so we can, and by now there is even a choice. It's a pretty hard area. There are a few projects. So in this presentation I specifically would like to focus on two implementations. It's MicroPython, which implements Python's real language subset. And Jerascript Plus, the four-dot.js projects, which implement JavaScript 5 plus Node.js subset. Yeah, so there are some vanity figures. To explain, Jerascript implements just a core of JavaScript language. It's like no input-output support. Zephyr.js project builds on top of that to provide actual something useful, so you can work with hardware to input-output. And yeah, both these implementations have board for Zephyr.rTOS, and that's why we discuss it and compare them. Okay, so a few words about each language, well, with my perspective. Yeah, so Jerascript appeared in 1995. And well, it started, of course, as a browser scripting language alone to just script the pages. And yeah, I remember old good days when the only place you could see Jerascript in action was like Netscape pages about dynamic HTML, then it was called and there was various examples, which worked only for Netscape browser 4.0 and barely anywhere else. And for a long time, well, then other browsers picked up Jerascript implementation, but it was plugged for a long time by incompatibilities between browser і API was pretty bare. Yeah, but as time goes by when web 2.0 was introduced, it was centered around all these dynamic scenes and Jerascript API started and projects around it started to blossom. And yeah, so if it's good for web pages, then maybe it's good for everything. That's how Node.js project appeared, which followed the idea like JavaScript everywhere, not just on client-side and browser, but also on server-side. And nowadays it's like being pushed everywhere. But yeah, there is a good saying by Abraham Maslow, who is author of Psychological Idea of Netscape. I suppose it's tempting if the only thing you know is the hammer to treat everything as a nail. So one criticism of this Jerascript everywhere approach is that it tries to push a language, which was initially designed just to script web pages to everywhere and treat it as a golden hammer and approach and a problem with how it started initially and browsers with many limitations. So Python is appeared four years before JavaScript, so it has a bit more history. And yeah, it started like standard language, which you run just from command line on your system with Linux or Windows or macOS. It supports different operating systems almost from the start and was multi-paradigm from the start, so it was used for scientific computing. Its main author is a physicist who worked in CERN initially where Python was written and used for system administrations that web development, mostly of course server-side development, and it's pretty easy to learn initially language, used in education, etc. So it never was like number one on any language list, but usually number five, and a lot of people know it. Yeah, Python community is very prolific. There are different limitations written for this more than almost 30 years. Yeah, I mentioned JavaScript problems. Yeah, Python has its own problems. To mention one, it's like Python 2 versus Python 3 split. So Python 3 is new version. It was upgraded, some syntax was changed. And there are still split in the community because Python 3 was released like eight years ago. But Python 2 is still well supported and well some part of the community don't even want to upgrade due to good support of the old version. Yeah, okay, moving closer to embedded in IoT, one of the myths I keep hearing and like a lot of people expecting that you can take all the wealth of software written for scripting languages and just put it on embedded systems and like reuse. Yeah, that definitely hardly can be the case due to very big difference in the scale of resources. So for example, like a typical deeply embedded system still has like 16 kilobytes of RAM and this machine I present from has 16 gigabytes of ROM. So one million difference in RAM available and RAM is by and large the most precious resource for scripting languages. So most useful software would likely be written from scratch for a deeply embedded systems in these languages. But of course all the skills could be reused and maybe some support libraries could be ported or written from scratch. Yeah, but with all in mind that we can't use the software as this but implementing some particular languages is definitely easier if target language is small. And JavaScript has better features or smaller features set so it's easier to implement a JavaScript engine which I'll mention because of smaller features set and for example JavaScript project actually implements complete ECMAScript 5 standard which is still like two generations behind the latest ECMAScript JavaScript, which is 7. Yeah, Python has it's more like better as included which means that it packs a lot of functionality it's packs a lot of functionality in the language and there are even really big West standard library so you can write a lot of applications just with standard library. But of course for our use case it would be like throwback and it's not realistic to implement entire Python language only some subset makes sense. Yeah, but there are drawbacks in being small language too for example if we're going to another extreme there is like language which we abbreviate BF which effectively implements just a TuralMation. Yeah, you can look up but I'm sure a lot of people heard about it. By the way, I'm very sorry can you hear me well because yeah, great. Yeah, so which almost machine implementation is very simple but develop an application is very challenging so if it gets too simple like too small language that it actually gets harder to program it. Yeah, and another issue with small languages is that there are a lot you need to rely outside of the core languages and for example there was an interesting heat in JavaScript community when some package like literally doesn't online package was pulled from its standard location and it broke thousands of packages. I don't know, I didn't follow this case I googled it up again and it's just journalists' titles but you see how it's presented. So being too small has a problem being too big also has a problem so the nice idea for language for IoT for deeply embedded IT would be finding a sweet spot and yeah, so different languages implementations which we've reviewed here go for its own sweet spot so for example from most complex it's complete Python implementation MicroPython tries to be subset of that then JavaScript the core language is even smaller you can go even smaller with law I don't follow discuss specific implementation but there are of course more than JavaScript and Python of course and well complete extreme is BF language but if we go beyond just the core language there are standard libraries so with ECMAScript there is no standard library on the language but to realistically use JavaScript at ECMAScript there is still a standard library even in browser there is extension not just a language but some models, some libraries and when you add standard library to a picture it gets above the same or JavaScript that only subset of standard library can realistically be implemented so for example while JavaScript implements complete ECMAScript 5 language Zephyr.js which builds on top of it implements only subset of console specification maybe it will be fixed in the future, maybe not but realistically no complete API from Node.js can be put into IoT because well Node.js is few megabytes and we are talking about hundreds of kilobytes of code yeah, so that was already talking about different paradigms, different approaches of languages, MicroPy and we also suggest great plus for this another point or decatomy to work to decide is what we develop language for like on the one extreme you can have just main function written in scripting language and everything else develop and see it's of course like the generate case, it's not realistically useful so no language implements on that but another case is that we try to allow to implement even the lowest level operations like all operations in high level language and that's actually MicroPy some way, so it tries to do as much as possible and for some platforms not currently for Zephyr but for some B-metal platforms it allows for example to write interrupt handless in high level language to initiate any low level operations like set up DMA and all that stuff MicroPy some's idea is to be general people's language like during complete you can do everything I need and how it's being developed is that we usually start from smallest things and build bottom-up functionality on top of that and Zephyr.js from my point of view I didn't mention that I actually come maintainer of MicroPy so I know it pretty well and I'm contributor to Zephyr.js so I know a lot of MicroPy some and I'm still known on Zephyr.js but I tried to do my homework very well before the session like contributed more or less sizeable codes and from my point of view and Zephyr.js is still pretty young project is probably like maybe 9 months in development and probably less than half year as open source project it's still developing but my current outlook is that it starts from the middle approach like it keeps some basic functionality for example standard TCP-UTP support code but for example open connectivity foundation OCF bindings before that and another dichotomy of the same question what we develop language for is either we support one specific product, one specific board I don't know for example Arduino 101 or we try to write core language implementation which can be ported well to any board something like that Definitely each project initially starts viable project starts which do something working for just one platform but MicroPython has a name to be a generic language which can be ported on to any almost how I formulate MicroPython runs everywhere and we try to achieve that and provide common APIs etc and Zephyr.js currently officially supports so it runs on top of COS which already supports like a few dozens of boards but it itself supports just two boards officially Arduino 101 and Freedom Board K64 and my actually interest in making Zephyr.js support more boards until now I was interested Yes, so let's talk about it that MicroPython has different different target support we started with bare metal support for STM32 and with support for Linux port I talked about but Zephyr.js officially supports this It's already possible to run it on any Zephyr board due sense to patches contributed but me but only basic GPIO support so you can make a blinking demo to show that something works Yes, so important part of yeah, existing part of both projects is Linux port and both projects have it and for MicroPython it's very important part because that's part where regression to suite is being run because yeah embedded hardware is different people have different hardware but like big system, Linux system for example everyone has it and that's place to develop and comfort and also run to suite and comfort and Zephyr.js also has Linux port but it is somewhat under maintained currently and I myself even don't know exact direction so I'm trying to use my experience with MicroPython in my understanding an approach and contribution to Zephyr.js so I think Linux port is being important but yeah, it's currently in pretty flaky shape like you run in a script it doesn't like it goes into net loop and so it's really hard to use it and I don't know what exactly project wants to it because one way maybe not spend effort on Linux port and for example to use Node.js and I heard that from Jeff project leader so yeah, I don't know which way it would go Okay, so more about testing so both project have to suite support and continuous integration on GitHub both hosted on GitHub and use Travis CI also in MicroPython we also measure coverage and fight for coverage and have pretty, pretty good coverage for an open source project so when I wrote this it was 97 due to factor and drop to 96.5 something like that, but yeah we maintain it like that Well, so Jeraski project has also comprehensively suite and yeah, for MicroPython it's possible to run this both on Linux but also on target yeah, there is not so big coverage on targets on embedded targets but it's still possible to run it Jeraski have very good also comprehensive to suite, but I don't know I didn't see option to measure coverage and it's not possible to run on device to suite on device Well, and for the project Node.js it's still information stage like I submitted like how to use the suite for the Node.js and since that there are big improvements but it's still not possible to make test and get the test you would need to reverse engineer a bit how it works and it's on my to do to follow all these three factors it would be nice to have like easy to use for that Yes How default development environment is structured so for MicroPython tries to follow upstream see Python, big Python project as closely as realistically possible, so we have default mode is interactive prompt like you connect via UART and you start start typing and we also have like Python language as peculiar as it is that has new lines in white space important for interactive use that may be a bit of chore but we have to indent and other completion support to make that easy Yes, the default mode operation is that you take your application, JavaScript application and build complete image to flash and it runs Yes, there is interactive mode for the third JS shell but yeah, to my shame I still didn't try it so I cannot see how good it is because it's somewhere in the background and I'm actually a bit afraid to try it because I'm afraid that it works only on Arduino 101 and I work on freedom board I don't know if that's true but I'm just afraid to get dragged into resolving those issues we'll have another MicroPython also has this mode to bundle user application for production deployment Yes, so that was more or less high level comparison of paradigms and approaches and yeah, going further I would like to delve into more detailed comparison of languages and implementations too How languages including scripting languages differ is strict versus weak type almost all scripting languages are dynamically typed like you cannot declare type of variable and can put into any variable any type but some languages have types associated with values well all have and Python specifically is more strict than other scripting languages usually so for example in Python you cannot subscript array with a float it's an error, it doesn't make a sense and Python errors and that another interesting example is concatenating string and integer so you see in different scripting languages result is different like in JavaScript it takes type of left operand and in PHP in right operand if you work in more than one language you can end up with errors if you are not careful on API level JavaScript also has only one numeric type which is floating point number and Python offers separation between integer and floating point which for deeply embedded systems could be and definitely is a good point when you write code you can know exactly what you are writing on integers or floating points and of course there is a difference because deeply embedded simple microcontrollers don't have floating native floating point support and it's interesting so Jerascript has on its internal level separation between store and integers and floating point but it's public API which is recommended to use and which for example do JS use reduces everything to just floating point numbers like external API I don't know to say deficiency or just trade Micro person at all can be built without floating point support and also continuing that ID is hierarchy of variable strictness for example in law also for comparison you can take non-existent variable and use it in expression and it's not error like it's special but valid value in Jerascript this case which is valid in law leads to error but you still can access to non-existent property and it gives valid value not error so in Python all these are errors so it's most strictly type language which also closer to completely strict strictly type language like Java CC++ and in them of course everything using run type is error but you need to declare everything very very carefully and in case of Java it's very long name usually yeah compare container type again as I mentioned Javascript is conceptually simple language just one container for all cases that you may need it's called object and it's used to pre-represent objects dictionary and even arrays pure ECMAScript 5 specification when you create an array actually it involves access and it involves conversion from integer to string keys in Python there are well defined single proposed containers for example there is list which guarantees all from one access like constant time access and there is separate dictionary and objects are also separate so implemented on dictionaries yeah differences in memory management so MicroPython is solely garbage collected language and yes because the most efficient way you don't have any extra overhead in storing objects so no reference counts no pointers, nothing Javascript uses combined GC plus reference count well it's known that reference counting alone is not enough for general peoples scripting languages because loop and reference would lead to not collectable sense so they use reference counting and the C2 so reference counting also used by full Cpython implementation and yeah so there are definitely like benefits from using reference counting that you usually can free up memory a bit earlier than with just pure GC but also it requires storage for reference counters and it complicates the API a bit and yeah I know that because Zephyr.js is like only recently so to say get the reference counting well and we discussed this job again if it makes sense to optimize it but yeah the response that yeah no that's crazy no need to optimize it, let's do it simple way otherwise it's very easy to get into errors yeah so as a advanced since which Javascript has is compressed pointers it's like can use just 16 bit for storing object pointers but yeah for some kind of objects it can reduce memory requirement and half but also limits the heap size to half megabyte yeah it's probably okay for just IoT usage but drawback in language which cannot scale be here for example maybe next year we have one megabyte as it's baseline maybe 2S from this in microcontrollers but they solve that and it's possible to use 32 bit pointers we also would like to implement compressed pointers in micropython but didn't get to that because well it's optimization and doing it prematurely can complicate further maintenance yeah and also for my not very deep research but there was chunking implemented in Javascript which is another very interesting optimization technique used to fight the fragmentation which is big problem that later but my understand is that it was removed apparently because of complications with maintenance yeah and actually the biggest challenge in the scripting languages language phase is on constrained platform like deeply embedded like each IoT use cases is memory so scripting languages call for like easy style to write applications where you don't care much about memory memory management yourself it's supposed to do automatically and it's easy to write code which does a lot of allocations and collections etc and memory fragmentation is the biggest issue for writing like real world long running applications in scripting languages and it's actually of course not scripting languages problem pose it affects any system which uses dynamic memory management and that's why of course our TOS and deeply embedded software tries to use statically allocated pools objects etc that's the way default way for the for RTOS but with scripting languages we definitely need dynamic allocations that's one of the biggest point of using scripting languages is not to care about that memory allocation and let interpreter VM do that and one way to resolve that would be to use compact and garbage collectors but so it's very well known technique in 60s of previous century for various languages but developing it well and for more or less big in functional language so initially such implementation all the garbage collectors etc we prototyped for least scheme languages which has very small domain of operations for bigger languages even javascript and specially Python it would require some well a lot of work to get it right to develop it so that's definitely something we would like definitely to look into MicroPython I don't know so I don't didn't hear so far much from people actually using javascript or zephyr.js in real projects about memory problems but my expectations as more people start to use it they will surface and it will require some attention so it's a big task to implement more advanced garbage collector and well we are waiting in MicroPython for stick hold this is like maybe one man year or half man year so it's a long work you cannot do it like in your free time somebody really should need it assign you to it pay for it or whatever but we are trying to improve no allocation support in Python and Python is good for that that it supports no allocation operations and like in place operation it's memory view memory view objects which allows it to improve on that again I don't know how grave this problem for javascript and for javascript I'm sure that core team faced cases they ran out of memory but was it fragmentation or just trying to put too much into RAM it's something to to have a look yeah a few words about hardware API it's easy to implement some API's functionality when we just inherit them from upstream languages they are just like well known we just need to find what subset of them we implement just cut some some extra pieces which don't fit but when we hit API's which are not well supported on upstream languages like for example hardware access API well a big problem so currently there is somewhat common approach in both Micropycin and Node.js and I was pleasantly surprised to see it in Zephyr.js that they both use object-oriented approach like for example GPIO pin is real object you call methods on it and yeah it's easy to understand conceptually and to a big extent because many other languages for example are other JavaScript bindings I saw use functional approach where pins are identified by numbers and you call functions on them and it's less easy to extend well I know that Zephyr.js rewrites as I had the code or this branch with new API I didn't have chance to look at that so I don't know how it changes but the fact that it's hard to implement hardware API it requires various approach in Micropycin we fight with that last year and a half because a lot of backshed and different people want different things we cannot stabilize but we are moving but slowly very slowly Zephyr.js is pretty young but already have rewrite of that API that's another big problem with memory management yeah I guess we can pause here other questions custom minutes left well my own opinion go is not script and languages it's more classical compiled language probably on the level of Java which has automatic memory management strongly typed but compiles to native code and I didn't hear about go port to deeply embedded hardware because its runtime is pretty big for that usage it's in contrast to Rust which actually its usage seems to grow into embedded space but it's still compiled language relatively low level there are both there was a slide on that default mode of operation for Zephyr.js is pre-processed, pre-compiled into bytecode and then ship, flash and run that but it has interactive mode for Microperson interactive mode is default you start with that but you can also optimize it to run one specific application yes it's essentially of course not the primary purpose but for example when this support was merged support of such feature was merged into Microperson I personally was a bit concerned because it's not like wide open source community needs that essentially it's like particular vendors which tries to do specific product would be more interested and it's still not like there are still things to improve and it would be better if it was completely implemented based on some specific request based on some contract but well it's needed to maintain a feature parity with other languages explicit memory management to Microperson or it would cease to be related well it depends on what you mean by explicit memory management no so Python has support for in place operations they are a natural part of language and they fit pretty well and you can do a lot but not everything for example string manipulation is inherently like dynamic memory reliquation if you work with strings you will allocate memory but if you work with buffers it's a similar concept to go like I can say that some features from Go taken from Python there is like some also parity but yeah it's definitely an optimization you would initially write in standard style in Python and then if you have problems you would optimize if it works as this then there is no optimization but if you run out of memory if you want to do a lot on MCU you can with Python you can Microperson you can optimize yes we have specific set of tests in our regression tests which like re-disable GC and then test some operation and yeah so it's regression tested again I can very well talk about that for Microperson because I am part of that for few years and have only basic ideas about JavaScript so for Microperson it doesn't ship complete standard library like Cpython does but there is separate project also part of the project which is provide all the modules in standard Python library one by one and these are sometimes they are dummy like they we just reserve space but don't implement it sometimes they are written from scratch but some are actually imparted from Cpython and sometimes it work at all sometimes maybe a couple of lines changes and for me it was important point to prove that we actually develop a small but Python implementation so we can run a real Python code yeah and we probably okay three minutes okay then just conclusions conclusions and approaches so JavaScript implements the whole ECMAScript file language but yeah for the speaking it's not too much but it's important checkpoint yeah Microperson seeks to find a good sweet spot of supported subset of Python 3 yeah both languages implement just a subset of yeah I'm sorry I didn't answer about JavaScript your question libraries yeah so one interesting point just as this reminded me is that one of tests which javascript developers use is running SunSpider javascript benchmark so it's more this big javascript code and it runs on javascript it's like with big heap but it runs yeah we can run standard Python benchmark Python yeah but it's one small benchmark we didn't try to run more much more than that so Microperson is strictly typed and good inventory of types javascript is weakly typed and just one object but universal object yeah and the point that currently ECMAScript 5 is supported by javascript but work on adding features from ECMAScript standard versions in ongoing and for example recently ECMAScript 6 typed arrays yeah so UPy tries Microperson tries to be like look and feel of big Cpython but that zephyr.js tries to be like production ready from the start have that feel yeah and memory management is definitely the next big challenge I expected would be the same for javascript based project and I don't know I would expect it to be more problem because yeah it lacks was it a fine grained details and separation of Python but we will see maybe reference counting does make a difference I don't know and general conclusions that yeah if you think that javascript is universal is one and only choice for IOT yeah there are other languages other choices to also be there for example Microperson but there are many other languages again I review javascript zephyr.js Microperson here because they work support zephyr.js which is new exciting RTOS we hope would be Linux of deeply embedded and of course don't try what I say here I tried to be objective I don't know how good I was but I would be definitely biased because I'm commentator of Microperson and I do it even in my own free time while I contribute to zephyr.js in my employer's time so give it try yourself and both projects need contributions and it's not just contribution to the codebase we really need people to start writing applications and then tell us what they find the issues good, bad, what we should do and if you're not convinced and prefer to keep writing and see it's pretty good, both projects are written and see I guess it's fair to say that we write in C to write less in C in the future but we definitely see that we keep writing just a little bit and if you like Microperson tell my boss ok, thank you