Close
0%
0%

Soma

Soma is a project that has been close to my heart for a long time. A "real" object-oriented and low-level programming language.

Public Chat
Similar projects worth following
Soma is a project that has been close to my heart for a long time. A "real" object-oriented and low-level programming language. With a wide standard library and forcing the developer to respect certain conventions while leaving the possibility of doing low level (I already have a test on a UEFI application for example). Without bind on libc or others.

--- /!\ This project is on pause for at least the next 3 months (since : 03/2019) ---
--- NB: I didn't published/pushed code for months but i'm working on a private repo ;) ---

The goal of this project is making the language step by step while explaining why I do things and how.

You can also tell me if you think I'm doing something wrong or contribute to the project.

The domain name is already reserved and is pointing here for now : soma.codes

Also, I'm french, I write articles in french and then translate them by hand and with a software. If the translation look good for the software it may not for you.

"A gramme (of Soma) is better than a damn" - Aldous Huxley's Brave new world

mapping-high-level-constructs-to-llvm-ir.pdf

The useful ressource that explain how Clang transform C++ into LLVM IR. PDF Version.

Adobe Portable Document Format - 280.68 kB - 11/18/2018 at 18:38

Preview
Download

RiSC-isa.pdf

Used in example for ISAs

Adobe Portable Document Format - 41.50 kB - 11/18/2018 at 10:20

Preview
Download

  • 1 × Computer That can run LLVM
  • 1 × Keyboard To type
  • 1 × Mouse Can be useful
  • 1 × Screen Also useful with a computer
  • 1 × Brain That can do programming

  • Still alive

    damfle01/10/2019 at 09:55 0 comments

    I'm working on this project on my free time so it take... time.

    I'm currently working on code exceptions. (And yes I'm using Visual Studio ;) )

  • Some basics constructs

    damfle12/02/2018 at 19:05 0 comments

    This is a draft that I publish. It will be edited soon. It is there to make you wait while I rearrange my notes ;)

    Lets get started and look at this piece of dumb C# code to highlight some basics constructs.

    The constructs will be detailed in other projects logs. We're just defining some syntax here.

    using System;
    
    namespace SampleApp
    {
        public class Program
        {
            private int op;
            private int square;
    
            public Program(int op = 0)
            {
                this.op = op;
    
                Console.WriteLine("Hi, I'm a program and will do a square calculation of " + this.op.ToString());
    
                return;
            }
    
            public void doSquare()
            {
                this.square = this.op * this.op;
    
                return;
            }
    
            static void Main(string[] args)
            {
                int inputOp = 0;
    
                if (args.Length < 1)
                {
                    Console.WriteLine("Error you must specify an argument !");
                    return;
                }
    
                try
                {
                    inputOp = int.Parse(args[0]);
    
                    Program theProgram = new Program(inputOp);
                    theProgram.doSquare();
    
                    Console.WriteLine("The square of " + theProgram.Op.ToString() + " is " + theProgram.Square.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine("The argument must be an integer !");
                    return;
                }
    
                return;
            }
    
        }
    }
    

    So. We do have a dumb code who's doing a dumb square calculation. Lets cut it into small parts.

    using System;

    In C# is a way to import externals classes or packages. We do need this in your language. Code must be modulable.

    namespace SampleApp
    

    Help to keep things where they should be. But we won't talk about this for now.

    public class Program

     Hmm. We may have some things to keep here.

    • public is a visibility modifier. I'll talk about them later but most used visibility modifiers are public, protected and private. We need them.
    • class describe a class in OOP. And I'll jump some steps but we'll also need interface, and enumeration.
    • And of course a class must be named.
    private int op;
    private int square;
    

    Next. Here are some members of the class. We do have :

    • a visibility modifier
    • a type, and also int is a basic type.
    • a member name.

  • Paradigms or ways of programming

    damfle11/19/2018 at 07:11 0 comments

    Small quote from Wikipedia "A paradigm is a way of approaching programming. Each paradigm brings its philosophy of programming; once a solution has been imagined by a programmer according to a certain paradigm, a programming language that follows this paradigm will make it possible to express it. "

    There are several ways to approach programming. I already say that I wanted to make an object-oriented language. But what are the other solutions ?

    The two biggest paradigms that come to my mind :

    •  Procedural: Like the assembly, all the instructions are executed step by step.
    •  Object oriented: That's what I want. The program is divided into "objects", or "data blocks" or structures, manipulated by and only by the methods of the object that contain them.

    Warning : This is an oversimplified view of things. My goal being to introduce Soma and not to do a full course. Object oriented paradigm is itself a derivate of the procedural one. This is mostly because of how processors works. And there is many more paradigms. 

    From these two (and many subclasses of theses paradigms), thousands of languages have been created. 

    Indeed, several languages allow to use the two paradigms. Even if they are close to each other, the rules of the object-oriented are not or little respected while programming the object-oriented way.

    For having worked a lot in the web, I saw "object oriented" PHP codes really badly done, because the developers didn't understand all or much of the principles of the object-oriented paradigm. Errors that I have frequently found in C++, less in C# and Java.

    Also did you know that SQL is really good (and designed) for storing and managing object-oriented datas ?

    As a result we do need to find a way to force developpers to learn more about object-oriented programming.

  • Why do we need programming languages and how did we get here?

    damfle11/18/2018 at 10:04 0 comments

    According to Wikipedia "In computer science, a programming language is a conventional notation for formulating algorithms and producing computer programs that apply them. In a similar way to a natural language, a programming language is composed of an alphabet, vocabulary, grammar rules, and meanings. "

    Indeed, computers and processors are dumb. They know how to perform certain calculations in binary and sequentially with only access to memory and some registers.

    They use an instruction set called ISA to perform tasks.

    An example of a simplified instruction set:

    ADD: Adds some datas
    ADDI: Makes an addition to the intermediate registers
    NAND: Do a Not And operation on a register
    HIM: Load an intermediate register in a register
    SW: Saves a word (series of bits usually one byte) in a register
    LW: Load a word in a register
    BEQ: Performs the operation if equal and goes to a certain memory address if the condition is good.
    JALR: Jump to a memory address

    As you can see, a processor may have a very few instructions. In reality today processors have a lot more. But it's not practical for a developer to work directly with an instruction set for big programs. The code is completely sequential and not very legible for a human. Also you may not want to learn everything about a thousands of instructions.

    I talked about registers ?

    This is where things get more complicated.

    In my example there are only three registers: regA, regB and regC and an intermediate register representing memory.

    This leaves us only three "variables", usable only by a few instructions and a stack of data, which must be popped up and stacked in the right order.

    My goal here is not to do an assembly course but to explain why we have moved on to more modern programming languages so I did jump many things.

    And now ?

    Now, and for quite some time now, developers have been using a so-called programming language. As well as a compiler used to transcribe the program into the machine ISA.

    Advantages :

    • Easier to read and understand for a human.
    •  More operations and logic possible.
    •  The language can be compatible with several ISAs without the developer having to do anything with his program. Only the compiler changes.

    The major disadvantage is that we may lost optimization and features of the ISA. Some compilers compile for a precise ISA but without using all the instructions. Or some operations require direct use of the ISA of the machine. For this purpose some languages leave the possibility to insert pieces of assembly language.

    But we can easily guess that programming languages makes life easier for developers.

View all 4 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates