felixhao28 / JSCPP

A simple C++ interpreter written in JavaScript

Home Page:https://felixhao28.github.io/JSCPP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any missing feature of pure C (not C++)?

Naereen opened this issue Β· comments

Hello there,
First of all, πŸ‘ πŸ‘ this project is amazing, I just discovered it, and played for an hour on the online JSCPP interpreter.
It's a great tool for teaching I think! So thanks!

Regarding teaching, I'll have to teach a few introduction courses to C, and of course I'll start by using a local real compiler for C, but I would like to also have such basic environment online, and hosted locally on the machines that my students will use: this way, there is nothing to install, it works on Windows, and no need for Internet access, just a web-browser to a local folder.

I'm not a very strong expert of C and C++, but from what I understood, any valid C99 or C11 program is also valid in C++, with the same semantic, so I can expect JSCPP to be able to run correctly any (small and simple enough) C program?
I saw the list of libraries, and #include <math.h> works, which will be enough for a huge part of my classes.

My question is in the title: Is there any (known) missing feature of pure C (not C++)?

Thanks!
Regards from France, @Naereen

I link here a similar question I've opened on Jupyter notebook kernel for C++, that I also intend to use for my teaching.
jupyter-xeus/xeus-cling#386

Is there any (known) missing feature of pure C (not C++)?

Actually, there is a lot of missing features:

  1. Most of the headers. Here is a very limited list of currently added headers. Although these headers are enough for my C++ lessons, you might find them not enough. If you need any more, feel free to open a new issue.
  2. JSCPP is an interpreter. Therefore some compile errors will only be reported during execution. So JSCPP is not a good way to teach students what compiling means.
  3. The support for macros is experimental for now.
  4. goto statements.
  5. Embedding assembly.

Hi @felixhao28, thanks for the detailed answer.
At the level I'll be teaching, I can safely assume that macros should be limited, goto forbidden, and assembly completely out-of-scope.
Regarding headers, thanks for the link. I guess for advanced lectures in 2nd semester and beyond, it won't be enough (no assert for instance) but for a start that's really enough.

And you're right to remind that it's an interpreter, but precisely I want to avoid presenting things in binary like "Python is interpreted, C/C++/Java are compiled" (Python has Numba, Pypy with JIT, Cython ; C/C++ have well your project, CLING and a CLING kernel for Jupyter, Java have JShell and IJava for Jupyter).
Of course after one lecture explaining all this I'll dive in the "classical" way of using these languages, with clang/gcccompiler for C/C++, javac/java for Java, and CPython interpreter for Python.