#include <iostream>
int main() {
int x = 23;
std::cout << x;
return 0;
}
It seems like it can't handle namespaces.When I write
#include <vector>
it complains, "cannot find library: vector".I think this isn't going to be very useful for people unless you get a C++ evaluator that works correctly. There is a demo of Clang running in the browser using webassembly here: >> https://tbfleming.github.io/cib/ << but it doesn't actually work for me on Firefox. Maybe I need to use Chrome. That is probably a better option for getting C++ running in the browser.
Which notable features are not implemented yet?
Goto statements
Object-oriented features
Namespaces
Multiple files support
The target audience would consists in students trying simple algorithms. By the end of the high school, students are only using very basic C-syntax: variables, arrays, functions, and a couple of functions from the standard library.Some partial implementations: iostream (only cin and cout and endl) cmath cctype cstring cstdio (partial) cstdlib (partial)
Other includes could be added too.
What I am trying to highlight is if there is any possibility to increase the visual feedback for students heading first to programming.
Something more like an interpretor would be more suitable in this case, but the wasm compilation doesn't seem too slow though. Thanks for this demo!
if the goal is to have them writing C-style C++ code, why not just use C? or if the goal is to teach C++, why start with only the features available in C?
I've been a TA for classes in both C and C++, and I think we ultimately do a disservice to these students by not treating these languages more separately.
I'm not familiar with other countries' curricula, but we had vectors and strings very early on when I learned C++. I like the general idea of the debugging interface, that could help a lot of people. But I think you should upgrade the interpreter. I don't know if that's possible while retaining the debugging interface, unfortunately.
E.g. the following doesn't do anything
#include <iostream>
using namespace std;
int get7() { return 7; }
int main() { return get7(); }
but if you manually inline the get7() it displays 7, so returning the value from another function doesn't work which seems quite odd and I think would preclude playing with recursion. (You can assign the get7() return value to a local var and return that and it works so there is a workaround but it's awkward.)Similarly, if there are compiler errors it gives no indication as to what the error might be. C++ compiler errors are always pretty terrible but not showing anything about where even a parse went wrong could really get in the way of fixing typos etc that can really get in the way of learning the concepts.
I was thinking at a solution to teach code easier for the beginners. C++ is the only available language for computer science classes in my country.
The project is aimed to teach coding for students as the next step after Scratch.
The language implementation is just a subset of C++, it relies on JSCPP interpreter.
I am looking for feedback and suggestions.
Thanks!
And why that is, sounds very particular. I started programming in C and C++. Back then it was the knly languages I could find books for in the library and I had managed to get my hands on a Borland compiler via an older cousin, but I wouldn’t have picked it as a newcomer language today.
AFAIK it uses clang for parsing, which is as good a C++ parser as any.
That said, its a bit sad that this is in C++, which I think is an atrocious language for coding beginners to learn. Sure, a lot of people here might have learned C++ to start with (me included), but there are much, much better alternatives available today (pretty much any modern interpreted language for example).
I've noticed that people who are new to coding get the biggest boost to learn more about programming if they are in an environment where they can cause some kind of interesting visual output. In this regard, many languages that have good visual tooling integration (like Javascript's integration with HTML, python integrating with a GUI toolkit like pygame) really kicks it out of the park when it comes to motivating newcomers.
If the devs are reading this, could I suggest adding a 2D graphical component to this tool? unfortunately I can't think of any good, easy-to-use graphics APIs in C++ (a la the canvas API in JavaScript), but SFML and CairoMM come to mind.
Examples of differences I can see:
* pythontutor requires a backend and does not run entirely in the browser.
* pythontutor supports much more of C++ (i.e., has fewer limitations)
* shows pointers, heap and stack better.
But there are probably many more differences; would like to see a comparison among similar resources. Anyway, I think this sort of live visualization is indeed very useful; great work and please continue.
#include <iostream>
using namespace std;
int* foo() {
int y = 2;
return &y;
}
int main() {
int* x = foo();
cout << *x << endl;
return 0;
}
I would recommend not using this for educational purposes yet; it could mislead students about pointer usage.