Thread: Cero

  1. #1
    Registered User
    Join Date
    Mar 2014
    Posts
    3

    Cero

    Hi all!
    I've created a small flavour of C++ called Cero. I find it useful and would just like to share it, maybe you will too. Cero is basically C++ without semicolons and curly braces, plus some additional stuff.
    See http://cero-lang.org

    Thoughts?

    -- Henrik

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Why did you decide to modify C++ and not design a general purpose language from scratch?

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    No header files
    O_o

    Code:
    +++ public
    +decl
    +++ private
    #include <iostream>
    #include <string>
    +void myprint(std::string s)
        std::cout << s
    If you are going to "bake" header files from `import' statements and the `ce' file, you should handle include files as `import'.

    If you are correctly handling forward declarations on behalf of the client, you can use the same juice to eliminate the need for `+++ public' and `+++ private'.

    Code:
    +++ public
    +decl
    +++ private
    In other words, you may assume the above unless otherwise stated.

    No curly braces and semicolons - some exceptions
    Why not "overload" "null assignment" for that context? The expression would be familiar to Python, Javascript, and several other programmers.

    Code:
    void fun() = null;
    You'll also find relatively few contexts where brace initialization occurs in C++11, and if you don't consider "in-place" contexts you can easily parse comma-delimited lists allowing a client to forgo the braces if they put everything on a single line.

    Breaking long lines
    A line beginning with a unique operator may be parsed no differently from a line ending with a unique operator.

    Why did you decide to modify C++ and not design a general purpose language from scratch?
    Can't be done; programmers are doomed to repeat the mistakes of earlier languages.

    People shape the world with tools, but the tools inevitably shape the wielder.

    Soma
    Last edited by phantomotap; 03-02-2014 at 10:52 AM.
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  4. #4
    Registered User
    Join Date
    Mar 2014
    Posts
    3
    Quote Originally Posted by manasij7479 View Post
    Why did you decide to modify C++ and not design a general purpose language from scratch?
    C++ as a base is good enough for me, but I wanted a few minor changes to the syntax. Also, the effort involved in designing a new language is huge.

    -- Henrik

  5. #5
    Registered User
    Join Date
    Mar 2014
    Posts
    3
    Quote Originally Posted by phantomotap View Post
    <No header files>
    If you are going to "bake" header files from `import' statements and the `ce' file, you should handle include files as `import'.
    The idea is that 'import' imports Cero files and #include includes C++ files. I think it's good to keep them apart.
    If you are correctly handling forward declarations on behalf of the client, you can use the same juice to eliminate the need for `+++ public' and `+++ private'.

    Code:
    +++ public
    +decl
    +++ private
    In other words, you may assume the above unless otherwise stated.
    The idea with "+++ public" is that you put everything to be exported in that section. That way you don't have to put "+" on every little thing to be exported. That method can be used for e.g. exported functions where the function definition header can be reused/copied to the +decl statement.

    <No curly braces or semicolons - some exceptions>
    Why not "overload" "null assignment" for that context? The expression would be familiar to Python, Javascript, and several other programmers.

    Code:
    void fun() = null;
    You'll also find relatively few contexts where brace initialization occurs in C++11, and if you don't consider "in-place" contexts you can easily parse comma-delimited lists allowing a client to forgo the braces if they put everything on a single line.
    Might be difficult for e.g intializers for multidimensional arrays where the braces correspond to the structure of the initialized data.


    <Breaking long lines>
    A line beginning with a unique operator may be parsed no differently from a line ending with a unique operator.
    That's a good idea. I will have to think some more about it.

    Thanks for your comments.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by suncore View Post
    C++ as a base is good enough for me, but I wanted a few minor changes to the syntax.
    Syntax... frankly, the least useful aspect of your proposed language. More interesting to know is what is the impact of your changes on the compiler speed and generated code.
    Last edited by Mario F.; 03-02-2014 at 04:45 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by phantomotap View Post
    [snip] programmers are doomed to repeat the mistakes of earlier languages. [snip]
    like OOP

    ^_^

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    I rather like curly brackets and semicolons. doing away with semicolons makes it more difficult to have multi-line statements, and curly brackets make scope more clear to the individual reading the code, even if they aren't entirely necessary for the compiler to understand it.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed