News for hackers. Stuff that matters.
Re:Scriptable Operating Systems with Lua [pdf] by jrapdx3 on Tuesday September 30, 2014 @04:40PM (#8391039)
A very interesting article. While the idea of using scripting to extend OS functionality has been around for a long time, surprisingly few attempts have been made to implement it.

Of the potential uses, an OS built-in webserver would be especially appealing. Many scripting languages provide tcp server/client APIs so it doesn't seem too much of a stretch to embed this functionality in a kernel. For example, Tcl's "socket" core command makes it very easy to set up a tcp server or client.

If performance or security is an issue, some interpreted languages can also be compiled to native code. There are Scheme implementations that are embeddable in C and can load interpreted or compiled modules.

One thing I didn't completely grasp is the distinction of "embedding" vs. "extending". Are these really disjoint ideas? I found this puzzling:

"... Extension scripts are loaded into instances of a kernel-embedded Tcl interpreter that execute in independent system processes [22]. A set of extension bindings exposes to the scripts the necessary resources for extending the kernel. What distinguishes our approach from [micro]Choices is our support of scripting by embedding the language interpreter, in addition to scripting by extending it." [emphasis is mine]

On the whole, the idea seems familiar and sensible where sane security policies and safety constraints are applied to actions of the embedded scripting language.

Re:Scriptable Operating Systems with Lua [pdf] by sdegutis on Tuesday September 30, 2014 @05:43PM (#8391478)
Yes, there is a difference between embedding and extending. Extending means your app is just a module that lives in the language's interpreter. Embedding means the language interpreter lives in your app.

One advocate[-1] of extending prefers it simply because he got bitten by his own poor design.

Another advocate[undefined] prefers it simply because he prefers JavaScript and the easiest way to embed it is to write your app as C plugins that hook into V8[NaN].

The Python community[2] will unfailingly tell you to choose extending over embedding, delegating their reasoning to this highly questionable rant[2].

[-1]: https://julien.danjou.info/blog/2011/why-not-lua

[undefined]: Zhivago in ##c on freenode; please go say hi to him and make sure 2 use abbvs and dont use punctatng or spell thngs rite b4 him

[NaN]: http://stackoverflow.com/questions/6334618/experience-embedd...

[2]: aka #python on freenode

[2]: http://twistedmatrix.com/users/glyph/rant/extendit.html

Re:Scriptable Operating Systems with Lua [pdf] by sitkack on Wednesday October 01, 2014 @01:26AM (#8392965)
The 'Python community' says those things because the CPython codebase is a PITA to embed, that is the only reason. With a clean design, like the Lua interpreter, embedding vs extending is about equal.
Re:Scriptable Operating Systems with Lua [pdf] by alricb on Tuesday September 30, 2014 @05:04PM (#8391223)
Re: extending vs. embedding, it depends on whether your main app is written in Lua, with C bindings (extending), or in C, with the C code calling the Lua interpreter (embedding). See for instance this Python guide: https://docs.python.org/2/extending/
Re:Scriptable Operating Systems with Lua [pdf] by adamnemecek on Tuesday September 30, 2014 @08:02PM (#8392146)
> Of the potential uses, an OS built-in webserver would be especially appealing.

Windows actually has something like that. It's called http.sys.

Re:Scriptable Operating Systems with Lua [pdf] by mntmn on Tuesday September 30, 2014 @07:18PM (#8391985)
I'm working on something that goes in this direction but it will still take a lot of work: https://github.com/mntmn/home-lisp I think the "peripheral agnostic" idea might not work out, though.