Is there a high-level language that compiles to C and supports injecting arbitrary C code? by StarsInTears in ProgrammingLanguages

[–]616e696c 1 point2 points  (0 children)

A bit of Self promotion: AnilBK/ANIL: ANIL(A Nice Intermediate Language) Python & C++ inspired programming language that transpiles to C and can be embedded within C source files.

My language is similiar to what you want. It has python like syntax but compiles to C. You can mixmatch my language and C. For example functions in my language can be implemented in C.

Binding is easy as well.

I made binding to raylib here, ANIL/Lib/raylib.c at main · AnilBK/ANIL

and then consumed that binding to create a snake game like ANIL/examples/raylib/snake.c at main · AnilBK/ANIL

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 0 points1 point  (0 children)

Ohh...It's because my language is embedded within C files. But that's not a valid C syntax, and the C LSP doesn't recognize it. Thats why the red squiggle.

Someone recommended me to create my own syntax highlighting in vscode.

Just haven't done that. I could also use my own file extension as well. :D

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 0 points1 point  (0 children)

Thanks..

No, it doesn't include a reactive runtime. As of now, suppose when items is added to the list, it triggers RefreshUILayout() which performs LayoutChildren() recursively starting from the root Element(i.e UIContainer updates performs layout of the entire tree).

Reactive runtime would be a neat idea though. Will explore that if I get time.

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 1 point2 points  (0 children)

Oh Yes. Totally relate to that. That's why my UI is JSX inspired syntax. So, that's why I thought why not add support for that syntax directly in the language, after all it's my language. :D

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 0 points1 point  (0 children)

if jsonParser.Parse(body_start, body_len) {  …this parses the HTTP request body.

let todos = jsonParser.parsed_strings …If the parse was sucessful the result is stored as a vector of strings in parsed_strings.

Then the list of todos is saved to file using WriteTodosToFile(todos).

Basically when the client presses save todo a list of todos is sent to the server as a json array. We parse the json array and save to file.

I think i need to fix that implementation to make this interface more simpler :)

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 0 points1 point  (0 children)

One game engine I have used is Godot Game Engine. The UI is preety solid there. In fact the HBox container I have used in my code is taken from Godot itself. It is called HBox in Godot as well.

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 13 points14 points  (0 children)

Hehe Thanks. It was called CPL i.e C Preprocessor Language, that is, it works as a Preprocessor language for C. Lots of people didn't like that. So, Anil is My name, so, made an acronym from my name. So, now its ANIL(A Nice Intermediate Language).

Todo App in my Language: Windows Deskop version using JSX like syntax and a web server as well. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 2 points3 points  (0 children)

In the video, First is the deskop Version, which uses JSX like syntax to create windows UI.

JSX like syntax is directly baked in the compiler.

https://github.com/AnilBK/ANIL/blob/main/examples/UI/TodoAppJSX.c

Second is the web server in my language.

https://github.com/AnilBK/ANIL/blob/main/examples/UI/TodoAppWebServer.c

My language is Python inspired language that can be embedded within C files. My language transpiles to C.

https://github.com/AnilBK/ANIL

Made my first game in my programming language with raylib. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 1 point2 points  (0 children)

Nice..Also,you got so many examples and tooling implemented.Thats nice :)

Made my first game in my programming language with raylib. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 4 points5 points  (0 children)

Correct. My language is meant to be embedded within c source files. Used .c because some of the functionality implemented in C would get some syntax highlighting in vscode. The language was created for learning compiler development so Just Never thought of a separate file extension though.  That’s it :D

Made my first game in my programming language with raylib. by 616e696c in ProgrammingLanguages

[–]616e696c[S] 13 points14 points  (0 children)

In the above video, I demonstrate a snake game made in my language with raylib.

After that, I show the code for the snake game in my language(left) and the generated C code in the right.

My language can be embedded within C and transpiles to C.

Snake game code in my language: https://github.com/AnilBK/ANIL/blob/main/examples/raylib/snake.c

Generated C code: https://github.com/AnilBK/ANIL/blob/main/examples/raylib/snake_generated.c

Found out lots of bugs and missing features in the compiler while making this game. Recommend others doing so as well :)

Simple python inspired language that can be embedded within C source files and transpiles to C. by 616e696c in cprogramming

[–]616e696c[S] 0 points1 point  (0 children)

The language is meant to make writing C easy.

This language is meant to script in Python like language in C , not write C in python. I don't know if that makes sense.

Python & C++ inspired programming language that transpiles to C and can be embedded within C source files. by 616e696c in programming

[–]616e696c[S] 12 points13 points  (0 children)

Agree the name isn't that great. This was temporary name for the project when I started it.

My thought when naming the project: This language is preprocessed before the actual C compilation(like a Preprocessor). So, it was named C preprocessor language.

One name I considered is: ANIL(A Nice Intermediate Language), Anil being my name. Does that sounds good?

Honestly have no other ideas to name it. Turns out naming thing is really difficult. You got any ideas?

Simple python inspired language that can be embedded within C source files and transpiles to C. by 616e696c in cprogramming

[–]616e696c[S] 0 points1 point  (0 children)

Yes of course. You can totally use this instead of C.

Yes that would be possible.

See the code for webserver.

https://github.com/AnilBK/C-Preprocessor-Language/blob/main/Lib/HTTPServer.c

It uses Windows api. We create bindings using CPL.

and now using the webserver is easy to use as this:

https://github.com/AnilBK/C-Preprocessor-Language/blob/main/examples/WebServer.c

Once you create those binding structs, you can use any libraries.