Hey, I was researching into V5 and I noticed that it is now being programmed through “Vex C++”. How would you write lines of code through this language as compared to ROBOT C? For example, in ROBOT C, I would write
motor[Claw] = 127;
wait1Msec(1000);
How would I write this in Vex C++? Additionally, what are the main differences between ROBOT C and Vex C++? Thanks in advance.
"
I don’t know the answers to most of your questions, but I do know that C++ is based on C, so that whatever lines you desire to write will be relatively similar in both languages.
I don’t know the specifics for the function calls and objects, but you’ll see commands that look something like this:
motorClaw.setPower(127);
in place of
motor[Claw]=127;
What I recommend is looking up a quick tutorial in C++. Once you understand the idea behind object-oriented programming, with the similarities between C and C++, you’ll pick up the rest quickly. The trick is really just understanding how objects are implemented and used, and you’ll get that from all sorts of online tutorials.
This is essentially the same as wait1Msec(500); that you would use in RobotC. What I prefer is it is consistent throughout C. So, for example, if you program Arduinos using C/C++, you would use the same command.
JavaScript, like Python, is (on paper) an interpreted language. Sure, there are the compilers, but they were both conceived as scripting languages. There is a reason why performance hounds gawk at large amounts of JavaScript-it is awfully slow when interpreted, like most web technologies. I am not saying they don’t have a place in the V5 system. They are not the same as a naturally compiled language like C++.
The problem of scripting languages isn’t as much the speed (there are crazy optimizing compiler techniques that blur the speed difference, at the cost of startup time and metadata footprint), as the lack of reasonable compile/build/upload-time validation.
You really don’t want to learn that you typed “shooot(50)” instead of “shoot(50)” in the middle of the match when you engage that part of the code for the first time…