Jump to content

new C-like programming language

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
kenna

kenna

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Hi, what would my chances be of finding someone to help me with creating a new C-like programming language?

I'm not interested in anything fancy, I mostly want to do it because I want to tidy up and improve on C. Initial target would be x86, but additional targets could be added later on, I'm quite interested in making sort of a macro compiler, so creating new targets would be quite simple. A set of definition files (foo.def) would define how to create object files for a specific target.

Anyway, personally I don't think it should be too difficult, the difficult part would be the parser (especially if the use of def files is used), but the compiling is basically just assembly.

Anyway, would there be someone interested in at least discussing it...?

C is basically the only language I like, f**k C++, f**k C# and all the rest T_T I don't like it, and I hate how C so often get's shunned by these newcomers! Well, I also like Lua, but it's a scripting language.

Anyway, any *CONSTRUCTIVE* feedback is much appreciated!

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Do you have any programming experience, and if so, which languages?

To make a new language is really hard. Most people thinks that the hard part is the parser, and it's, but designing the language is also very hard. Just look at a language such as C++, there's so many aspects of the language, and so many small nifty details.

How are you gonna make the language? You can choose just to make a specification, implementation or both. An example of a specified language could be C, and an example of an implemented could be Java. The difference is that everybody can follow the specification, and make their own compiler, but if there's only an implementation, there's no one that can make a compiler, except for those making the single and only one implementation like Sun, with their Java.

Before you're even thinking about making a new language, check out the already existing language, because there's many C-look-a-like-languages. Some of them are Objective-C, D, C--, C++, etc. Maybe some of the languages already full-fills your needs, and maybe you don't even need a new language.

Another thing you need to think about is how, if you chooses to make an implementation yourself, how it shall be done. Will you both do the assembler and compiler, or will you use another assembler as backend - or what are you going to do. Take f.ex. GCC, it uses GAS as a backend for the assembling. GCC itself only compiles the C code into Assembly code, which then is assembled by GAS, and later linked. If you're going into the compiler development, you should think about reading the book, "Compilers: Principles, Techniques, and Tools", which is considered as the best book at compiler designing and implementation. If you're going to make an assembler, you should maybe take a look at some Open Source assemblers, like FASM, where all the source is freely available for DOS, Linux and Win32.

I'm actually working at a compiler myself, just as a private project. But it's for a much simpler language, which you maybe know, Brainfuck. I'm not making the assembler, only the compiler. I'm using NASM as a backend for the assembling process. I'm coding it all in the C language. Brainfuck is also a specified language, but also have an original implementation (written by Urban Müller) So I don't need to think about the language design, because it's already fixed, so I just have to care about the compiler. Brainfuck is not a big language, so you don't have to make million of lines of code, but it's just to tell you about a real-world example.

#3
kenna

kenna

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
I've worked with C, Lua, and some assembly (mostly RISC, only a little x86).

Quote

To make a new language is really hard. Most people thinks that the hard part is the parser, and it's, but designing the language is also very hard. Just look at a language such as C++, there's so many aspects of the language, and so many small nifty details.

Before you're even thinking about making a new language, check out the already existing language, because there's many C-look-a-like-languages. Some of them are Objective-C, D, C--, C++, etc. Maybe some of the languages already full-fills your needs, and maybe you don't even need a new language.

Well, I'm not aiming to make a C++ clone, my aim is actually to simplify C. I've read about and tried Objective-C, C#, C--, C++, D, etc., but I like none of them. What I want is a strict, regular, pure procedural, simplistic, lightweight, portable, mid-level programming language, resembling C and assembly.

I'm planning to make both a specification and an implementation, and will probably use FASM for assembling the x86 code. However, the aim is for the compiler to support any target, so I'll have to create my own assembler as wel, but I can do that later on, x86 is the most important target.

"Compilers: Principles, Techniques, and Tools", wonderful book indeed, I have it, but haven't read it all yet. Only browsed through it, and it looks like a goldmine!

yes I have heard of Brainfuck, and if my memory serves me correct, it truly lives up to its name ^o^

#4
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts

"kenna" said:

Well, I'm not aiming to make a C++ clone, my aim is actually to simplify C. I've read about and tried Objective-C, C#, C--, C++, D, etc., but I like none of them. What I want is a strict, regular, pure procedural, simplistic, lightweight, portable, mid-level programming language, resembling C and assembly.
If you can live up to that, I'll probably look into the language. I miss a language like that, though I like C and C++. It would be nice with a language like you're talking about, instead of all the new high-level languages, where everything is about pulling as much in it as possible, so the user doesn't have to do anything in the end.

I think you should start trying to make a specification, and then afterwards make your implementation. You should maybe start reading the book as well. Personally, I've also only browsed through it too, but that's mainly because I don't have a wish of making a new language.

I can't help you much from here, I simply don't have much more experience with it, than I've told you in this thread. It would be nice if you some day could announce your specification, and I'll be glad to look into it.

"kenna" said:

