Custom programming language ~ How to interact with the operating system

advertisements

I am trying to create my own programming language but I am already thinking ahead a little. Of course when I can compile a little program I won't have a Standart Library at that time, and you'd have to create one yourself. Now take for example I'd like to add some functionality to print a string to the screen, I am pretty sure I'd have to do a few System Calls to the operating system to get this displayed.

So to the point: What would be the best way to interact with the Operating System?

Possibilities I came up with myself: - Generate Object Files and link those to the (for example) C Standart Library - Writing the files with embedded assembly language containing System Calls

I have a feeling there are better possibilities!

I hope you can help me,

Christian

EDIT: It's a compiled language I am creating!


You have basically two options, like you say yourself. You can link your standard library with the standard C library, so that the I/O functions in your standard library can use C functions. Alternatively you can make system calls to the operating system directly.

The second approach seems like it's going to be more work: The system calls will be different on each operating system, so you'll have to put a lot of work into porting your system. The system calls may not be well documented, causing many frustrations.

You could start by linking your standard library to the C standard library and worry about other aspects of your language for the moment. Later you can look into replacing the C functions you use with syscalls.