Programming Languages Targeting Arduino/AVR - programming-languages

What programming languages or environments target Arduino or AVR besides the default C++ environment?
PS: I'm using Mac OS 10.5.

Some commonly known ones:
Ada
Basic, alt, alt
Forth, alt, alt
Java
Pascal
Python
C (mac) and C (Windows)
In theory you should be able to extend avr-gcc to support other languages, though this is no small undertaking. I should also caveat that support for languages other than C typically comes with some fairly weighty restrictions on language components -- for instance, even with C++ it's discouraged to be instantiating new objects as malloc and free are extremely expensive in both memory space and cycles.
Besides using Google, the following references are applicable:
http://www.piclist.com/techref/atmel/avr/languages.htm

An incredibly popular option is to program your Arduino directly in C, versus Wiring (the programming language used by the Arduino IDE). This allows a lot more control over the low-level operation of your microcontroller.
The Arduino IDE supports C (as Wiring is based on C and C++) and compiles with the AVR-GCC toolchain, or you can go without an environment and use a text editor, the command line (with AVR-GCC toolchain installed) and avrdude (a command-line tool available on MAC, Windows and Linux).
AVR devices can also be easily programmed with Atmel Studio (formerly AVR Studio), which can use a multitude of programming languages.
The Arduino forums have a lot of information for programming in C.
Information regarding the AVR-GCC toolchain can be found here.
http://www.nongnu.org/avr-libc/
I personally quite enjoyed taking the hard way around and learning how to program an AVR chip without the IDE, but this comes down to personal preference and how much you want to learn.

You can use Java. Check Arduino and Java. It contains some instructions that may be useful to you.

Related

System libraries in Linux vs. Windows

My background is in Windows and I'm a Linux noob. Still trying to wrap my head around some basic concepts, and specifically the system libraries:
Windows has ntdll.dll which wraps system calls, and a CRT dll
which interface between the C syntax to the ntdll OS-exposed
services.
(for simplification I ignore the intermediate layer of
user32, kernel32, kernalbase etc. I also realize the CRT is several dlls, this is not the point).
It seems Unix/Linux has pretty much just libc, which wraps system calls and called directly from your application code.
Is this the right analogy? (ntdll + CRT) <===> libc ?
I realize that C & Unix evolved together, but am still surprised. Can it be that the C interface is hard-wired into the OS for Unix/Linux? In Windows non-C programs link against the underlying OS provided dlls. Is it possible that in Linux there is no OS/C-runtime border?
In general, most programs link against libc, even if they are written in another language. It provides the C standard library interface (like MSVCRT), POSIX features (the equivalent of certain parts of the Win32 subsystem), and wrappers around system calls. For example, Rust uses libc because it provides a portable environment to link against.
However, on Linux, you don't have to link against libc. Go chooses to make system calls directly, which means it can ship static binaries that have no runtime dependencies. This is possible because Linux guarantees a stable kernel ABI, but not all operating systems do this (e.g., macOS). So unless you have significant resources (like an entire programming language team), this isn't generally a smart move unless you're only working with a handful of syscalls.
I should point out that even Windows is intrinsically wired into the C language: it uses C strings (granted, usually wide C strings) for its system calls, and much of the kernel is written in C. Even if you were starting a kernel from scratch, you'd still need a general C interface, because virtually every programming language has a way to interact with C.
The Linux system calls are documented in syscalls(2) and are the foundation of user-land programs. The calling conventions are documented in the ABI specifications. The ELF executable format is documented, e.g. in elf(5).
Read also Advanced Linux Programming and about the Unix philosophy.
You can make system calls directly in assembler. The Linux Assembly HowTo explains that. You'll prefer to use the C interface, and for that reason the libc is preferable. In practice, the libc.so is the cornerstone of most Linux systems.
Play with ldd(1), pmap(1), strace(1), BusyBox
The GCC compiler enables useful language extensions, and mixing C and assembler code.
Some programming languages implementations are barely using C and could call system calls directly (look into SBCL or Go ...)
Both the Linux kernel and usual GNU libc (or musl-libc), and also the GCC compiler and the binutils are free software or open source, and you can study their source code.
Things become trickier with systemd and vdso(7).
See also http://linuxfromscratch.org/
Graphical applications are using some display server, often Xorg or Wayland. Read about X11. You would want to use GUI toolkits like GTK or Qt to code them.

