Tagged: Javascript

A Comparison of Programming Languages I’ve Used

Comparing programming languages has been a popular sport for many years.

I love the quote from Antoine de Saint-Exupery who once said “If you want to build a ship, don’t tell people to collect wood, or assign them tasks, but rather teach them to long for the endless immensity of the sea“. 

So let’s see how each of the dozen-or-so programming languages I’ve used over the last few decades support that epic vision of empowerment: Continue reading

JavaScript is the new C

assembler programming languageIn the days when processing power was expensive, writing assembler code was the benchmark, and high level languages were seen as an extravagance, C was a revelation. Near-assembler fast, bit-level operations, but still an expressive 3GL.
OK, so nothing like JavaScript then?

Wait, that’s only the beginning of the story.

Continue reading

REST API on a Pi, Part 2: control your GPIO I/O ports over the internet

In Part 1 of this series, we built a simple REST API in JavaScript on our Raspberry Pi.
One of the most useful reasons for providing your Raspberry Pi with a REST API is to expose its input and output ports via the Internet for remote monitoring and control. This will allow you to control your RPi’s inputs and outputs from the browser on any smartphone or PC wherever you are in the world.
So now we will do just this, extending our REST API implementation from part 1 to read and display digital input ports.

Continue reading

Event-driven programming, Finite State Machines and NodeJS

I started out in my software engineering life writing software for embedded real-time systems and communication stacks, so I often think of myself as an async native. I’ve written a lot of code in various languages, mostly not using event-driven programming models and design patterns, but hardware interrupts, callback functions, event loops and finite state machines – I still see these as reassuringly familiar features of my original habitat. Call it the baby duck syndrome.

Who is this post for?

This post is primarily aimed at developers working with (or planning to work with) server-side JavaScript using NodeJS. If you’re already familiar with event loops and state machines then much of this article will be familiar to you. For others, I’m hoping this post will provide you with an understanding of the fundamentals of the event-driven programming model you will need when creating Finite State Machines or working with NodeJS on the server or on a Raspberry Pi or similar device. Continue reading

Javascript on a Raspberry Pi – How to install Node.JS

 

Why install Node.JS on a Raspberry Pi ? 

Nodejs_logo_lightI’ve been using Node.JS as the backend framework for building single-page web apps recently. On top of providing the advantage of an asynchronous, event-based programming model on the backend, it means I can code in Javascript on both the frontend and the backend again – just like in the good old days coding client-server applications in C.

Raspi-PGB001-300x267

And so when I come up with an application where I want to use my Raspberry Pi as a micro web server, but one that needs more than the ability to serve static webpages, I  right away think of Node.

Continue reading

How to build a REST Web API on a Raspberry PI in JavaScript

One of the most useful reasons for providing your Raspberry Pi with a REST API is to expose its inputs and outputs to a web client (on any iPhone, laptop or desktop PC anywhere in the world) for remote monitoring and/or control. This is part 1 of a 2 part blog showing how to implement a REST API in JavaScript.

Continue reading

A Node.JS Application on Amazon Cloud. Part 3: A simple Webserver in Javascript using Node, Express, and MongoDB

In this third part of our exercise, we’re going to use the primary AWS EC2 instance on which we installed Node in Part 1, and the database EC2 Instance  we set up in Part 2, as the platform for  building a simple web application server. We are going to code that web server in Javascript, using Node together with the Express and Mongoose Node library packages.

Continue reading

A Node.JS Application on the Amazon Cloud. Part 1: Installing Node on an EC2 instance

In this three-part exercise, we’re going to build a web application using Javascript on both the client and server side, using Amazon Web Services (AWS) cloud-hosting infrastructure and the Node.JS framework.

web app

aws

What we’re going to do first is install Node on an Elastic Cloud Computing (EC2) virtual server instance provided by Amazon Web Services. In the following parts of this series, we’ll add a MongoDB database instance, and develop a simple server-side web application in Javascript using the Express framework and the Mongoose library for accessing our database.

Continue reading