|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Quote:
Code:
.L2:
cmpl $9, -12(%ebp)
jg .L3
movl -12(%ebp), %eax
sall $2, %eax
addl -4(%ebp), %eax
movl %eax, -8(%ebp)
leal -12(%ebp), %eax
incl (%eax)
jmp .L2
.L3:
Quote:
Code:
.L2:
cmpl $9, -12(%ebp)
jg .L3
leal -8(%ebp), %eax
addl $4, (%eax)
leal -12(%ebp), %eax
incl (%eax)
jmp .L2
.L3:
Quote:
Last edited by The Lucas : 18-05-2009 at 00:00. |
|
#17
|
||||
|
||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Quote:
Here is swap with references: Code:
public class MyInt {
int data;
public MyInt(int x)
{
this.data = x;
}
public static void swap(MyInt a, MyInt b)
{
a.data ^= b.data;
b.data ^= a.data;
a.data ^= b.data;
}
}
Last edited by Chris27 : 18-05-2009 at 01:09. |
|
#18
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
You can't dereference (&) and do pointer arithmetic like that in Java.
Quote:
Code:
ptr = 365; Array indexing requires a symbol (base of array) and a type (size of element). When an integer can be cast to a pointer, pointer arithmetic can be done without an array. Quote:
Again, I understand both languages and the reasons why Java doesn't allow explicit pointers (source of bugs, reference counting for garbage collecting, sercurity, etc..). Lets revisit how this whole conversion happened (with me paraphrasing) Billy: Yuck Java. Pointers ftw Jared: What cant you do with Java references? Me: Pointer Arithmetic. Jared: Granted, but you better have a good reason. <Long posts involving example code by Chris, me and Alan> I thought twice before pressing Submit Reply on my first post because I knew it wouldn't be my last on this thread Programming debates are interesting (for me atleast) but time consuming. Maybe I should have just let Billy reply or learned from C++ vs LV threads.Last edited by The Lucas : 18-05-2009 at 12:23. Reason: oops quote fix |
|
#19
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Quote:
|
|
#20
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
More importantly, how much does it matter in our application? What difference will it make? |
|
#21
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
(I know that's not Brian's argument, but it is a good excuse to post one of my all time favorite programming urban legends) |
|
#22
|
||||||
|
||||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION***
I split this conversation into 2 threads into a java discussion and an orbit ball one.
|
|
#23
|
||||||||
|
||||||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Quote:
Alan, to show that pointer arithmetic can be more efficient than array indexing, I used ptr++ (cant use in Java) instead of array indexing in Chris' example loop. The generated assembly showed: Quote:
So basically I am saying (since my first post here) is pointer arithmetic (that can be done in C not Java) can be slightly more efficient in some situations. Nothing major that will make a significant difference in our robot code. Can we agree on that? Quote:
Quote:
Quote:
Quote:
Quote:
![]() |
|
#24
|
|||
|
|||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
An instruction cycle here or there makes zero difference in the face of the larger picture. If you want to have a truly useless argument, just remember that our new processor is pipelined AND has a double dispatch with multiple ALU elements. So while you are all optimizing the instructions, I'll be working on what I want the code to do. As a point of interest, I know someone who wrote his own graphical programming language that compiles to something that is on average twice as fast as C for embedded power and motion control applications. |
|
#25
|
|||
|
|||
|
Re: **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION***
Quote:
Quote:
Quote:
The second is that there is most likely a set of libraries that he uses for the down and dirty interfaces. He optimized them to work with his target platform. Speed in Java the last few years has come from:
If you optimize the algorithm you seldom have to bit fiddle to make it faster. |
|
#26
|
||||
|
||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Anyway, it just bothers me that java turns the idea of pointers from a more numerical approach to an object-oriented approach. I like knowing that the variable i am passing into a function is explicitly a pointer, not something determined by java. Its also bothersome that for primitive datatypes such as int's an entirely different datatype (Integer) is required if you want to pass it by reference into a function (i know there is a system to go around this but god knows how much overhead it incurs, along with the garbage collection of the implicit object). I'm a C man. i need to know what is happening with my code at all times. It helps (me) with debugging and low-level optimizing a lot. also: double/triple/quad/etc pointers. |
|
#27
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION***
Our programming mentor is excited, because his AP classes use Java. It never hurts to give the school a really obvious reason why the time commitment is beneficial now.
Wetzel |
|
#28
|
||||
|
||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls
Quote:
Granted the rules with Java references can get odd at times as well. Honestly, working on a team where the school has no programming courses at all, I welcome being able to work with the kids using an industry standard language that does not involve having to address pointers and pointer arithmetic. Labview is not bad, but I see it as a niche product. C++ and Java have a much wider user base. |
|
#29
|
|||||
|
|||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION***
Quote:
When you don't have the option of using pointers, you can usually trust that the compiler is keeping track of things for you appropriately. Debugging is a lot easier when your tools can show you how things are going wrong. |
|
#30
|
||||
|
||||
|
Re: **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION***
And i do. So whats the problem?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| **FIRST EMAIL**/Java and Orbit Balls *****Orbit Ball Discussion**** | Pjohn1959 | FIRST E-Mail Blast Archive | 44 | 18-05-2009 20:19 |
| "Java, Sun SPOT and the FIRST Robotics Competition" | pogenwurst | Programming | 54 | 02-05-2009 23:37 |
| Amazing Circuit Build and Simulation Java Applet | Chris_Elston | Electrical | 2 | 26-06-2008 19:36 |
| Eclipse Plugin, Linux, and a Java Loader | shtylman | Programming | 5 | 17-01-2008 14:44 |
| Learn C, C++, and Java with new board game. | Elgin Clock | Programming | 8 | 04-11-2005 13:28 |