Which programming language to learn

I have recently become interested in robotics - I've done a bunch of reading, and am about to embark on a "first robot tutorial" on the
Society of Robotics website.
When I reach a more advanced level, I know I will need programming skills. I haven't done any programming apart from some BASIC at school 20 years ago! But I'm willing to learn. So, what would be the best programming language for me to learn in connection with hobbyist robotics? C++? Some form of BASIC? Or something else entirely?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Both C and BASIC are well supported by microcontroller compilers / interpreters, so either language is a good choice. I personally prefer compiled C for my micro work (I use CCS's awesome C compiler). On the (Windows) PC side, I recommend C# or VB.NET. Don't bother with C++, as it and its COM/DCOM ilk are deprecated. .NET / C# / VB.NET is where it's at now.
BRW
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

I agree, unless you are writing a huge program, plain old C is much simpler and reduces your risk of encountering compiler induced bugs. Don't repeat that out loud on the C++ news group though or they will start screeching and throwing feces at each other in protest. They can be an ornery bunch when you suggest that C has any use in modern day life.
For robot control C is great although I can see if you get into heavy image processing or very complex behavior heuristics then C++ could help insure isolation between software components. Of all the programming languages, learning C will give you the best return on your investment long term. An interpreted language like C# might help speed things along when you are making constant changes but I dont think you are going to find a C# interpreter for your 8 or 16 bit micro controller.
Oh, and try to start with a PC as your experimenting platform. Buy a few servos and hook them up to your serial port (or USB port) using that Mini-SSC adapter thingy and just start making things move.
-howy
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
BRW wrote:

Agreed. Not all Basic's are the same, but if you learn one you can usually get something working on the other. ANSI-C is really quite standardized, but most microcontroller C compilers only implement a sub-set of ANSI-C. Thus, code written for one microcontroller C compiler tends to need some "tweaking" to get it to run on another microcontroller C compiler. I'd vote for ANSI-C, but Basic is not a bad choice either.
> I personally

Many people are extremely happy with the CCS C compiler for Microchip PIC microcontrollers. For the Atmel AVR folks, most people use the GCC (Gnu C Compiler) tool chain which is "free".

C# tends to be mostly Windows these days (although there is the mono project for Linux.) C++ is available on more platforms. Also, Java is quite popular. These languages tend to require pretty beefy machines to run. There are exceptions (C++ on the AVR) and the Java on PIC effort out of the Netherlands, but for the most part you need a 32-bit processor for the Java/C++/C# stuff.
Your mileage may vary,
-Wayne
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Thanks everyone for your advice! It's a coin-toss, C or BASIC... I'll have to give it some thought. Thanks again.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

There is the option of learning both BASIC and C so you can use whatever is suitable at the time.
-- jc
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

You're right, of course. Why limit myself?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Based on my experience, you pretty much have to learn C before you can learn C++ (of course, I learned C roughly two decades before I learned C++, so I might be biased. But we tend to teach our students concepts that apply to both languages first, and then move to C++ constructs). But no single event has improved my C code as much as learning C++ did -- you end up thinking in objects, which is (IMHO) just plain a better way to think, no matter what the application or the language you're working in.
So I'd say learn C, then C++. I'd suggest a scripting language like PHP (or Perl, or Python -- but PHP is the one I know) next, but that's not really useful for a robotics project.
You'll notice BASIC didn't make my list. As a historical note, it was the first language I learned.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

people do tend to think that but the truth is you only need to learn c first if you want to be a *good* c++ programmer. pretty much everybody who knows c++ writes "c/c++" on their resume. when i interview software engineer candidates i usually ask coding questions in c. it is astounding how many "senior c/c++ programmers" fall on their face when you ask them to use malloc.
the scary part about c++ is how much you can do without understanding what you are doing.
-chris.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
wrote:

Or even knowing where the "shift" key is.
Deep.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Seems like a civil group....let me ask a question too.
What are the differences between C C++, C#, C.Net? and any other variations out there?
I used to BASIC and PASCAL...each had its place.
I especially liked PASCAL...it allowed one to write readable and well structured code.
TMT
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Too_Many_Tools wrote:

I recommend reading the appropriate Wikipedia articles to answer your question. Anything I write here would be a rehash of what the articles already say.
Many people have fantastic religious wars about how language A is better/worse that language B. These religious wars obscure the fact that a programming language is a tool. In the hands of a skilled programmer, each language can be made to sing; likewise, in the hands of an amateur, the resulting code is not pretty to read or debug.
Rather than focusing in on a particular programming language it is probably more important to learn basic programming skills that are applicable across most languages. Particularly important programming skills for programming are 1) data structures and 2) debugging skills. There are many books on data structures, but rather few books on debugging.
My $.02,
-Wayne
-Wayne
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

