Doubts about programming languages.

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Doubts about programming languages.

Post by yByonic »

Hello everyone,
I am thinking of developing an operating system but there are some doubts that will not let me proceed. I am very grateful to everyone who can help. Here are the questions:

1) Is it possible to "install" a programming language? I love Java (remember that the goal is not to make the operating system in Java) and it would be great to be able to make APIs with Java syntax.
2) HTML, CSS, JS ... If I wanted to make a "Chrome", how could I use these languages.

Thanks.
Octocontrabass
Member
Member
Posts: 5512
Joined: Mon Mar 25, 2013 7:01 pm

Re: Doubts about programming languages.

Post by Octocontrabass »

yByonic wrote:1) Is it possible to "install" a programming language? I love Java (remember that the goal is not to make the operating system in Java) and it would be great to be able to make APIs with Java syntax.
To use a programming language on your OS, you need a compiler and a runtime. Java typically compiles to bytecode and relies on a JVM to provide the runtime, so you could port an existing compiler and JVM to your OS, and then modify them to provide your Java APIs. (Or write your own Java compiler and runtime!)

For comparison, many hobby projects provide support for C by porting a C compiler and C runtime library. Java sounds like a bit more of a challenge than C! (And if you choose to port a JVM, you might discover that it depends on a C runtime library anyway...)
yByonic wrote:2) HTML, CSS, JS ... If I wanted to make a "Chrome", how could I use these languages.
Port Chromium. :wink:

Or write your own browser engine, but that's way beyond my area of expertise.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Doubts about programming languages.

Post by PeterX »

yByonic wrote:Hello everyone,
I am thinking of developing an operating system but there are some doubts that will not let me proceed. I am very grateful to everyone who can help. Here are the questions:

1) Is it possible to "install" a programming language? I love Java (remember that the goal is not to make the operating system in Java) and it would be great to be able to make APIs with Java syntax.
2) HTML, CSS, JS ... If I wanted to make a "Chrome", how could I use these languages.

Thanks.
Developing a complete operating system (short: OS) is a huge task.

1.) Java syntax is very similar to C syntax when it comes to brackets etc. Of course Java is OOP and C is not. I think there are many programming languages with syntax like Java. AFAIK there still is not a freely available Java compiler, so you have to write a Java compiler yourself. Or write an OS which is compatible to an existing OS so you can install Java.

2.) If you want to make a browser you need an application programming language. The programming languages you mention are web development languages. You can't use them for making a browser.

Let me ask you: Why would it be fun for you to write an OS? And why do you want to write a "Chrome"? Because it depends on your goals and motivation whether OS development is the right thing for you.

Greetings
Peter
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Doubts about programming languages.

Post by bzt »

yByonic wrote:Hello everyone,
I am thinking of developing an operating system but there are some doubts that will not let me proceed. I am very grateful to everyone who can help. Here are the questions:

1) Is it possible to "install" a programming language? I love Java (remember that the goal is not to make the operating system in Java) and it would be great to be able to make APIs with Java syntax.
No, you can't install a programming language. What you can do, is to install a compiler and runtime for a specific language. Most compilers produce native executable code in which case the runtime is usually a library with standard functions; others produce machine independent bytecode where the runtime must include an interpreter and/or a bytecode-to-native code JIT compiler.

Java source compiles to bytecode, so if you want to run it on your OS, then you'll have to write functionality enough to run a Java bytecode interpreter (also called Java Virtual Machine). Luckily to you, others have already done that, take a look at SanOS:
The kernel was developed as part of an experiment on investigating the feasibility of running java server applications without a traditional operating system only using a simple kernel.
Which is exactly what you were asking.
yByonic wrote:2) HTML, CSS, JS ... If I wanted to make a "Chrome", how could I use these languages.
First of all, HTML and CSS are not programming languages, neither is JavaScript. The first two are declarative languages, and the last being a scripting language, however with the invent of WASM JavaScript can be seen as a fully featured programming language.

As others have said, port Chromium or Firefox, that's the simplest (but not easy) way. For HTML+CSS, you could use some simple FOSS browser, like NetSurf or a FOSS HTML rendering library, like lexbor, both having a small codebase and relatively easy to port. But for Javascript, you're screwed, no viable and working alternative exists to mainstream browser's engines, which are huge, bloated, and insanely hard to port to a hobby OS.

Cheers,
bzt
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Re: Doubts about programming languages.

Post by yByonic »

Hello everyone,
Sorry for the delay.
@Octocontrabass, what compilers and JVMs are there for me to port or how can I make my own? Would that allow me to use the "java" command in CMD?
Would Chromium understand HTML, CSS and JavaScript?
@PeterX, I am determined to start this project, I am just collecting information and looking for answers to my questions so I can start in the best way :D

Thank you.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Doubts about programming languages.

Post by PeterX »

yByonic wrote:@PeterX, I am determined to start this project, I am just collecting information and looking for answers to my questions so I can start in the best way :D
Then you have already the most important qualification for OS dev: determination. Great! (This is important because it makes it possible for you to have high ambitions.)

You have several options from which you can choose:
1.) develop an OS and then your browser or your Java on it.
2.) Use an existing OS and develop Java on it.
3.) Explore Sanos mentioned by bzt. (I didn't know that project. It sounds cool.)

Similarly you have these options to develop a browser:
1.) Tinker with existing open source browsers.
2.) Use existing libraries and develop an browser ontop of them.
3.) Write one from scratch.
Octocontrabass
Member
Member
Posts: 5512
Joined: Mon Mar 25, 2013 7:01 pm

Re: Doubts about programming languages.

Post by Octocontrabass »

yByonic wrote:what compilers and JVMs are there for me to port or how can I make my own?
If you want to port a Java compiler and runtime, the obvious choice is OpenJDK - it's the reference implementation for Java. It includes a compiler, JVM, and standard runtime libraries, and it's open-source so you can modify the platform-specific parts to run on your OS. Unfortunately, it's also a rather large project, so it'll be a lot of work.

There are also compilers that can compile Java code to native machine code rather than JVM code; if you port one of those, you won't need a JVM (but you will still need the Java runtime libraries).

I'm not familiar with compiler development, so I can't really help you there. If you choose to write your own JVM, though, I suggest you look into emulator development. A lot of the techniques that go into emulating video game consoles apply pretty well to executing Java bytecode.
yByonic wrote:Would that allow me to use the "java" command in CMD?
Sure, but you'll have to write your own CMD since Microsoft won't let you use theirs in your OS. :wink:
yByonic wrote:Would Chromium understand HTML, CSS and JavaScript?
Yes, of course. Chromium is a complete web browser, and Chrome is just Chromium with a handful of extra features.
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Re: Doubts about programming languages.

Post by yByonic »

Thanks!
For all who see this and have more questions, feel free to continue.
moonchild
Member
Member
Posts: 73
Joined: Wed Apr 01, 2020 4:59 pm
Libera.chat IRC: moon-child

Re: Doubts about programming languages.

Post by moonchild »

bzt wrote:for Javascript, you're screwed, no viable and working alternative exists to mainstream browser's engines, which are huge, bloated, and insanely hard to port to a hobby OS.
There are quickjs, duktape, serenityos libjs, etc...
Post Reply