Hardware hacking is a way of life here at Hackaday. We celebrate projects every day with hot glue, duct tape, upcycled parts, and everything in between. It’s open season to hack hardware. Out in the world, for some reason software doesn’t receive the same laissez-faire treatment. “Too many lines in that file” “bad habits” “bad variable names” the comments often rain down. Even the unsafest silliest of projects isn’t safe. Building a robot to shine lasers into a person’s eyes? Better make sure you have less than 500 lines of code per file!
Why is this? What makes readers and commenters hold software to a higher standard than the hardware it happens to be running on? The reasons are many and varied, and it’s a trend I’d like to see stopped.
Software engineering is a relatively young and fast evolving science. Every few months there is a new hot language on the block, with forums, user groups, and articles galore. Even the way software engineers work is constantly changing. Waterfall to agile, V-Model, Spiral model. Even software design methodologies change — from pseudo code to UML to test driven development, the list goes on and on.
Terms like “clean code” get thrown around. It’s not good enough to have software that works. Software must be well commented, maintainable, elegant, and of course, follow the best coding practices. Most of these are good ideas… in the work environment. Work is what a lot of this boils down to. Software engineers have to stay up to date with new trends to be employable.
There is a certain amount of “born again” mentality among professional software developers. Coders generally hate having change forced upon them. But when they find a tool or system they like, they embrace it both professionally, and in their personal projects. Then they’re out spreading the word of this new method or tool; on Reddit, in forums, to anyone who will listen. The classic example of this is, of course, editors like the vi vs emacs debate.
If you’ve ever been curious if there’s a way to program microcontrollers without actually writing software, you might be interested in FlowCode. It isn’t a free product, but there is a free demo available. [Web learning] did a demo of programming a Nucleo board using the system. You can check it out below.
The product looks slick and it supports a dizzying number of processors ranging from AVR (yes, it will do Arduino), PIC, and ARM targets. However, the pricing can add up if you actually want to target all of those processors as you wind up paying for the CPU as well as components. For example, the non-commercial starter pack costs about $75 and supports a few popular processors and components like LEDs, PWM, rotary encoders, and so on.
An experimental project to mix reality and virtual reality by [Drew Gottlieb] uses the Microsoft Hololens and the HTC Vive to show two users successfully sharing a single workspace as well as controllers. While the VR user draws cubes in midair with a simple app, the Hololens user can see the same cubes being created and mapped to a real-world location, and the two headsets can even interact in the same shared space. You really need to check ou the video, below, to fully grasp how crazy-cool this is.
Two or more VR or AR users sharing the same virtual environment isn’t new, but anchoring that virtual environment into the real world in a way that two very different headsets share is interesting to see. [Drew] says that the real challenge wasn’t just getting the different hardware to talk to each other, it was how to give them both a shared understanding of a common space. [Drew] needed a way to make that work, and you can see the results in the video embedded below.
Sometimes there’s just no place like your desktop. You’ve already got your favorite development tools and references setup or installed and it’s a pain when you’re trying to work on an unfamiliar, or simply uncustomized, system. On your desktop everything is at your fingertips. If you want to search the web, the browser is just an alt-tab away. If you need a calculator, it’s right there to run. Your editor highlights syntax in your favorite colors already.
When developing on a Raspberry Pi, you leave all these creature comforts behind unless you spend the time to configure the Pi to your liking. Then it all gets wiped when you install a new distribution, like the recent change from Wheezy to Jessie. Even then it’s frustrating to switch back and forth between the desktop and the Pi because there is always something on the other system that you need. My usual comment is, “dirty word”, literally.
Cross-developing on your desktop is a very workable solution. We’re going to walk through setting up your desktop and a Pi to do this. This means loading a Pi ARM toolchain on your desktop and a debugging server on the Pi. This’ll let you develop and debug from in the comfort of your desktop. An added advantage is when you put that Pi in a robot you can debug over a wireless link.
The Arduino software environment, including the IDE, libraries, and general approach, are geared toward education. It’s meant as a way to introduce embedded development to newbies. This is a great concept but it falls short when more serious development or more advanced education is required. I keep wrestling with how to address this. One way is by using Eclipse with the Arduino Plug-in. That provides a professional development environment, at least.
The code base for the Arduino is another frustration. Bluntly, the use of setup() and loop() with main() being hidden really bugs me. The mixture of C and C++ in libraries and examples is another irritation. There is enough C++ being used that it makes sense it should be the standard. Plus a good portion of the library code could be a lot better. At this point fixing this would be a monumental task requiring many dedicated developers to do the rewrite. But there are a some things that can be done so let’s see a couple possibilities and how they would be used.
The language C++ is big. There is no doubting that. One reason C++ is big is to allow flexibility in the technique used to solve a problem. If you have a really small system you can stick to procedural code encapsulated by classes. A project with a number of similar but slightly different entities might be best addressed through inheritance and polymorphism.
A third technique is using generics, which are implemented in C++ using templates. Templates have some similarities with #define macros but they are a great deal safer. The compiler does not see the code inserted by a macro until after it has been inserted into the source. If the code is bad the error messages can be very confusing since all the developer sees is the macro name. A template is checked for basic syntax errors by the compiler when it is first seen, and again later when the code is instantiated. That first step eliminates a lot of confusion since error messages appear at the location of the problem.
The Wall Street Journal reported that [Eric Schmidt] of Google and now Alphabet Inc, promoted the idea of an inexpensive version of the Raspberry Pi to the Raspberry Pi foundation’s [Eben Upton]. Apparently [Upton] accepted this recommendation despite existing plans to make a more expensive, more powerful version of the Pi. The outcome is the Raspberry Pi Zero that sells, in some places, for $5.00 and was given away for free on the cover of the MagPi magazine.
From the WSJ article:
“He [Schmidt] said it was very hard to compete with cheap. He made a very compelling case. It was a life-changing conversation,” Mr. Upton said, adding that he went back to the lab and scrapped all the engineering plans for more expensive versions of future Pi computers. “The idea was to make a more powerful thing at the same price, and then make a cheaper thing with the same power.”
Plans were scrapped. The more powerful Pi 2 was released at the price point of existing Pis, and now we have the Zero.
The Raspberry Pi Foundation is a registered educational charity in the UK. The purpose of this Foundation according to their About Us page is to, ‘advance the education of adults and children, particularly in the field of computers, computer science, and related subjects.’
Why is the Raspberry Pi Foundation so concerned about computer education? From the 1990s onward, fewer and fewer A Level students in the UK applying to study Computer Science had previous experience as hobbyist programmers. An applicant in the 2000s usually might have only done a little web design.
Why then does the Raspberry Pi Zero exist? [Upton] also told Cnet, “We really hope this is going to get those last few people in the door and involved in computer programming.”
Very good, but how well does the Zero support this goal or address their concerns?