r/programming • u/SerenityOS • Mar 14 '20
One week ago, I started building a JavaScript engine for SerenityOS. Here’s me integrating it with the web browser and adding some simple API’s like alert()!
https://youtu.be/DYmmEWnwZPw85
u/lordleft Mar 14 '20
Amazing. Out of curiosity, is SerenityOS POSIX-compliant or planning to be?
85
u/SerenityOS Mar 14 '20
Hi lordleft! It’s mostly POSIX compliant yes! There are some extensions (e.g purgeable memory, customizable mmap() alignment, etc.) but nothing that violates the spirit of Unix :)
11
u/valarauca14 Mar 14 '20
So how does alignment based mmap work? process's pages need to be aligned to page size, or are user land processes sharing a memory map?
6
u/SerenityOS Mar 15 '20
It's pretty simple:
void* serenity_mmap(void* addr, size_t, int prot, int flags, int fd, off_t, size_t alignment, const char* name);Notice the extra
alignmentparameter. This informs the kernel that the returned pointer should be allocated on a specific boundary. This is used by things likemalloc()and the LibJS garbage collector to allocate large blocks that are guaranteed to have all-zeroes in the bottom of their pointer address. This allows some very useful pointer manipulation tricks ("for a given address returned bymalloc(), find its metadata by masking off the bottom bits" being the most common one.)5
u/ProgramTheWorld Mar 15 '20
Is it possible to compile popular browsers like Firefox and Chromium on it?
-25
u/EpoxyD Mar 14 '20
"mostly POSIX compliant"
So yes, but actually no?
46
u/SerenityOS Mar 14 '20
POSIX is a very large specification. We have not had time to implement all of the interfaces and behaviors yet.
The interfaces that are implemented do tend to follow the POSIX specification pretty well. The best pudding proof I can offer is the Ports directory where you can see the list of 3rd party software already working on SerenityOS, mostly due to the system's POSIX-ness. :)
25
7
25
34
Mar 14 '20
I've been following your project for ~2 weeks and now I am somewhat interested in operating system user interface design.
Not gonna lie I really dig into SerenityOS's Windows 9x-ish/old Linux aesthetics.
33
u/SerenityOS Mar 14 '20
Hello hilde_01! I'm a big fan of those aesthetics too. :)
There are many things I love about modern computer systems, but I definitely think we took a few missteps in the design department. SerenityOS is my attempt to correct those mistakes by turning back the GUI clock to ~1998 and starting over from there without going down the "consumer computing" path. I'm obviously biased, but I think it's going pretty okay so far.
15
u/nilamo Mar 14 '20
I'm curious why you're doing this. Not the OS, that's cool, but a random user program. Why not just compile Firefox and run that? Is your goal to have a custom everything?
38
u/SerenityOS Mar 14 '20 edited Mar 14 '20
Hey nilamo! In my opinion, the web browser is an essential part of the operating system. I have more browser tabs open on my desktop right now than I have native applications running. :)
I also have a long background in browser development, and a pretty specific vision of a lightweight browser that doesn't put performance and "the web can do anything a native app can do" above everything else.
Regardless, SerenityOS does indeed aim to be a complete system with no third-party dependencies. So there are already quite a few random user programs in development! :)
1
14
u/monsto Mar 14 '20
What's your goal with building the OS?
44
u/SerenityOS Mar 14 '20
Hi monsto! My goal is simple: to build a new operating system based on all the things I like in other systems (+ some novel concepts), and then switch to using it as my main system. :)
2
u/usedocker Mar 14 '20
But isnt that all OSs are created based on what their creators like in other systems?
25
u/tjpalmer Mar 14 '20
But they aren't based on what the Serenity author likes. Except for Serenity.
-4
u/usedocker Mar 15 '20
So the answer to that question should be a list of features the Serenity author likes.
13
3
u/tjpalmer Mar 15 '20
Good point. Might be some info in the repo if he doesn't reply on the matter here.
51
u/chutiyabehenchod Mar 14 '20
Building his own RAGE engine on SerenityOS then making GTAVI on it
20
u/KillianDrake Mar 14 '20
will only take him 2 hours to get a guy running around a procedural city shooting people and stealing cars
6
3
u/somevice Mar 15 '20
Don't know much about C but was very interesting watching you go through the thought process and overall a totally rewarding programming video. Thanks
2
13
u/bausscode Mar 14 '20
I really love the development that has been done on SerenityOS. I've been following you for a while and have watched a lot of your videos.
Keep it up, I hope someday your OS will be on pair with mainstream operating systems.
5
u/mikael624 Mar 14 '20 edited Mar 14 '20
Damn how many people are in your team? You're achieving lots of things from all different type of practice like os and language development. Edit: there's an OS called ReactOS that's doing something related to retro OS aswell. Maybe you folks should collaborate with them. The react team have been working on it for like 22 years.
29
u/SerenityOS Mar 14 '20
Hi mikael624! Earlier this week, the project hit 100 individual contributors on GitHub. Of course, most of those are one-time contributors, but it's still a pretty awesome number! :)
I'm the principal author and largest contributor by time and volume, but there's a growing group of hackers who are doing strong work on the system as well!
36
u/Kwpolska Mar 14 '20
ReactOS is not doing “something related to retro OS”. ReactOS’s goal is to build an open-source Windows-compatible OS. Making a custom OS from scratch and reimplementing Windows are two vastly different tasks with different requirements.
53
u/lordleft Mar 14 '20
I honestly think it’s just this one dude
31
u/tim466 Mar 14 '20
With some help from his community.
18
3
u/futlapperl Mar 15 '20
Lots of help. Not trying to downplay his accomplishments; he still has by far the most commits on GitHub, but there are lots of active contributors, which is nice to see!
17
u/awesomeisluke Mar 14 '20
ReactOS is completely different though, the goal being to be completely binary compatible with Windows. I don't believe SerenityOS has any such goal.
6
u/bilfred_ Mar 14 '20
This is incredible. Every time I see your posts come up, I just go "wow this guy's good"
I've always wanted to mess around making an OS, but I'm not experienced enough for that yet
2
u/ajr901 Mar 14 '20
How hard would it be to port over something like firefox or chrome? Or maybe just their engines, gecko and blink.
20
u/SerenityOS Mar 14 '20 edited Mar 14 '20
Hi ajr901! It would be a lot of uninteresting busywork. If someone wants to spend time on porting software, that's fine, but it's not something I'm interested in personally.
That said, if I ported an existing engine, I would definitely use WebKit since it's by far the most beautiful! :^)
0
Mar 15 '20
[deleted]
8
u/doubtfulwager Mar 15 '20
One method is to treat the browser as a means to navigate between documents and nothing much more than that.
9
u/SerenityOS Mar 15 '20
Hey doubtfulwager! That's definitely the sort of browser I'm aiming to build.
Obviously it will require a large amount of dynamic functionality to be useful on the modern-day web. However I don't believe it's necessary to have a hundreds-of-thousands-of-lines optimizing multi-threaded JIT compiler to browse documents. I can wait a little bit for complex things to load, if it means my browser is several orders of magnitude simpler. :)
2
Mar 15 '20
If it runs JavaScript then it's got the potential to be abused. If you just want to view documents then it would be best to not include any dynamic code like JavaScript at all. This would break many modern pages and online apps.
3
u/Somepotato Mar 17 '20
JavaScript isn't the only point of potential vulnerability. Plenty of zero days have existed in DOM parsers as well.
1
u/doubtfulwager Mar 17 '20
A vast majority of sites actually perform OK without Javascript. Obviously the consumer Internet borks without it however.
-4
u/badsectoracula Mar 15 '20
I think this is very easy: as a new browser nobody would bother targeting it, so it'll be practically secure :-P. If it ever happens to become popular, it'll also be popular with developers (and other open source browsers are an indication, are it'll be popular with developers way long before anyone else), so it'll already have a team of developers to go after security bugs.
2
u/PinapplePeeler Mar 15 '20
I follow your videos for a while. Can you please share with us where did you got your desktop wallpaper? it's awesome.
Reminds me princes mononoke
2
u/SerenityOS Mar 15 '20
It's a painting called Link and the Temple Forest by artist Jeremy Fenske :)
2
1
-11
u/mikael624 Mar 14 '20
After browser implementation. You should start implementing wine or make another version of it., that's completely compatible with online games.
29
Mar 14 '20
ah yes, just a quick implementation of the windows api, won't take 2 decades.
-4
u/mikael624 Mar 15 '20
He did made an OS for like a year or 2 and didn't he implemented bash recently.
9
-10
134
u/SerenityOS Mar 14 '20 edited Mar 15 '20
Hello friends! After a week of active development, I figured it was time to see if we could get LibJS running in the SerenityOS web browser.
I set the relatively modest goal of getting these two things working within a
<script>tag:alert("foo")document.getElementById("foo")It all went pretty okay! (Check out the video if you want to see the whole process.)
I've received a whole bunch of pull requests while working on this, as well as many helpful comments and suggestions about things I didn't know about JavaScript. So shoutouts to everyone who has been helping out! I definitely wouldn't be this far ahead without you all :)
If you're interested, here are all the videos I've made about LibJS so far, in chronological order:
Browser hacking: Let's build a JavaScript engine for SerenityOS!
Browser hacking: Let’s build a garbage collector for JavaScript
Browser hacking: JavaScript variables (locals and globals)
Browser hacking: Primitive strings, String objects and "foo".length
Browser hacking: Calling native (C++) functions from JavaScript
Browser hacking: Let's add JavaScript to the Browser! (the video this thread is about)
Browser hacking: JavaScript object prototypes
Oh, and when I first posted about my browser hacking on here ~5 months ago, someone asked what I want to do differently in a new browser: https://www.reddit.com/r/programming/comments/degdih/i_started_building_a_web_browser_for_my_os_heres/f2warj2 (my answer would still be the same.)
Thank you for visiting my thread! :)