What type of programs are C/C++ used for now? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
in which area is c++ mostly used?
I started off with C in school, went to Java and now I primarily use the P's(Php, Perl, Python) so my exposure to the lower level languages have all but disappeared. I would like to get back into it but I can never justify using C over Perl or Python. What real-world apps are being built with these languages? Any suggestions if I want to dive back in, what can I do with C/C++ that I can't easily do with Perl/Python?
To borrow some text from the answer I had for another related question:
Device drivers in native code.
High performance floating point number crunching (i.e. SIMD).
Easy ability to interface with assembly language routines.
Manage memory manually for extended execution runs.
Most of my work has been C and C++. I studied computer engineering in school and worked with embedded devices. My Master's degree had an emphasis in graphics and visualization. One of our visualization apps was written in Python, but for the most part, graphics demands C/C++ for the speed. I now work with embedded devices running Windows Mobile and Windows CE - all C++, though you can do a lot with C#. I previously worked in simulations, which was all C++ code on the backend. C++ is still king for time-sensitive IO, embedded applications, graphics and simulations.
Basically, if you need tight control of timing, you go lower level. Or if you need light-weight (ie, small program size, small memory footprint)
Somewhat unscientifically I took a look on Sourceforge and the top twenty projects/language break-down is currently thus:
Java(43,199)
C++(34,313)
PHP(28,333)
C(26,711)
C#(12,298)
Python(12,222)
JavaScript(10,307)
Perl(8,931)
Unix Shell(3,618)
Delphi/Kylix(3,353)
Visual Basic(3,044)
Visual Basic .NET(2,513)
Assembly(2,283)
JSP(1,891)
Ruby(1,731)
PL/SQL(1,669)
Objective C(1,424)
ASP.NET(1,344)
Tcl(1,241)
ActionScript(1,164)
Perl + Python together still total less than C alone. I have no idea why Java is so high, I know of no single Java developer and have not seen a single Java project, but I am sure someone is using it! For probably the same reason, you are not seeing much C/C++, you are just not working in a domain where it figures highly. I work in embedded systems where C and C++ are ubiquitous and Python comes nowhere. Different languages are encountered to different extents in different worlds.
You ask what you can do with C/C++ that you cannot do easily with Perl/Python; well the answer is plenty, real-time embedded systems for one; but if that is not what you want/need to do, then there is no reason to. On the other hand I might ask the reverse; I'd use C++ for things you might use Python for, simply because for me it would be easier and quicker (than learning a new language and getting the tools working)
C/C++ can be, and is, used for nearly all "types" of programs.
There are some major advantages to C and C++:
Potentially better performance
Easier to build interoperable libraries, especially if working with libraries usable from multiple languages.
well the interpreters for your "P's" languages are most certainly written in c/c++. Most OS code is written in C/C++. On the application side, if you are into games, they are generally written in c/c++. Anything that needs high performance and or low memory is a good candidate.
I've used Gsoap, a c++ soap client implementation for a web service that got HUGE traffic.
Most desktop/console applications with a bias toward graphics rely heavily on C++. This includes CAD software and AAA video games, among other things.

Programming VHDL on Linux?

