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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Collapse OS – Why Forth?

281 点作者 crousto将近 5 年前

34 条评论

megameter将近 5 年前
If I had to put my finger on why Forth is hard for most programmers, it&#x27;s like this: the structured program theorem suggests using sequence, selection, and iteration to control program logic. Assembly code on hardware architectures will assign all meaning sequence-relative, late-binding the selection and iteration. Forth doubles down on this sequence-first approach through a more versatile assignment mode(the stack) while only minimally accommodating the other two. That makes it easy to implement, while not explicitly addressing expressability.<p>Forth written &quot;flat&quot; with shallow data stack usage is assembly by another name, a wrapper for load-and-store; Forth that does everything with intricate stack manipulation is a source of endless puzzles since it quickly goes write-only.<p>But, like any good language with meta expression capabilities, you can work your way up towards complex constructs in Forth, and write words that enforce whatever conceptual boundaries are needed and thus check your work and use the system as a compiler. That&#x27;s what breaks Forth away from being a simple macro-assembler. But you have to write it in that direction, and design the system that makes sense for the task from the very beginning. That falls into an unacceptable trade-off really easily in our current world, where the majority of developers are relatively inexperienced consumers of innumerable dependencies.
评论 #23453784 未加载
评论 #23453640 未加载
评论 #23452372 未加载
评论 #23459158 未加载
评论 #23453805 未加载
评论 #23460204 未加载
jstanley将近 5 年前
If this gets you interested in z80 hardware, I would recommend building an RC2014: <a href="https:&#x2F;&#x2F;rc2014.co.uk&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rc2014.co.uk&#x2F;</a><p>I built an RC2014 after CollapseOS was posted last year, and thoroughly enjoyed it.<p>I ended up adding a front panel, complete with switches and lights, to allow toggling in and executing code without a ROM, and also wrote a HTTP&#x2F;1.0 server for CP&#x2F;M (which was an enormous headache for lots of different reasons). Never did get around to running CollapseOS on it though.
评论 #23451298 未加载
zentiggr将近 5 年前
I think I&#x27;ve had my own moment of clarity that spans both Forth(s) and Lisp(s) and explains why neither is as common as other languages.<p>In most common languages, there is a complicated base spec that covers many cases and defines a broad range of affordances, plus libraries and libraries that expand on an already fleshed out collection of tools and etc.<p>Forths and Lisps give you the core of an environment, and let&#x2F;expect you to build on the foundation to create your own implementation. Like someone else in this thread said, N programmers, N dialects. Or, more accurately, every Forth program is its own DSL for accomplishing its work.
评论 #23452541 未加载
评论 #23454612 未加载
评论 #23456754 未加载
评论 #23453409 未加载
评论 #23456582 未加载
ojnabieoot将近 5 年前
I hate this headline but the project is very cool. People like me who were ignorant should start here instead of the Github to get a better sense of the design goals (and why they are using Forth): <a href="https:&#x2F;&#x2F;collapseos.org&#x2F;forth.html" rel="nofollow">https:&#x2F;&#x2F;collapseos.org&#x2F;forth.html</a>
评论 #23450666 未加载
评论 #23450764 未加载
评论 #23451690 未加载
bsaul将近 5 年前
First time i hear about this project and i love it.<p>I often talk with a friend who&#x27;s an historian, and that makes me realize how our relationship with time, as an industry, is extremely short sighted.<p>The internet archive is an immensely valuable project, as well as all the websites archiving old documentation, etc. But i don&#x27;t think a lot of people realize the value of things they&#x27;re destroying everytime they execute a delete statement in a DB or a filesystem.<p>This Collapse OS ambition to be able to &quot;bootstrap&quot; something useful over any kind of primitive hardware and sustain the passage of time ( or catastrophic event) may have an immense value in the future.
评论 #23458736 未加载
Narishma将近 5 年前
&gt; The Z80 asm version of Collapse OS self-hosts on a RC2014 with a 5K shell on ROM, a 5K assembler binary loaded in RAM from SD card (but that could be in ROM, that&#x27;s why I count it as ROM in my project&#x27;s feature highlights) and 8K of RAM. That is, it can assemble itself from source within those resources.<p>Meanwhile, you can&#x27;t compile rustc on a 32-bit system because it runs out of address space...
dreamcompiler将近 5 年前
There seems to be a common conception that Forth is always interpreted by some kind of virtual machine. But it&#x27;s quite possible to compile Forth all the way down to native machine instructions with no loss of interactivity and without losing the rapid bootstrap capability the author describes. Such a Forth runs almost as fast as C (<i>almost</i> because modern out-of-order and other processor optimizations probably don&#x27;t work well on compiled Forth code).<p>I used this approach when I bootstrapped a Forth compiler on the TI 34010 graphics chip in a similar fashion as the author. It even had local variables so you didn&#x27;t drive yourself mad thinking about the stack all the time.<p>My favorite commercial example of such a Forth was Mach 2 Forth on the early (pre-OSX) Macs. I don&#x27;t know if any modern Forths do down-to-the-metal compiling or local variables, but I&#x27;d be interested to find out.
评论 #23453980 未加载
krick将近 5 年前
I thought this is pretty fun project and the idea is just cool right away, but then I went on reading and was surprised by the fact it seems the author is serious. I would be really curious to hear his opinion on why the supply chains should collapse before 2030. Obviously, there wouldn&#x27;t be a shortage of people in the comments who can start speculating on why it might happen, and, of course, I myself also can provide a couple of feasible scenarios, but nobody of us were serious enough to actually start this project, so <i>his</i> opinion on the matter is somehow quite more interesting to me than it would normally be.
评论 #23451451 未加载
评论 #23451915 未加载
评论 #23451210 未加载
onetom将近 5 年前
I&#x27;m surprised that no one has mentioned <a href="https:&#x2F;&#x2F;flashforth.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;flashforth.com&#x2F;</a><p>There is no intriguing backstory for it, like for CollapseOS, but it&#x27;s a ~6 kiloword, practical 4th environment for Microchip PIC microcontrollers, which are a lot simpler than Z80, btw... The source code is trivial to understand too. My father is still using it daily to replace&#x2F;substitute Caterpillar machine electronics or build custom instruments for biological research projects.<p>We started with Mary(Forth) back then, when the first, very constrained PIC models came out, with 8 deep stack and ~200 bytes of RAM. Later we used the <a href="https:&#x2F;&#x2F;rfc1149.net&#x2F;devel&#x2F;picforth.html" rel="nofollow">https:&#x2F;&#x2F;rfc1149.net&#x2F;devel&#x2F;picforth.html</a> compiler for those, which doesn&#x27;t provide an interactive environment.<p>I made a MIDI &quot;flute&quot; with that for example, which was fabricated from sawing out a row of keys from a keyboard and used a pen house as a blow pipe and a bent razor with a photo-gate as the blow-pressure detector...<p>There are more minimal Forth OSes, which might be more accessible than a Z80-based one.<p>I would think those are more convenient for learning, how can you have video, keyboard and disk IO, an interactive REPL and compiler in less than 10KB<p>I remember, I played a lot with <a href="https:&#x2F;&#x2F;wiki.c2.com&#x2F;?EnthForth" rel="nofollow">https:&#x2F;&#x2F;wiki.c2.com&#x2F;?EnthForth</a><p>But if you really want to see something mind-bending, then you should study Moore&#x27;s ColorForth! I found it completely unusable, BUT I&#x27;ve learnt immense amount of stuff from it: <a href="https:&#x2F;&#x2F;colorforth.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;colorforth.github.io&#x2F;</a><p>There are more usable variants of it, btw. Also worth looking into Low Fat computing: <a href="http:&#x2F;&#x2F;www.ultratechnology.com&#x2F;lowfat.htm" rel="nofollow">http:&#x2F;&#x2F;www.ultratechnology.com&#x2F;lowfat.htm</a> I think it&#x27;s still relevant today.
TheUndead96将近 5 年前
The weird thing about history is that it only makes sense backwards. Someone 500 years in the future might think of this as the Gutenberg printing press. It is often difficult to appreciate the magnitude of actions in the present.
评论 #23454463 未加载
RodgerTheGreat将近 5 年前
I&#x27;m delighted to see that hsoft took suggestions about Forth to heart, and that it has lead to both simplification and enrichment of the project.
tarkin2将近 5 年前
I love this project. Thank you for posting it. The idea of a post collapse operating system reminds me of slackware&#x2F;subgenius’s old slogan: “...the world ends tomorrow and you may die!”<p>I’ll be trying to compile collapseos, write forth and load slackware on floppys in a few years then. (Will systemd survive civilisation’s collapse, especially when it caused it, that is the question....)
评论 #23451107 未加载
haolez将近 5 年前
&gt; Some Forth enthusiasts like the language for itself. They think that its easier to express much of the logic of a program in this language. Many books and tutorials are touting this. [...] That&#x27;s not my opinion.<p>In my opinion, it&#x27;s not that FORTH code is hard to read, but that FORTH gives the programmer so much freedom that every program becomes its own microcosm of DSLs.
评论 #23452344 未加载
pwdisswordfish2将近 5 年前
<a href="https:&#x2F;&#x2F;collapseos.org&#x2F;why.html" rel="nofollow">https:&#x2F;&#x2F;collapseos.org&#x2F;why.html</a><p>&quot;That being said, I don&#x27;t consider it unreasonable to not believe that collapse is likely to happen by 2030, so please, don&#x27;t feel attacked by my beliefs.&quot;<p>Triple negative? Quadruple negative? (If we count the second &quot;don&#x27;t&quot;.)<p>Compare something like:<p>&quot;I consider it reasonable to believe that collapse is unlikely to happen by 2030, so please, don&#x27;t feel attacked by my beliefs.&quot;<p>It is almost as if the grammatical structure reflects the life perspective of the author.
评论 #23452042 未加载
评论 #23452781 未加载
评论 #23451374 未加载
评论 #23452061 未加载
评论 #23451598 未加载
messe将近 5 年前
Nice. Must revisit my own Forth OS, or maybe just start contributing to this.
mshockwave将近 5 年前
this might be a dumb question but can someone briefly explain why Forth is more suitable over C or other languages in general on post-apocalyptic OS?
评论 #23451470 未加载
评论 #23452624 未加载
评论 #23451284 未加载
评论 #23451975 未加载
bitwize将近 5 年前
This is the kind of malarkey I&#x27;d get up to on a personal project of mine. Like, I wonder if I&#x27;d get farther if I&#x27;d written it in Forth&#x2F;TinyScheme&#x2F;Erlang? May as well completely overhaul it and find out!
jvanderbot将近 5 年前
I feel sheepish for being on that thread as a detractor, after reading this post.
redisman将近 5 年前
Love this project. I wonder why not make it run on smartphones? I&#x27;d imagine that&#x27;s the vast majority of computers out there today. Easier to find a working smartphone than retro consoles.
评论 #23461245 未加载
评论 #23456672 未加载
Koshkin将近 5 年前
CollapseOS? Meh. What we need is ApocalypsOS. Something to play Tetris on after having hauled a bucket of wellwater (and some wood) to the 23-rd floor apartment where I try to survive.
dang将近 5 年前
See also <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21182628" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21182628</a> from last year.
MaxBarraclough将近 5 年前
On the topic of compactness: is FORTH ever used in the demoscene?<p>As I understand it, they tend to write assembly, and compress the resulting machine code, for decompression at runtime.
jbb67将近 5 年前
I want to learn forth now. Where can I find a modern usable forth that works well on windows to make real programs? Does such a thing even exist?
评论 #23454676 未加载
fouc将近 5 年前
I keep hoping that a Rubyist will someday do the same thing for Forth like José Valim did for Erlang, with Elixir.
pwdisswordfish2将近 5 年前
Here is a Forth you can use on Linux and Windows<p><a href="http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20080828064920&#x2F;http:&#x2F;&#x2F;ronware.org&#x2F;reva&#x2F;wiki&#x2F;stable" rel="nofollow">http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20080828064920&#x2F;http:&#x2F;&#x2F;ronware.org...</a>
garmaine将近 5 年前
Forth is Lisp, but with composition as the basic operator instead of application. The result, of course, is a wildly different language but one which inspired the same degree of fanaticism among its adherents in their search for simplicity and elegance.<p>A truly under appreciated language imho.
评论 #23453073 未加载
detaro将近 5 年前
somewhat OT, but are there any active Forth communities&#x2F;forums to follow if one wants to see what people get up to with it?
tibbydudeza将近 5 年前
And all I wanted was a pipboy.
johnisgood将近 5 年前
Why not Factor? :P
评论 #23454653 未加载
RandomGuyDTB将近 5 年前
It&#x27;s odd to highlight that Forth is 50 years old, considering C is 48 years old and still in very heavy use in operating systems development.
评论 #23450811 未加载
评论 #23450932 未加载
评论 #23450990 未加载
评论 #23450609 未加载
评论 #23451613 未加载
mlang23将近 5 年前
Forth is one of the last languages on my list. Whenever I read something like this article, I want to learn it. The advice at the end of the article seems interesting. Does anyone have any resources that might help with this?
评论 #23451707 未加载
monadic2将近 5 年前
Is the focus on forth to rapidly bootstrap from more than just z80, or for readability, or for some other concern?
评论 #23450629 未加载
imode将近 5 年前
If the author wants their code to survive the apocalypse, they should generate Turing Machines that have a simple shim interpreter for low-power architectures. The benefit of this is you can build an interpreter for a TM in wood or other simple materials. Semi-Thue systems also fit.
评论 #23462487 未加载
undershirt将近 5 年前
&gt; Forth doesn&#x27;t elegantly describe complex algorithms… However, this mental pain does makes you question your need for complexity… This is something that I think few developers are familiar with and is hard to describe with words. It needs to be experienced.<p>Nice framing, that it’s not an intellectual argument you can make to justify the benefits of drawbacks (i.e. an infamous red flag of stockholm syndrome), so you have to point to the experience of the thing itself (“you had to be there”).
评论 #23451295 未加载
评论 #23452167 未加载