New arduino language

For a course that is part of our Masters degree in Computer Science (university of Delft, Netherlands) we, a team of 3 students, are required to create our own DSL (domain specific language). We are currently brainstorming about a new language for the Arduino.

The current Arduino language is a subset of C++ but we think that with a language specifically build for the Arduino it could help a lot of people. Not only to those that are new to programming but also to make programs more structured and easier to understand for everyone.

We think of things like

  • build-in keywords for writing and reading to pins
  • making the language dynamically typed
  • defining actions (button presses) to execute blocks of code
  • ...

We will implement the language as a plugin for eclipse, so we can give good feedback on the code with specific errors and warnings but it will also be possible to extract the compiler and use it in other editors. The language will compile directly to an executable that can be loaded to the Arduino, possibly compiling it to C first or directly to assembly.

We want to ask the Arduino community to give us some feedback on this idea. We understand that a new language is not really needed and/or it possibly won't be as powerful or fast as C++ but if you could design a new language from scratch, what are things that you would like to see?

Very cool project. I look forward to following your progress.

For my opinion on what such a language might look like, please consider Bitlash, which you can find at http://bitlash.net

The Bitlash architectural approach is a little different, but I believe our objectives are similar: to facilitate the development of application-optimized languages that are easy for beginners and highly tuned for the hardware environment.

One key issue is dynamic memory allocation. So far, Bitlash doesn't use any. This is by design, to avoid heap fragmentation crashes, a debugging nightmare in the embedded environment. But this also means, so far, no strings or other advanced data types.

Clearly there is room for Bitlash to grow here. Anyway, you may find this the most challenging part of your project.

Best regards,

-br

http://entropymouse.com

Hi, interesting project.

I advice you guys to spend 2 days going through all discussions and check the Original Questions to see what problems people have with Arduino. I think the number one is how to handle communication especially serial - parsing converting etc. A second tip is to check the playground for libraries that were written.

