#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.
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!
> 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.
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 agree.
However, the goal of the computer science classes is to teach basic algorithms and data structures, and not focusing on the language particularly.
For instance, in the national exam (written) you may use any printing function (printf / cout), but you are limited to use C-style string functions. No vectors, no additional containers C++. Pointers are being studied too, but there are no exercises which involve coding in exams for memory allocations, so you never get to choose between new/malloc.
I don't like this situation but this is the problem I am trying to address, any idea is well appreciated!
As far as I can tell, this interpreter doesn't even have std::string, and you can't define your own datatypes or allocate. The interpreter also doesn't handle pointers into arrays properly.
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.
These are the main downsides indeed.
As a matter of fact, in the current curricula the only option is cstring, and it's been that way in the last 20 years.
I am looking forward to put in balance the upsides and downsides in using such an interpreter.
Thank you for feedback!
If it has no object-oriented features, then I don't think it deserves to be called a C++ interpreter at all, since that's basically the one feature everyone thinks of when they're asked to compare C and C++; from the description it looks more like a C-subset interpreter.
Kinda neat but it looks extremely limited in ways that I think would frustrate a beginner:
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.
In this case there are no variables updated so the editor is not very useful indeed. The parsing erros for this interpreter are very limited, however there is internal access to the location of the failure (line, column) so there could be added a red underline to suggest the errors. Thanks for the feedback!
I’m curious as to which country it is that only teaches C++ for all programming?
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.
This Jupyter integration seems really cool. Since I'm targeting educational environments it would open even more options for automated evaluation. Thanks!
This is the definitely the best implementation of a C++ code visualization i've seen yet, kudos to the developers for this
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.
Good work, pleasing UI (when it works). Please also compare with the excellent pythontutor.com website (it works with C++ too: http://pythontutor.com/cpp.html ).
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.
Python Tututor is the first project in this category that I totally loved it. The dream would be to have all the options Python Tutor has and also speed and user experience, but technically there is not very easy to achieve. Thanks for the feedback!
When I write
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.