language advice for newbie programmer

I'm starting to get the hang of the arduino programming language. Or I should say, I can make it do what I want with a lot of research and some trial and error.

Now I'm hooked. I'd like to start writing little apps and down the line, more flushed out programs. What programming language would you recommend to someone just starting out?

I work mostly in OS X and Linux and would like to avoid C# and other MS based languages. Python looks good but seems far removed from the C based code the arduino uses. C++? well why not just learn C?

The stink of it is I've got an upside down pyramid thing going on. I'm trying to build knowledge on a small foundation. I'd like to flip it around and learn the fundamentals and build up from there. But where to begin?

So, for those of you that have been doing this for awhile, if you had to start over, what language could take you the furthest quickest, and lend itself to building a foundation on witch you could grow into the future?

I appreciate all advice.

Thanks

If you want quick feedback, don't want to depend on the Arduino-board, but still stay close to the Arduino environment - I guess you should try Processing. (www.processing.org)

That's the language Wiring was derived from and it'll give you quicker feedback since it's mainly used to do graphic stuff.

Good luck!

Amit

Hi, you are probably starting a war with this question :) because, as you might not know yet, there is very often a religious aspect concerned with selecting the right programming language.

Here is my advice : I still think that Java is a very good language to start with. There is an enormous amount of tutorials around for every aspect of programming problems. If you switch between Linux and Mac you will benefit from the fact that the code runs on both platforms.

And since c++ and C are both very close relatives of the Java langugae, basic concepts learned in Java tutorials will reoccur in the other languages as well.

Eberhard

I think Eberhard gives good advice.

And, if language popularity is important to you, then Java is tops!

I dug up the top 5 most popular languages:

  • Java - C-like syntax
  • C - C-syntax
  • Visual Basic
  • PHP - (vaguely) C-like syntax
  • C++ C syntax

See source:http://littletutorials.com/2008/05/28/13-reasons-java-die-old-age/ See discussion: http://ask.slashdot.org/article.pl?sid=08/05/29/163253

But personally, I have spent too much time jumping from one language to another to develop any real skill.

Knowing that, I would tend give this advice:

  • Spend 90% of your time learning C, [u]because that is what the Arduino is programmed in.[/u]
  • The other 10% of your time could be spent on the other languages.

Note that your interest in Linux (UNIX) make C a natural. But I might add that Ruby and Python are a lot of fun! Java and C++, both OO, look very interesting, too.

Good Luck, Steve.

  • Spend 90% of your time learning C, [u]because that is what the Arduino is programmed in.[/u]
  • The other 10% of your time could be spent on the other languages.

For me it's more like 70% PHP 20% Arduino, 10% VB.

Thanks for the input!

Advise from those who've been down this road is really helpful. I hate to go against any of your ideas but I have to admit to some hesitation about going with Java. It's one of those hard to quantify things, but I've just had one too many bad experiences with Java apps. Possibly due to it being many peoples first languages?

Amit - Processing is really neat. Modifying the Graphing tutorial/example is actually what sparked my desire to really go further and learn something more standardized/ubiquitous.

I think I'm going to stick with C/C++ for now. It's portable between mac and nix systems and so closely related to the arduino language that my efforts can serve a dual purpose. It will also help me avoid what optique pointed out about jumping from language to language and never developing any real skill with a single one.

Of course, have stated that learning a little of more than one language is probably bad, I have to admit that I still feel a pull towards Python. I'm just worried that it's structure is so unique that it will slow me down and complicate obtaining a move advanced level of understanding when it comes to arduino code.

Again, thanks for all the input. I'm going to hit google and collect some reading material for this evening.

Hope everyones weather is as nice as it is here in Chicago!

The weather's pretty nice out here, we just cut through a 2 week rain drench, now it's sunnay. (Vancouver, BC, Canada)

Do you have any skills i programming? Bcause if you're just starting and don't know anything yet, you'd better start with the basis : algorithmy. It's not a language, just the "science" behind every language : how to structure your code, how the various conditionnal statements works, etc... If you can't understand the difference between a while and a if loop, start by this ^^

When I was in what is equivalent of a college in the US (Licence Pro, in France), I was one of the few having ever done algorithmy, and it really helped me achieving functionnal & optimized code (Actionscript, at that time).

