[HN Gopher] Collapse OS - Why Forth? ___________________________________________________________________ Collapse OS - Why Forth? Author : crousto Score : 94 points Date : 2020-06-07 20:01 UTC (2 hours ago) (HTM) web link (collapseos.org) (TXT) w3m dump (collapseos.org) | bsaul wrote: | First time i hear about this project and i love it. | | I often talk with a friend who's an historian, and that makes me | realize how our relationship with time, as an industry, is | extremely short sighted. | | The internet archive is an immensely valuable project, as well as | all the websites archiving old documentation, etc. But i don't | think a lot of people realize the value of things they're | destroying everytime they execute a delete statement in a DB or a | filesystem. | | This Collapse OS ambition to be able to "bootstrap" 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. | mlang23 wrote: | 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? | japanoise wrote: | A Forth shibboleth is that you have to implement your own in | order to understand it. Try reading the assembly, then forth | source, for jonesforth: | https://github.com/AlexandreAbreu/jonesforth | | This is how I learned. | bitwize wrote: | This is the kind of malarkey I'd get up to on a personal project | of mine. Like, I wonder if I'd get farther if I'd written it in | Forth/TinyScheme/Erlang? May as well completely overhaul it and | find out! | RandomGuyDTB wrote: | It'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. | downerending wrote: | I suspect that a lot of readers have no idea how old it is. | | ( _I_ , on the other hand, have to be reminded that 50 years | have passed.) | lstodd wrote: | It's odd to compare C and Forth. They are so different. | | Edit: as someone below mentioned there can not be a 'Standard | Forth'. You just write your own one as you see fit. | bitwize wrote: | There's ANS Forth. Chuck Moore doesn't like it, but it | exists. | crousto wrote: | Collapse OS was initially written in assembly for the Z80, a | microprocessor first launched in 1976. The fact that Forth is 6 | years older than the Z80 seems interesting enough of a step | further back in time to be hightlighted. | moonchild wrote: | Not to mention lisp, in which HN is written. | CameronNemo wrote: | Perhaps Forth has changed less than C in that time. The C of 48 | years ago can look quite different from modern C. | RodgerTheGreat wrote: | There has never been one Forth. In a world with N Forth | programmers, one can expect roughly N implementations of | Forth. Perhaps closer to 2*N. An ANS spec exists, but most | Forth programmers would say it misses the point. | | Forth is a collection of ideas and philosophies toward | programming as much as it is a language. Two stacks and a | dictionary. Threaded code (direct, indirect, token, | subroutine, etc...). Collapsed abstractions. No sealed black | boxes. Tight factoring. | | C has changed. Forth is everchanging. | LargoLasskhyfv wrote: | There has been OpenFirmware. | moonchild wrote: | Not really. Function definitions look different, and we can | declare variables in the middle of function bodies, but those | are surface-level changes. The language itself hasn't changed | appreciably. | dang wrote: | See also https://news.ycombinator.com/item?id=21182628 from last | year. | tarkin2 wrote: | I love this project. Thank you for posting it. The idea of a post | collapse operating system reminds me of slackware/subgenius's old | slogan: "...the world ends tomorrow and you may die!" | | 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....) | mhd wrote: | For me this is slightly into Poe's Law territory: Is this | actual prepper mindset, or tongue-in-cheek? | tarkin2 wrote: | Thanks. I'd never heard of that law before. I think he's | serious. I'll appreciate his work both pre and pos | civilisation collapse. I like his software aesthetic too. | | Maybe I'm getting old, maybe I'm seeking more control, maybe | the world has come needlessly complex, but there's a certain | appeal about returning to more manageable days, where it was | possible to fit a software and hardware system in your brain, | and your brain was swimming with ideas on how to use a | limited system rather than drowning in layers of complexity. | undershirt wrote: | > Forth doesn'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. | | 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"). | hxegon wrote: | Or there are experiences which have hard to describe intangible | qualities that are hard to put logically. Not sure why you have | to reach for stockholm syndrome here. | Koshkin wrote: | 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. | pwdisswordfish2 wrote: | https://collapseos.org/why.html | | "That being said, I don't consider it unreasonable to not believe | that collapse is likely to happen by 2030, so please, don't feel | attacked by my beliefs." | | Triple negative? Quadruple negative? (If we count the second | "don't".) | | Compare something like: | | "I consider it reasonable to believe that collapse is unlikely to | happen by 2030, so please, don't feel attacked by my beliefs." | | It is almost as if the grammatical structure reflects the life | perspective of the author. | microcolonel wrote: | There's a difference between "not unreasonable" and | "reasonable". | pwdisswordfish2 wrote: | Can you provide more details? | bondarchuk wrote: | > _It is almost as if the grammatical structure reflects the | life perspective of the author._ | | That seems like a perfectly valid thing for grammatical | structure to do, although this one tripped me up admittedly. | megameter wrote: | If I had to put my finger on why Forth is hard for most | programmers, it'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. | | Forth written "flat" 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. | | 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'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. | jstanley wrote: | If this gets you interested in z80 hardware, I would recommend | building an RC2014: https://rc2014.co.uk/ | | I built an RC2014 after CollapseOS was posted last year, and | thoroughly enjoyed it. | | 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/1.0 server for CP/M (which was an enormous | headache for lots of different reasons). Never did get around to | running CollapseOS on it though. | mbauman wrote: | I love this project, and check in on it every few months. I | particularly like the idea of scavenging hardware: | | > With a copy of this project, a capable and creative person | should be able to manage to build and install Collapse OS | without external resources (i.e. internet) on a machine of her | design, built from scavenged parts with low-tech tools. | | I'd be interested in trying to build my own proof-of-concept, | but my hardware experience pretty much starts and stops with | kids' electronics kits from 20 years ago. | | Assuming I can scavenge a Z80, what would be a logical next | step? What books/other resources should I be reading to learn | more? | KajMagnus wrote: | > > _a capable and creative person should be able to manage | to build and install_ | | > _trying to build_ | | What if there was a crowdfunding project to pay different | people, to actually do this? | | They could find unclear things in the docs, or missing docs. | Usability Testing, sort of, of Collapse OS? | | This is maybe pretty important after all :- ) More important | than Fly-to-Mars rockets? | [deleted] | mshockwave wrote: | 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? | yellowapple wrote: | - It's tiny and dead simple to implement | | - It sits very close to assembly | | - It allows high-level programming like in C | | - The concept of pushing/popping things onto/off the stack is a | relatively straightforward programming model when done | consistently | | One of the old competitors to the likes of UEFI and uBoot is | OpenFirmware (also known as OpenBoot), for which the primary UI | is a Forth shell; OpenFirmware was the BIOS equivalent for | Sun's SPARC workstations/servers (and still is for | Oracle's/Fujistu's SPARC servers, last I checked) and most | POWER hardware (including "New World" PowerPC Macs), among | others. About the most delightful pre-boot environment I've | used; it's a shame it didn't catch on in the x86 or ARM space. | gridlockd wrote: | It is very small. | RodgerTheGreat wrote: | I'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. | haolez wrote: | > 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's | not my opinion. | | In my opinion, it'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. | monadic2 wrote: | Is the focus on forth to rapidly bootstrap from more than just | z80, or for readability, or for some other concern? | messe wrote: | Not the developer, just a forth enthusiast. But I'd imagine | it's the ability to rapidly bootstrap on other architectures. | Readability is just a bonus on top of that. | | The focus of CollapseOS is, well, an OS that can be used after | society has collapsed, something running on scavenged chips on | hand-soldered boards (in the worst case scenario). | | The original logic was the Z80 is still pretty prevalent, so it | was thought to be a good choice to base the OS on. | | Turns out that a Forth interpreter/compiler is incredibly easy | to write (just a few hundred bytes of a assembler, a few | thousand at the upper end), so by using Forth they hugely | expand the range of scavengeable chips. | ojnabieoot wrote: | 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): https://collapseos.org/forth.html | dang wrote: | Ok, we'll change the url to that from https://github.com/hsoft/ | collapseos/commit/d777a74be30cefc1f.... Thanks! | | (Submitted title was "Collapse OS was entirely rewritten in | Forth, a 50 year old language".) | | The project itself was discussed last year at | https://news.ycombinator.com/item?id=21182628. | weare138 wrote: | I think that's a better headline personally... | MaxBarraclough wrote: | I've read that page and I'm still wondering why they're using | FORTH. | | C has excellent portability and performance. The article agrees | with the general consensus that C is also generally a better | language for the programmer. So why use FORTH? What does it | matter that it can do cute things with self-hosting? What does | 'compactness' matter? | | If the goal is to build a portable means of writing programs | for Z80 and AVR, why not develop a C-like language, or an IR, | or put work into developing a serious optimising C compiler | targeting the Z80? I get the impression that's a relatively | unexplored area for (rather niche) compiler research. | [deleted] | krick wrote: | 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'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 _his_ opinion on the matter is somehow quite | more interesting to me than it would normally be. | arcadeparade wrote: | If you had told me last year that we would have a pandemic, | lockdown, massive economic recession and job loss and now riots | and protests etc and all at the same time I probably wouldn't | have believed it. I'm starting to think the world is a lot more | fragile than we all thought. | wwright wrote: | Not "we all" thought -- plenty of people have been saying | this would happen for years. Specifically, epidemiologists | and black people. Maybe we should listen more! | slim wrote: | he gives a book name "Comment tout peut s'effondrer" by Pablo | Servigne, Editions du Seuil, 2015 | | https://collapseos.org/why.html | messe wrote: | Nice. Must revisit my own Forth OS, or maybe just start | contributing to this. ___________________________________________________________________ (page generated 2020-06-07 23:00 UTC)