C programming API comparison

There’s been lots of discussion about the four flavors that we have for C programming APIs. I think the differences are being over emphasized for the beginning programmer as they are more similar than different when used for simple student programs. Here is a small comparison and a reference comparing the APIs.

This program in ROBOTC (tank drive with two motors)

task usercontrol()
{
    while (true) {
        motor port1 ]  = vexRT Ch3 ];
        motor port10 ] = vexRT Ch2 ];

        // Don't hog cpu
        wait1Msec(25);
    }
}

Is equivalent to this code in EasyC (although EasyC has a function to do this in a slightly simpler way).

void OperatorControl ( unsigned long ulTime )
{
    while ( 1 ) // Insert Your RC Code Below
        {
        SetMotor ( 1 ,  GetJoystickAnalog( 1, 3 ) );
        SetMotor ( 10 , GetJoystickAnalog( 1, 2 ) );
        
        // Don't hog cpu
        Wait ( 25 ) ;
        }
}

Looks like this in PROS

void operatorControl() {
    while (1) {
        motorSet( 1,  joystickGetAnalog( 1, 3 ));
        motorSet( 10, joystickGetAnalog( 1, 2 ));

        // Don;t hog cpu
        taskDelay(20);
    }
}

and finally like this in ConVEX.

msg_t
vexOperator( void *arg )
{
    // Register and name the task
    vexTaskRegister("operator");

    // Run until asked to terminate
    while (1) {
        vexMotorSet( kVexMotor_1,  vexControllerGet( Ch3 ) );
        vexMotorSet( kVexMotor_10, vexControllerGet( Ch2 ) );

        // Don't hog cpu
        vexSleep( 25 );
    }

    return (msg_t)0;
}

Here is a comparison of the basic API functions.

vex_apis.jpg

1 Like