A Minimalist TypeScript for C

43 points by GLC-ninja 9 days ago

A Minimalist TypeScript for C. Cp1, or C+1, or C plus 1 programming language adds only the bare essentials to C language that allows you to output C codes and able to use namespaces, modules, methods on enums/structs, auto variable deduction and more.

Github: https://github.com/galileolajara/cp1

billev2k 7 days ago

Crazy usage of "+". Using "+" as a synonym for "var" seems pretty pointless. Suffix "+" to mean stack allocated (vs not yet allocated?), unless it's an array, in which case "+" means objects not pointers. Or so it seems.

And allowing the minus sign as an identifier character is just asking for errors.

Some nice ideas (member functions!). Love to see the next evolution.

lelanthran 7 days ago

Two different overloads of '+' for a total of 3 different meanings for '+'.

4 if you include ++.

  • rurban 7 days ago

    As it should be

    • lioeters 7 days ago

      The C stands for Cursed.

tzmlab 7 days ago

Is it possible to replace LibC? We'd like to test this on bare-metal target using newlib-nano.

  • GLC-ninja 7 days ago

    Yes you can replace LibC. Just use "cp1 c" command to output C codes and then use appropriate command line arguments to gcc or clang to use newlib-nano. I cannot give direct instructions for you to use newlib-nano because I'm not yet familiar with that library.

WorldMaker 7 days ago

This feels to me halfway to reinventing Pascal the long way around. Fascinating

  • Gibbon1 6 days ago

    If Pascal had opted for BASIC's string types and phat pointers.

leecommamichael 6 days ago

Looks like more of an idea than usable compiler. Generated parser and all.

  • sparkie 6 days ago

    What's wrong with a generated parser?