Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Learning to Program in Java (http://www.chiefdelphi.com/forums/showthread.php?t=77325)

Kingofl337 11-05-2009 21:15

Learning to Program in Java
 
This is a great resource on learning how to program in Java. If your interested in learning this is a good place to start.

http://www.javapassion.com/javaintro/

If anyone else has any resources to share, I'm sure it would be helpful for teams considering Java as an option next year.

Jared Russell 11-05-2009 21:46

Re: Learning to Program in Java
 
Sun maintains a fantastic set of Java tutorials on their official web site.

http://java.sun.com/docs/books/tutorial/index.html

These tutorials, along with JavaDocs of the Java API, are pretty much the only resources you need to get going.

derekwhite 13-05-2009 14:36

Re: Learning to Program in Java
 
You can also try the robot emulator to test out the versions of Java and tools that will be available next year. Check out the "Get the emulator NOW" link at:
http://sunspotworld.com/frc

bobwrit 13-05-2009 17:16

Re: Learning to Program in Java
 
Quote:

Originally Posted by Jared341 (Post 858759)
Sun maintains a fantastic set of Java tutorials on their official web site.

http://java.sun.com/docs/books/tutorial/index.html

These tutorials, along with JavaDocs of the Java API, are pretty much the only resources you need to get going.

Seconded.




I also like the sam's 24 day series(or something like that) on Java.

brianelite 16-05-2009 18:13

Re: Learning to Program in Java
 
How hard is it to learn Java coming from C++?

computerish 16-05-2009 20:57

Re: Learning to Program in Java
 
It ought to be fairly easy, since they are similar languages. I haven't done anything with Java for years, though, so I guess I'm about to find out.

Anyone know if we will be able to run whatever IDE they give us on Linux? All the software available now runs on Linux, so I am hoping whatever FIRST gives us will, too.

timothyb89 19-05-2009 00:35

Re: Learning to Program in Java
 
Quote:

Originally Posted by computerish (Post 859910)
It ought to be fairly easy, since they are similar languages. I haven't done anything with Java for years, though, so I guess I'm about to find out.

Anyone know if we will be able to run whatever IDE they give us on Linux? All the software available now runs on Linux, so I am hoping whatever FIRST gives us will, too.

Its likely going to be NetBeans (which is awesome!), and that runs on Linux. The problem is that Eclipse does as well, and there definitely wasn't Linux support this year for C/C++ (I blame WindRiver).

Everything they use is probably going to come directly from the SunSPOT project, which is definitely cross platform. Even if FIRST doesn't provide the software for us, there's a good chance we'll be able to get it ourselves, assuming they don't brand it in some horrible way (i.e., the FIRST downloader).

Jared Russell 19-05-2009 07:11

Re: Learning to Program in Java
 
Quote:

Originally Posted by brianelite (Post 859884)
How hard is it to learn Java coming from C++?

In general, C++ -> Java is definitely easier than going in reverse. If you are good with C++ (and understand its underlying object oriented paradigm) you can pick up Java in a snap - it is both semantically and syntactically very similar.

purduephotog 02-06-2009 13:13

Re: Learning to Program in Java
 
Quote:

Originally Posted by Jared341 (Post 860363)
In general, C++ -> Java is definitely easier than going in reverse. If you are good with C++ (and understand its underlying object oriented paradigm) you can pick up Java in a snap - it is both semantically and syntactically very similar.

Exactly.

I just finished working on a project where we 'ported' / rewrote large segments of code- brought it over from C++. I'd say 80% of it was copy/paste from C++ to Java with no problems. Yes, there were issues with some things (copy constructors, destructors, etc) but for the most part it was pretty simple.

The modern editor, assuming they give us netbeans to work in, will be a pleasure to work in compared to the older IDEs. I'll admit I know nothing about the graphical programming languages (heck I can't even remember the name of it)... but Java was fun to learn and use.

ExarKun666 08-06-2009 19:43

Re: Learning to Program in Java
 
I came across a weird thought in this process. One of my teachers, who teaches C++ and Java, told me that when you program and compile Java Code [not to robot, but for animation for example], and when you compile C++ [not to robot, but for animation for example], and you execute them both, and if they did the same thing, all same except the syntax of course, that C++ does the compiling and executing a little faster then Java. First of all is this true for the robot, and if it is, what possible effects could it have?

Jared Russell 09-06-2009 07:23

Re: Learning to Program in Java
 
Quote:

Originally Posted by ExarKun666 (Post 862811)
I came across a weird thought in this process. One of my teachers, who teaches C++ and Java, told me that when you program and compile Java Code [not to robot, but for animation for example], and when you compile C++ [not to robot, but for animation for example], and you execute them both, and if they did the same thing, all same except the syntax of course, that C++ does the compiling and executing a little faster then Java. First of all is this true for the robot, and if it is, what possible effects could it have?

In general, C++ is faster. This is because C++ gets compiled into native machine code that can be directly executed by your processor. Java, on the other hand, gets compiled into an intermediate representation called byte code. The byte code is portable across all sorts of operating systems and processor types, but it must be interpreted into machine code at run time in order to execute. It is this interpretation step that generally makes Java run slower (although sometimes it can actually be a benefit with JIT compilation, but that's another issue). However, the Java Virtual Machine is constantly being improved and this performance gap is much smaller than it once was.

One other factor that has traditionally scared roboticists away from Java is garbage collection. In C/C++, memory is allocated and freed by the programmer directly. In Java, memory is periodically freed when needed (a process called garbage collection). While this makes a programmer's life much, much easier, it means that sometimes the system will decide to do garbage collection at an inopportune time, causing you to miss real time deadlines. However, once again there has been some advancement in this area that has turned this issue from show stopper to mere nuisance.

I don't think we'll see an enormous performance difference between Java and C++ on our cRIOs. Besides, most teams are only scratching the surface of what the cRIO can do. And good Java is both more robust and oftentimes faster than bad C++ - if a team isn't comfortable with C++, any code that they produce may well end up being faster in their Java implementation anyways.

ExarKun666 09-06-2009 18:07

Re: Learning to Program in Java
 
Quote:

Originally Posted by Jared341 (Post 862870)
In general, C++ is faster. This is because C++ gets compiled into native machine code that can be directly executed by your processor. Java, on the other hand, gets compiled into an intermediate representation called byte code. The byte code is portable across all sorts of operating systems and processor types, but it must be interpreted into machine code at run time in order to execute. It is this interpretation step that generally makes Java run slower (although sometimes it can actually be a benefit with JIT compilation, but that's another issue). However, the Java Virtual Machine is constantly being improved and this performance gap is much smaller than it once was.

One other factor that has traditionally scared roboticists away from Java is garbage collection. In C/C++, memory is allocated and freed by the programmer directly. In Java, memory is periodically freed when needed (a process called garbage collection). While this makes a programmer's life much, much easier, it means that sometimes the system will decide to do garbage collection at an inopportune time, causing you to miss real time deadlines. However, once again there has been some advancement in this area that has turned this issue from show stopper to mere nuisance.

I don't think we'll see an enormous performance difference between Java and C++ on our cRIOs. Besides, most teams are only scratching the surface of what the cRIO can do. And good Java is both more robust and oftentimes faster than bad C++ - if a team isn't comfortable with C++, any code that they produce may well end up being faster in their Java implementation anyways.

So out of the languages allowed: C/C++, LabVIEW, and Java, there is not a real big difference that would effect the performance of the cRIO, or robot operations?

Greg McKaskle 09-06-2009 21:19

Re: Learning to Program in Java
 
There will be a difference, but since much of the heavy lifting is done by the FPGA, the differences will often not show up. Also since another expensive element, vision, is being done by an optimized binary library written in C, the differences again will not show up.

Raw arithmetic for control or other processing carried out on the cRIO will show the differences, and I'm as eager as anyone to see how they compare. LV is a compiled language, not a VM, but a good VM can beat a bad compiler. As with most engineering tasks, it will be a system of tradeoffs where performance is not the only thing to be concerned with. The ability to debug well and quickly modify code may be more important than the runtime performance.

Greg McKaskle

purduephotog 10-06-2009 13:06

Re: Learning to Program in Java
 
I once was designing a program to perform several million iterations and distance calculations. I worried constantly about memory and time. When it was run in java it executed in just under 1 second.

1 second.

I gave up on the differences between C++ and Java at that point.

JohnFogarty 12-08-2009 18:01

Re: Learning to Program in Java
 
What i'm hoping is the software will run on windows 7


All times are GMT -5. The time now is 11:04.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi