Hacker News new | past | comments | ask | show | jobs | submit

  Now, when you say no libraries, exactly how far does that go?
No libraries at all like stb_image, openssl, libcurl, etc. But it does use the platform APIs to create a window, get keyboard and mouse events, create TCP sockets, etc. It uses some libc calls like printf and malloc, but then it has its own memory allocators and arenas for DOM objects, CSS rules, and other common objects.

On Windows it just targets Win32.

On macOS it uses a bit of Objective-C to create an NSWindow and for the main message loop.

On Linux it uses libxcb to connect to X11. I planned on using Xlib originally, but libxcb is closer to the protocol and IMO cleaner. After using it I also got a sense that the X11 protocol is pretty straightforward, so I might just replace libxcb with a custom implementation.

For example, I need to query DBus for things like the desktop theme preference (dark/light) but didn't want to link build the DBus protocol messages from XML in the build, so it just queries libdbus directly and parses all the messaging. Maybe it should have a custom DBus client too...

(Linux doesn't have a "native" UI, so I made this exception on that platform to be able to make windows, etc as in the other platforms)

---

There are lots of reasons to "do it yourself" (and lots of good reasons NOT to do it too -- I wouldn't do this professionally!)

My goal here was to make a presentable and polished product, so I spent some time on code quality, correctness, performance, etc. and in presenting a nice browser that feels familiar. Here's a screenshot: https://imgur.com/a/ojWvciR

More than anything, I really like being in the flow and feeling the joy of programming -- building something step by step and seeing the results incrementally. A browser is quite a nice project for that, since you have the whole web to interact with and lots to implement.