On Monday, 5 January 2015 at 11:38:17 UTC, Paulo Pinto wrote:
Personally I would chose Netduino and MicroEJ capable boards if
I ever do any electronics again as hobby.
Given your experience wouldn't D be capable to target such
systems as well?
Yes, D is perfectly capable of targeting those boards using GDC
and potentially even LDC, although LDC still has a few strange
bugs [1]. In fact, with the right hackery, I assume D will
generate far better code (smaller and faster) than the .Net Micro
Framework or MicroEJ.
Another interesting offering is the Intel Edison/Galileo boards
[2]. I'm under the impression that DMD would be able to generate
code for those boards as well. Although those boards are less
like microcontrollers and more like micro PCs (e.g. Raspberry Pi,
BeagleBone Black)
As a hobby, I highly recommend anyone interested getting
themselves a board and trying it out. The boards are
surprisingly inexpensive. With the right knowledge, it takes
very little to get started, and can be quite rewarding to see the
hardware "come alive" with your code.
1. Get yourself a GDC cross-compiler [3], and whatever tools are
needed to interface a PC to your board (OpenOCD, or
vendor-supplied tools).
2. Throw out Phobos and D Runtime, and create a small object.d
with a few stubs as your runtime.
4. Write a simple program (e.g. blinky, semi-hosted "hello world"
[4])
5. Create a linker script for your board. This can be difficult
the first time as you need an intimate understanding of your
hardware and how the compiler generates code.
6. Use OpenOCD or your vendor's tools to upload the binary to
your board, and bask in the satisfaction of bringing the board to
life.
You won't be able to use classes, dynamic arrays, and a multitude
of other language features unless you find a way to implement
them in your runtime, but you will be able to write C-like code
only with added bonuses like CTFE, templates, and mixins.
I'm sure those that actually take the plunge will find it to be a
fun, educational, and rewarding exploration.
Mike
[1] - https://github.com/ldc-developers/ldc/issues/781
[2] -
http://www.intel.com/content/www/us/en/do-it-yourself/maker.html
[3] -
http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler
[4] -
http://wiki.dlang.org/Minimal_semihosted_ARM_Cortex-M_%22Hello_World%22