http://en.wikiquote.org/wiki/Programming -- especially. it's not always obvious which quotations are supporters and which are detractors, though.

technically speaking what you really mean is that in the hands of a skilled programmer any language can be used to simulate a turing machine. sing is subjective. if you take a brilliant lisp hacker and make him write java servlet pages, he'll be able to do it, but he won't describe it as "singing". he'll tie a noose with his mouse cable and hang himself. the desire to avoid that leads to fanaticism.

while programming concepts are similar across languages, language choice affects how you think about programming (see also: sapir-whorf) as well as which operations are simple vs. contrived. in the last week, i have worked on code in three languages: c, c++, and perl, for three projects: a website i'm writing, an avr in a robot, and a high performance distributed server system for my job. assuming for now that i'm a skilled programmer, do you really think i could make those "sing" in any language/project combination?
if the goal is programming small microcontrollers for robots, in the long run the best option is to learn c.
-chris.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Thank you chris, and everyone else who replied. It's been very helpful, and has focused my attention.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
dapunka wrote:
[snip]

I was not trying to say that the languages are interchangable; they are not. What I was saying is a that a skilled programmer will know how to write reasonable code for each language. Indeed, they will choose the language based on the problem at hand.
Actually, I do know some phenomenal LISP hackers and they have largely moved onto other languages. Many of them now regularly program in languages other than LISP with committing suicide.

In the likely situation where you are a skilled programmer, I suspect that you use the best language for the application at hand. I repeat, I was not trying to say that languages are interchangable.
I've been writing code since the 1960's, so I have quite a number of programming languages that I've used over the years (Algol, FORTRAN IV, APL, PDP-8 assembler, PDP-10 assembler, 8080 assembler, Bliss-10, SAIL, Pascal, Bliss-11, K&R C, Clu, Snobol, 808x assembler, C++, Bourne Shell, Tcl/Tk, Java, Perl, SQL, Python, Microchip PIC assembler, etc.) Many of the skills that I learned in now obsolete languages have been transfered to newer languages. Thus, my paragraph above was trying to focus on learning useful transferableprogramming concepts rather than just programming languages.

I agree, C is an excellent choice for embedded microcontrollers.
-Wayne
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Wayne C. Gramlich wrote:

Typo: I meant "... with[out] committing suicide."
oops.
-Wayne
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

It was more fun the first time :)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

C++ is a superset of C (well, not quite, but pretty close) which adds object-oriented constructs -- classes, in particular. The syntactic differences are small, but you think very, very differently when programming C++, and that bleeds over (in a good way) to your C code. It has some features supporting genericity in functions, which can lead to huge problems with bloat in the generated machine code.
I don't do Windows, so I don't speak C# or C.net, and can't comment on them.

Me too -- in my experience, BASIC's place was in a wastepaper basket. To the extent that BASIC has become a useable language, it's been by adopting C constructs -- you're much better off with a more modern scripting language (in a post I made a couple of minutes ago, I mentioned PHP, Python, and Perl -- forgot Ruby, which should also be listed).

I was a real Pascal bigot (first structured langauge I learned, and the group that wrote the VAX Pascal compiler for DEC was in the department where I got all my degrees) until the day I had a tape with data in Data General floating point format data and needed to convert it to run on a VAX. I think that may have been my last Pascal project. C will let you do what you want to do, and not argue with you about it -- it's got lots of flaws that the programming languages researchers will complain all day long, but that one virtue covers almost anything.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Wed, 29 Aug 2007, Too_Many_Tools wrote:

