Click here to Skip to main content
15,891,473 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: C vs Python Pin
Jochen Arndt20-May-15 4:02
professionalJochen Arndt20-May-15 4:02 
GeneralRe: C vs Python Pin
Albert Holguin20-May-15 4:59
professionalAlbert Holguin20-May-15 4:59 
GeneralRe: C vs Python Pin
Rage20-May-15 5:15
professionalRage20-May-15 5:15 
GeneralRe: C vs Python Pin
Bitbeisser21-May-15 9:55
Bitbeisser21-May-15 9:55 
GeneralRe: C vs Python Pin
Eddy Vluggen20-May-15 5:59
professionalEddy Vluggen20-May-15 5:59 
GeneralRe: C vs Python Pin
Ygnaiih20-May-15 9:54
professionalYgnaiih20-May-15 9:54 
GeneralRe: C vs Python Pin
Dan Neely21-May-15 3:53
Dan Neely21-May-15 3:53 
GeneralRe: C vs Python Pin
Member 1073194421-May-15 15:37
Member 1073194421-May-15 15:37 
Umm - it's not "a version of C" - it is C (AVR C - and actually C and C++ mixed together). The compiler is GCC.

The "front" you see (with the setup() and loop() functions) - those functions are called by a simple main() - essentially setup() is called first, then loop() is called over and over in a for(;;) construct (or something similar).

A preprocessor loads in the main library (Arduino.h or WProgram.h - depending on the version being used) - see http://www.arduino.cc/en/Hacking/BuildProcess[^] for more details.

That library is actually a huge monster - with tons of compiler directives and checks for which processor is being compiled for - to get the pin and other assignments correct. It's one reason why (on an objective scale) that Arduino code can be comparatively "slow" - because at the core, a ton of checks and other things are being done for you behind the scenes by the library (not to mention the fact that the compiler flags are set to optimize for size over speed - given that you only have a few kilobytes of program space, and even less of memory - that's a good thing).

Could you make your code faster and smaller? Sure - but only at the expense of the code being able to be compiled for only one platform. If you wanted to move the code to another platform, you would be out of luck, until you modified things and recompiled. The system could have probably been made better (ie - independent main libraries per platform, instead of one single giant library) - but given it's origins (the Wiring and Processing hardware/software platform combo) - it's saddled with some baggage that seems impossible to move away from without breaking something or making it more complex for the Arduino's target audience (ie - artists and students, some of whom have never programmed or understand programming). It's also why the IDE is such a (lovable to some) dog - it's based off the Processing IDE, and shares much with it.

You can go more bare metal - remember, the Arduino is not the board or the microcontroller - but an entire platform and a community. Nothing says you have to forever only use the Arduino system. If you get better at things, you can certainly ditch the bootloader, and code for the ATMega328 (or other) in straight AVR C (and include inline assembler if you want). In fact, the bootloader and the main library are all done in regular AVR C/C++ - check it all out sometime and see how they did things. Just be aware, though, that you might code something that works great on say the ATMega328 - but fails on a 644 (for instance).

I'm sure you can code in C/C++ for the Raspberry Pi - just don't expect it to be a super-simple easy process (ie - compile and go, then refactor and do it all again) - you'll likely need to set up a small build chain and a make file at least for each project.

Python is meant to be a quick turnaround language - you can code and run it, quickly make changes, then run it again to see the results. You can also go in an "interactive" editor mode, and run snippets of code and/or commands and see the results instantly. It makes for a very easy and approachable system for development, at the expense of code speed. Nothing stops you, though, from writing some C for speed critical parts, and linking them to your Python code if you want, though.
GeneralRe: C vs Python Pin
Ygnaiih22-May-15 0:57
professionalYgnaiih22-May-15 0:57 
GeneralRe: C vs Python Pin
PIEBALDconsult21-May-15 15:49
mvePIEBALDconsult21-May-15 15:49 
GeneralVote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 3:31
professionalCornelius Henning20-May-15 3:31 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
snorkie20-May-15 3:43
professionalsnorkie20-May-15 3:43 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 4:47
professionalCornelius Henning20-May-15 4:47 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
JimmyRopes20-May-15 4:50
professionalJimmyRopes20-May-15 4:50 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 5:01
professionalCornelius Henning20-May-15 5:01 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Richard Deeming20-May-15 5:03
mveRichard Deeming20-May-15 5:03 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 5:07
professionalCornelius Henning20-May-15 5:07 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
JimmyRopes20-May-15 5:15
professionalJimmyRopes20-May-15 5:15 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 5:21
professionalCornelius Henning20-May-15 5:21 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Nagy Vilmos20-May-15 5:50
professionalNagy Vilmos20-May-15 5:50 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Cornelius Henning20-May-15 6:10
professionalCornelius Henning20-May-15 6:10 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Marc Clifton20-May-15 5:55
mvaMarc Clifton20-May-15 5:55 
GeneralRe: Vote for the president's party, and be cleansed of your sins! Pin
Nagy Vilmos20-May-15 6:15
professionalNagy Vilmos20-May-15 6:15 
GeneralScope creep (plumbing edition) [updated] Pin
Duncan Edwards Jones20-May-15 2:04
professionalDuncan Edwards Jones20-May-15 2:04 
GeneralRe: Scope creep (plumbing edition) Pin
HobbyProggy20-May-15 2:15
professionalHobbyProggy20-May-15 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.