Page 1 of 1

A new browser in the works

Posted: 2022-08-01, 14:56
by noobsoftware
I'm working on creating a browser built on top of .NET, C#, PHP, Xamarin.Forms and JavaScript. I am working on a JavaScript engine written from scratch, and it's coming along nicely, i already have a majority of the basics completed, although it will probably take some time to iron out the kinks and make it work comparable to other browsers. I am at the point of starting work on a layout engine. And i was wondering if anyone here has relevant information or documentation that might be helpful to get started, I have the CSS Spec to work with but it is amazingly complex. I will be using the layout engine in Xamarin.Forms as the basis for rendering so things like BackgroundColor will be taken care of. But properties like display, position, float etc, will have to be calculated. And i'm wondering if there are some principals to consider when it comes to HTML/CSS layout rendering, that are not obvious from the css standpoint. I must admit i haven't read the entire spec (yet). But i thought people that have worked on Goanna for instance might have a take on this.

Also if people have thoughts on what they would like to see i new browser supporting (HTML/javascript) extensions it would be fun to hear.

Also to explain a little about this project, i mainly started it because i love web technologies but find C++ to be overwhelming and overly complex. Which is why i decided to program this browser almost completely in PHP and C#, my favorite programming languages, hoping that it will be a nice basis for the future.

Also if someone is interested in taking part in the project let me know.

Here's is the repo for php code, if you want to take a look at the javascript parser or engine, async functions require the c# code which i will keep as private repo for the time being.
https://github.com/noobsoftware/ice

Re: A new browser in the works

Posted: 2022-08-01, 19:09
by bSun0000
Which is why i decided to program this browser almost completely in PHP and C#
The second worst decision you can make in your life after "she cheated on me but i decide to forgive her".

Re: A new browser in the works

Posted: 2022-08-01, 20:52
by Moonchild
noobsoftware wrote:
2022-08-01, 14:56
I am working on a JavaScript engine written from scratch
I wish you the best of luck with that one. The ECMAScript specification is obscenely large and complex. And if you want it to be meaningful you'll have to have a solid document object model as well to interface with from JS.
noobsoftware wrote:
2022-08-01, 14:56
I am at the point of starting work on a layout engine.
I'm afraid that the layout engine is going to be more complex than you realise. You think the CSS spec is complicated? Wait until you get into the thick of stacking contexts, flexboxes, animations and transitions/transformations. And let's not forget they are working hard on making CSS a scripting language too now :P

Re: A new browser in the works

Posted: 2022-08-01, 22:27
by Sajadi
noobsoftware wrote:
2022-08-01, 14:56
I am working on a JavaScript engine written from scratch
Why not offering your help towards Moonchild Javascript engine wise if you go in depth so far? Pale Moon is in need for more additional skilled people with knowledge in that 8-)

Re: A new browser in the works

Posted: 2022-08-01, 23:25
by RoestVrijStaal
Well, creating a browser rendering a subset of HTML, JavaScript, et al could be instructive at worst.

For what reason do you require to use PHP in your project?

Instead of writing a JavaScript engine, you could consider writing an engine which uses a superset of JavaScript instead, like TypeScript.

Same story goes for CSS. Why not make a LESS or SASS engine instead? Why not limit the units used in the styling engine to px? Implementing additional support for pt and (r)em means only more burden.

What most browsers nowadays still do "wrong" is ignoring the programming best practice of "Fail fast". Almost no matter how much element tags you've not closed or attributes you've put into the element, the browser still tries to render despite the document is invalid.

Same goes for encodings. Why accept (redudant) file encoding like Windows-1250, 1252-1254, 1257 while Unicode is around for years? Just accept Unicode only and you do not have to worry about file encodings.

Re: A new browser in the works

Posted: 2022-08-02, 11:58
by noobsoftware
Sajadi wrote:
2022-08-01, 22:27
noobsoftware wrote:
2022-08-01, 14:56
I am working on a JavaScript engine written from scratch
Why not offering your help towards Moonchild Javascript engine wise if you go in depth so far? Pale Moon is in need for more additional skilled people with knowledge in that 8-)
I've spent some time trying to understand the UXP and Basilisk source codes, and i find them extremely overwhelming, and my c++ skills are not up to par for me to be able to contribute to UXP.
RoestVrijStaal wrote:
2022-08-01, 23:25
Well, creating a browser rendering a subset of HTML, JavaScript, et al could be instructive at worst.

For what reason do you require to use PHP in your project?

