How to get in to "normal" programming from an arduino background

(I don't know in which other section to put this, so I hope its the right one)

Hi

After having programmed Arduino for some time, I've been thinking about getting in to "normal" programming. Meaning, for example how to make a simple Programm for Windows or Mac. Initially I thought about learning how to use Objective C and Xcode, but then I read that Java is more closely related to the arduino language than Objective C.

What language would be easier to learn if I have only done Arduino before?

An example of what I would like to do (when I'm a bit more advanced) would be for example a chess playing programm, as this would be related to an arduino project of mine. Also I would be Interested in getting a program to work with a webcam (on the computer), and take certain actions depending on light levels and similar things. What programming language would you suggest I learn? What IDE should I use?

What system do you have available? For a PC I like C# and Visual Studio (It was free for just C#). For the Mac at this time, XCode and Objective-C are the way to go, though Swift is almost ready for prime time.

but then I read that Java is more closely related to the arduino language than Objective C.

Where did you read that nonsense? "the Arduino language" is C++.

I know. But:

The Arduino integrated development environment (IDE) is a cross-platform application written in Java, and derives from the IDE for the Processing programming language and the Wiring projects. (wikipedia)

And Processing was influenced by Java. Which I guess should mean that its more similar to Java than Objective C. And you only use scaled-down C++ for arduino, right?

And yes, I use Mac. So I guess Xcode is the easiest. Do you know any good books for beginners? I don't think I want to read everything online.

The C/C++ used for Arduino programming is as vanilla as it can be. Yeah you're using libraries and things that are Arduino specific, but the base language is still C/C++. Putting that another way, anything you learn while programming your Arduinos is going to be beneficial in the future. C/C++ is never going away.

My concern with XCode or Objective-C is that it's mostly Mac-specific. If you're looking for a more platform agnostic, high level language you should be learning Python.

And Processing was influenced by Java. Which I guess should mean that its more similar to Java than Objective C.

"Processing" is a desktop programming environment, and it IS Java. and Processing is written in Java as well. But while the Arduino IDE uses a lot of the Processing IDE code (so the Arduino IDE is also written in Java), that doesn't make the language that you are writing for Arduino any less C++. That would be like saying that writing a desktop linux program is "more like C", just because the linux kernel (or the editor you happen to be using) was written in C.

OTOH, Java, C++, and (probaby) Objective C are all pretty similar at their most basic level.

On a desktop, you will need to learn about a bunch of libraries for accessing "desktop things" that are probably unlike anything you have encountered on Arduino. (Although, if you want to write rather poor, Command-Line programs that do a lot of data processing, you might be able to avoid that and have a program look a lot like an arduino program.

Most popular programming language for Macs: probably Objective C
Most popular programming language for PCs: probably Visual Basic
Most popular programming language for linux: probably C++
Most popular programming language for Android: Java (almost a "must use.")
Most popular programming language for Microsoft Phone: C#

(sounds ... unfortunate, doesn't it. It is. Fortunately, learning any of those will teach you concepts common to all of them, so I wouldn't worry too much about it. Also, it can be more educational to learn something a bit different than what you already know. I'd say: look for a good class you can take. How about: https://www.coursera.org/course/interactivepython1 ?)

westfw:
"Processing" is a desktop programming environment, and it IS Java. and Processing is written in Java as well. But while the Arduino IDE uses a lot of the Processing IDE code (so the Arduino IDE is also written in Java), that doesn't make the language that you are writing for Arduino any less C++. That would be like saying that writing a desktop linux program is "more like C", just because the linux kernel (or the editor you happen to be using) was written in C.

I did not know that. Interesting...

westfw:
"Processing" is a desktop programming environment, and it IS Java. and Processing is written in I'd say: look for a good class you can take. How about: https://www.coursera.org/course/interactivepython1 ?)

Well, I don't think I have time (or will) for that, as I only really am doing this out of personal interest. I'm probably still going to do arduino mainly, even after I've done desktop programming. So I would much prefer a book.

PaulS:
Where did you read that nonsense? "the Arduino language" is C++.

There's JAVA in the sources for my Arduino IDE. Serial is done in JAVA for one.

Hmpf, AVR LibC site is down.

There's JAVA in the sources for my Arduino IDE.

Yes, in the source for the IDE. No Java code actually runs on the Arduino.

I found this book. It seems good, but what I want to know is: Are there any "classic" books that you should read if you want to learn objective c? Should I look for books that say they teach Objective c or books specifically for xcode?

bestanamnetnogonsin:
I found this book. It seems good, but what I want to know is: Are there any "classic" books that you should read if you want to learn objective c? Should I look for books that say they teach Objective c or books specifically for xcode?

If you insist on going with Objective-C (not sure why, unless you only intend to code for iOS), then your best bet is to look into "Objective-C for iOS and Xcode" or something similar. Xcode is basically the development environment and framework for native iOS applications. It uses a variant of Objective-C for the language. I say "variant", because Objective-C is an old language - it was supposed to be the answer to "object oriented C" code - but it never became a standard, and I suspect that almost no one other than Apple supplies an Objective-C compiler. Instead ANSI C++ became the standard (also, IIRC Objective-C was spawned as a commercial product in the hopes of it becoming a standard).

Just note that Objective-C is not the same as C, nor C++; if you are ok with this (and only want to write code for iOS) - then go for it.

Personally - I would move to learn standard ANSI C/C++ (ie - using gcc) - and learn how to use a cross-platform GUI system (so you aren't stuck only developing for one platform or another). You might even consider learning how to create Chrome Apps (DHTML5, javascript, etc); they can be run anywhere Chrome exists - even on a smartphone:

Just about a true "write once, run anywhere" kind of experience (but note, there are a ton of tradeoffs with such a system).

Another possibility to look into might be the "Go" or "Rust" languages; I personally had to learn Go for a project my employer assigned me and a colleague to tackle - it is a very strict language (for instance, if you define a variable, you must use it somewhere, otherwise it won't let you compile!), but honestly it showed where we could do better in software development practices in general. It basically forces you to be a better programmer. At first, it is something you fight against - but over time, it grows on you, and then soon you realize how just about whatever language you were using before has a ton of flaws that let you "get away" with so many things (which in many cases introduce bugs and security holes).

Rust is of a similar vein - but I can't speak to how strict or otherwise it is because I haven't used it outside of the online interactive tutorial (but what I did see intrigued me).

Ultimately, though - don't concentrate on the language - instead, concentrate on the practice and structures of programming. You honestly want to be able to get to a point where you can pick up a new language and run with it (provided it isn't too "esoteric" - for instance, LISP isn't anything like most common computer programming languages). You should be able to "code" in your own made up "pseudo-code". Basically, you want to learn how to take problems, break them up into components, and then be able to describe in some form of a formal code "language" (whether made up or an actual programming language) how that problem is to be solved, it's steps toward solving it, and the overall "process" it takes to get to a solution.

This is independent of the programming language used. If you can get to this point, the language used fades into the background - it's just another tool in the toolbox (of the many hundreds of languages that exist - each with strengths and weaknesses) - and instead you can focus on the problems and their solutions. If you are looking to use this knowledge to pursue a career, it is ultimately better to have the ability to pick up a language and code, rather than only understanding the "language-du-jour" and potentially becoming pigeonholed in your knowledge base.

Great answer!!

I don't really care what platform I use. The reason I chose xCode and objective c was because it seems to be easier in the sense that the is an official IDE and objective C is the "official" apple language. Whereas if I do Windows (or so) there are hundreds of languages and everybody says a different one is best, and there is no standard IDE.

So, how different is objective c compared to C? Will I have to relearn programming or will I feel at home with the language?

The object oriented stuff is very different than most other OO languages, but you can intermix c and objective-c

The way the language is used in arduino is obviously different from objective c. What I mainly want to know: Is the syntax similar? Meaning: do I write an If statement the same way (if(){};), do I declare variables like this: int i =1 ; Is the basic language similar? If its completely different I may not want to go with objective c.

I't was designed to tack on the OO bits to standard C, so all the control structures and variable declarations are the same.

This may sound a little far fetched as I haven't even started to programm objective c, but I like to have an objective when I start something new. What I would eventually (maybe in half a year or so), would be to make an app, which uses a camera connected to the computer. This camera would point at a chessboard and take pictures at regular intervals. When a piece is moved (by the player) The program would detect that a piece is missing on one square, and see on which square the moved piece is now. It would then calculate which move should be made and display it.

My questions:

Is it realistic:

  • to expect that I will eventually be able to make the image processing part and the camera? (using objective c)
  • to be able to make a chess playing algorithm? (again, using objective c + xcode)

Yes, I know there might be other (and better) ways to do this. Processing for the imaging part for example. But I would like to do this with xcode, just to have an objective of what I LATER want to be able to do.

Were you planning on using one of the existing vision libraries (OpenCV is popular, I think?)
If so, you'd need to check whether it can be used with Objective C.
If not, I don't think it's realistic to expect to get to writing your own CV software within 1.5y. That would be ... master's thesis caliber stuff; figure a year learning languages, a year learning more advanced algorithms, a year learning about graphics, a year learning about about vision, and another year to actually implement something. That's just the CS track; the last time I was involved, graphics stuff was pretty intensely mathematical (gradients and normal vectors to 3d surfaces and optimized equations for calculating the intersections of ellipses, etc.) So figure you should probably have math up through linear algebra as well. Now, that WAS a long time ago, and perhaps there have been new developments that simplify things a great deal. But vision/graphics was one of the most advanced topics in computer software; just because it shows up in toys doesn't mean that it's easy!

Objective-C can easily use any libraries written in C.

Well obviously I would want to use libraries and so on... If I would use processing or so I might already be able to do it today.

What I would do Is just take a pic, then resize the image it into 8x8 pixels (so that every square is equal to one pixel). Then I'd analyse what the grayscale value of an empty square looks like and what the greyscale value of a square is, when a piece is on it. I think this would easily work, don't you? You'd obviously have to be careful about lighting and camera positioning, but the hardest coding part I'd guess would be controlling the camera...

bestanamnetnogonsin:
Well obviously I would want to use libraries and so on... If I would use processing or so I might already be able to do it today.

What I would do Is just take a pic, then resize the image it into 8x8 pixels (so that every square is equal to one pixel). Then I'd analyse what the grayscale value of an empty square looks like and what the greyscale value of a square is, when a piece is on it.

There are two types of squares on a chessboard, black ones and white ones.
Also, the pieces are either black or white. You will have 4 possibilities to detect.
Black piece on a white square.
White piece on a black square.
White piece on a white square. (How are you going to distinguish between that and an empty white square?)

Black piece on a black square. (How are you going to distinguish between that and an empty black square?)