Application language for you OS

Programming, for all ages and all languages.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Application language for you OS

Post by AndrewAPrice »

If you had to create a language for application programming for your operating system, what would it be?

Mine would be a hybrid between C++ and Limbo.

Code: Select all

(int) Return4 = ()
{
   return (4);
}

(int,unsigned int)ReturnNumTwice = (int no)
{
    return (no, (unsigned int)no);
}

~class SomeClass =
{
   public:
      (SomeClass *)SomeClass = ();
      ~SomeClass = ();

   private:
      (int) someMember;
}


() Main = ()
{
   (int) myVar = Return4;
   // myVar now equals 4
   (int, unsigned int) nums = ReturnNumTwice(myVar);
}

My OS is Perception.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Application language for you OS

Post by thepowersgang »

For the GUI in my OS I've tried to design a XML based language for simple programs.
The scripting is a cross between C and Pascal.
Sample:

Code: Select all

<Application
	Name="AcessOS XMLA Test"
	Version="1.0"
	Category="dev"
	Author="thePowersGang" >
	<Code>
	<![CDATA[
function TextboxKeydown(Entity: self; Integer: keycode): Integer
{
	if(keycode == KEYSYM_RETURN)
	{
		Core.MessageBox(self.contents);
	}
}
]]>
	</Code>
	<Window id="mainwin" title="AcessOS XMLA Test" width="200" height="200">
		<Element
			type="TextBox" id="mainInput"
			x="100" y="100"
			width="80" height="30"
			onKeyDown="TextboxKeydown"
			value="Test Box" />
	</Window>
</Application>
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Application language for you OS

Post by Solar »

It would be a language that'd allow to port all the other languages over...
Every good solution is obvious once you've found it.
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: Application language for you OS

Post by Combuster »

Well, my OS is exokernel, so the point is that programs need to be able to do as much as they want. That means for the language that it has to support programming from a level as low as C to as high as Java, and multiparadigm where possible. I have some prototype ideas on how I want to have stuff done, mainly it comes down to having very sophisticated Aspect-oriented features and template support.

To give you an idea of what I mean:

Code: Select all

import Kernel;
import GraphicsIPC;
import GC;
import String;

namespace default
{   
  use GC; // Garbagecollection by default
  use String::autotostring; //allow automatic conversion to string

  function getframebuffer () returns (boolean *, -GC void ptr framebufferaddress)
  {
    Log("initializing framebuffer");
    Kernel::AllocatePageDirectory(0xE0000000, -1);
    (boolean b, String s) = GraphicsIPC::RequestFramebufferAccess()
    if (!b) { Log(s); return (b, null); }
    Log("Framebuffer access granted");
    (framebufferaddress, int bytes,*) = GraphicsIPC::GetFramebufferProperties();
    Log("Framebuffer base address at 0x" + framebufferaddress + String::NEWLINE);
 
    processif (Compiler::Arch == ARCH_I386)
      subsection
      {       
        use Kernel::Registers;
        directive exclusive([edi,eax,ecx]);

        edi = framebufferaddress;
        ecx = bytes >> 2; // will compute bytes
        eax = 0;
        asm "cld";
        asm "rep stosd";
      }
    else 
      memclear(framebufferaddress, bytes);

    // return success, the lfb address was already set.
    return (true, *);
  }