Anyone knows good environment to program VHDL and simulate it (don't matter Xilinx or Altera) using Linux?
You're stuck with either vendors tools, which are spotty at best on Linux (though my experience with Alteras utilities are somewhat better than with ISE).
However, if all you want to do is run your testbed, not actually synthesize anything, ghdl will be of use.
As mentioned by Arpan (almost) every VHDL simulator is supported by Linux, but they are usually very expensive. Your best shot would be to use one of the following:
Altera DS Web edition (Linux support has just been added) which comes with a free version of ModelSim.
Symphony EDA Sonata 3.1 is available as a free version with limited support.
Xilinx ISE which comes with Xilinxs own simulator: ISim.
Just to add an update to this: Xilinx Vivado has now been released with Linux support for ubuntu/debian and (I believe) redhat/centos.
The software is free for a range of the smaller devices and more common IP cores and includes a mostly decent simulator that is integrated into the tools and is also free.
It has a pretty steep learning curve, as do most of these tools, but as far as software in this industry goes, they've really done a good job with it.
If you prefer open source tools, look into http://www.cliftonlabs.com/vhdl/savant.html - vhdl does not have too many options in the FOSS space currently. If you are opting for vendor tools, all vendors would do Linux version of their simulators. Modelsim is a personal favorite due to the easy-to-debug features that it sports.
For a coding environment, I usually use VIM with vhdl syntax checkers turned on. Sigasi apparently has a commercial IDE with fancy stuff as automatic code completion, on the fly syntax check etc.
Let us know if you have further questions.
Arpan
For coding vhdl, Emacs with vhdl-mode is a must. You can use advanced edition functions, view the structure of designs, manage architectures and configurations. You can setup for multiple simulators.
I use the modelsim from Altera's Quartus web edition. Beware if you use a 64 bits Linux, this version of modelsim is 32 bits only.
There is now QUCS (http://qucs.sourceforge.net/) as well. It is open source and based on FreeHDL.
It can be used to design and simulate circuits using a graphical interface. And it can also simulate VHDL. Although for this you must also design the circuit components on the graphical area.
This video shows it clearly:
https://www.youtube.com/watch?v=-RrQlzLsf18
I'm using the linux ppa on Debian Jessie and it works fine.
GHDL is a nice simulator for VHDL, and even works with some third-party libraries (for example, Xilinx UNISIMS).
If you combine it with gtkwave, you should have a full working VHDL simulator and waveform viewer.
GHDL also supports writing to .GHW waveforms, which are fantastic for small simulations, cause it does include (often) all of the signals on your design.
I've used them with standard RTL simulation, and also for post-synthesis simulation with Xilinx UNISIMs.
Both should be available in your Linux distro repository. If not, you can fetch them from:
GHDL: http://ghdl.free.fr/
GtkWave: http://gtkwave.sourceforge.net/

Linux programming - getting started, how?

I've taken the plunge and installed Linux (Linux Mint 9 if that's important) on one of the boxes - and I'd like to start some small-time programming... but where to start.
My background:
Mostly LOB-applications in C#/WPF
Some XAL-basic
A wee bit of VB/VBA and SilverLight
I would like to turn to a new programming language - but still focused on desktop applications.
What I need:
An editor - preferably with good intellisense
A programming languages and the resources to get started
If anyone can point me in the right direction, I'd be happy for a little push...
EDIT:
Thanks for all the advice - I've come up with the following:
I'll start out with Python - and use Vim for the editor
I'll definetly try out Vala and Perl later and have MonoDevelop as backup editor - and if all else fails, I'll turn to C++. I've upvoted all answers as they all helped me.
EDIT2:
Okay - Vim was a bit too hardcore... Installed Cream on top.
Unlike the Windows world, where everything is designed to be Windows-only, I think it is quite typical to find that the rest of the world designs software to specifications, not to implementations. If you are developing in Java, then it doesn't matter what platform you intend to use, and Eclipse and NetBeans provide excellent tooling for Java on all platforms, Linux included. If you are developing in C++, then Boost and Qt provide excellent cross-platform support. If you need to go outside of Boost or Qt, then before delving into Linux-specific features, it is best to target the Single UNIX Specification also known as IEEE Std. 1003.1 POSIX, which will ensure that your application not only runs on Linux, but also on any UNIX-compliant operating system (including Mac OS X, FreeBSD, Solaris, and others).
As for IDEs and other editors... I think most programmers on UNIX platforms build from the commandline (using CMake, Make, scons, or some other standard build tool); however, there are plenty of IDEs with support for those that can run such tools automatically. Anjuta C++ and KDevelop are probably the easiest IDEs to use on Linux. Emacs (emacs, emacs-gtk, xemacs) and Vim (vim, gvim) provide a great deal of power and flexibility, but take a little bit more time to get used to. You might also want to consider a basic text editor such as GEdit (Gnome) or Kate (KDE); GEdit, though billed as a simple text editor, supports some more advanced coding features via a number of plugins. I don't recall whether it supports autocompletion, but it does support line numbers, automatic indenting, using spaces instead of tabs, commenting a block of code en-masse, and executing a Makefile with a shortcut.
Depends on how much you want to learn (from the easiest option to the hardest one):
Just use C# via Mono - that gives you access to most of the POSIX interfaces via Mono.UNIX, access to GTK# so you can do desktop apps, access to many linux libraries, so you can do more advanced stuff / integrate better. (you can program in Monodevelop - it's a Sharpdevelop clone, kind of VS-ish)
Learn Vala - it's a language compiled down to C, very similar to C# but closer to the bare minimum. It's gathers anti-MS people who wanted a response to C# IMHO. (never really used it, but apparently there's a Vala plugin for Monodevelop and the language itself is becoming more popular)
Learn Python - it's a scripting language. It's got bindings to most popular libraries (also GTK and QT) (IDE: anything that can edit text - you won't get good intellisense from a dynamic language anyways)
Learn C++ and QT, or C and GTK - although those are very low level languages where you will spend a lot of time just getting used to the environment. (IDE: Anjuta, Kdevelop, Monodevelop with C++ plugin, Eclipse+CDT, emacs, vim, etc. - anything goes really)
If you want "something new", but don't want to spend loads of time learning a completely new environment, I'd recommend trying out Vala. If you're more curious about different styles, go for Python, which I think has a very good tutorial for new people (but not new to programming): Tutorial or Beginner's Guide. With Python you also have an advantage of having the whole environment available in packages in any distribution, no such luck with Vala (yet).
Try perl and python and see what appeals to you. Learn bash to get around happily at the command-line. If you're feeling adventurous, give C/C++ a shot.
As for editors, this will probably spark up a holy war, but if you're using at the command line, check out vim and emacs, pick one, and lament never making friends of those in the "enemy camp." :-)
I say Python + Emacs or gEdit (what ever suits you)
Linux Mint is a KDE environment, right? That would make it pretty convenient for you to get started writing KDE apps in C++. The Qt toolkit which KDE is based on is widely considered to be relatively developer-friendly, which should make it easy for you to get started.
If you want to go on that route, I'd suggest downloading KDevelop, which is KDE's IDE (optimized for developing KDE programs, but it can handle several different languages). Alternatively, you could use Eclipse, which has C++ capability. You can find tutorials on how to develop KDE apps at http://techbase.kde.org/Development/Tutorials. (Unfortunately I think those are not as good as the documentation they used to have before KDE 4 came out, but it should be enough to get you started.)
EDIT: Come to think of it, you may want to try your hand at writing some C++ console (non-GUI) applications first, since it's probably easier to get comfortable with basic C++ before you jump into GUI programming. Given your experience, it shouldn't be too hard to pick up. Unfortunately I don't know of any particularly good resources to learn C++ with, but I'm sure that information is somewhere on this site, and KDevelop or Eclipse would work fine as an IDE for simple C++ console apps as well.
Weird that nobody suggested ALP, even if it is a bit outdated, it teached me a lot of things regarding the UNIX way of programming.
First, Learning C is a MUST!
Perl is underused for most stuff and you'll want to learn BASH Shell Scripting instead.
Grock the C code of existing (stable, well-written software) example is the Linux kernel itself! Google "Linux LXR"
Once you learn the basics to C (in Linux) the manpages are an invaluable resource. Just do man printf for information on writing characters to the screen, for example.
If you are talking GRAPHICAL GUI Programs, you need to learn GTK+ or one of the many cross-platform GUI toolkits (e.g. wxWidgets). Do not learn to program the X Windows System directly unless you are crazy.
For text editors, I like Komodo Edit and SciTE.

Programming languages that compile to native code and have the batteries included

What are the programming languages that compile to native code and which have provided a comprehensive library with them?
Libraries that includes functionality such as Networking, File IO, RegEx, Database, Graphics, Multimedia, Win32 API bindings, File compression, etc.
I'll assume everyone has thought of C and C++.
Haskell is the obvious one here. In particular, if you want batteries included, you want the Haskell Platform.
OCaml fits this category, as well.
Go is a new player that has (most of) the feature you asked.
The D programming language with it's standard library Phobos.
Some Lisp dialects include a native compiler, like Common Lisp with its SBCL, CCL or ECL (to C) compilers.
Rust is a system programming language but doesn't include batteries but has crates ― to avoid stale standard library modules
Delphi meets all those requirements. This is a development environment based on the Object Pascal language.
Is Objective-C with Cocoa/CocoaTouch an acceptable answer?
You can use this pair for programming applications running on devices with restrictive constraints on batteries (laptops and mobile phones).
Swift by Apple, but now Open Source, compiles to native code and is available for OS X and Linux.
Batteries are completely included for Mac OS X and iOS through Apple's extensive libraries/APIs, and support for OS independence is on the way with the development of core libraries.
Hmmm. The funny thing is, most OSes have native APIs for all that stuff. So all you really need is a language that can link in OS calls. Pretty much any compiled language worth its salt will do that.
I am currently working with Qt.
http://doc.trolltech.com/4.5/index.html
Edit: a Nitpick..
A programming 'language' is a grammar and set of semantics and syntax. It contains NONE of the things you are asking about. What you want to know about is API's, not languages.

Resources