View Single Post
  #4   Spotlight this post!  
Unread 15-05-2009, 17:57
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: **FIRST EMAIL**/Java and Orbit Balls

Quote:
Originally Posted by Chris27 View Post
Code:
char *ptr = malloc(SIZE);
ptr + i is equivalent to &ptr[i]. Both cases boil down to just a load effective address instruction. Besides the obvious that Java hides the virtual address of all values in the symbol table, I don't see how you are missing anything by not being able to explicitly use pointer arithmetic. in an array. the "[]" operator retrieves that element and many people find this interface more intuitive. There is no performance advantage of using pointer arithmetic and there is nothing you can't do with the "[]" that you can do with pointer arithmetic (as the "[]" operator just encapsulates pointer arithmetic).
[SIDE RANT] I think you are missing the point (sorry for the pun). The point of pointer arithmetic is to compute the address of an element (the array data structure is optional). If you can get that address by simply adding to a pointer (stored in a register) that is more efficient than computing that address by loading a symbol and adding the result of a multiplication (indexing an array using a variable).[/SIDE RANT]

I actually used a bit of pointer arithmetic this year to make a simple circular buffer for Camera Report Structures. Of course I could make a circular buffer class in Java too. Again, I am not recommending pointer arithmetic or saying it's vital, I am just saying it can be useful, simple and intuitive.

My real concern with Java is not the pointer stuff but rather the runtime performance. Java uses just in time (JIT) compilation and garbage collection which should add additional (non deterministic) load to the programs run (of course I need to read more about how theses features are implemented). That being said, I think additional language options are a good thing and all of my programing students are taught Java (not C) in high school for the AP exam.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 15-05-2009 at 18:01.