A problem still is that it are traditional programming languages. LOGO was a new concept for graphic programming. The Arduino sketches are most [ Sensor => process => actuator ] pipelines with some state in memory. Some things are both sensor and actuator (ethernetshield?) So maybe the language should be called plumber - a pipe fitting language :slight_smile:
PLUMBER could be an acronym for Programming Language Using Metaphors By Example Recursively? (You definitely need to find a better one! :wink:

Have a look at - Visual Programming Arduino: modkit and the others | Arduino Blog

Finally Python for Arduino would also be nice.

sofar my 2 cents,
Rob
PS you can contact me in Dutch by PM.

@billroy
Would it be possible for bitlash to read instructions from SD card iso serial? That would enable large automatic scripts ...

I would like to see a DSL such as RAD, except that RAD doesn’t actually work, but if it did, it’d be excellent. The Ruby syntax is friendly and approachable.

Ideally I would like to see a modern Forth on the Arduino, but apparently that’s not possible because it has a Harvard architecture.

Alternatively, I think a DSL built in Lua (which is simple and understandable, but not quite as friendly and approachable as ruby) would be excellent. I don’t mean (of course) running Lua on the chip, I mean using a framework on the Mac that uses Lua syntax to propel a compilation down to atmega binary which ends up on the chip.

robtillaart:
So maybe the language should be called plumber - a pipe fitting language :slight_smile:
PLUMBER could be an acronym for Programming Language Using Metaphors By Example Recursively? (You definitely need to find a better one! :wink:

I disagree with the current vogue of creating projects that have names that overlap with existing projects that have the same or highly similar names. Beginners would be highly confused between your “plumber” and the “concurrency” “plumbing” or “occam” language (whichever one it really is called, they apparently haven’t decided which). It’s an avoidable confusion.

Ian, regarding a "modern Forth" for Arduino, FORTH, Inc. recently released a SwiftX for Arduino -- you can check for it at http://www.forth.com -- I don't know if they plan to release a demo/evaluation version, but you could ask them!

robtillaart:
Finally Python for Arduino would also be nice.

This is as close as you can get for now.
http://code.google.com/p/python-on-a-chip/

The support is minimal, but implementing a full python distribution with such little program memory would be
impossible

I would prefer Object Pascal -- like Emabarcadero Delphi.

Don't hold your breath.
You would need huge ,bloated Win32 libraries to do that, not to mentions the gigabytes just to install a Delphi like environment

Thanks for responding everyone! We have decided to pick up this project so hopefully you'll hear more from us soon. We are going over the languages and issues discussed here. I think we are going to drop the dynamically typed part but there are a lot of other idea's we can implement.

ArdLang:
Thanks for responding everyone! We have decided to pick up this project so hopefully you'll hear more from us soon. We are going over the languages and issues discussed here. I think we are going to drop the dynamically typed part but there are a lot of other idea's we can implement.

Are you doing that alone? :confused:

from OP

we, a team of 3 students,

I am working on a Common Lisp compiler. I have a lot of it working. If you interested, check out my project at Arduino Lisp download | SourceForge.net

Dave.

How do I actually use what the above link leads to?

Hi, my first advise for the community would be to go with atmega1284p as the arduino cpu of choice (the pin compatible with 644p, 16kB ram, 128kB flash, available in DIL40 as well as 44pin smd, price equal to at328p). With such a hw platform you may develop an OS on the chip (e.g. an "Ardos" based on "Bitlash"). Bitlash alone compiles to 14kB w/o a SDcard support. I did assembled Bitlash 2.0RC2, RTC an SDfat libs and it is ~29kB of flash, 90Bytes free ram. And you need a space for your application of course.. No way to go with 328p.
Provided the arduino enthusiast go with an at1284p you will free your hands for a serious development. And for the same price. 8)
p.

I am doing a design now with the 1284P, starting with a deumilanove layout, keeping the shields, and expanding the board size some for some custom IO and a memory card. Seems like a nice chip.

If I may add a point to the original motive.

I’ve tried Bitlash, and Transterpreter, and they both promise to work, and probably do. However, they fall down considerably because there isn’t a wide enough range of examples from which to patch together one’s own programs with. It’s almost as though one is expected to actually learn the language, as the first step.

The conventional Arduino language has a vast amount of examples, which is a good thing (even if the language itself is unusably bad and unintuitive). Of course, most people stop using it when they find that the examples are not able to be easily combined in any useful way without errors or requiring actually learning the language at such an inappropriately early stage of usage and familiarisation.

My recommendation, therefore, is to start with a wide range of examples of pretty much everything that is possible, and design it such that they can all be combined, in any permutation that a person would imagine useful. Then design the language around that framework, so that the user doesn’t have to actually see any of it.

The 1284 has to be the best overall chip in the AVR lineup I think, 2x the 2560 RAM, one extra UART which is all most need, gobs of flash and IO.

I'm using it on two boards about to go to PCB fab.


Rob

@crossroads and greynomad: my recommendation for an arduino for the second decade of this century is to put a sdcard (micro) and an external RTC chip with a coin battery (cr1220 is enough) on the board. The rtc e.g. pcf8563t - very cheap and lowest power consumption (200nA), or ds1307.
1284p + sdcard + ext_rtc gives you a very good base for the future projects. In the moment as you start with sdcard as the storage for data, scripts, sketches, firmware backups etc. you have to have a source of actual time, anytime, even you switch off the main power. And maybe as an option a 32khz watch crystal at timer2 for low power operation (not for rtc).
As the language is concerned - I am a little in doubt whether there is something better than C/C++ supported with good libraries and good approach to the overall concept. Maybe to design a better mechanism for writing modular libraries fully_independent on the actual cpu_hw_resources_assignment would be a good first step. Maybe a GUI where you take modules/methods/libraries and edit&reconnects them with a few clicks. An RTOS would be a nice to have feature on arduino, but mind the drivers are the biggest trouble with a practical rtos - they need to be rewritten. General acceptance of forth is low today and there is an issue with ready libraries availabilty (almost none..). So for such cpus as the atmegas are (with limited resources) the C is the most feasible choice, however for the arduino users with a good code generation automation.

But all I ever see with C is errors, nothing actually works, so it’s the least appropriate language.

There must be a relatively restricted range of things you can want to do with an arduino. Stop forcing people to write it in ‘code’ in case someone intercepts the message and decodes it and all the plans are foiled. Just let people write actions that work. The blink sketch should be a single word, being such a common task. Most of the tasks that people put the arduino to are not wholly unique, they’re in common with what other people have also done at some time. The words to make it do that should be as simple as possible.

Plenty of people want to write information to an LCD. Plenty of people want to read temperature from various devices. Plenty of people want to make RGB leds change colour. Plenty of people want to control motors. Plenty of people want to read pots and adjust servos. Plenty of people want to read switches and turn relays on and actuate optoisolators and measure light and read accelerometers and so on. Very rarely would someone want to do any of these in a way that totally and fundamentally differs from the way everyone else is. In most cases, they’d be glad to adopt best practice. This should all be made simpler. Just present a framework that offers all the common possibilities of arduino use instead of having to write this ridiculous ‘code’ over and over again, which hardly ever works.

After all, it’s not as though each person using an arduino is having to invent the wheel all over again from scratch, and it’s not as if the arduino offers unlimited or limitless possibilities and therefore requires as flexible and efficient as possible a language to control it. Most stuff is the same as most other people’s stuff, most of the time. The common use cases cover almost all of what most people want to do with it in the first few years of their experience. Anything outside of those use cases can be programmed with custom ‘code’. The bulk, however, might as well be encapsulated into a very predictable and very efficient to use framework — one that doesn’t frustrate or infuriate or deter.