Instead of writing a JavaScript engine, you could consider writing an engine which uses a superset of JavaScript instead, like TypeScript.

Same story goes for CSS. Why not make a LESS or SASS engine instead? Why not limit the units used in the styling engine to px? Implementing additional support for pt and (r)em means only more burden.

What most browsers nowadays still do "wrong" is ignoring the programming best practice of "Fail fast". Almost no matter how much element tags you've not closed or attributes you've put into the element, the browser still tries to render despite the document is invalid.

Same goes for encodings. Why accept (redudant) file encoding like Windows-1250, 1252-1254, 1257 while Unicode is around for years? Just accept Unicode only and you do not have to worry about file encodings.
PHP is an excellent high level language which i prefer to use in my projects. Although this implementation is of course always going to be slower then a well implemented C++ browser, and i have to wait and see how the layout engine implementation goes, it will obviously take some time just to get started and even then it will have faults (atleast to start with), as i said this is hopefully a good basis for the future, not something that will be ready soon. I don't get what you mean by the file encodings? And as for making a typescript or LESS or SASS engine that would not be necessary by any means for the web, to my understanding.
Moonchild wrote:
2022-08-01, 20:52
noobsoftware wrote:
2022-08-01, 14:56
I am working on a JavaScript engine written from scratch
I wish you the best of luck with that one. The ECMAScript specification is obscenely large and complex. And if you want it to be meaningful you'll have to have a solid document object model as well to interface with from JS.
noobsoftware wrote:
2022-08-01, 14:56
I am at the point of starting work on a layout engine.
I'm afraid that the layout engine is going to be more complex than you realise. You think the CSS spec is complicated? Wait until you get into the thick of stacking contexts, flexboxes, animations and transitions/transformations. And let's not forget they are working hard on making CSS a scripting language too now :P
Modern web browers definitely have the most complex layout engine you can find, I was hoping, and still am hoping to be able to find simple generalization methods or some simple way to implement this huge complexity, and animations only make matters more complex. But i will try my best.

Re: A new browser in the works

Posted: 2022-08-02, 23:06
by Bilbo47
Very cool. What is the plan to 'link' php and C++ into a compiled executable system? Does it involve any interpretation of source code at runtime, or any 'just-in-time compiling' at runtime?

Re: A new browser in the works

Posted: 2022-08-05, 22:16
by The Squash
Bilbo47 wrote:
2022-08-02, 23:06
What is the plan to 'link' php and C++ into a compiled executable system?
Beware that the OP talked about writing this browser in PHP and C#, not C++. @noobsoftware explicitly mentioned that they are not C++-proficient.
Off-topic:
And, I'm not judging -- after all, I understand C++ but choose never to write it if I can avoid it. As much as people protest, C++ is a very vast and strict programming language and it's plenty easy to shoot yourself in the foot. My preference is C -- you sure can shoot yourself in the foot with C; but since C has far, far fewer language features than C++, it's pretty easy to remember all the rules about the C language. And, when programmers write C++ code, they sort of hide a lot of stuff from the compiler (it's the nature of OOP), so in very huge C++ projects, often the compiler can't do very much optimization at all.
So I tip my hat to @noobsoftware and hope them the best of luck.
Off-topic:
EDIT: Yes, PHP and C# are hard for the compiler / interpreter to optimize for the same reasons that C++ can be tough to optimize. But hey, this browser will probably turn out fairly simple even in the end -- just so long as it doesn't become a platform for e-mail readers, Zip/RAR archive extractors, and Web browsers alike! :grin: (EDIT 2: No offense intended.)

Re: A new browser in the works

Posted: 2022-08-05, 22:31
by Bilbo47
OP talked about PHP and C#, not C++
Oops, yeah, my goof. Of course my real question is: What is the plan to 'link' php (with or without any other language) into a compiled executable system? "Any other language" could be C / older traditional compile or C++ / newer traditional compile or C# / (dunno if this means Microcrust dotNet framework only). Anyway afaik the hurdle is linking php so that it executes natively and not interprets source at runtime, regardless of also using any other language in the project.

Re: A new browser in the works

Posted: 2022-08-08, 18:51
by noobsoftware
Bilbo47 wrote:
2022-08-05, 22:31
OP talked about PHP and C#, not C++
Oops, yeah, my goof. Of course my real question is: What is the plan to 'link' php (with or without any other language) into a compiled executable system? "Any other language" could be C / older traditional compile or C++ / newer traditional compile or C# / (dunno if this means Microcrust dotNet framework only). Anyway afaik the hurdle is linking php so that it executes natively and not interprets source at runtime, regardless of also using any other language in the project.
PHP can be used in .NET and C# using a great new thing called PeachPie. But as far as this project goes i'm having trouble making the JavaScript parser work fast enough to be feasible, and as Moonchild said the layout engine is far beyond feasible at this point in time at least. But if anyone is interested and has knowledge of making programming language parsers work fast i would accept any help. Because the js-engine is interesting enough, it can also possibly be used within .NET to use JavaScript within .NET in combination with PHP. Although it would have to access C# objects through PHP. But there are some javascript engines in .NET already, but none that support async functions, atleast i don't think so. But this project was premature to be announced like i did, even though i have a foundation for a "browser" it would look like something from 1995 if it were ever completed. But the JS engine could still be useful.

Re: A new browser in the works

Posted: 2022-08-12, 01:57
by Eduardo Lucas
I'm not trying to be repetitive, but it makes me really doubtful the amount of endless work it would take to learn and contribute with some stuff inside PM as a project or addons. I saw you spoke about how the PM project seems hard to even be grasped as much as it's needed, but is it going to be easy to grasp what will be needed to do what you want as the first guy to do it fully, even if in 1995 functionality?

Re: A new browser in the works

Posted: 2022-08-12, 04:36
by athenian200
The thing is, there's not really a shortage of simpler 1995-era browser engines like the one you're trying to create...

There's stuff like Dillo, BrowseX, Lynx, Arachne, etc. It's not so much that a new browser engine can't be created exactly like was done in 1995 or so, it's that a new browser engine that supports modern web standards essentially can't be created from scratch by a small team.

https://drewdevault.com/2020/03/18/Reck ... scope.html

I mean, if you're just creating it for educational purposes to see what can be done, go right ahead, but there's a reason Pale Moon exists as a hard fork of Firefox. If we thought starting over from scratch with a new engine would be easier, we would have taken that approach. Though I do admit, the layout engine we have is not in great shape, isn't well-documented, and I could definitely understand why someone would think writing a new one from scratch makes sense.

Re: A new browser in the works

Posted: 2022-08-12, 11:30
by Falna
Eduardo Lucas wrote:
2022-08-12, 01:57
...the amount of endless work it would take to learn and contribute with some stuff inside PM as a project or addons.
Having forked a few, I'd suggest that addons would be a good place to start, and certainly not endless work. XUL, used for the interface, is fairly well documented; you clearly understand JavaScript, which is almost universally used for scripting; there are plenty of working examples that can be examined and plenty of others that could be forked. And a couple of issues with one or two of my forked ones that you could take a look at :)

Re: A new browser in the works

Posted: 2022-08-15, 15:20
by noobsoftware
athenian200 wrote:
2022-08-12, 04:36
The thing is, there's not really a shortage of simpler 1995-era browser engines like the one you're trying to create...

There's stuff like Dillo, BrowseX, Lynx, Arachne, etc. It's not so much that a new browser engine can't be created exactly like was done in 1995 or so, it's that a new browser engine that supports modern web standards essentially can't be created from scratch by a small team.

https://drewdevault.com/2020/03/18/Reck ... scope.html

I mean, if you're just creating it for educational purposes to see what can be done, go right ahead, but there's a reason Pale Moon exists as a hard fork of Firefox. If we thought starting over from scratch with a new engine would be easier, we would have taken that approach. Though I do admit, the layout engine we have is not in great shape, isn't well-documented, and I could definitely understand why someone would think writing a new one from scratch makes sense.
Indeed. I have basically canceled this project, the idea of course being that it would be "cleaner" to start from scratch, but i will definitely just focus my efforts on PM, Extensions, and possibly UXP if i can ever grasp it. PM and Basilisk and the mac forks have basically everything a browser needs, but it is very annoying to have to use other browsers. I would love to see things like customelements implemented despite it being a pretty useless feature to my knowledge. And one of the problems i have with grasping the UXP code and the browser code is of course lack of documentation and lack of understanding the structure. And i personally could use a refresher in C++ to understand some of the code. And it's noteworthy that the JavaScript engine in Pale Moon and Basilisk actually runs a simple mathematical program I've written multiple times faster than C# does. And comparable animations run similar in C# and JavaScript in most cases. So the UXP code and PM are amazingly well written and work amazingly well.

-Edit-
By animations in C# i of course meant: native animations in native code, not just in C#.

Re: A new browser in the works

