I've been designing a new programming language (mostly as a hobby, nothing to take the world by storm ) based mostly on C++ and C# (with some other language features) called N. The language will be designed as to be compilable to native machine code however I have one question about such languages.
How would one provide system interaction to the language? Would it require a platform invocation feature to call system DLL functions that perform useful hardware interaction such as file I/O?
What I mean is that, essentially, C allows access to memory addresses etc but other than that there is no real 'hardware' interfacing features in C other than using inline assembly.
For example something like this? (no conversion from char [] ref needed as when compiled they are the same as char* or char[])
A ref is a mutable C++ like reference.
Code: Select all
alias int ref HWND;
alias const char [] ref LPCSTR;
platform ("user32.dll") HWND FindWindowA (LPCSTR lpszClassName, LPCSTR lpszWindowName);
public static int Main (int argc, char [][] ref argv)
{
for (int i = 0; i < argc; i++)
{
PrintFormat("Argument %d: %s\n", i, argv[i]);
}
HWND hWnd = FindWindowA(null, "My Computer");
if (hWnd != null) {
// stuff
}
return 0;
}
I was also considering first developing it as a virtual machine language like Lua etc to be used as a scripting language.