Do you have any skills i programming? Bcause if you're just starting and don't know anything yet, you'd better start with the basis : algorithmy. It's not a language, just the "science" behind every language : how to structure your code, how the various conditionnal statements works, etc... If you can't understand the difference between a while and a if loop, start by this ^^

I (partially) disagree. Learning algorithms is a very important part, but should better be done in the same time of learning a language, because when you're looking to learn "how to do stuff", it can be quite boring to take much time learning the perfect way to do stuff, before learning that it won't work IRL.

So you should consider learning a bit on algorithms, and in the same time and IMHO, study a strictly-typed, formal language, like, as suggested, Java and C++. Those two will open you the door to most modern languages, like PHP.

Since there is no "best" language, you can also give a look from time to time to others, because they all something different which can be interesting for some special uses.

Just stick to common, widely-used languages (which don't mean just C(++) and Java). You probably won't need to try Brainfuck, at least for a beginning ^^

Of course, have stated that learning a little of more than one language is probably bad, I have to admit that I still feel a pull towards Python. I'm just worried that it's structure is so unique that it will slow me down and complicate obtaining a move advanced level of understanding when it comes to arduino code.

If you feel a pull towards Python, go learn it, you won't regret it.

--Phil.

Automated "censorship" is evil : Read B*r*a*i*n*f*u*c*k instead of Braincrappity smack. It's a funny language.

Thanks again for all the input.

I've been spending my evenings with Senior O'reilly extending my C knowledge and absorbing the fundamentals of Python. I'll be sure to post any code that may be of interest to the community.

It's becoming clear to me that Arduino is lop-sided. The hardware is designed to be very easy to get accustomed to, the projects are very well explained in books and on web sites, etc. It's not difficult to understand how it can all fit together physically. For many people, these electronics hardware skills are new skills — even learning sewing using conductive thread — but are presented in a way that a non-technician or non-engineer can accomplish something positive.

Until it comes to the programming. It's pretty much impossible, because almost none of the things that make the physical side so comfortable and gratifying are attended to. The programming language is hideously arcane and impossible to understand in the context of a non-engineer's hobbyist platform. It's frankly the wrong choice. The language should be nothing to do with what real technicians actually use, it should be structured to be very easy to understand, very very easy to modify, and should not produce so many complicated yet meaningless errors, and it should above all produce something that actually works most of the time (even if it doesn't work in the way intended).

The vast majority of the experience of a non-engineer meeting the Arduino Lilypad platform seems to consist of:

  • blink the LED
  • upload a few of the examples, once the hardware has been crocodile clipped or actually sewn together
  • try modifying the examples to make it do something different, at which point
  • the original code stops working
  • anything new you've typed produces a failed dead lifeless pile of what is now expensive hardware with a lot of time invested in it and nothing to show for it
  • more weekends of the same experience
  • despondency, depression, disheartenment
  • give up because nothing works
  • make it blink the LED to prove that it actually still works
  • realise that that is as far as you'll ever get because the programming language is just far too difficult, obtuse, arcane, and badly designed.

  • find some other artistic outlet that actually produces positive results beyond the preset examples.

I'm sure that since I've been reading this board, and much later, when I registered for it, I've noticed a constant stream of people apologising for not being a programmer. Surely that's the point. These little microcontrollers are not for people doing this for a living all day, they're for people who tuck in a few hours of progression of this hobby during a weekend now and then. They're for non-technicians. They're not even for people pretending to be technicians and engineers, which I suspect a lot of the members on here do, and the arduino probably isn't what actual engineers actually use. They'd use something complicated, like the ARM boards and use an equally baffling and complicated programming language, like C. Because they do that sort of thing all day. For their hobbies, they probably do the sort of thing we do for a living, only slowly and badly.

Ian,

you're impressions are very wrong on many levels. First, hardware isn't easy, people just think it is. Look at the default answers provided GrumpyMike or other guys with experience: Decoupling, currents, resistor dimensioning etc. Being a software guy I can tell you, the hardware stuff is just as baffling as the software part. Second, the Arduino isn't really built to be easy or user friendly. It's designed to be cheap and simple to interface with. The hardware isn't much more than the Atmel reference design and the software is just a thin veneer over the AVR-GCC and AVR-Glibc. So nothing of the sort you mention.

If you want simple and easy, solutions like Nationals Instruments Labview or Lego Mindstorm are better solutions to isolate the user from engineering complexities.