C, originally a portable but high level "assembler" is a procedural language designed in and around the original Unix operating system at AT&T, and become useful for portable OS development, system level coding and indeed, embedded programming, as it is a relatively low level language which gets close the iron, and supports structures and syntax easily supported directly by most processor instruction sets. C is simple, straightforward, efficient and widespread with many implementations both open source and commercial. (see also predecessors BCPL, B and variant D)
C++ was an extension to C created by Bjarne Stroustrup, and originally consisted of a preprocessor which added object oriented features (objects, classes, inheritance, operator overloading ...) to the intial C language, which remains a valid subset of C++ by the way. Modern C++ implementations are full compilers, rather than a preprocessor tacked onto the front of a C compiler. C++ is often criticized as being a write only language, and indeed it is easy to write convoluted and undecipherable C++, and this is exacerbated by the features which continue to creep into the language over time. Smalltalk, it is not!
C# is a language developed by Microsoft to counter Java, and in this regard has many similarities to Java (as opposed to C). C# was closely linked to the .net environment on Windows, and was more about locking software onto the Microsoft platform. This has been countered to some extent by the existance of the open source Mono project which has a portable implementation of the .net environment on Linux/Unix, and which is not on Microsoft platforms.
C.net? Visual C? Visual C++? simply a compiler/IDE with bundled Windows libraries for Win32, and the .net wrapper for the Microsoft environment.
Pascal is similar to C in certain respects, but indeed, has aspects common to Ada, in that strong type checking, nested functions, and some aids to prevent programming errors. Assignment (:= vs =) is sufficiently different from logical test (= vs ==) to avoid many common C bugs.
Basic is an ideal language for babies, or hw engineers who think that programming is mostly done with solder, and can't be bothered to learn programming in a proper language (eg: C or Forth). The BASIC various dialects are so numerous and so different from any standard, that no two basics share much in common. Microsoft's Visual Basic as a case in point has very little to do with basic, and was named mostly to impress potential programmers as to how easy it is to use (propaganda).
Having said this, I'm surprised that noone on this thread has mentioned Forth as an embedded language, as it in certain respects beats most languages hands down for robotics. Originally used to control telescopes for astronomical tracking, this langage has been around since Charles Moore described it in the very early 1970's, and literally exists on just about every processor invented by man.
Forth is often "available" as an option wherever embedded basic is available, and typically offered as a me-too. Having gone through the learning curve with Forth, with its embedded assembler(s) cross compilation, metacompilation simple multitasking, and inherent ability to bit-bang, it is very close to the hardware, high level words can be re-written in assembly for efficiency when needed, there are all kinds of advantages.
Anyway, I hope the above (admittedly biased) descriptions help ... 8-)
Cheers, Rob Sciuk
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Aug 29, 9:42 pm, snipped-for-privacy@controlq.com wrote:

I think this is the standing myth, but it misses BASIC's historical origins. BASIC was named because the authors wanted a very basic language. But it's early popularity was not its simplicity, but its interactivity. I would suggest it was one of the very early IDE's (integrated development environments). If you were a beginner and were going to write a program in the '70's, you have your choice.
1) Learn how to launch BASIC. Start typing.
2) Or learn how to launch an editor, learn the system file structure and save your edited source with only allowed character names and extensions, learn how to launch a compiler, with half a dozen command line parameters, which implies learning the command line structure of the system as well, learn how to launch an assembler, again with command line parameters, extensions, and file modifications, learn how to run a linker, etc., and then see if your program did anything but crash. The differences were astounding. BASIC accomplished this by being interactive. You could enter your program, edit your program, run your program, all from the terminal. So BASIC became popular by being interactive.
Lest we forget interactivity was what made the Personal Computer, well, personal. Most contact with computers in the 1970's was through a punch card deck. Someone else took care of the JCL cards that proceeded and followed your job, and a print out was all you got back. Unless you were a system guy, you never saw the part where all that was done. The JCL (or the paper tape, or even the front switch panel) was the interactive part.
Now those days are gone. The new "Basic"s aren't interactive any more. They are roughly like any conventional language. Hence only the leagacy of "simple" carries Basic forward, and the simpicity stands in the way of useability, without the advantage of interactivity. Yet it tends to be a very low performance language, speed-wise.

Yes, sorry. Generally promoting Forth falls to me, here (self appointed). Been down sick for over a week (or should I say very weak).
Forth retains its interactivity (most versions), runs natively on the final system, has good speed (particularly for a language retaining interactivity), and has unparallel code compaction. Forth is generally available at very reasonable prices, as well as in freewear "unsupported" versions.
In robotics, the wonderful thing about Forth is, again, its interactivity. You don't have to wonder what value some variable holds, you can query it and see. You don't have to wonder if some output is high or low, you can query it and see. You don't have to wonder what some input from a sensor is, you can query it and see. You don't have to wonder if changing some variable slightly would do, you can just set the value and try it. You don't have to wonder if some servo is working or not, you can just try it, set it where you want, and see if it follows. And so on. They way you do these sorts of changes with conventional debugging are usually convoluted and complex, and done with very expensive ICE equipment, while Forth programmers feel totally enabled with a tiny bag of tools readily at hand.
Interactivity. Nearly a lost concept in the world of modern programming.
You might want to atleast have a look at Forth. MPE is one of the remaining leading vendors, and is resident in the UK.
-- Randy M. Dumse www.newmicros.com Caution: Objects in mirror are generally more confused than they appear.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Site Timeline

  • - the site's newest thread. Posted in

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.