Page 1 of 3

Wich programing language are you using for your os

Posted: Sun Sep 02, 2012 11:32 am
by pikasoo
Im just wondering wich language is the favorit and also if you are starting from scratch or from an existing base (open source os)

im at my second attempt to build my own os, doing it for the fun. My first attempt was about 8 or 9 years ago doing it all in ASM
booting it from a floopy on a old 486 pc. i ended up with a simple command prompt, my own file system and a cdrom support.

finaly recently i started a new project, still doing it in ASM but this time in protected mode using paging and graphic... while researching for information google often pointed me to this website and i want to say a big thanks to those that posted all those usefull informations!!

So to awnser my own question:

language : ASM using nasm compiler
started from scratch

p.s. dont mind the bad english

Re: Wich programing language are you using for your os

Posted: Sun Sep 02, 2012 2:57 pm
by Tosi
It's not the bad english, it's statements like this:
language : ASM using nasm compiler
that set off alarms.

Re: Wich programing language are you using for your os

Posted: Sun Sep 02, 2012 4:14 pm
by Kazinsal
Tosi wrote:It's not the bad english, it's statements like this:
language : ASM using nasm compiler
that set off alarms.
He could be writing a real mode OS (like I am), in which case your options are limited.

Re: Wich programing language are you using for your os

Posted: Sun Sep 02, 2012 5:04 pm
by Griwes
Blacklight wrote:
Tosi wrote:It's not the bad english, it's statements like this:
language : ASM using nasm compiler
that set off alarms.
He could be writing a real mode OS (like I am), in which case your options are limited.
Calling NASM a "compiler" is setting off the alarms, anyway.

Re: Wich programing language are you using for your os

Posted: Sun Sep 02, 2012 5:13 pm
by Kazinsal
Griwes wrote:Calling NASM a "compiler" is setting off the alarms, anyway.
I missed /that/.

Eek.

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 7:34 am
by CWood
IMHO, I'm well aware that NASM is an assembler, but as long as he knows what it is and what it does, does it really matter if he refers to it as a compiler, assembler, or Derek, so long as he can use it?

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 8:17 am
by JuEeHa
Using Forth (own compiler) and x86 assembly (own assembler).

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 8:25 am
by Griwes
CWood wrote:IMHO, I'm well aware that NASM is an assembler, but as long as he knows what it is and what it does, does it really matter if he refers to it as a compiler, assembler, or Derek, so long as he can use it?
Compiler is something that generates code in output language from code in input language (like, C -> assembly is compiler).
Assembler is something that assembles code from assembly language to machine language (which has 1:1 mapping in most cases, so it's plain translation, not rewriting sentences, if you let me to compare it with natural languages).

It's quite clear (and quite basic) distinction; and using proper terms allows people to determine (or assess) level of person in question.

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 1:18 pm
by turdus
Griwes wrote:It's quite clear (and quite basic) distinction;
...and also quite wrong. Well, strictly speaking
1. there are high language assemblers with "for" and "while", so even an assembler could "rewrite sentences" as compilers
2. gcc does not generate code in output language (by default), but machine language binary, so according to your definition, it's not a compiler?
3. from user's point of view, the plain text source goes in, the binary executable comes out in both assembler and compiler case

I understand the effort to tell apart assemblers and compilers, and fundamentally there's nothing wrong with it. It's just you have to create better definitions.

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 1:33 pm
by Love4Boobies
Sigh. A compiler, or translator, is a program that translates from one language to another. Machine code is a language, too; they can target it. An assembler is a type of compiler. Can we move on?

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 11:47 pm
by Brendan
Hi,
pikasoo wrote:Im just wondering wich language is the favorit and also if you are starting from scratch or from an existing base (open source os)
This has been a constant problem for me. My goal is to write a radically different OS in an entirely new language, with no compatibility with existing OSs, languages, file formats, tools, etc.

There are 2 ways to achieve this:
  • write my own language/toolchain and then write the OS in that new language. In this case I'd need to write the toolchain twice (e.g. once as a set of tools for Linux that I can use to write the OS, then again as native tools for my OS).
  • write the OS in an existing language, and then create a native toolchain for the OS. This ends up being worse as I'd need to write parts of the OS twice (e.g. once in an existing language so I can start developing the tool chain, and then a second time in the new language) and also write parts of the toolchain twice (once in assembly and again in a native language).
At the moment, my current plan is to write the least amount of OS code I need to start developing native tools, and do this initial code in assembly (NASM); then write native tools starting with an assembler and a "legacy text file to assembly source" file format converter.

I keep having second thoughts though. Every now and then I decide I should be doing the opposite and start writing tools (for Linux) in C. :oops:


Cheers,

Brendan

Re: Wich programing language are you using for your os

Posted: Mon Sep 03, 2012 11:57 pm
by Love4Boobies
Programming language theory, language design, and compiler theory have always been of interest to me. However, I've unfortunately decided that designing a better (tm) language has more disadvantages than advantages:
  • It doubles the amount of work that has to be put into the project.
  • It will become much harder to get other developers on your project.
  • Difficult to get any feedback for the language because people don't know it.
  • Difficult to test the new toolchain because there's no existing code for it.

Re: Wich programing language are you using for your os

Posted: Tue Sep 04, 2012 1:13 am
by Antti
Brendan wrote:This has been a constant problem for me. My goal is to write a radically different OS in an entirely new language, with no compatibility with existing OSs, languages, file formats, tools, etc.
This is the way to go for you and I encourage you to do this. It is the next level after doing things with using the existing knowledge and tools in the operating system field.

I think that you waste your time if you do not do this. It even sounds depressing if you end up being "a POSIX-C-NASM-Linux-ELF developer" (not the best definition). There is nothing wrong with that but I think that is not suitable for you. For most of us, including me, the traditional way is more suitable.

It goes without saying that a lot of specifications need to be written. These documents are quite important when looking the project as a whole. Your excellent formal writing skills will have a great importance when it comes to that.

When looking the previously mentioned aspect and your contributions to the OS developer community, it would be easy to get more people involved in the project if desired. It is not always the techical things that matter when it comes to that. Unfortunately, those other developers will probably ruin the project so keep it under your control. In fact, keep it strictly under your control.

Re: Wich programing language are you using for your os

Posted: Tue Sep 04, 2012 1:15 am
by Combuster
Well, if you write your tools using only the standard components of ISO C, then there's no double code to be written since a correct implementation will make any such code portable without modifications.

Of course, new languages typically have a share of other languages. You can write a compiler in the semantically shared subset so you don't need a rewrite either. (you can write a C++ compiler in C and it'll still be able to compile itself. Similarly, Freebasic was originally bootstrapped from Quickbasic)


