A Minimalist TypeScript for C

44 points by GLC-ninja 5 months 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 5 months 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 5 months ago

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

4 if you include ++.

  • rurban 5 months ago

    As it should be

    • lioeters 5 months ago

      The C stands for Cursed.

tzmlab 5 months ago

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

  • GLC-ninja 5 months 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 5 months ago

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

  • Gibbon1 5 months ago

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

leecommamichael 5 months ago

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

  • sparkie 5 months ago

    What's wrong with a generated parser?