TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Why aren't there DSLs for Operating Systems? (Or are there?)

34 点作者 abrax3141超过 2 年前
There are DSLs for nearly eveything we do with computers. Indeed, even "general purpose" programming languages are, in a sense, DSLs for ... math (Fortran), gofai (Lisp), etc. And of course there are zillions of more specific DSLs. The purpose of a DSL is to reduce the complexity of writing code for the target domain, which usually involves specialized vocabulary, functionality, and syntax. But the most complex programs that exist (well, at least among them) are operating systems. Yet we still build them in general purposes languages, like C. Of course, we almost immediately build a layer of functionality on the hardware and system services, but even when you get to the top, like programming bash commands, it's largely done in C (for Unix-likes). I'm wondering whether/why there isn't a DSL for operating systems. (Or maybe there is, but it's hard to find if so; I've never seen one, and it's a difficult set of phrases to search the web for, so I might be just missing the obvious, for which I apologize in advance, and appreciate the pointers.)

24 条评论

constantcrying超过 2 年前
If you look at C and UNIX, you will see that there is a very intimate relation between those two. If you write an operating system, what is the easiest language to use if you want to build on top of that operating system? The answer is almost certainly <i>the language you wrote that operating system in</i>.<p>In some sense C was <i>the</i> DSL to build UNIX. It becomming a general purpose language happened after that and <i>because</i> of the success of UNIX.<p>Also in general operating systems are extremely complex and need a wide range of functionality and extensibility while being able to easily interface with assembly. That makes a DSL tend towards a general purpose language, as has happened with C.
评论 #33734671 未加载
评论 #33735019 未加载
linguae超过 2 年前
You may be very interested in the STEPS project from Alan Kay’s Viewpoints Research Institute. STEPS was an attempt to build an entire desktop operating system environment with only 20,000 lines of code. In order to accomplish this, the design makes extensive use of DSLs defined using OMeta. There are examples of TCP and the 2D graphics framework being implemented in an impressively small amount of code.<p><a href="http:&#x2F;&#x2F;www.vpri.org&#x2F;pdf&#x2F;tr2012001_steps.pdf" rel="nofollow">http:&#x2F;&#x2F;www.vpri.org&#x2F;pdf&#x2F;tr2012001_steps.pdf</a>
评论 #33735674 未加载
评论 #33735339 未加载
Brian_K_White超过 2 年前
sh IS the DSL*, otherwise, I&#x27;m not sure what you mean by &quot;for operating systems&quot;.<p>The question &quot;What is the domain specific language for operating sysyems?&quot; is meaningless and unanswerable, because &quot;operating systems&quot; does not define the D in DSL in any meaningful useful way.<p>* For instance, when you try to replace all the sh scripts in a distro with say python (as some distros have tried to do) you immediately discover several ways that python is far less convenient for executing external executables and feeding, collecting, piping, their inputs and outputs. Then for all of the arcane annoyances with bash&#x2F;ksh syntax, it&#x27;s basic shell &#x2F; batch &#x2F; glue functionality is more important than all of it&#x27;s &quot;not like a better designed general purpose language&quot; annoyances. In other words, exactly, it&#x27;s not a general purpose language, it&#x27;s a domain-specific language.
johndoe0815超过 2 年前
There are a number of DSLs for specific tasks, such as eBPF or Dtrace filters, Julia Lawall’s semantic patches, DSLs for device driver development or writing system call emulators and many more.<p>A DSL covering more and different parts of OS development would probably have to be so general that it doesn’t make sense not to use a general purpose language…
CharlesW超过 2 年前
If macOS has a DSL, it&#x27;s AppleScript.<p><i>AppleScript is a scripting language created by Apple. It allows users to directly control scriptable Macintosh applications, as well as parts of macOS itself. You can create scripts—sets of written instructions—to automate repetitive tasks, combine features from multiple scriptable applications, and create complex workflows.</i><p><pre><code> set targetFolder to POSIX file &quot;&#x2F;Users&#x2F;Me&#x2F;Desktop&#x2F;MyFolder&quot; tell application &quot;Finder&quot; set finderFolder to item targetFolder set lstTargets to target of every Finder window if {finderFolder} is in lstTargets then set target of (make new Finder window) to targetFolder end if end tell </code></pre> That said, AppleScript is probably not long for this world. The future looks more like visual programming via Shortcuts.
Findecanor超过 2 年前
I&#x27;m not sure I understand the question, but I interpret it as being about one of two things: Importing code written in a DSL into the OS at run-time, and creating a custom OS kernel specified in a DSL at compile-time. There do exist examples of both, and there is some overlap between projects.<p>Widespread examples include firewalls and routing rules written in DSLs, which get compiled into a form that gets run inside the kernel. Example: nftables in Linux.<p>Some research OSes allow drivers to be written in a &quot;safe&quot; language to run inside the kernel. Some perform JIT-compilation, others create a custom kernel at compiled-time. Go search for Scout, Termite2, and Synthesis Kernel.
评论 #33736806 未加载
wmf超过 2 年前
Devil is a DSL for device drivers: <a href="http:&#x2F;&#x2F;phoenix.inria.fr&#x2F;software&#x2F;past-projects&#x2F;devil.html" rel="nofollow">http:&#x2F;&#x2F;phoenix.inria.fr&#x2F;software&#x2F;past-projects&#x2F;devil.html</a>
Const-me超过 2 年前
The definition of DSL is vague, but at least in some sense, some operating systems do implement such a DSL.<p>For Windows between 2000 and 7, that would be VBScript. The language itself is primitive, but through various COM APIs (WMI, ADSI, ADO, MSXML, WScript.Shell, etc.) one can do borderline anything with the OS, or even with the whole Windows networks.<p>Modern Windows, while still supporting VBScript and most of these COM things, has also added PowerShell as another option.
评论 #33734961 未加载
评论 #33735697 未加载
t-3超过 2 年前
Defining a DSL for writing operating systems would essentially be the same as writing an operating system (a huge amount of work!). The range of what an OS does is wide enough that your DSL will probably be pretty general purpose anyway, though.<p>DSLs for interfacing with OSes exist in the form of command shells, syscalls, and ABIs.
评论 #33736772 未加载
wsh超过 2 年前
For many years, IBM has developed its mainframe operating systems in a series of proprietary languages, such as PL&#x2F;S and PL&#x2F;X, designed specifically for systems programming.<p>Compilers and manuals for these aren’t generally available, but here are published descriptions of two older variants, for use by customers who received source listings on microfiche:<p><a href="http:&#x2F;&#x2F;www.bitsavers.org&#x2F;pdf&#x2F;ibm&#x2F;360&#x2F;pls&#x2F;GC28-0786-0_Guide_to_PL_S_Generated_Listings_Jul72.pdf" rel="nofollow">http:&#x2F;&#x2F;www.bitsavers.org&#x2F;pdf&#x2F;ibm&#x2F;360&#x2F;pls&#x2F;GC28-0786-0_Guide_t...</a><p><a href="http:&#x2F;&#x2F;www.bitsavers.org&#x2F;pdf&#x2F;ibm&#x2F;360&#x2F;pls&#x2F;GC28-6794-0_PLSIIguideMay74.pdf" rel="nofollow">http:&#x2F;&#x2F;www.bitsavers.org&#x2F;pdf&#x2F;ibm&#x2F;360&#x2F;pls&#x2F;GC28-6794-0_PLSIIgu...</a>
mrweasel超过 2 年前
Your question isn&#x27;t completely clear. What is it that you want this DSL to do exactly? Windows has PowerShell, which is precisely a language to reduce the complexity of managing systems. AppleScript is a DSL for controlling your macOS desktop (and more). The various shells available on Unix systems works as glue, but perhaps not exactly a DSL in the same sense that I feel PowerShell is.<p>Ansible, Puppet or Nix could also be viewed as operating system DSL. Again depending on what your goal is.
sargstuff超过 2 年前
Depends on how define OS &#x27;DSL&#x27;, &#x27;os&#x27; just metadata bindings for hardware &#x2F; software<p>* embedded os : <a href="https:&#x2F;&#x2F;blog.felgo.com&#x2F;embedded&#x2F;embedded-operating-systems" rel="nofollow">https:&#x2F;&#x2F;blog.felgo.com&#x2F;embedded&#x2F;embedded-operating-systems</a><p>* OS modules &#x2F; daemons : ebpf &#x2F; systemd<p>* ebpf : <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33489935" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33489935</a> ; <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33462031" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33462031</a><p>* tiny core : <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Tiny_Core_Linux" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Tiny_Core_Linux</a><p>* yocto : <a href="https:&#x2F;&#x2F;www.yoctoproject.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.yoctoproject.org&#x2F;</a><p>* &#x27;bootloaders&#x27; don&#x27;t have to just &#x27;load an os&#x27; <a href="https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;syslinux" rel="nofollow">https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;syslinux</a><p>* uefi : <a href="https:&#x2F;&#x2F;askubuntu.com&#x2F;questions&#x2F;651902&#x2F;what-is-the-difference-between-grub-and-syslinux" rel="nofollow">https:&#x2F;&#x2F;askubuntu.com&#x2F;questions&#x2F;651902&#x2F;what-is-the-differenc...</a><p>* OS device drivers for external devices such as printers (post script printers)<p>* OS api&#x27;s
samsquire超过 2 年前
I like your question.<p>I am currently interested in this problem and more specifically the expression problem.<p>Also the problem of how do you tell a computer to do X operation when it encounters Y.<p>Computers are often turning machines and state machines.<p>I recently implemented async&#x2F;await with a giant switch statement.<p>Async await is far more powerful than bash jobs.<p>I think the scheduling of processes on a computer needs a powerful DSL.<p>Kubernetes is interesting since it scheduled processes on a cluster of nodes. But it doesn&#x27;t define pipelines.<p>Kafka defines a pipeline for processing.<p>Bash defined pipelines of operations and processes text.<p>Java streams define a pipeline.<p>JavaScripts promises and C# async&#x2F;await are interesting for scheduling tasks.<p>ETL workflows Extract Transform Load and Enterprise service buses often have visual DSL&#x2F;GUIs with eclipse tools for defining mappings.<p>In Python I often chain together processes with POpen. But it&#x27;s very low level<p>I think all these topics are linked.<p>I want a DSL for defining operations and chaining them together similar to a pipeline. I also want when_any and when_all support and multithreading support.
krylon超过 2 年前
I didn&#x27;t read a lot about it, but I recall that Microsoft created a language called P that was a DSL for writing device drivers (more generally, state machines, but I think the point was to use it for device drivers). I also recall they (allegedly, at least) used it to rewrite the USB stack for Windows 8.<p>Looks like they released the compiler under the MIT license and put it on Github, so you may want to look into it.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;P_(programming_language)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;P_(programming_language)</a><p><a href="https:&#x2F;&#x2F;p-org.github.io&#x2F;P&#x2F;" rel="nofollow">https:&#x2F;&#x2F;p-org.github.io&#x2F;P&#x2F;</a><p><a href="https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;project&#x2F;safe-asynchronous-programming-p-p&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;project&#x2F;safe-asynch...</a>
AnthonBerg超过 2 年前
Programming probably has a better shot at this happening if programming can be automated more.<p>DSLs for operating systems might be easier to write with programming languages that have higher-order unification – meaning that they can automatically piece together programs to fill out the meaning of one smaller word that has a complex, concise meaning – and totality checking, which means that given subprograms can be known to run to completion. And first-class types. (Dependently typed languages.)<p>This combination allows for tightly controlled and deterministic automation of programming, which is especially useful for getting rid of boilerplate code, conversion between formats, serialization and deserialization – and the maintenance of this kind of code… when all targets are moving targets due to many pieces of software that change from day to day. As found in things as complex and arbitrary as operating systems.
p_l超过 2 年前
Original LISP was pretty much a DSL for symbolic computation, something that wasn&#x27;t exactly catered to at the time (it wasn&#x27;t <i>first</i>, but it was so early in computing you could write a Master&#x27;s Thesis about IF-THEN-ELSE construct).<p>That said, various Lisp Machine systems as well as internals of Lisp implementations often contain DSL for implementing the OS&#x2F;language, sometimes with many smaller DSLs (while the ur-example is &quot;LOOP&quot; macro from MIT, my favourite is a file from Genera bearing a comment - paraphrased - &quot;behold, I implement half of PL&#x2F;I to implement structure packing into byte vectors&quot;).<p>Of course, in languages like Lisp or TCL the separation between DSL and main language is not so stark as in case of DSLs implemented in let&#x27;s say C or Java.
abetusk超过 2 年前
This smacks of forgetfulness. I wonder what the age is of the OP.<p>As others have pointed out, *nix systems (Linux in particular) are rife with DSLs. Not just C but (c|ba|k|tc|z)sh, sed, awk, grep, to name a few. Each of these tools has it&#x27;s own mini DSL, some more complicated than others, that can than be composed to with other tools, using their own DSLs to manage tasks (e.g. operating system tasks).<p>Even the task of creating DSLs has many DSLs attached to it (lex, yacc, etc.).<p>Programs that get used and become popular introduce their own DSLs, often times. Apache, NGinx, etc. all have config files that each have their own special sauce of DSL for their own tasks.<p>Even many of the newer systems like Docker, Kubernetes, etc. have config files&#x2F;DSLs to manage them.<p>I&#x27;m sure I&#x27;m forgetting even more.
评论 #33737513 未加载
butMebbe超过 2 年前
We need less DSL, IMO, more constrained code generation from data models.<p>There is so much bloat due to everyone making a DSL to learn distributed systems with, or every little bit of UNIX coming with its own text config format.<p>I’d like to get away from generating yaml for Docker and k8s and import balancing forks of microservice logic v8 style; read kernel telemetry from eBPF in the app to determine how many forks the code can add or needs to subtract, and terraform because it’s still just a Linux box under there.<p>But the cottage industry that profits from these ideas is threatened by these ideas and sticks with showing off a new arbitrary string parser that ALSO sends the strings to an API for you!<p>The software industry has turned into a jobs program and has little to do with novel engineering.
评论 #33734932 未加载
评论 #33735336 未加载
bjourne超过 2 年前
Aside from automatic memory management, there is very little evidence of productivity gains from using higher-level languages. $hypedlanguage fanboys can talk until your ears bleed about why $hypedlanguage is better than the competition. But invariably they can not cite empirical evidence that support their claims. Furthermore, productivity is much more than just programming language (e.g C sucks, but I got Valgrind now so it sucks less). Those who write OS&#x27;es knows this and stick with what works.
评论 #33736925 未加载
评论 #33736919 未加载
评论 #33738662 未加载
评论 #33738681 未加载
closeparen超过 2 年前
I think a DSL is a more often a type of “user interface” for a large and powerful underlying software system, than a way of writing native code for particular specializations. Operating systems <i>offer</i> many DSLs as a way for programmers to interact with them: Linux has bash and eBPF, Windows has VBScript and Powershell, etc.<p>If something were to offer a DSL for writing operating systems with, I think it would be either an embedded platform or a hypervisor.
评论 #33735668 未加载
fsloth超过 2 年前
Wasn’t Python originally conceived as a systems configuration language?
评论 #33735226 未加载
评论 #33735730 未加载
secondcoming超过 2 年前
ACPI is pretty much a DSL, if I&#x27;m not mistaken
评论 #33735275 未加载
coding123超过 2 年前
Domain specific. The entire OS is domain less, it&#x27;s a host to run what is to be your domain. The OS has APIs to get anything done. And there are libraries to access those APIs from many languages, some that can be somewhat labeled a DSL supporting language. But until you have a domain, it&#x27;s just the OS. The OS the non-domain or everything domain.
conorcleary超过 2 年前
I&#x27;ll just state for all us dummies, I suppose, that your casual use of DSL as an initialism without writing what it stands for, is not cool.
评论 #33735342 未加载
评论 #33734752 未加载
评论 #33734757 未加载
评论 #33734739 未加载