Opinions differ about what the most-used programming language in right now is, but it’s hard to deny both the popularity and versatility of Python. In the nearly 30 years since it was invented it has grown from niche language to full-blown development environment that seems to be everywhere these days. That includes our beloved microcontrollers now with MicroPython, and Adafruit’s CircuitPython, greatly lowering the bar for entry-level hackers and simplifying and speeding development for old hands and providing a path to a Python-powered Internet of Things.
And as extra enticement, we’ll be giving away five free one-year passes to Adafruit.io! We’ll draw five names at random from the list of Hack Chat attendees. Stop by for a chance to win. And, the Adafruit team will be streaming video live during the Hack Chat as well.
You are, of course, encouraged to add your own questions to the discussion. You can do that by leaving a comment on the Python and the Internet of Things Hack Chat and we’ll put that in the queue for the Hack Chat discussion.
Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about.
Want a quick peek at what’s possible with CircuitPython? Check out this PyPortal event countdown timer that just happens to be counting down the hours till the next Hack Chat.
This is likely not to come as much of a shock to you, but the ESP8266 is pretty popular. At this point, we’re more surprised when a project that hits the tip line doesn’t utilize this incredibly cheap WiFi-enabled microcontroller. If you’re making a gadget that needs to connect to the Internet, there’s a good chance some member of the ESP family is going to be a good choice. But is it a one-trick MCU?
Well, judging by software frameworks like the “Little Game Engine” created by [Igor], it looks like the ESP is expanding its reach into offline projects as well. While it might not turn the ESP8266 into a next-gen gaming powerhouse, we’ve got to admit that the demos shown off so far are pretty impressive. When paired with a couple of buttons and a TFT display such as the ILI9341, the ESP could make for a particularly pocket-friendly game system.
The game engine that [Igor] has developed provides the programmer with a virtual screen resolution of 128×128, a background layer, and 32 sprites which offer built-in tricks like collision detection and rotation. All while running at a respectable 20 frames per second. This environment is ideal for the sort of 2D scrolling games that dominated the 8 and 16-bit era of gaming, and as seen in the video after the break, it can even pull off a fairly decent clone of “Flappy Bird”.
In addition, [Igor] created an online emulator and compiler which allows you to develop games using his engine right in your web browser. You can load up a selection of example programs and execute them to see what the engine is capable of, then try your hand at developing your own game before ever having to put the hardware together. Incidentally, the performance of this online development environment is fantastic; with even the fairly complex “Flappy Bird” example code compiling and starting in the emulator nearly instantaneously.
[tom7] started off with the instruction set for the Intel 8086 processor. Of the instructions available, he wanted to use only instructions which are also readable in a text file. This limits him dramatically in what this file will be able to execute, but also sets up the puzzle. He walks through each of the hurdles he found by only using instructions that also code to text, including limited memory space, no obvious way of exiting the program once it was complete, not being able to jump backward in the program (i.e. looping), and a flurry of other issues that come up once the instruction set is limited in this way.
The result is a sort of C compiler which might not be the most efficient way of executing programs, but it sure is the most effective way of showing off [tom7]’s PhD in computer science. As a bonus, the file can also play an antiquated type of sound file due to one of the available instructions being a call for the processor to interact with I/O. If you want to learn a little bit more about compilers, you can check out a primer we have for investigating some of their features.
The feature of being easier to write than assembly is often seen as the biggest advantage of high-level programming languages. The other benefit that comes with them is portability. With high-level languages, algorithms can be developed independently from the underlying hardware. This allows software to live on once the hardware becomes obsolete.
The compiler was a concept that was met with resistance when it was first introduced. This was at a time when computers were custom-built machines bearing individual names like ENIAC, UNIVAC and Mark I. A time when the global demand for computers was estimated to be around five units by the CEO of IBM. In this scenario, it took a visionary to foresee a future where the number of computers would outgrow the number of programmers and hardware would evolve so much faster than software that a compiler would make sense. One visionary was [Grace Hopper].
There are many projects that call out for a custom language parser. If you need something standard, you can probably lift the code from someplace on the Internet. If you need something custom, you might consider reading [Federico Tomassetti’s] tutorial on using ANTLR to build a complete parser-based system. [Frederico] also expanded on this material for his book, but there’s still plenty to pick up from the eight blog posts.
His language, Sandy, is complex enough to be a good example, but not too complex to understand. In addition to the posts, you can find the code on GitHub.
We don’t use a GUI IDE, but if we did, it would most certainly be something along the lines of [Martin]’s embedded-IDE project. We’ve always felt that most IDEs are just fancy wrappers around all the tools that we use anyway: Makefiles, diff, git, ctags, and an editor. [Martin]’s project makes them less fancy, more transparent, and more customizable, while retaining the functionality. That’s the hacker’s way — putting together proven standard tools that already work.
The code editor he uses is QScintilla, which uses clang for code completion. The “template” system for new projects? He uses diff and patch to import and export project templates. Because it uses standard tools all along the way, you can install the entire toolchain with sudo apt-get install clang diffutils patch ctags make on an Ubuntu-like system. Whatever compiler you want to use is supported, naturally.
We can’t see a debugger interface, so maybe that’s something for the future? Anyway, if you want a minimalistic IDE, or one that exposes the inner workings of what it’s doing rather than hiding them, then give [Martin]’s IDE a try. If you want more bells and whistles that you’re not going to use anyway, and don’t mind a little bloat and obscuration, many of our writers swear by Eclipse, both for Arduino and for ARM platforms. We’ll stick to our butterflies.