  // etc
"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 ]
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Re: Application language for you OS

Post by Alboin »

Some cross breed between Alef and Haskell would be interesting...
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Application language for you OS

Post by bewing »

I am actually intending to do this at some point, but I am still at the design stage of only having a vague impression of how I want it to work -- I haven't gotten nearly as far as deciding how I want it to look.

I think MessiahAndrew's language looks nice.
Mine would intentionally be an unstructured language -- much more K&R C-like than his C++ style. My language will have lots of pointers and gotos and will encourage their use (IMO structured programming is idiotic). The standard types will have defined sizes -- programmers will be encouraged to use those types, and #typedef'ing will be discouraged (IMO typedefs are vastly overused, and obfuscate memory usage).

I like the multiple return values.

One other thing that I am concerned about is separating error returns from value returns. In almost all coding, when a function returns you want to first test if the function got an error, and then use/save the return value. And in ASM, you can use some EFLAGS bits for indicating error returns. I'd like to extend that feature into the HLL. But this means that I'd need some way of handling error returns as exceptions or something, rather than having all the error handling built directly into the code, perhaps. And truly, I find it very irritating to write code where I have to test every single function return for an error, and then handle that error somehow -- when in truth, almost all functions return good values under almost all circumstances. Error handling should not be such a large part of the code, as it usually is.
chezzestix
Member
Member
Posts: 118
Joined: Mon May 05, 2008 5:51 pm

Re: Application language for you OS

Post by chezzestix »

Im nowhere near needing a language for my OS but if I had to make one I would probably keep it close to ASM since IMO its the easiest to learn but kick it up a level so as to make writing it a tad less tedious. Im still toying with the pointer idea but the rest of it is prettty solid.

Probably an ASM and C++ hybrid with a touch of pascal:

Code: Select all

int start:
.variables
32 hello := "Hello World!",0;  \\variables are declared by bit size not by type
32 output;  \\Since hello isnt a pointer all you can access is the 'H' in this form
.code
push output; \\reliqueshes both its value and its name.  If this isnt done then the address of output is written over to point to the function's output.
precall printf;  \\precall inits all variables marked with pre for passing purposes
output = hello;
call printf;
pop output; \\gets both back now that output isnt in use
start := END_SUCCESSFULL;
end;

int printf:
.variables
16 x := 0;  \\These two variables dont exist until call printf
32 char current;
32* char output (pre);  \\This pointer is preinitialized.  Pointer is the only variable type in this whole language.
.code
current := output[x];  \\Array stuff can be done on pointers with the address in question incing the variable size every element
while (current != 0);
\\Code to print the letter to screen
x++;
current := output[x];
end while;
ret SUCCESS;  \\sets the value of printf and returns
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: Application language for you OS

Post by salil_bhagurkar »

This is the language of objects and links. It is basically not something that goes to a compiler. Hence you cannot write statements that do more work in one line. Hence instead of i=i-1 you write dec(i). The () at the start of each statement indicates the condition for that statement....

Boring? I like it... :D

Code: Select all

#struct test
int number
string id
#endstruct


#object printfun
test m
int i=5
string s="Salil is good"
(i>0) {
	()printstring(s)
	()dec(i)
	()printnumber(m.number)
}
#endobject

User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Application language for you OS

Post by Troy Martin »

Definately a cross between assembly and C. I'm good at both, and our OS project is in 16-bit assembly.

BTW, chezz, that seems awefully complicated. Way more so than regular assembly.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Application language for you OS

Post by piranha »

Code: Select all

use lib std;
use inc "include_file.h"

int, char function_test(int x)
{
       return x, 't';
}

int main ()
{
       int h, x=0;
       write("Hello. Does x==0? %?\n", (does (x==0)?));
       char d;
       h, d = function_test(5);
       if(h==5)
              write("five\n");
       return 0;
}
output:

Code: Select all

Hello. Does x==0? Yes
five
Kinda like C, but with some other things that I'd like.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
chezzestix
Member
Member
Posts: 118
Joined: Mon May 05, 2008 5:51 pm

Re: Application language for you OS

Post by chezzestix »

Really Troy? What part about it seems hard?

I maybe could see how its harder than assembly but I've always said "power and stupidity cannot exist in the same [programming] language." Powers such as functional variables that are only initialized when they are needed is going to come at the price of simplicity.

heh... I just quoted myself, that probably makes me seem a tad pretentious.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Application language for you OS

Post by AJ »

Hi,

I know my limits and wouldn't attempt a new language for my OS - I would love to get to the stage where C# could be used as the main apps language, though (and anything else that can be compiled to the IL that I go for).

Cheers,
Adam
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: Application language for you OS

Post by Combuster »

If I really found a loophole in this space-time continuum, I would work out things like this. But the absence of time wasn't really part of the question, more like that cliched "what if?"
"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 ]
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Application language for you OS

Post by AndrewAPrice »

I've redefined my language a lot. Inspired by Modula, Python, and C. Scoping in tab indented, here it is:

Code: Select all

/* reserved keywords
	define, signed, struct, class, function, while, for, do, extern, return, this, new, delete, operator, static, asm

	The C preprocessor will run through the sources files first
*/


define signed 4 MyGlobalVariable

struct hello
	signed 4 Foo
	unsigned 4 Bar

extern class someClassInAnotherFile
extern struct someStructInAnotherFile

class someBaseClass
	function someMemberFunc() signed 4
		printf("this is someClass, my address is %d\n", (unsigned 4)(deref this))

	operator new() // called when class is created
		Foo = 5

	operator +(ref someClass)
		Foo += someClass.Foo

	virtual someMemberFunc2()

	invisible
		signed 4 Foo

class anotherBaseClass
	// empty class

class someChildClass extend someBaseClass anotherBaseClass
	function someMemberFunc2()
		// overwrites above member - does nothing

	function multiply2Numbers(signed 4 numA, signed 4 numB)
		return numA * numB


function main()
	define someChildClass HiThere
	define ref someChildClass HiThere2 = ref HiThere // ref HiThere accesses the address of the variable
	(deref HiThere2).someMemberFunc()
	(deref (ref someBaseClass)HiThere2).someMemberFunc()	// you can also type cast references

	define signed 4 ACounter = 0
	while ACounter < 10
		printf("%d ",ACounter)

	for ACounter = 0; ACounter < 5; ACounter++
		printf("%d ",Acounter)

	someChildClass = new someChildClass // dynamically allocate it
	delete someChildClass // dynamically destroy it

		define unsigned 8 AnotherVar // local scope only because it's indented

		asm
			eax = AnotherVar // all you can do in asm blocks is move variables in/out of registers
			"int 100" // and call assembly instructions
			AnotherVar = eax
My OS is Perception.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Application language for you OS

Post by piranha »

Hmmm....MessiahAndrw, I like your first language better.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Post Reply