Designing my own Programming Language

Programming, for all ages and all languages.
User avatar
xvedejas
Member
Member
Posts: 168
Joined: Thu Jun 04, 2009 5:01 pm

Re: Designing my own Programming Language

Post by xvedejas »

I've modified the syntax just slightly, but it's essentially the same. I'd like to show you how basic flow-control blocks could be defined just using built-in data matching and recursion.

Code: Select all

if:
{ x: true, y.
    y.
}
{ x: false, y. } <-- no error, but do nothing

while:
{ x: bool, y.
    if x,
    { .
		y.
		while x, y.
	}
}

for:
{ stop: int, block.
    start: 0.
    step: 1.
    for start, stop, step, block.
}
{ start: int, stop: int, block.
	step: 1.
	for start, stop, step, block.
}
{ start: int, stop: int, step: int, block.
	i: int; = start.
    while (i between start, stop),
    { .
		block start.
		i += step.
    }
}

foreach:
{ x: enumerable, block. <-- enumerable is the prototype to a bunch of objects, like lists
    for 0, x length, 1,
    { i.
		block (x i). <-- i is the index in the enumerable x
    }
}
Now I'm wondering if I really want to be so reflective or if I want to build in basic functions like this... Someone also suggested constructs like the following, for advanced control over the data matching with a 'where' keyword:

Code: Select all

isEven:
{ x: Int where (x % 2 == 0).
    ^true.
}
{ x: Int.    <-- less specific so gets called otherwise
    ^false.
}
Still, that's easily done with an if statement and doesn't really help with typing, so I doubt its use.
polas
Posts: 5
Joined: Fri Sep 04, 2009 2:23 am

Re: Designing my own Programming Language

Post by polas »

I am at the end of a PhD in programming language design (actually created a parallel language and associated compiler.)

Couple of comments:

1) I once read an article that said you can score each language a number. However, new languages start at -1000 because basically there must be something absolutely great to encourage people to learn it (and document it) in the first place. What is your unique selling point?

2) "syntax is a necessary evil of semantics" - I am sure I have read that somewhere. You have considered in great detail the syntax of your language but often more importantly you will find formalising the semantics of great use. Not least it can act as a blueprint for compiler creation.

3) I saw the issue of performance raised - be aware that a high level language does not always mean that it will run slower than a lower level one. For instance with my language we actually out perform C code written by NASA for their supercomputer benchmarks run over clusters of between 2 and 256 machines. The reason for this is that a high level language can offer a rich amount of information to the compiler which it can use to perform an abundance of static analysis and optimisation upon.

4) Unless you are very good at language design you will find that when you have written the compiler and start actually using the language you will need to make modifications. Produce a compiler which is flexible enough to allow for this.

Nick
User avatar
~
Member
Member
Posts: 1226
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: Designing my own Programming Language

Post by ~ »

polas wrote:I am at the end of a PhD in programming language design (actually created a parallel language and associated compiler.)
Is such a parallel language one that pruduces "pesudo-threaded" machine code to make it run like lightweight threads for times when part of the code delays and awakes another one that fits the unused time?
YouTube:
http://youtube.com/@AltComp126

My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
polas
Posts: 5
Joined: Fri Sep 04, 2009 2:23 am

Re: Designing my own Programming Language

Post by polas »

~ wrote:Is such a parallel language one that pruduces "pesudo-threaded" machine code to make it run like lightweight threads for times when part of the code delays and awakes another one that fits the unused time?
Nope, each process is actually a process - these can be located on the same machine (and are wrapped around any SMPs), can all be located on different machines connected via tcp/ip or a mixture of both. Target code of the compiler actually uses the MPI standard for communication at this level, although this is irrelevant (anything could be used) to the programmer of the source language.
Post Reply