As a last point, what are people in reality? Look inside all those small appliances and what do you see there? PICs mostly, 8051 and also Atmel processors.

To sum it up, only because it's cheap and easy to get something to blink that doesn't meant that the the product is without complexities. Hiding those is either very limiting or takes a lot of effort, both things the Arduino crew didn't choose to do. For me the product works fine as it is and going by the number of successful project base on it for many others too.

Korman

I've just been looking at this “Labview”. It looks very interesting. Works on a Mac, which is good, and you can see what's going on, instead of reams of badly typeset Courier, which is also good.

Then I looked at the price. Are you 'king insane? Two and a half grand? Didn't you understand that the Lilypad is essentially a hobbyist platform, which occupies only a tiny percentage of most people's otherwise busy weekends? Labview is out, then.

I really don't see how anything you said can amount to a positive contribution. The syntax is bafflingly bad. It needs to be easy, more forgiving, rather than the strict authoritarian dictatorship that is C, which will only actually work when every single letter of every single word is right, and all the words are the right words. You could be guessing forever.

The design philosophy behind html is a good exemplar (and before any stupid idiots chime in, thinking I'm suggesting programming the Lilypad in html, let me tell you: I'm not suggesting programming the Lilypad in html — I'm using it as an abstract example of the mode that the designer will find themselves in when exposed to such a technology). When most people started programming web pages, they found their new programming skills could increase at a viable rate of learning because you could look at html examples, try them out, and they'd work. Then you could make modifications, cut and paste bits of two different people's html together, and (this is the important thing) you would still get a web page. You would still get a result. It might not be the result you intended, but the forgiving browser wouldn't simply stop in its tracks and rudely refuse to progress as far as showing you something, while redly and angrily prompting you with a series of red and angry meaningless error code lines.

No, the browser, and html, was forgiving and as such, people actually learned. They weren't discouraged. They tried things, mixed and matched. The true spirit of hacking. This is not present in Arduino, where if you take two programs that perform different functions, and you want to combine them, for the novice, this is just about impossible. Try, and it will fail. Over and over. For months. Getting a new piece of arduino code actually working with the hardware becomes tantamount to winning the lottery, for the novice. Give up. Throw all the arduino hardware in the bin and resign yourself to failure. Find something else to do that actually works, for a happier experience.

When most people started programming web pages

I've been programming for uncomfortably over 30 years, and I've yet to write a complete web page. HTML looks to me like centipedes have walked through inkpots and then over the page.

No, the browser, and html, was forgiving

So was BASIC in the 70s and 80s, and look where that got most peoples' programming skills. That's fine, if you never want to graduate from BASIC programming.

The syntax is bafflingly bad

After Algol 60, the syntax of C is a paragon of clarity and simplicity. Don't get me started on PL/1 or APL (a write-only language if ever there was one).

I've noticed a constant stream of people apologising for not being a programmer.

Thay have to be allowed their dreams, don't they? They can aspire to be engineers and programmers - don't deny them that.

Ian,

I've just been looking at this “Labview”. [...] Then I looked at the price. Are you 'king insane? Two and a half grand?

LabView is a very nice product which is reasonably priced. It was built to allow laboratory scientist with no ambitions at programming to connect together laboratory gear (the price of most is above what you pay for a small car and ends with stuff you can build a house for) and do their science stuff without bothering about programming. And it was successful at this and totally worth the price.

On the other side is Lego Mindstorm which is another very fine example of making robotics available to people not interested in the details of electronics or programming. Don't discount the product simply because Lego produces it and is marketed as toys.

What both products have in common is that quite a lot of work has been invested to make those products so. Also interesting is the fact, that there aren't many free solutions with a similar focus that actually work as well. You can take this as a sure sign, that either the need for such a thing is only limited to the people able to write it or that the commercial products serve the market well an cheap enough or that the complexity of such a task is higher than one would assume. Most likely a combination of all three.

Didn't you understand that the Lilypad is essentially a hobbyist platform, which occupies only a tiny percentage of most people's otherwise busy weekends?

Your perspective is rather irrelevant to the people selling and producing the stuff. If the makers of the Lilypad don't provide an easier development platform, this means that either the stuff sells well enough as it is or that the effort of making a better platform doesn't promise to generate enough additional sales to warrant the risk to invest into it. That's basic business logic for you - don't invest to lose money. And as stated above, people don't seem to be too keen on investing their spare time to create an open source alternative either. So you're a bit out of luck - those people you pay aren't interested in making it easier for you and those giving it away for free neither. That leaves you with just three solutions: Start creating something better on your own, get used to what you have or look for another platform.

The syntax is bafflingly bad. It needs to be easy, more forgiving, rather than the strict authoritarian dictatorship that is C, which will only actually work when every single letter of every single word is right, and all the words are the right words. You could be guessing forever.

Yes, it's bad, but it's a standard many people know in all it's ugliness and there was a ready made and working solution to program the ATmega chips. So the Arduino developers just took that as it is and spent their time on things they considered more important. As to guessing for ever, you don't seem to get it: There's no guessing at all in C. It's all documented and available for inspection. I agree that this documentation isn't very easy to understand for beginners, but it's all there. And there's also tons of material to learn it. And once you get the first understanding how C (or most other programming language for the matter) works, things become easier. Just like with HTML, you need to have some idea how things work and then you can copy and paste, steal, be inspired from other people's code. It has been done in C for the past 40 years or so and there's a tremendous amount of resources available which can be used on the Arduino.

Getting a new piece of arduino code actually working with the hardware becomes tantamount to winning the lottery, for the novice. Give up. Throw all the arduino hardware in the bin and resign yourself to failure. Find something else to do that actually works, for a happier experience.

That's like saying crossing a street is a deadly gamble and surviving is pure lottery. It is if you're a blind chicken who doesn't know about cars and traffic lights. Once you understand how cars move and what the coloured light mean, crossing a street becomes predictable and moderately safe. You seem just a little frustrated because with programming and electricity you haven't reached the point where you can identify the import data from the irrelevant and understand properly how to fit the pieces together.

If you stay with it, that point will come faster than you expect and the forum here is a great help to point you the right way in case you're lost. I find it also helpful to read what problems other people have and what kind of answers they get. It gives a very quick overview what the common problems are and things to check first when I run into troubles.

Korman

This whole discussion has made me wonder if we need some form of a "language" for the Arduino akin to LOGO (actually, you could probably expand on LOGO fairly easily)...

Oh - and AWOL:

BASIC has evolved since the 1970's-80's; I'm sure you're aware of that. BASIC got a bad reputation, I think, because people were able to "get into it" without having any clue as to what they were doing, and producing tons of ugly code that, while it worked, was an absolute nightmare to maintain. Used properly, with an eye for layout and design, BASIC could be used to create large and maintainable systems. Where you tend to see this was in the various shops turning out "business BASIC" (of various flavors - a very popular one was PICK) applications.

No language is immune to improper usage; I've seen more than my fair share of cringe-worthy C/C++ code (if you ever want to see a real mess, check out the code for the 6DOF shooter game "Descent"). Unfortunately, since BASIC became a hobbyist's language in most people's minds with the advent of personal microcomputers which tended to come standard with it, that opened the floodgates to every amateur software developer on the planet. This was both a good and a bad thing - but it became a severe liability for BASIC in general, one which it has never managed to shake, even with today's highly sophisticated forms of BASIC (if you want to see what modern BASICs are like - beyond commercial offerings like VB and PowerBasic - check out XBasic, FreeBASIC, and GAMBAS).

Oh - and I'm a long time BASIC programmer, but I never let that stop me; over the years I've played with a ton of different programming languages (including various dialects of assembler). I still have yet to try any of the more esoteric languages (one I want to try badly, though I have yet to be able to wrap my head completely around it to the point of knowing how to build an application with it - is LISP). I typically try new languages to keep my skills fresh (I really need to get into Ruby); right now I mostly play with PHP, Perl, and Python - outside of the little C/C++ for the Arduino.

:P

Well, this is why I wanted to load amforth onto my Lilypads (but I've been unsuccessful over the past several weeks thus far). Of all the computer programming languages I've ever seen, Forth is the one that seems understandable and approachable (if you use long-ish descriptive words, not stupid unpronounceable abbreviations). Where did it all go wrong and C became popular instead?

Where did it all go wrong and C became popular instead?

There was a useful operating system which could be extended with C, the compiler came with the operating system, it had a decent standard library, it allowed easier access to system functions than with assembler or Cobol, the performance was better than Basic, Fortran or Cobol without being too different from either.

Korman