Live data from Hacker News

Show HN: Redbean – Single-file distributable web server

justine.lol

161–170 of 264 posts

Re: Show HN: Redbean – Single-file distributable web server

#161
post #137

Earlier quoted context omitted.

I'm just one woman. What Cosmopolitan does so far, it does really well. It was only as recently as a few days ago that I got mmap() and malloc() polyfilled on bare metal. It has serial uart i/o. It's going to have e1000/virtio sockets soon. You can help me will that future into existence. I need people who know o/s dev and can help me write code that does things like correctly set up pic controller.

Sorry, wasn't meant as a criticism, just as an explanation because people were assuming magic... Taking on bare-metal is a significant job much greater than your original task and you may be better targeting something like buildroot instead, after all what is the Linux kernel but a hardware abstraction layer.

How hard could stdio/sockets on metal possibly be? So far bare metal has been a walk in the park. I love the fact that PML4T lets me do things like move memory without copying it. I want to be able to have that power without schlepping in the entire Linux world. I believe it should be possible for programs to be able to boot on metal as just programs which are tiny and auditable. Especially considering everything runs on hypervisors these days, which are in some respects the true operating system. Ring 0 is the new Ring 3. Who among you is willing to accept being pushed to the outer bounds of computing? If MINIX gets to run in Ring -3 then it should at least be easy for our programs to run in Ring0.

Re: Show HN: Redbean – Single-file distributable web server

#162

So it's a tiny virtual machine. Intriguing, but not really shocking.

>So it's a tiny virtual machine. Intriguing, but not really shocking.

Nope... it's native code, that runs on multiple platforms, all in one small executable.

How? Lots of very clever hacking, and trimming all the accumulated dreck out of the normal C runtime, while making it work across all the supported platforms. (Polyfill is the term she uses)

This is the most amazing thing I've seen in a decade or so. It is right up there with GIT in terms of the possibility space it opens up.

Re: Show HN: Redbean – Single-file distributable web server

#163
post #10

I just spent 30 minutes reading about this. I'm so shocked that I'm logging in to comment after 5 years of lurking. Justine has built a c library that allows you compile a binary once and have it run it on any os or baremetal. The SAME binary. Quite frankly, that sentence doesn't even make sense to me. Check out https://storage.googleapis.com/justine/cosmopolitan/index.ht... As far as I'm concerned, this is literal m…

Everything she does has this level of jaw-dropping amazingness. Between her and Fabrice Bellard i don't know many people who consistently get my chin to hit the table. I hope that Cosmopolitan becomes mainstream, so much more software could have that It Just Works quality.

Mike Pall for LuaJIT

Re: Show HN: Redbean – Single-file distributable web server

#164
post #42

Am I the only one having issues trying to get this working? The webserver starts just fine, but once I add the index.html with zip as in the example, it stops working. This is on Mac 10.15, CentOS 8 and Ubuntu 18.04 LTS. Centos: [centos@test ~]$ ./redbean.com -vv error: Uncaught SIGSEGV on test.novalocal ./redbean.com EINVAL/err=22/errno:2/GetLastError:0 Linux test.novalocal 4.18.0-240.10.1.el8_3.x86_64 #1 SMP Mon Ja…

IIRC, from vague memories of things flying past, Big Sur won't let a modified binary run once it's been checked by Gatekeeper. Which means the first run gets checked and notarised but when you add the `index.html`, the on-disk binary has changed and Gatekeeper won't allow it to run - I guess it's to prevent malicious code modifications, etc.

Thank goodness AAPL is here to protect us from doing cool stuff.

Re: Show HN: Redbean – Single-file distributable web server

#166
post #156

Can someone explain this to me like I'm an 8 year old?

On most computer systems these days can select a set of files and folders and tell the computer to "Send to compressed file", the files that come out of that process usually end in ".zip", and are thus known as "zip files"

This is a zip file, like any other... you can add and remove things from it. However, this ZIP file has a superpower, it can display the contents on the web... it has a web server built into it.

You can take this file, run it on a Windows, Linux, Macintosh, and it will work. You don't need separate versions for each different system... this just works on all three systems, unlike almost every program ever written.

This is one of the most impressive feats of programming things I've seen in my 40+ years of programming. The web serving is clever, but the superpower that it can run on anything really took a huge amount of work, which the author built into a tool called "ape", and has shared with the world, so other people can use it, and help her make it better.

Re: Show HN: Redbean – Single-file distributable web server

#168
post #156

Can someone explain this to me like I'm an 8 year old?

Can someone explain this to me like I'm a 31 year old?

I've been programming since before you were born... and this is the most impressive hacking feat I've ever seen.

A single executable, that doubles as a valid ZIP file, that you can put a complete website into, also doubles as a valid executable on Windows, Mac, Linux.

The build infrastructure is a complete reworking of C to make it far more portable than even K&R thought possible.

I probably wouldn't have believed it possible, but here it is!

Re: Show HN: Redbean – Single-file distributable web server

#169
post #161

Earlier quoted context omitted.

Sorry, wasn't meant as a criticism, just as an explanation because people were assuming magic... Taking on bare-metal is a significant job much greater than your original task and you may be better targeting something like buildroot instead, after all what is the Linux kernel but a hardware abstraction layer.

How hard could stdio/sockets on metal possibly be? So far bare metal has been a walk in the park. I love the fact that PML4T lets me do things like move memory without copying it. I want to be able to have that power without schlepping in the entire Linux world. I believe it should be possible for programs to be able to boot on metal as just programs which are tiny and auditable. Especially considering everything run…

As someone who knows programming in higher level languages well but has no experience with low level, bare metal, how can I get started with this stuff you're working with?

> So far bare metal has been a walk in the park. I love the fact that PML4T lets me do things like move memory without copying it.

> I believe it should be possible for programs to be able to boot on metal as just programs which are tiny and auditable.

I would love to be able to learn more about this. Maybe even contribute to your project :) perhaps a good way to start would be to address some small tasks you might have laying around?!

Re: Show HN: Redbean – Single-file distributable web server

#170
post #104

Earlier quoted context omitted.

The go std library offers the embed package. You can just embed your files and use the std lib's webserver and generate a single file binary. No need for Caddy. All this would be roughly 15 lines of code.

People use Caddy for automatic HTTPS, which the std lib does not give you.

Obviously you don't need to know this but others might not be aware that certmagic is a great middle ground between Caddy and rolling your own ACME.
Post reply on HN