Hobby Programming Language

Programming, for all ages and all languages.
Post Reply
rob
Posts: 7
Joined: Thu Apr 30, 2009 10:24 am

Hobby Programming Language

Post by rob »

Hello everyone!

I got interested in OS development some time ago, primarily tinkering in assembly language. More recently, I've found myself experimenting with compiler design, a topic that may very well have eclipsed my interest in operating systems (heresy around here, I'm sure :wink: ). I thought writing a tiny, low-level language (in some respects, a high-level assembly given that it's not portable) that compiles to x86 assembly code would be a fun project, and I'd like to share the product of my work thus far with you. If anyone has any questions, suggestions, or finds a use for it in a separate project, I'd love to hear about it!

Some features of the language (dubbed "U"):
* Simple syntax - This is largely due to it being a hobby project, but this could make it a good candidate for teaching the basics of how compilers and assembly code work. It also lacks some of C's idiosyncrasies (header files, etc).
* Compiles to 16-bit Intel x86 assembly code - The output can be read by a human (again, potentially good for learners) and doesn't require knowledge of a linker (executables are, of course, created with an assembler like NASM or FASM).
* Inline assembly - the language makes incorporating assembly code into the main program flow quite simple (since I'm not shooting for portability)

You can download the source and documentation, here:
https://github.com/upcrob/u-programming-language

Again, questions/comments are welcome (just post below). I can't promise I'll have time to implement features if they get requested, but I'm open to hearing about them. Keep in mind, I'm not trying to create any sort of "C killer" - if you're writing production code or an OS that needs to exit real mode, this language isn't for you. Nonetheless, I'd love to see it used in a small OS project like MikeOS, but we'll see what happens.

Have fun!
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: Hobby Programming Language

Post by bubach »

Interesting project, and I wish you good luck! Looking forward to seeing a self-compiling version. ;)
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
rob
Posts: 7
Joined: Thu Apr 30, 2009 10:24 am

Re: Hobby Programming Language

Post by rob »

Thanks, though I can't say that I'm quite that ambitious. :D
mansi21
Posts: 3
Joined: Thu Dec 13, 2012 2:06 am

Re: Hobby Programming Language

Post by mansi21 »

That sounds interesting =D>
How did you come up with this idea? :idea: Very impressive..looking forward for the final one!
rob
Posts: 7
Joined: Thu Apr 30, 2009 10:24 am

Re: Hobby Programming Language

Post by rob »

I developed it largely because assembly was too low-level and C was too portable for me - I wanted to know exactly how my high-level code was being translated down to the machine level.

And just to be clear, the current version is functional. I just say that it's a work in progress because in my experience, a project hasn't reached its 'final' or 'complete' version until its dead. :wink: Feel free to download the source and give it a try!
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Hobby Programming Language

Post by Love4Boobies »

Have you looked into HLA? It is a high-level assembler, with support for structured, procedural, and OO programming. It might even have support for generic programming---I am not certain.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
rob
Posts: 7
Joined: Thu Apr 30, 2009 10:24 am

Re: Hobby Programming Language

Post by rob »

I looked into HLA once upon a time. By the time I got around to working on the U compiler, I was more interested in the project itself than its potential uses (sounds kind of like any given IBM product when I put it that way in writing). Otherwise I probably would have looked into something like HLA or C--. This hobby aspect has been really been the primary motivator behind it. Any outside use it gets is just a bonus.
joviermark
Posts: 1
Joined: Mon Jan 14, 2013 1:58 am

Re: Hobby Programming Language

Post by joviermark »

rob wrote:Hello everyone!

I got interested in OS development some time ago, primarily tinkering in assembly language. More recently, I've found myself experimenting with compiler design, a topic that may very well have eclipsed my interest in operating systems (heresy around here, I'm sure :wink: ). I thought writing a tiny, low-level language (in some respects, a high-level assembly given that it's not portable) that compiles to x86 assembly code would be a fun project, and I'd like to share the product of my work thus far with you. If anyone has any questions, suggestions, or finds a use for it in a separate project, I'd love to hear about it!

Some features of the language (dubbed "U"):
* Simple syntax - This is largely due to it being a hobby project, but this could make it a good candidate for teaching the basics of how compilers and assembly code work. It also lacks some of C's idiosyncrasies (header files, etc).
* Compiles to 16-bit Intel x86 assembly code - The output can be read by a human (again, potentially good for learners) and doesn't require knowledge of a linker (executables are, of course, created with an assembler like NASM or FASM).
* Inline assembly - the language makes incorporating assembly code into the main program flow quite simple (since I'm not shooting for portability)

You can download the source and documentation, here:
https://github.com/upcrob/u-programming-language

Again, questions/comments are welcome (just post below). I can't promise I'll have time to implement features if they get requested, but I'm open to hearing about them. Keep in mind, I'm not trying to create any sort of "C killer" - if you're writing production code or an OS that needs to exit real mode, this language isn't for you. Nonetheless, I'd love to see it used in a small OS project like MikeOS, but we'll see what happens.

Have fun!
Wish you all the best , consider c++ too.

jovier.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Hobby Programming Language

Post by qw »

Nice piece of work indeed. How exactly is dynamically allocated memory handled? If I declare a pointer byte[] p = 10:5, then does p = "Hello, world!" store "Hello world" into address 10:5 or does it assign a new address to p?
rob
Posts: 7
Joined: Thu Apr 30, 2009 10:24 am

Re: Hobby Programming Language

Post by rob »

Hobbes wrote:Nice piece of work indeed. How exactly is dynamically allocated memory handled? If I declare a pointer byte[] p = 10:5, then does p = "Hello, world!" store "Hello world" into address 10:5 or does it assign a new address to p?
If you assigned, "Hello, world!" to p, p would then be pointed to the location of "Hello, world!" in memory (not 10:5 anymore).

The core language doesn't support dynamic language allocation, so you would have to write your own malloc(). Assuming you had this (and some string functions, in this case strcpy()), you could do something like this:

Code: Select all

byte[] p = malloc(20);        // allocate memory and point p to it
strcpy(p, "Hello, world!");   // copy "Hello, world!" to the location pointed to by p
Alternatively, if you knew you were going to put the string at a position like 10:5, you could do something like this:

Code: Select all

strcpy(10:5, "Hello, world!");
lauryfriese
Posts: 1
Joined: Mon Dec 04, 2023 4:02 am

Re: Hobby Programming Language

Post by lauryfriese »

Looking forward for the final one!
Post Reply