New version… new features.

If you get involved in the software development industry, or heck, even just use a computer, you know that vendors pump out new versions of their software very frequently. It often seems like just when you get a handle on version 10, version 11 is introduced. Making the learning curve start all over. I’m so stubborn that I’m personally still on Microsoft Office 2003… I know, don’t laugh.

Sometimes new versions offer nothing but bug fixes and additional headaches. Other times new software versions come packed with a wide assortment of immediately useful new features. Such is the case of the latest release of MongoDB, 3.4, released in December of 2016.

I’d like to take a look at some of the included new features in this latest version for developers. There are several new features more suited for a discussion from an administrator standpoint, such as zones, elastic scalability enhancements, consistency control, and improvements to security for database access. For this post though, let’s stick to a discussion about some of the development-oriented features.

Version 3.4 provides some excellent improvements for data processing and aggregation, international language considerations, and third-party application connection tools.

$graphLookup

They have brought the ability to do graph processing directly into MongoDB with the new $graphLookup aggregation stage. This new stage allows MongoDB to recursively lookup documents based on a specific relationship to a starting document. There are, of course, many uses for this feature alone. Such as graphing social networks, business entities, genealogical family trees, etc. One can now utilize the power of a graph database natively within MongoDB. For those that have used a separate graph database, like Neo4j, they can now process their data using a single MongoDB datastore and get graphs along with other business critical data. With the rise of applications that are connected globally, being able to graph relationships is becoming a larger and larger need.

Additionally, it is becoming more and more critical to be able to offer localized language considerations to your application. My family just got done hosting an exchange student from Germany. She let us know that German phone books and German dictionaries sort words differently. Well, it would be great to be able to have the ability to account for these language rules and nuances. MongoDB 3.4 has support for over 100 different languages and locales. One can specify a collation based on collection, index, or view. Further, several operations support collation as well, such as find, aggregate, and update.

Big Data Tools

A couple of additional things which personally got me excited were some updates to the MongoDB Connector for BI and the MongoDB Connector for Apache Spark. As someone who enjoys being able to visualize data, the Connector for BI is very exciting. The performance improvements have been made by moving more query execution into MongoDB processes to reduce latency and bandwidth. Other improvements around the Connector for BI include a simplification of the installation, configuration process, authorization, and support for Windows.

The Spark Connector has received some nice attention as well with updates to support the latest Spark 2.0 release. For those familiar with Spark, the connector allows us access to Spark’s libraries for Scala, Java, Python, and R and brings MongoDB data in as DataFrames and Datasets. This allows us to utilize data already in MongoDB to be analyzed through Spark’s tools for machine learning, graph, streaming, and SQL APIs and provide shorter turnaround times for data scientists and engineers.

Wrap Up

There are several other features new in 3.4 as well, such as faceted navigation, enhancements to the aggregation pipeline, and a support for the decimal data type. In previous posts, I have mentioned some of the advancements to MongoDB Compass and their DBaaS offering Atlas. There are a lot of exciting things in all of these new and/or enhanced features that make version 3.4 worth examining further.

I am excited to continue to examine the possibilities especially around $graphLookup, multi-language collations, and the various connectors. I know that not every organization is in a place and able to upgrade to 3.4 today, but it is definitely worth a look. You can download it in their download center here.

Follow me on Twitter @kenwalger to get the latest updates on my postings.

Facebooktwitterredditlinkedinmail

An Overview of MicroPython

There are a lot of options available when one starts exploring the exciting field of the Internet of Things, or IoT. Not only are there many choices of micro-controllers, there are also a variety of languages in which to program these devices. Many times the micro-controllers are sold as being dependent on C or C++ as a language. That’s great, but I don’t know either of those. There is some great and amazing working being led by Andrew Chalkley around using the JavaScript language for micro-controllers over at thingsSDK. If JavaScript is your language, I’d highly recommend checking out their work. There are also lots of resources for using Java for IoT, Nathan Tippy, for example, is an excellent resource.

All those are great languages. What if you are a beginning developer just interested in playing around in IoT? Or what if you are a Pythonista and don’t want to pick up another programming language? Well, for many micro-controllers there is a Python option which is, arguably easier to learn in many ways than Java, JavaScript, C or C++. That option being MicroPython. You can see that project’s website here.

Overview of MicroPython

MicroPython is a tiny, open source Python programming language interpreter that runs on embedded boards. It was originally developed in 2013 and released in 2014 by Dr. Damian P. George of Cambridge University. It implements Python 3 and is designed specifically to run on devices with limited resources.

As with many things in the IoT world, the use of a particular language is greatly influenced by the tools, libraries, and packages one has available. MicroPython comes with an interactive read-evaluate-print-loop (REPL) for quick prototyping. It also fully supports loading MicroPython scripts onto a device to run as well. It supports an extensive Python based library and for lower level operations can be extended with C/C++ functions as needed.

Many of the tasks that beginning IoT folks start off with, such as blinking lights, reading switches, driving servos, etc. are all easy to do in MicroPython. Further, it is often incredibly easy to read as well, as it is all Python based. For example, if one has MicroPython installed on a NodeMCU ESP8266 board, a popular and inexpensive board to start working in IoT, with a basic LED light connected to GPIO Pin 5 it is pretty simple to get the light to turn on (high state) and off (low state).

import machine

led = machine.Pin(5, machine.Pin.OUT)
# Turn on LED
led.high()
# Turn off LED
led.low()

The machine module is included with MicroPython and handles many of the hardware connections from software.  It allows access to things like GPIO pins, CPU frequency, I2C busses, etc. If it is low-level on the hardware, the machine module is the way to go!

Platform Support

There are many devices that support MicroPython. The NodeMCU is one of them. But several other options are available such as the LoPy or similar PyCom devices, the PyBoard, and many others.

Differences from Python 3

As one can imagine, cramming everything from Python 3 into a micro-controller isn’t possible. But, core data types and modules which make sense for embedded systems are included. Another limitation is that since Python is a high-level programming language it isn’t as fast or lean as C or C++. Many operations aren’t impacted by this. However, if your application requires tight timing or performance is of utmost importance, using MicroPython can be an issue. However, as stated earlier, one can extend MicroPython to use C/C++ in these circumstances.

Since MicroPython is open source, check it out on GitHub, one can further extend or adapt it specific use case scenarios. For example, if you need something specific to run at boot time you can include it in the package that is flashed to the device. Pretty handy and convenient.

Conclusion

Hopefully I have at least sparked your interest enough in using MicroPython for IoT to take a further look at it. The development site actually has a live, interactive device where you can try out some code and see it run on a real world device. Give it a try and leave a comment below to share with others what you’ve done and built!

Follow me on Twitter @kenwalger to get the latest updates on my postings.

Facebooktwitterredditlinkedinmail