Hi! I'm currently working on an operating system with it's own new programming language, called ExC.
ExC is a programming language which is meant to be a decent replacement for C. It won't require any pre-existing runtime environment to run, but if you want to do any serious development with it you'll probably want to make some code libraries for printing and such. The syntax currently looks a bit like this:
(subject to change, and pls don't kill me for how I placed that bracket near the struct declaration)
The syntax is similar to higher-level languages, and there are features such as function/variable hiding, packages and importing, and, of course, inline assembly. I chose to do packages instead of file paths because of three main reasons:
- Separate from directory structure (though good directory structure is definitely advised)
This is good because you can move files around without having to rewrite a thousand import statements. #getorganised
- Packages don't have to contain files
Which basically means you don't need a stdio.exc file to provide a stdio interface, which might be useful if you're doing fancy stuff with VMs.
- I like packages better, anyway
That's probably not a real reason, but Java was
the first language I learned, if that helps explain why.
When you import another code file, you can reference any accessible variables and functions by specifying the file name and then using the dot operator to access the variable/function from inside the file:
public int main()
When I say "accessible variables and functions", I'm talking about function/variable hiding. There are two keywords dedicated to this, public and private.
- Private variables are only accessible from inside the file in which they are defined.
- Public variables are accessible from all other files.
- If a function or variable does not declare itself as public or private, then it is accessible from other files that are in the same package, or a subpackage.
- No, this isn't C#, but yes, it's quite similar. I expect that as development continues it'll become more distinct.
- Yes, it'll be suitable for osdev, I'm designing it with low level stuff in mind.
- Possibly, I might even make an ExC compiler in ExC. You probably wasn't curious, but it'll be possible, and it'll be a pretty large scale test of the language.
So yeah. This is the first time I'm ever making a real, general-purpose programming language. It's both fun and educational to make, and, if I remember to, I'll keep you updated on it's development. What are your thoughts and/or opinions?