yes I have heard of Brainfuck, and if my memory serves me correct, it truly lives up to its name ^o^
You remember right. It's really... f u c k e d.

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
As far as creating a compiler, you may want to look at the source for GCC/MinGW, as that could help you create a compiler for the new language.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
kenna

kenna

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
There are basically two things which eventually got me to think about a new language, operating system development, game development. I do both, but the x86 architecture is so messy that I really don't feel like learning to create an OS for it, so for a year or two I've been thinking about creating an emulator, so that I'd be able to create my own architecture, everything from cpu, pic, to video and audio. From my point of view, that would be easier, it would take longer, but the end result would be much better. OS development is kind of my hobby (one of them), since I don't like any of the currently available OSs, not even linux. The kernel is great, but as a platform linux kind of sucks, just as much as windows.

Anyway, the thing that really made me make up my mind is game development. For years I've been designing various games, a few times tried to get a team, but always screwed up, and lost my team (kind of the early days, newb stuff ^^). I've been looking at all kinds of engines, and found that Irrlicht is the best one so far. However, I'm still not satisfied, so some time ago, a year maybe, I started thinking about my own game engine. The fact that Irrlicht was C++ and not C also contributed to not settling for it, as well as Irrlicht not being as modular as I'd want. Anyway, C is quite nice, but there are times (quite often), when I wish I'd be able to create my game engine and physics engine etc. in assembly...the language I love t he most...and that's where I got my idea.

So I thought that maybe a virtual architecture, similar to the one I've been designing for my emulator. However, to create a pure assembly language (a virtual one) would be too restrictive, as there are many different architectures. So, mixing assembly with some C-like syntax to create a mid-level language would be the ultimate solution. The simplicity of assembly, but still not low-level enough, to restrict the assembler to any certain architectures.

So there would be a basic set of instructions that include the most essential operations and nothing more, a set of assembler commands that provide the essential metalanguage and platform independent commands, and lastly a set of the most essential system calls, which are paltform dependent instructions.

E.g. there would be only a "write byte to stdout", no additional crap, so if you wanted something similar to the stuff in string.h from C, you'd have to built it yourself. Another important thing would be whether it's a single-data or multiple-data instruction.

E.g.
add rs, rt, rd;
would add two numbers, while
iterate add (
    rs0, rt0, rd0;
    rs0, rt0, rd0;
)
would add several numbers, and the important thing here is that you should never use add several times, i.e. add ... add ... add ..., but always use iterate instruction. The idea is that the assembler generates different code based on the context. So the definitions files contain different rules for different usage, so "add" uses one set of rules, while "iterate add" uses another set of rules. Ofcourse, this is kind of a simple example, not really too descriptive, but you get the idea. It gives the assembler more room to generate correct code for various architectures. So, besides the basic set of instructions, there would be a few mid-level commands that sort of change the context of the instruction, so two almost identical lines could generate completely different code, because of the context...the modifiers, that's a better word for it.

So basically I'd want to get as close to assembly as possible without causing too many restrictions.

The standard instructions must always be defined, but you can also define your own instructions to extend the functionality of the assembler. MEL (as I like to call my language, after Mel from "My Parents Are Aliens" ^^) also doesn't use labels like most assembly languages, but this is replaced with way of creating procedures, which can behave in a different ways.

Data handling is quite similar to assembly, MEL does not use C-like variables, but instead deals only with bytes, which can be arranged in different ways to create arrays, tables, sets, lists, etc. MEL also doesn't restrict variables like C, where you have to define a type for each variable, e.g. int, float, etc., instead it depends on the expression what the assembler does, so no matter what length, or what you intend you use it for, so e.g. add will always treat any data as a number of bytes, you need to use special modifiers/instructions to manipulated the data in a different way, just like plain old assembly. I might think of a way to optionally allow type checking for those who are a bit lazy, but I'm not so sure.

I'm also thinking alot about how the instructions should look, if it should be just like real assembly (rt, rs, rd) or something more abstract to give additional assembling-room for the assembler. Also, I like RISC architectures very much, especially MIPS, so the virtual architecture is very simple and clean, definately something to look forward to.

Anyway, I guess MEL is sort of a "portable assembly language" ^^ although the additional non-assembly commands make it more of a mid-level language.

Anyway, I'm glad that you're interested, and once I get a decent specification written, I'll post it, but so far I still have a lot to write ^^, and hopefully my rambling here made some sort of sense!

#7
ViRuSS

ViRuSS

    Learning Programmer

  • Members
  • PipPipPip
  • 78 posts
you making your language cool :D
I didn't write here anything this is Illusion

#8
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Humph. Old thread....

But since it's now revived: How's that language goin'? v0id is still around, dunno about thread starter.... Did his dreams come true?
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#9
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
I've been talking with him some times since, and he did continue working on it, I've even seen samples of it. I think he has dropped the idea now though, but I'm not sure. I'll ask him, if I get the chance.

#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I just learnt how to Brainfuck - v0id.dk: Learn how to Brainfuck.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#11
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Whoa.... I'll stick to oral C... :p
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#12
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You do that, marwex... as long as it's with a human this time!
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums