Coding in V5? C++ vs. ROBOTC

  1. 6 months ago

    csiv23

    14 May 2018 Hopkinton, MA, 01748 2602J

    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 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.

  2. 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.

  3. callen

    14 May 2018 Answer Braintree, MA, USA

    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.

  4. csiv23

    15 May 2018 Hopkinton, MA, 01748 2602J

    Thanks! Do you know how timers work, as in ROBOTC's wait1Msec(x) command?

  5. callen

    15 May 2018 Braintree, MA, USA

    The standard C command for this is

    void delay(unsigned int);

    So you use it like this to delay 500 ms:

    delay(500);

    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.

  6. java script is were its at noobs

  7. TheCrimsonDoubleChin

    23 May 2018 Appleton, Wisconsin 5062C,A,D

    ^

  8. EricHallahan

    24 May 2018 Chester Springs, Pennsylvania 81Y

    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++.

  9. nenik

    25 May 2018 V5 Beta Tester

    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....

 

or Sign Up to reply!