Wich programing language are you using for your os

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Wich programing language are you using for your os

Post by Combuster »

A human would not optimize it either.
Well, do you want an obfuscated but actual implementation of the problem instead of a reduced version? :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
h0bby1
Member
Member
Posts: 240
Joined: Wed Aug 21, 2013 7:08 am

Re: Wich programing language are you using for your os

Post by h0bby1 »

Brendan wrote: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
it's something i ponder as well, there is some hint toward this somewhere in the wiki with the language approach, i'd clearly like to implement a powerfull scripting language for application, why not using lua, something close to flash AS3 actually

i really liked the experience of AS3 with runtime defined object type, and it allow (and even force) asynchronous definition for everything, data loading, and pretty much everything is handled with load events

with the object/COM approach, there would be a way to make some premade little scripted object library to build application uppon , that are supposed to handle image and ressource loading asynchronously, application would then use them either based on mime-type with a generic loading function and runtime class definition to handle structure specific to the object loaded, or either the application would have to search manually for an object that can handle this mime type in the system and using the object methods to manipulate it

but at low level layer, the problem with PC is in the same time a good thing, is that there is no true hardware specification for what modern pc can be, and most of the function that modern computer offer are more defined by the os than by the hardware itself, modern computers would be pretty useless today without the several Go big os like linux and windows, and it already need a fair level of complexity to initialize correctly even the basic hardware, it need good ressource mannagement, handling of buses and drivers tree, and an efficient way to manage and process interupts manipulating data types to communicate with the device that are not that easy to handle, and it already require a robust language to handle basic things

at the moment i'm looking into AML and acpi and the kind of functionality it offer can be interesting for that purpose, as it is already an hardware standard that is well established on pc, and allow to find the whole hardware configuration of the machine, and it can be used also to provide an high level api to mannage all the pc hardware

but even from there, it still require lot of things to have a real software basis on which to build application, and to even handle all the hardware, either the scripting language would need to be also kernel oriented and being able to call kernel-like functions, like accessing io /port, managing interupt, and hardware level things, potentially being based on acpi, and then you would program even drivers and other things in scripting language

then with a COM-like approach to have system wide scripted object that can be instanciated or used in other higher level script, and having the whole system built up from scratch using self defined language, with a good support for asyncrhnous object oriented kind of programming, the basic parser for that kind of scripting language could be made simple and more function added on top of them with object definition

in the same time, i still prefer to handle lot of things in a c compatible manner, there are tons of compilers on every plateform that are well working, and i made my own ABI that convert from .so and .dll file for export functions, so i can easily manipulate modules as object with a c interface specific to each instance of the module loaded

i'd rather have a clean interface in C, with runtime object definition, to eventually build a script system uppon, rather than having to depend on whole tool chain that is os specific to develop it, as there are many tools to compile/debug/parse/edit C code, and the binary format compilers output are also well known and not so hard to work with

eventually i'd just make a linker to output a dynamically linked binary object in a specific format, eventually with a generic interface to probe the definitions of the module in a generic manner like with COM an IDL, embeded in binary dll at link time, that would be something that i'd like to do in the future, something that would work on exported symbol to build a class definition at link time, and a system to instanciate dynamic objects at runtime when the module in a binary file is probed/loaded

if you define the type you use in the base kernel C function in a way that is clean enough, you can mannage to make a script language that can manipulate them as well, even if you code some of the base module in C, you can bind the interface they expose after in an higher level scripted language
Kortath
Member
Member
Posts: 57
Joined: Sat Sep 07, 2013 11:23 am

Re: Wich programing language are you using for your os

Post by Kortath »

In 2000 I made an OS that I coded with pure assembly. I got the mouse back then to show up.. but it wouldn't move. And it at least had a graphic on it. It didn't do much, but I had fun.

Now I am back at it and I am using a mixture of assembly and C.

I am writing all my own code, libs included. It's a SLOW DRAWN OUT process. Not trying to make a full OS. But, its a hobby, so no worries if it ever gets done. My goal is to enable the mouse correctly this time in 32-Bit PMODE.. unlike the 16-Bit version I made back in 2000. :)
Last edited by Kortath on Sun Sep 08, 2013 9:55 am, edited 1 time in total.
User avatar
Satoshi
Member
Member
Posts: 28
Joined: Thu Sep 13, 2012 2:18 pm

Re: Wich programing language are you using for your os

Post by Satoshi »

Trinix (written in D) https://github.com/Rikarin/Trinix
Streaming OS development https://www.livecoding.tv/satoshi/
chrissacchi
Posts: 15
Joined: Sat Sep 15, 2012 5:02 pm
Libera.chat IRC: csacchi

Re: Wich programing language are you using for your os

Post by chrissacchi »

Hey pikasoo,

I appreciate that you are using NASM as your assembler. NASM stands for "Netwide Assembler". With this name it is obvious to point out that NASM is not a compiler. NASM is an assembler, and it can be used with macros converted to flat binary machine code. A good example of a compiler would be GCC (GNU Compiler Collection) or DJGPP. Also, not very many languages can be used for OSDev, because of some (if not all) high-level language abstractions that can't interface with an unmade kernel. Languages besides these low-level languages, such as C, C++, and Assembly can be used when you have a stable, working userspace running. These languages can include, and are not limited to Python, Perl, LISP, Ruby, etc. However, this may require a year or more of a stable userspace, and a working kernel could take more time, especially considering all of the factors that a kernel needs to function. Some examples are: security, IPC, IRQs, DMA, I/O, VFS, GDT, IDT, TSS for each CPU, etc. Plus, with multiple DMA addresses, multiple IPC functions, different I/O ports, different file systems, it can get very complicated. So, if you're ready for OSDev, I think that's a very cool idea 8) .

Anyway, I do use NASM too :D .

Regards,
Christopher
https://github.com/christophersacchi/RazorOS
"... you notice that this scanner will... woah!"
"Moving right along!"
"That must be, uh. That must be why we're not shipping Windows 98 yet..."
"Absolutely. Absolutely."
User avatar
bwat
Member
Member
Posts: 359
Joined: Fri Jul 03, 2009 6:21 am

Re: Wich programing language are you using for your os

Post by bwat »

chrissacchi wrote:Hey pikasoo,
I appreciate that you are using NASM as your assembler. NASM stands for "Netwide Assembler". With this name it is obvious to point out that NASM is not a compiler. NASM is an assembler, and it can be used with macros converted to flat binary machine code. A good example of a compiler would be GCC (GNU Compiler Collection) or DJGPP.
Actually, the word compiler used to mean linker up until about the mid 1950s. See the quote that introduces the first chapter of "Modern Compiler Implementation in C/ML/Java" by Andrew Appel. The word is an example of quite strange coinage, I mean, in the modern sense a compiler doesn't really compile, it generates code that specifies a language's evaluation function to a given input program.
chrissacchi wrote: Also, not very many languages can be used for OSDev, because of some (if not all) high-level language abstractions that can't interface with an unmade kernel. Languages besides these low-level languages, such as C, C++, and Assembly can be used when you have a stable, working userspace running. These languages can include, and are not limited to Python, Perl, LISP, Ruby, etc.
Firstly, kernels in C/C++ almost always end up using assembly language, they cannot do the whole job on their own on most processors. How do you disable interrupts in C on an x86 machine?

Secondly, there have been major operating systems written in Lisp (Symbolics, TI Explorer, and many more), Prolog (SIMPOS - part of fifth generation computing project at ICOT), and Smalltalk-80 (Xerox D machines, and others, possibly Tektronix 4404).
Every universe of discourse has its logical structure --- S. K. Langer.
Post Reply