Live data from Hacker News

Show HN: Redbean – Single-file distributable web server

justine.lol

51–60 of 264 posts

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

#52
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…

Will this work if your code uses the C++ standard library ? Or is this just for pure C ?

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

#53
post #13

I really like your view of the world, that programs should be portable, tiny, and just work. The slamming of so much functionality into a zip file is inspiring. Would it be possible to do something similar with Free Pascal, allowing the recreation of something like Turbo Pascal, except really, really portable .com output?

Author here. Absolutely. I used to love Turbo Pascal and Delphi when I was younger. If Free Pascal uses GNU LD.BFD or LLVM LLD when it links programs, then all you'd need to do is is configure it to use cosmopolitan.a when linking system call functions like read(), write(), etc. See https://github.com/jart/cosmopolitan Another option is if Free Pascal wants to write all the system call support from scratch, then doin…

Speaking of other languages, given that the APE is a zip container, it shouldn't be too hard to have a "starkit" like setup where the binary part is basically node/python/perl/tcl and the main script and all required libraries are in the executable.

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

#54
post #13

I really like your view of the world, that programs should be portable, tiny, and just work. The slamming of so much functionality into a zip file is inspiring. Would it be possible to do something similar with Free Pascal, allowing the recreation of something like Turbo Pascal, except really, really portable .com output?

Author here. Absolutely. I used to love Turbo Pascal and Delphi when I was younger. If Free Pascal uses GNU LD.BFD or LLVM LLD when it links programs, then all you'd need to do is is configure it to use cosmopolitan.a when linking system call functions like read(), write(), etc. See https://github.com/jart/cosmopolitan Another option is if Free Pascal wants to write all the system call support from scratch, then doin…

I love what you've produced here. I noticed that pthreads seems to be fail-stubbed for the time being, i guess it's a todo with tricky semantics?

As for holding off on UI for the time being is probably the right thing to do, keeping with the minimal style planning on going for raw-x11,etc.

However, as much as I personally love plain framebuffers (late 90s democoder myself), it'd be totally non-accessible for "plain" applications and totally lacking performance compared to anything accelerated when it comes to rendering. Graphics cards are just so many times faster that it's not really even the same kind of usage (only sad part is Apple punting on OpenGL driver updates even if Intel on the low end has become so much better).

That said, having looked for a minimal UI framework and sadly they seem to be far inbetween these days (libUI is fairly compact on win/osX but required GTK on *nix but they've lost a bit of steam since 2018)

Best of luck on it all (hopefully I can snatch out some time to contribute)

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

#55
post #45

Odd, I'm getting $ ./printimage.com image.jpg run-detectors: unable to find an interpreter for ./printimage.com

Author here. That error happens if you have binfmt_misc enabled. The solution is simple:

    sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"
I intend to upstream a patch with the Linux kernel so it can do this automatically. If any kernel devs are reading, please email me!

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

#56
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…

After adding a new file with WinRAR, I get:

EINVAL/err=87/errno:2/GetLastError:203 The parameter is incorrect.

Probably the ZIP needs to be saved in a certain format.

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

#57
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…

Author here. It works fine on RHEL5 / CentOs5 for me. I can also confirm RHEL7. Please file an issue. What will help in particular is if you can give me the faulting RIP address. That should be in the crash report or in your dmesg log.

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

#58
post #56
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…

After adding a new file with WinRAR, I get: EINVAL/err=87/errno:2/GetLastError:203 The parameter is incorrect. Probably the ZIP needs to be saved in a certain format.

Author here. The zip shouldn't need to be saved in any special format. If WinRAR is posing problems then please file an issue because I'd like to fix that. That error doesn't seem like something that would indicate executable corruption. I want to learn more.

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

#59
post #37

Everybody is hyped up here but can someone explain to me what are the implications for the future of programming? Will I be able to write apps in a single language and have then run truly native on any OS or what else will we be able to do?

This is something like a "fat binary" with some magic in the header that allows it to run out of the box on Windows and several different UNIXes, a bit like those sneaky shell scripts that run on several platforms[0]. It still needs to include some native code for each of the platforms inside the compiled binary, so it's perhaps better to see it as a slick packaging/distribution solution for C programmers than a tota…

Appreciate the response. So it's a bigger win for C devs specifically. I am a C# dev so I am trying to understand what opportunities this project unlocks.
Post reply on HN