A new browser in the works

For discussions about side projects, potential future projects or helper applications for Pale Moon.
User avatar
noobsoftware
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2020-09-01, 15:19

A new browser in the works

Unread post by noobsoftware » 2022-08-01, 14:56

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

User avatar
bSun0000
Hobby Astronomer
Hobby Astronomer
Posts: 19
Joined: 2022-03-22, 23:32

Re: A new browser in the works

Unread post by bSun0000 » 2022-08-01, 19:09

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".

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 32625
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: A new browser in the works

Unread post by Moonchild » 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
"The best revenge is to not be like the person who wronged you." -- Marcus Aurelius
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb

User avatar
Sajadi
Board Warrior
Board Warrior
Posts: 1155
Joined: 2013-04-19, 00:46

Re: A new browser in the works

Unread post by Sajadi » 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-)

User avatar
RoestVrijStaal
Moon lover
Moon lover
Posts: 78
Joined: 2019-06-19, 19:18
Location: Dependency Hell

Re: A new browser in the works

Unread post by RoestVrijStaal » 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.

User avatar
noobsoftware
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2020-09-01, 15:19

Re: A new browser in the works

Unread post by noobsoftware » 2022-08-02, 11:58

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.

User avatar
Bilbo47
Fanatic
Fanatic
Posts: 156
Joined: 2017-11-18, 04:24

Re: A new browser in the works

Unread post by Bilbo47 » 2022-08-02, 23:06

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?

User avatar
The Squash
Apollo supporter
Apollo supporter
Posts: 39
Joined: 2021-03-19, 19:39
Location: The Universe (?)

Re: A new browser in the works

Unread post by The Squash » 2022-08-05, 22:16

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.)
HANG-INDUCING ORPHANED ZOMBIE GARBAGE
In theaters now -- Rated R

(Thanks @[PCMartin], great title for a movie!)

User avatar
Bilbo47
Fanatic
Fanatic
Posts: 156
Joined: 2017-11-18, 04:24

Re: A new browser in the works

Unread post by Bilbo47 » 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.

User avatar
noobsoftware
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2020-09-01, 15:19

Re: A new browser in the works

Unread post by noobsoftware » 2022-08-08, 18:51

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.

User avatar
Eduardo Lucas
Moonbather
Moonbather
Posts: 57
Joined: 2021-07-08, 13:08
Location: São Paulo, Brazil

Re: A new browser in the works

Unread post by Eduardo Lucas » 2022-08-12, 01:57

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?

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 820
Joined: 2018-10-28, 19:56
Location: Georgia
Contact:

Re: A new browser in the works

Unread post by athenian200 » 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.
"There are two sentences inscribed upon the Ancient oracle... 'Know thyself' and 'Nothing too much'; and upon these all other precepts depend." -- Plutarch

Falna
Lunatic
Lunatic
Posts: 474
Joined: 2015-08-23, 17:56
Location: UK / France

Re: A new browser in the works

Unread post by Falna » 2022-08-12, 11:30

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 :)

Forked extensions :
● Add-ons Inspector ● Auto Text Link ● Copy As Plain Text ● Copy Hyperlink Text ● FireFTP button replacement ● gSearch Bar ● Navigation Bar Enhancer ● New Tab Links ● Number Tabs ● Print Preview Button and Keyboard Shortcut 2 ● Scrollbar Search Marker ● Simple Marker ● Tabs To Portfolio ● Update Alert ● Web Developer's Toolbox ● Zap Anything

Hint: If you expect a reply to your PM, allow replies...

User avatar
noobsoftware
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2020-09-01, 15:19

Re: A new browser in the works

Unread post by noobsoftware » 2022-08-15, 15:20

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#.

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 820
Joined: 2018-10-28, 19:56
Location: Georgia
Contact:

Re: A new browser in the works

Unread post by athenian200 » 2022-08-15, 17:20

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.
"There are two sentences inscribed upon the Ancient oracle... 'Know thyself' and 'Nothing too much'; and upon these all other precepts depend." -- Plutarch

User avatar
Nigaikaze
Board Warrior
Board Warrior
Posts: 1225
Joined: 2014-02-02, 22:15
Location: Chicagoland

Re: A new browser in the works

Unread post by Nigaikaze » 2022-08-15, 17:55

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:)
Nichi nichi kore ko jitsu = Every day is a good day.

Post Reply