|Scratch Can Even Do Linux Kernel|
|Written by Nikos Vaggalis|
|Monday, 11 July 2022|
Is writing a Kernel module in Scratch, the block-based programming language used primarily by kids, possible? Absurd it may be, but yes, it is absolutely possible!
Scratch is the original block-based programming language and still the best known and most widely used. It was invented in 2003 at MIT to make kids' introduction to coding a much smoother experience. That said, the educational value of block versus regular text based languages is highly debated with strong arguments on either side.
Furthermore, a recent official report of research carried out for the UK government found that:
Block-based programming languages can be useful in teaching programming, as they reduce the need to memorise syntax and are easier to use. However, these languages can encourage pupils to develop certain programming habits that are not always helpful. For example, small-scale research from 2011 highlighted 2 habits that ‘are at odds with the accepted practice of computer science’.The first is that these languages encourage a bottom-up approach to programming, which focuses on the blocks of the language and not wider algorithm design. The second is that they may lead to a fine-grained approach to programming that does not use accepted programming constructs; for example, pupils avoiding ‘the use of the most important structures: conditional execution and bounded loops’.This is problematic for pupils in the early stages of learning to program, as they may carry these habits across to other programming languages.
Further research has highlighted that, although block-based languages may help novices to overcome the difficulties with syntax that they can face when learning to program, they do not necessarily help pupils with the semantic and conceptual difficulties. It is therefore important that, if schools use block-based languages, they consider how to design the curriculum to mitigate these potential pitfalls.
On the plus side, block based languages have been found to carry the following benefits:
Since it's visual it's very easy to get started and is highly accessible;you just have to connect visual blocks in a logical way.Then its syntax-free programming takes the clutter out of the way to let students focus on doing something useful while reducing the time to get onto that.
Kid-students aside there's also been attempts to engage block based programming in more sophisticated endeavors.Take for example BlocklySQL, a block-based visual programming tool like Scratch but for SQL.The advantage is that while students use blocks to enter SQL, they can then see, and also export, the auto-generated SQL in order to learn the actual syntax.
The Scratchnative project has gone even further. Taking a Scratch project and converting it to C++ has enabled Scratch to be used for writing kernel modules, which is beyond the ordinary.
The stated goal of the project is to:
"Compile scratch3 code to native executables".
In other words, it takes this
and turns it into this
To work with it, first you need to build the program using cmake, and then invoke it as
scratchnative [OPTIONS] [INPUT]
There's also a Python wrapper which can download the Scratch .sb3 project and invoke scratchnative.
To get a more in depth picture, let's download the Scratch Linux Kernel Modules project from the Scratch website, which gets us a "Scratch Linux Kernel Modules.sb3" file. Renaming it to .zip and opening it we find the project's .json file that describes the project, the one that scratchnative works on. With that we dive into the internals of the native scratch format.
Why that is interesting is that we can observe scratch's opcodes used like :
Scratchnative currently supports the following opcodes:
The "procedures_call" looks especially interesting...
The dev who built scratchnative even created an operating system, ScratchOS, with it.
While these examples have little practical value, they serve as a strong proof of concept of what is feasible in the modern day of transpilers or cross-compilers.
Is that the breakthrough that low or no-code paradigms have been waiting for in order to hit a higher level of sophistication, getting capable of building previously out of reach application even under the realm of system level programming?
Time will show but scratchnative has certainly opened Pandora's Box...
No Language Left Behind - Meta's Progress Toward Universal Translation
Meta has made impressive progress with its No Language Left Behind project. It has already built a single model that can translate between 200 languages and has now open sourced the AI translati [ ... ]
NetBeans 14 Extends JDK 17 Support
NetBeans 14 has been released by Apache, with improvements including more support for JDK 17 and better handling of problem reporting in Gradle.
or email your comment to: firstname.lastname@example.org