Of course, neither of this works for Brendan where libc would be the most visible symbolication of all those *cough* "bad legacy designs" *cough*, but for most people, it works :wink:

Re: Wich programing language are you using for your os

Posted: Tue Sep 04, 2012 2:44 am
by Brendan
Hi,
Combuster wrote:Of course, neither of this works for Brendan where libc would be the most visible symbolication of all those *cough* "bad legacy designs" *cough*, but for most people, it works :wink:
That's just the start - the way tools work and the way people write software also needs to change.

Part of the idea for my OS is that (as far as applications know) all files are in a specific "native" format. For example, instead of having to deal with BMP, JPG, TIFF, PCI, GIF, PNG, etc, an application would only have to care about my native graphics file format. To make this work the OS has "file format converters". If an application tries to open a BMP picture, the VFS is responsible for finding a suitable "BMP to native file format converter" and transparently converts the BMP file into the native format. Multiple file format converters might be involved - e.g. an application might open "foo.bmp" as a sound file, and the VFS might convert BMP into native graphics format, then native graphics into native text (via. OCR), then convert native text into speech/sound (via. speech synthesiser). Of course the VFS may store the results of these conversions in the file system; so that if "foo.bmp" is opened as a sound file again later then the VFS just gets the pre-converted version from the file system instead of doing all the conversions again.

Now think about compiling, assembling and linking - the tools would use the same "file format converter" idea. If the OS opens "foo.c" as an executable; then the VFS might use a "C to byte-code converter", then a "byte code to assembly converter" then an "assembly to executable" converter (and then cache/store the resulting executable file).

Obviously, for the normal "bunch of separate plain text files" source code this would be a major problem. However...

The way programming is normally done is mostly crap - it was convenient (for compiler developers) in the 1970's and (for most of us) hasn't changed much since. What I'd like to do is build a graphical design tool, where (for a hypothetical example) a programmer drags boxes, etc onto a worksheet to create something like a UML class diagram, and can then click on methods, etc in the class diagram to add code to that method. An entire project's source code (including class diagram, resources, methods, etc) would exist in a "pre-tokenised" form within a single project file; and it's this single project file that file format converters would convert into executable form.

Of course I'm not saying this is exactly what I'm planning - to be honest I haven't really decided how software should be designed and written (or how the IDE will actually work). I am interested in getting rid of typing - e.g. rather than typing "while(foo < 6) { foo++; }" into a text box a programmer might drag an "while box" onto the page and then drag other things (an icon representing "foo", a "const integer" icon, an "increment" icon, etc) into appropriate places in the middle of the "while box". Also, it won't be OOP; but would be something vaguely similar intended for the actor model (e.g. "actor" instead of "class", "message handler" instead of "method", etc; where one or more actors are mapped to each thread).


Cheers,

Brendan