by Riccardo Musso
The modern and fun way to program.

Smudge is a Simple, Multi platform, User-friendly, Dynamically typed, Garbage-collected and Elegant programming language written in C++11.

Smudge is a very lightweight and general-purpose interpreted language that could be used for either desktop applications or scripts or incorporated as well into any kind of software that requires a scripting side (for 'modding') such as videogames, text editors, 3d/2d modeling software, etc.

With its C-like syntax, Smudge provides a simple but effective and powerful way to write elegant and modular code. For newbies Smudge could at first glance appear much more complicated than other programming languages like Python, Ruby, Swift or Go, but, after some practice, they will find coding Smudge natural and fun. C/C++, Java, JavaScript and C# developers, however, will love Smudge from the beginning.

import std.io, std.cast, std.system = sys;

class Log {
    var string;

    /*
     * again, constructor: a method called
     * when the object is created.
    */
    func new(str)
        string = str;

    /*
     * operator overloading: a method called
     * every time a certain operator is
     * applied to the object.
    */
    func + (str){
        /*
         * Using 'std.cast::kin()' and 'std.system::sterr()'
         * is the safest way to handle operator overloading.
        */
        if(cast.kin("abc", str))
            return Log(str + "\n" + string);
        else if(cast.kin(Log, str))
            return Log(str.string + "\n" + string);
        sys.sterr("unsupported type (" + cast.desc() + ")");
    }

    /*
     * Ordinary method: called explicitly
     *
    */
    func print(x){
        x.println(string);
    }
}

func main {
    // stored a Log in 'pm'
    var log = Log("first line") + "second";
    log += "third " + "line";
    log.print(io);

    // temporary object
    Log("Hello log!").print(io);
}
Information updated 12/27/19
Note: This entry has not yet been moderated.
View Comments