Posted: 2022-08-15, 17:20
by athenian200
noobsoftware wrote:
2022-08-15, 15:20
Indeed. I have basically canceled this project, the idea of course being that it would be "cleaner" to start from scratch, but i will definitely just focus my efforts on PM, Extensions, and possibly UXP if i can ever grasp it. PM and Basilisk and the mac forks have basically everything a browser needs, but it is very annoying to have to use other browsers. I would love to see things like customelements implemented despite it being a pretty useless feature to my knowledge.
Yeah, I feel the same way. The biggest obstacles we really face with UXP-based browsers are that we're struggling to add all the plumbing for WebComponents. Simple, one-off changes that touch code we have already are fairly easy to backport, and even some simpler stuff that's done to the Rust code can be translated over to what we have easily enough. The problem is that WebComponents requires different parts of the codebase to interact in ways they never did before, and there aren't clear tests you can do to tell if what you have implemented works correctly or not until you have more of it.

WebComponents/Custom Elements builds on itself in a way I dislike, it reminds me of how I always suffered at higher levels of Math and was always told by my teachers it was because "Math builds on itself," and the 10% I didn't get from previous classes was just always catching up with me at higher levels until I could barely keep up despite working my butt off and going to tutoring every day because what was previously a minor gap in my understanding becomes a huge gap that I can't cover up before the next test in the next year. They would always tell me that my approach wasn't good enough and that 95% doesn't cut it in higher-level Math like Calculus, that if you don't understand 100% of the material from the previous class, you aren't really ready for the next one and your mistakes will just build on themselves each year until you can't do the work anymore. WebComponents is designed just like a Math class. It requires you to have a solid foundation, understand how every part interacts with every other part, and learn/implement everything in a very specific order.
And one of the problems i have with grasping the UXP code and the browser code is of course lack of documentation and lack of understanding the structure. And i personally could use a refresher in C++ to understand some of the code. And it's noteworthy that the JavaScript engine in Pale Moon and Basilisk actually runs a simple mathematical program I've written multiple times faster than C# does. And comparable animations run similar in C# and JavaScript in most cases. So the UXP code and PM are amazingly well written and work amazingly well.
Oh yeah, for sure. It's pretty amazing that we have as much as we do and have been able to keep it functioning given how complex the modern web is, when you think about it. It really doesn't help that the pre-Rust layout engine is one the least well documented parts of the Mozilla codebase. There's probably a reason why replacing the layout engine came first on Mozilla's list of things to rewrite with their new language.

Re: A new browser in the works

Posted: 2022-08-15, 17:55
by Nigaikaze
Off-topic:
athenian200 wrote:
2022-08-15, 17:20
if you don't understand 100% of the material from the previous class, you aren't really ready for the next one
Oh man, does THAT bring back memories .... I still don't know how I was able to get through AP Calculus in high school and then more at the college level without being able to fully comprehend trigonometry. :D

(And then I found out a semester or two later that my first college advisor was rather dim, since my AP high school classes satisfied my college math requirements so I could've taken some other class instead of suffering through college-level calculus. :crazy:)

Re: A new browser in the works

Posted: 2022-11-10, 18:11
by noobsoftware
I've changed plans a bit and am now working on a torrent client called Noob Torrent that will allow JS addons and themes. And i will keep the JavaScript engine as a separate project so it will theoretically be possible to use it for more applications. I will possibly add this functionality to my video player (Noob Player).

Re: A new browser in the works

Posted: 2022-11-10, 23:44
by moonbat
noobsoftware wrote:
2022-11-10, 18:11
a torrent client called Noob Torrent that will allow JS addons and themes.
Built using UXP? If so, will you be able to make it a standalone application?

Re: A new browser in the works

Posted: 2022-11-11, 15:34
by noobsoftware
moonbat wrote:
2022-11-10, 23:44
noobsoftware wrote:
2022-11-10, 18:11
a torrent client called Noob Torrent that will allow JS addons and themes.
Built using UXP? If so, will you be able to make it a standalone application?
Not using UXP, using a JS engine i'm currently building. I've made one application using UXP, called Noob Music but i was able to transfer all of the code to .NET to make it viable for the app store and it was "hackish" because i based it on the basilisk codebase and simply replaced XUL files with my own instead of making it a proper UXP application with its own folder structure. I am focusing on the .NET platform, despite UXP having multiple advantages it's currently simply to complicated for me to start an application. I am still hoping someone with knowledge of UXP can create an app template like you would get in visual studio when starting a new project to make it easier to make UXP applications. But hopefully i can add to the "flora" of applications with JS addons and scriptability with my current project.