12 ms·
Reaching the Unix philosophy's logical extreme with WebAssembly
- beeburrt 3y agoThis person is amazing. I wish I was half as smart and just as funny
- xena 3y agoThanks, I try!
- some_furry 3y ago> It's magic, just without the spell slots. I laughed out loud during a work meeting when I read this. Bravo, Xe!
- lifeisstillgood 3y agoYou were reading HN during a work call ! Call HR !
- deleted 3y ago[deleted]
- some_furry 3y agoI'm losing my job soon due to their return to office bullshit. And I was hired as a remote employee. HR can kiss my fuzzy butt lmao
- lifeisstillgood 3y agoI am sorry to hear that. Please accept my apologies for a quick and easy sarcastic comment that cut too close. Good luck with the future job hunt.
- some_furry 3y agoAh, thanks for the compassion. I didn't take any offense though. :)
- ilaksh 3y agoWasn't there some kind of components proposal that would let modules written in different languages running in web assembly interop with each other? WASI is great but there was an opportunity to standardize on something much more powerful. Anyway I think the logical extreme of Unix philosophy started with Unix, moved on to Plan 9, and continued to improve from there. It's just that those further advancements are less popular and well known. An old-fashioned file is not the logical extreme of anything. Not that it isn't useful or interesting. I stead we don't even have a good way to do any kind of networking.
- magila 3y agoThe WASM Component Model https://github.com/WebAssembly/component-model https://github.com/WebAssembly/component-model
- deleted 3y ago[deleted]
- Animats 3y ago> An old-fashioned file is not the logical extreme of anything. ... Instead we don't even have a good way to do any kind of networking. One can take this further. There was a forgotten system called ChiOs which started with "A bit is a file. An ordered collection of files is a file." and went downhill from there. "Everything is a file" has its limits. I rather liked QNX. QNX is a microkernel with microservices. Everything is an inter-process function call. Call, wait for response or timeout. Works both locally and remotely. Very fast locally. There's a POSIX library, but when you call "read", some glue code makes a call to the file system service. As a base abstraction, remote procedure calls work better than files. Files implemented via RPC are simple. APIs via RPC work are very similar to local function calls. RPC via a file interface is complicated. You have to put a protocol on top of stream/file oriented sockets to get a message interface. The point that the author seems to be making is that WASI offers a standard API. It's one that crosses a memory protection boundary, like an inter-process function call. This is a reasonable way to do things. For historical reasons, neither Unix nor Windows supports that approach well.
- phickey 3y ago
- hoten 3y agoWonderful talk, now I finally understand what WASI is.
- galaxyLogic 3y agoEverything is not a file. There are files and file-contents. The content of a file is not a file. The magic trick happens with #SheBang because that tells you who should interpret and execute the file-contents. That is "magic" because in a sense you must read (part of the content) to know how the contents which is just 0s and 1s should be interpreted.
- deleted 3y ago[deleted]
- teruakohatu 3y ago> Everything is not a file. A file is a collection of data, which usually has an associated identifier (filename and/or path). A USB mouse drive is not a file, but it can be represented as such.
- wahern 3y agoThere are two dimensions to "everything is a file". The first is the concept of a hierarchical filesystem namespace. The second is the notion that read and write can be used as a universal interface to any resource from the perspective of the runtime environment (e.g. kernel). People focus myopically on the first aspect, but it's really the second that is the most important and most enduring. The word "file" is ambiguous, and was used ambiguously in Unix documentation and papers. It of course meant an object with a name in the filesystem. But it also can refer to an object (whether or not existing on or even referenced by the filesystem) which is accessed using read/write, independent of how you acquired the reference (i.e. file descriptor) to that object. If you look at the whole of the Unix system, read/write over file descriptors is the backbone of the environment; process inheritance, shell redirection... much of the time a program has no idea how a resource reference was acquired, just that it can be accessed using read/write.
- kaba0 3y ago> People focus myopically on the first aspect, but it's really the second that is the most important and most enduring But something you can read and write to is not called a file, it is called a stream. It is no accident that Linux differentiates between “files” that you can write to at arbitrary places, or ones that are append-only.
- jl6 3y agoThe UNIX philosophy’s logical extreme is the NAND gate. Does one thing, does it well, and can be composed into arbitrary applications.
- Drakim 3y agoOnly if the NAND gate is expressed as a file
- Waterluvian 3y agoOkay… please… someone implement ‘nand’ and write a script that does something simple using only it.
- deleted 3y ago[deleted]
- jewel 3y agoSure! Here's an implementation of nand and a 2-bit adder that uses it: https://github.com/jewel/nand https://github.com/jewel/nand
- Waterluvian 3y agoHah this is awesome! I’m going to poke around and see how much it would take to stretch this into a basic Turing machine emulator.
- hmcq6 3y agohttps://nandgame.com/ https://nandgame.com/
- thaumasiotes 3y agoGreat find. People who like this might also like http://incredible.pm/ http://incredible.pm/ . I don't know how I feel about the message "This is optimal!" displaying when you use one NAND gate to build an inverter at level 2. Level 1 forces you to build an NAND gate out of (1) an AND gate, plus (2) an inverter. It feels like it'd be more optimal to just reuse that inverter. (And then level 3 is an AND gate, the other primitive† you started with...) † Technically, you start with two primitives, implementing f(a, b) = a ∧ b and g(a,b) = ¬(b ⟶ a). You also get the ability to provide 0 and 1 as fixed inputs, thus ¬a ≡ g(a,1). What you lose after implementing the NAND gate is the ability to provide a fixed 1 input - instead, you are informed that you assume all gates automatically draw from this. Worst of all possible worlds.
- bykhun 3y agoI wonder if we can reliably expect React-in-Rust framework that compiles to wasm instead of js? Or maybe just a React library written in Rust, but you can still write the source code in javascript? Or maybe at least Typescript-to-WASM compiler to skip JS output?
- capableweb 3y agoI mean probably, yeah, but why? You'd still need JS to involve the DOM with anything, and that's the performance expensive stuff, so might as well just do the whole thing in JS.
- patmorgan23 3y agoIsn't there work on letting WASM call the DOM/Browser API's directly without having to go through JavaScript?
- mr_toad 3y agoLike nuclear fusion, it’s always just over the horizon.
- TheRealPomax 3y agoAt that point, why even bother with React? Just write a real user interface.
- yazaddaruvala 3y agoReact-likes (including Vue, Preact, etc) have the most ergonomic interface for UX devs to develop with.
- _navierstokes 3y agoWhat do you define as a "real" user interface?
- csjh 3y agoI doubt the gains from React rewritten in Rust would be significant; the expensive code is the stuff you write in components Also Typescript -> WASM exists in some form through assemblyscript
- syrusakbary 3y agoWASIX may be of relevance to the article https://wasix.org/ https://wasix.org/
- xena 3y agoI would use WASIX, but my WASM runtime of choice doesn't have WASIX support yet.
- IshKebab 3y agoIsn't most of the point of WASM to enable portable executables? Why wrap your portable bytecode with an entirely non-portable platform API? Seems mad to me.
- jeffparsons 3y agoTo play devil's advocate: targeting WASIX still gives you the benefit of compiling existing code once and running on any OS-architecture pair that Wasmer supports. I long for this sort of thing when building software that needs to run on Linux on multiple architectures inside AWS and also on developers' MacBooks. (Ever tried cross-compiling to macOS? Yeah, I prefer pulling teeth, too.) Caveat: you'd need to use Wasmer forks of, e.g., rustc and Tokio, but I imagine there are at least some people who would be okay with that.
- kazinator 3y agoThe Unix Philosophy: A) Tasks should done by combinations of simple tools combined into an elegant pipe. B) Each tools should do three things, one of them at least so-so well: Those three are: 1) Hackily parse the output of the previous tool by flaky assumptions like that a certain delimiter is always present, that spaces will not occur in such and such an item, or that such and such a field is from this column to that one and never overflows. 2) Do the actual processing correctly and efficiently --- provided nothing in the data, exceeds a 1023 character limit, or overflows an addition of two ints or doubles. 3) Produce output in some way that is hard to parse correctly for the next tool, like columns that may be empty, contain items with spaces, or overflow so that column widths are not reliable.
- deleted 3y ago[deleted]
- imiric 3y agoThat's a very twisted definition of Unix. 1) This is not done by every tool. Instead, there are tools built for specific parsing purposes, and each tool is only in charge of interpreting its command-line arguments or, optionally, stdin in some suitable way. Tools are agnostic of the output of previous tools, and only care about processing data that makes sense to them. It's the task of the user to ensure this data is structured correctly. 2) Where are you getting these limits? Shell limits can be controlled by ulimit(1p), but the standard file descriptors function as unlimited streams of data. 3) Again, every process is free to choose the best way to output data. Some have flags that make processing the output easier by another tool, otherwise they default to what makes sense for the user. You seem to have a bone to pick with the fact that the data shared between processes is unstructured, and that the user must handle this on their own, but this is what enables building independent tools that "do one thing well", yet are still able to work together. Sure, in a tightly controlled environment, tools can share structured data (e.g. objects in PowerShell, JSON in NuShell, Murex, etc.), but this comes at the expense of added complexity, since each tool needs to handle this specific format, encoding, etc. This is difficult to coordinate and scale, and arguably the rich Unix ecosystem wouldn't exist if some arcane format was chosen 40+ years ago, or if a new one needs to be supported whenever something "better" than JSON comes along. Leaving the data unstructured and up to each process and user to handle, ensures both past and future compatibility.
- dekhn 3y agoThe talk was amusing but much less interesting than it could be. Yes, we have adapters and shims and they make interfacing easier, sometimes. I guess after all these years of waiting for WebAssembly to actually be useful (as in: I can write apps as easily as I can on desktop, with similar performance, but with the safety guarantees of a web sandbox), I finally realized what I wanted: web pages that are backed by virtual machines. Every page is just a view into a VM's framebuffer. User events are delivered just like X11 or win32 events. The page works like a desktop app. Any code that can run in a VM, can run in the window. After all, the browser is just an inner platform and you should be able to run an virtual machine in your inner platform.
- deleted 3y ago[deleted]
- discreteevent 3y agoI think that this was what Alan Kay was saying when he said that web pages should be objects (where he had previously said that objects are virtual machines all the way down)
- dekhn 3y agoHuh. https://en.wikipedia.org/wiki/Croquet_Project https://en.wikipedia.org/wiki/Croquet_Project When I say VM, I mean, "VMWare-style VMs" not "VMs that run a language the same way on multiple platforms".
- jheriko 3y ago[flagged]
- dang 3y agoCould you please stop posting unsubstantive comments and flamebait? You've unfortunately been doing it repeatedly. It's not what this site is for, and destroys what it is for. If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html and taking the intended spirit of the site more to heart, we'd be grateful.
- alphazard 3y agoThe pipeline pattern has its uses, but it's not the most important (or even the most well known?) tenant of the Unix philosophy. It's "Everything is a File"[0]. That one has really stood the test of time. And it's often misunderstood to mean that everything implements {Read,Write,Seek,Truncate, etc.}. Then when a TCP socket or character device or whatever shows up, the whole abstraction leaks, and it seems like not everything is a file. The Good Parts of Everything is a File: 1. Everything exists in a Filesystem, meaning a directory tree. There are directories, they list things, either resources, or more directories. A process gets access to all additional resources through the filesystem. We've really screwed up by putting networking in it's own place, environment variables, etc. 2. File descriptors. If you squint, these are capabilities[1], which is probably the best way to manage resource permissions. They are fine grained, they handle delegation, there is a tree of legitimacy back to the root. We were so close, but we got this one wrong too, with a single global root, instead of a chroot per process by default. [0] https://en.wikipedia.org/wiki/Everything_is_a_file https://en.wikipedia.org/wiki/Everything_is_a_file [1] https://en.wikipedia.org/wiki/Capability-based_security https://en.wikipedia.org/wiki/Capability-based_security
- fyrn_ 3y agoThey talk pretty extensively about everything is a file? They even mention the "everything is a file" description of that concept
- colordrops 3y agoYeah seems the GP didn't watch the video.
- fallat 3y agoNeat talk but like... doesn't it all seem convoluted? What is the function of a Rube Goldberg web service? To allow it be made of anything? The problem with using Rust in Go is that you entirely miss all the parts you don't use Rust; you get the VM overhead of WASM so it kills Rust perf; you most likely introduce problems at the boundaries of Rust/Go. Again it's a neat idea but why in all things sane would anyone intentionally do this outside of puzzle-solving satisfaction?
- nine_k 3y agoThis looks more than a bit like the Inferno OS, created by some of the same folks who created Unix. WASM allows to distribute cross-platform binary code written in memory-safe Rust, running on pretty compact VM. Think about a plugin architecture that could be built on top of that.
- fallat 3y agoJava (like mentioned in the article) does the same though IIRC Inferno OS is like Java in this regard. How will WASM change what Java has already done? Why would I compile Rust to WASM when I can compile Rust natively to any number of platforms? And use FFI? I think WASM, while nice, doesn't bring much new to the table. It's been hyped for years, and I still only see it used here and there very sparingly.
- nine_k 3y agoThis is how. The installed size of OpenJDK 17 JRE on my machine is 186MB, according to the package manager. I suspect that the WASM VM embedded in the program demonstrated in the blog post is 1.5 to 2 orders of magnitude smaller.
- geokon 3y agoI'm no expert but the JVM is very modular these days and just the minimal modules also give you an order or two smaller runtimes. My guess is a set of minimal OpenJDK modules will be on the same order as a WASM VM. Would be curious to hear from someone more in the know Looking a the JRE size is a bit misleading bc it's been sort of deprecated. You're not really supposed to make Uberjars to run on a JRE anymore but are expected to bundle with the JVM modules you need. It can make very small bundles.. But naturally an Uberjars would be smaller. I think small executables are possible but are also just a nongoal now in the JVM world. Meanwhile they're obviously still very relevant in the webspace and hence WASM you're not really gunna send JVM bundles dynamically over the wire. I do sort of agree with the parent that while the goals are slightly different it feels like WASM reinvented the JVM without really bringing any huge improvement (while you loose several decades of libraries)
- p1mrx 3y agoReminds me of that time I wrote a StringToExecutableFile() function for running [e.g. a Rust binary] from C++, but that depended on several layers of build system horror to embed the executable file as a string, and it wasn't cross-platform. Imagine a utility function that dumps an embedded string to an unlinked temporary file, sets the +x permission, and returns a /proc/self/fd/N filename so you can exec() a subprocess. It's somewhat difficult because of write^execute limitations in Linux. Running WASM in process seems like a much saner idea.
- paulfurtado 3y agoThis is of course not the purpose of your post, but since you're interested in this topic, I wanted to mention that you can now create memory-backed files on linux using the memfd_create syscall without using any filesystem (nor unlink) and you can also execute them without the /proc/self/fd trick by using the execveat syscall. In glibc, there is fexecve which uses execveat or falls back to the /proc trick on older kernels.
- p1mrx 3y agoLooks like memfd_create is from Linux 3.17 (2014), which was after I wrote the function. I sort of miss the days when simple stuff was hard.
- tester756 3y ago>I sort of miss the days when simple stuff was hard. what? what's the point? for me it's the most annoying thing when the simple stuff is hard because why would it be?
- bheadmaster 3y agoHacking is the art doing things with software that don't seem possible. In other words, it's just fun :)
- 3y ago
- 38 3y agoI thought the Unix philosophy was do one thing well: https://wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well https://wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_... how is running anything through a giant virtual machine (web browser) anywhere close to that? the browser is the monolith people. using a web browser to deliver an application is, always has been, and always will be the slowest, and most bloated way to do that. the benefit of course is, that the result is user friendly and cross platform. but lets not kid ourselves, this is as far from the unix ideals as you can get.
- YoshiRulz 3y agoIt's probably referring to the Markdown to HTML translator library, an example of how Wasm enables Unix-style composition.
- ngc6677 3y agosee my comment in this thread about https://github.com/internet4000/find https://github.com/internet4000/find (for a summary); (web-)apps can be encapsultated, from the URI you access them, and the code that is served by the loaded page. It could also run client side only, local first (web apps manifest, service workers, sqlite/postgres wasm etc.)
- baudaux 3y agoThe new OS I am creating https://www.exaequos.com https://www.exaequos.com is WebAssembly in a POSIX environment. So it is running in every web browser
- ngc6677 3y agofun project! always love to see more unix cli in the browser. It is super nice with the local first approach, and I wonder what it would take to be able to `mount https://example.org https://example.org` from `test.com`, if both websites are running the "wasm web OS" your linked to. Cheers!
- baudaux 3y agoPrograms are compiled with a modified version of emscripten for supporting the system calls of exaequOS. I do not use WASI
- rapnie 3y agoOof. My Firefox browser on Ubuntu crashed and all my open VSCodium's went along with it. Happened when loading for a second time. First time worked.
- mkl 3y agoWhat's the connection between your Firefox and VSCodium? Or did your system run out of virtual memory and start killing things at random?
- rapnie 3y agoNo connection that I can think of. Might be the memory. 16 GB physical. But I didn't have a lot open (browser + 3 vscodium) and it happened in a heartbeat after clicking in the browser.
- baudaux 3y agoIt should not use a lot of memory when the login prompt is displayed and even when bash is launched
- ngc6677 3y agoIn this paradigm, the browser's URL Omnibox can also be used as CLI/repel/input. So each "URL or search" to a browser, can open an app that accepts commands and inputs, and allows outputs, through the interfaces, or back to URLSearchParams (which could then be piped again). Maybe related (diclaimer: working on it), https://github.com/internet4000/find https://github.com/internet4000/find ; can be used with "local first web apps", and all the web "apps" which accept input from the URLSearchParams. Great talk!!
- bmacho 3y agoWhen I search on https://internet4000.github.io/find https://internet4000.github.io/find the history disappears (Edge, Firefox). I don't know how did you do that, I can't imagine why on the Earth would you do that, but I suggest to remove that code. Even trying out the search is a total PITA, you can only search once, then you can't go back and try out a different search term
- petesergeant 3y ago> As a little hint for anyone here, when someone openly introduces themselves as a philosopher, you should know you're in for some fun I have found quite the opposite to be true in the real world, but Xe gets a special exemption for being a consistently high-quality writer and thinker.
- amelius 3y agoInstead of "files", they should have called it "objects". Unix is an object-oriented OS. (The nomenclature is quite backwards. It would be like building a database of employees, companies, etc. then saying "everything is an employee", companies are just a special kind of employees.)
- frou_dh 3y ago"We have persistent objects, they're called files." -- Ken Thompson https://en.wikiquote.org/wiki/Ken_Thompson https://en.wikiquote.org/wiki/Ken_Thompson
- DharmaPolice 3y agoThe problem with "everything is an object" it doesn't tell you a great deal off the bat. It's like saying "everything is a thing". Sure, it's true but it's not helpful. In your "companies are just a special kind of employee" example well if that is true within your data model then that is quite interesting and contributes to the listeners understanding of how things work. The alternative "companies are a just a special kind of entity" is less useful.
- 1z4n4g1 3y agoAny relation to: (Maybe Data is a Bad Idea?) 06-21-2016 https://news.ycombinator.com/item?id=11945722 https://news.ycombinator.com/item?id=11945722