Programming Prerequisite

Understanding the language, error messages, etc.

Programming Prerequisite

Postby Quibble » Mon Apr 07, 2014 10:45 pm

Hello to the forum and the future Gamebuino community.

I do hope my question doesn't fall into the category of 'already answered elsewhere'. I'm sure many others on this forum are can't wait to get their hands on the Gamebuino this summer and I'm sure my question will help others.

I'm a novice programmer with primarily HTML, Java and Python experience, some C/C++ but not much practical experience. I've never owned an Arduino, are they based on the C++ language? Would gaining a greater grasp of this language and reading the Arduino language reference guide be the best place to start while waiting for my Gamebuino to arrive?

Any other pointers or suggestions you can give would be greatly appreciated.

All the best
User avatar
Quibble
 
Posts: 9
Joined: Sun Apr 06, 2014 3:01 pm

Re: Programming Prerequisite

Postby adekto » Tue Apr 08, 2014 4:56 am

programming is in c
if u get the Arduino IDE and look up the example files from the wiki u may understand how most of it works

if ur having trouble with c and arduino IDE best way is just to read true the Arduino tutorial i learned allot just by going true the blink and fade examples of arduino IDE

u basically have 2 main functions setup() and loop()
User avatar
adekto
 
Posts: 448
Joined: Tue Feb 25, 2014 9:47 pm
Location: belgium

Re: Programming Prerequisite

Postby Myndale » Tue Apr 08, 2014 10:40 am

Heya Quibble, welcome to the Gamebuino forums!

If you already know Java then you shouldn't find Gamebuino too difficult at all. Most embedded systems like Arduino are best suited to C over C++ because 1) C++ tends to result in a lot of pointer de-references which makes the code slower, and 2) virtual function tables in C++ result in a lot of data being swapped in and out of cache lines (either data or code, depending on the compiler). Arduino doesn't suffer from either of these problems quite as bad as other architectures because it doesn't have a cache and the clock speed and pipeline are very simple. C code is almost always faster, but C++ isn't too far behind and if you're a Java programmer to begin with then that's probably a good place to start. (It also helps that the Gamebuino library is C++!)

There are, however, significant differences between Java and C++. C++ isn't a managed language, so under ordinary circumstances you are responsible for allocating and freeing all class instances yourself. However, with only 2KB of RAM you really don't have much to play with, and if you start allocating and deallocating memory at run-time then SRAM is going to fragment very quickly, so the best strategy is to allocate everything you need at the start of the game and then leave memory as is. If your game has dynamic memory requirements then you're better off allocating pools of objects during initialization and managing the allocation of those resources yourself.

For most games though you won't need this. Just declare variables, arrays and function globally and it'll be the same as if you'd declared them in whatever class holds your Main() function in Java. At the Arduino level it's all really quite simple, and the best place to start is the Arduino tutorials home page:

http://arduino.cc/en/Tutorial/HomePage
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: Programming Prerequisite

Postby Quibble » Tue Apr 08, 2014 1:22 pm

Thanks for your replies guys.

So there isn't a main() function, just the setup() which runs once and the loop() which loops around?
User avatar
Quibble
 
Posts: 9
Joined: Sun Apr 06, 2014 3:01 pm

Re: Programming Prerequisite

Postby adekto » Tue Apr 08, 2014 1:35 pm

yes its that simple

btw Myndale any ideas for some basic programming tutorials?
User avatar
adekto
 
Posts: 448
Joined: Tue Feb 25, 2014 9:47 pm
Location: belgium


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 12 guests

cron