View Single Post
  #23   Spotlight this post!  
Unread 06-03-2012, 16:10
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Advantages of each programming language

Quote:
Originally Posted by Jared341 View Post
I would argue that starting from scratch, it is easier for a student programmer to use Java (for FRC) than C++ (for FRC).

I cannot count the number of times I have been asked to help a team with C++ and seen problems like the following...

Code:
Victor myVictor(1);

myVictor->set(0.0); // Error!
Code:
Victor *myVictor = new Victor(1);

myVictor.set(0.0); // Error!
Code:
Victor *myVictor;

myVictor->set(0.0); // Error!  You declared, but did not substantiate, your Victor!
Code:
void SomeFunction(Victor victor)
{
victor.set(0.0);
}

Victor *myVictor = new Victor(1);

SomeFunction(myVictor); // Error!
Code:
void SomeFunction(Victor victor)
{
victor.set(0.0);
}

Victor myVictor(1);

SomeFunction(myVictor); // Still an Error!  You are making a copy of your Victor!
In Java you don't have to worry about objects on the stack vs. the heap (they are all on the heap), pass by reference vs. pass by value (always pass by reference unless you are a built-in type), memory leaks, C++ name mangling in compiler errors, initializing static class members outside of the class declaration, etc.
Nothing is ever passed by reference in Java.
__________________
Attending: MN Duluth Regional