Learn IoT from scratch #6 - Python/JavaScript for IoT
Tags: iot, tutorial, beginners, computerscience
Published: 2021-10-03 22:50:06

## Introduction

This is the #6 post of the IoT series that I am writing, in this article I will talk about the Python language, its specification, libraries and frameworks, and also we will talk about the JavaScript language, frameworks, use cases etc.

&nbsp;

## Python

![Python programming language logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/orqq478v0m1yy2qyoo8z.png)

Python is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.

Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library. Python is a programming language that is pretty close to a natural language.

Python is a very popular programming language,so it can be used in many different fields of computer science. Accordingly with the <a href="https://python.org">python.org</a> website, Python can be used for:

- Web development
- Data science
- Artificial Intelligence
- GUI development
- IoT
- Systems admnistration
- Advanced math
- Mobile development

In this article, I will focus in web development and data analysis, because these are two fields that dialogue with IoT. Usually you will need to develop a web server to receive the topics that will be published by the devices (web development), and this web server will need to process the brute data received, organize it and generate an output pointing out the flaws, possible improvements, insights (data analysis).

### Web frameworks

To build web servers, you can use Python native libraries, but you can also use the web frameworks, with them, you will be able to write stronger, more resilient systems with fewer lines of code. The main python frameworks for web development are: Flask, Django and FastAPI, and we'll talk a little bit about them today.

#### Flask

![Flask framework logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3yh7ndvpgn6l6bh8h7ji.png)

Flask is a micro web framework written in Python. A micro web framework is a web development framework with an easy setup and can be used in developing minimalistic web applications. Flask comes with options like template engines such as ORM, caching, and authentication.

It was created to build web apps with the Python programming language. It was designed to be easy, fast, and to scale up complex applications and microservices. If combined with ORMs and data analysis libraries, Flask becomes a very powerful tool.

#### Django

![Django framework logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fmsuk1oeuhul2h25nrk.png)

Django is a free and open-source Python web development framework used in building websites. It was created by Adrian Holovaty and Simon Willison in 2003 and used the Model-Template-View pattern.

It is popular for its robust and straightforward nature. It’s one of the most popular frameworks globally and is used by Tech giants like Instagram, Youtube, etc. Django is also popular because it encourages reusable code.

#### FastAPI

![FastAPI framework logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yx890jn32z9qbiekmumz.png)

FastAPI is a modern, fast, and robust framework that helps build APIs with python 3.6+ versions. It is considered to be one of the fastest Python frameworks. It’s a framework that is quick to code. FastAPI is not so popular as Django and Flask, so the community will be smaller, but is the best option if you need performance and scalability.

Big techs like Netflix and Uber use this framework which fully supports asynchronous programming and can work with WSGI (Web Server Gateway Interface) and ASGI (Asynchronous Server Gateway Interface). Flask and Django, until the time of publication of this post, still do not fully support asynchronous programming.

### Data analysis

Data analysis is defined as a process of cleaning, transforming, and modeling data to generate insights and information that will be used in the decision-making process. The purpose of Data Analysis is to extract useful information from data and taking the decision based upon the data analysis.

Data analysis is a branch of computer science, highly valued by companies, because with good data analysis, it is easier to make the right business decisions. And this branch is part of IoT, because the sensors/microcontrollers send the data in its "brute state", so as an IoT developer, we must be capable of modeling it, transform the data collected into structured information.

Python, because it is an "easy" and popular language, has many libraries and tools to handle data analysis and statistics. These libraries turn the work easier, because they have lots of builtin functions to receive data as parameter, and then returns structured information as output. But is very important to learn the algorithms and the math behind these data analysis tools.

#### NumPy

NumPy is a fundamental package for scientific computing in Python. It is a Python library that provides lots of functions to deal with datasets, multidimensional arrays, predictions, math, logic, shape manipulation, sorting, selecting, basic linear algebra, basic statistical operations.

#### Pandas

Pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real-world data analysis in Python.

#### TensorFlow

TensorFlow Lite is an open-source deep learning framework to run TensorFlow models on-device. TensorFlow's main implementation, the core, is written in Python, but is not just it, it also supports JavaScript, Mobile, IoT, and direct API access.

It is a symbolic math library that uses dataflow and differentiable programming to perform various tasks focused on training and inference of deep neural networks. It allows developers to create machine learning applications using various tools, libraries, and community resources.

&nbsp;

## Javascript

![JavaScript logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a7tpkzjk2d9ijt32lwjo.jpeg)

JavaScript often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, interpreted, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.

As a multi-paradigm language, JavaScript supports event-driven, functional, object-oriented and imperative programming styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions and standard data structures.

JavaScript is the world's most popular programming language, and it is continually growing more and more. Just like Python, JavaScript can be also used in many different fields of computer science, but it is widely adopted on web development, can be used on backend, frontend, mobile and desktop.

### Node.js

Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project, initially was made to run in the backend, but nowadays, it can be used as "platform" in frontend and mobile, for example, Next.js, frontend React framework that uses Node.js

Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. This allows Node.js to be very performant.

### Typescript

TypeScript is a strongly typed programming language which builds on JavaScript giving you better tooling at any scale. TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor.

### Frontend

Frontend is the "visible" part of a website, is where the user interacts with directly. It is also referred to as the "client side" of the application. It includes everything that users experience directly: text colors and styles, images, graphs and tables, buttons, colors, and navigation menu.

The web browsers just "understand" JavaScript, so, to develop websites you need to know JavaScript, HTML and CSS. But use this three languages, in their brute form, can be a very difficult task, and that's why we have frameworks and libraries, to make our work easier.

#### React

![ReactJS logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0i61dis5mkc19ewycmq.png)

React is a front-end library developed by Facebook. It is used for handling the view layer for web and mobile apps. ReactJS allows us to create reusable UI components. It is currently one of the most popular JavaScript libraries and has a strong foundation and large community behind it.

#### Angular

![Angular logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mat3p5dnrnztk78jv6zz.png) 

Angular is a JavaScript open-source frontend framework that is mainly used to develop single-page web applications(SPAs). It is a continuously growing and expanding framework which provides better ways for developing web applications. It changes the static HTML to dynamic HTML.

#### Vue

![VueJS logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hnge96qhs6t5tl4xvo0.png)

Vue is a progressive framework for building user interfaces. Unlike other monolithic frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects. On the other hand, Vue is also perfectly capable of powering sophisticated Single-Page Applications when used in combination with modern tooling and supporting libraries.

### Backend

Backend is where the business rules are located, it handles all the data, logic, services. It is also referred to as the "server side" of the application. It includes databases, microsservices, messaging systems, queues, data analysis tools and all these stuff that are closer to the server than to the browser.

#### NestJS

![NestJS logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocecoswe7a6s7x9y4bov.png)

NestJS is a framework for building efficient, scalable Node.js server-side applications. Is built with and fully supports TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).

Under the hood, Nest makes use of robust HTTP Server frameworks like Express (the default) and optionally can be configured to use Fastify as well.

#### Express

![ExpressJS logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5nc13m861ynocgfdsym.png)

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. It is an open source framework developed and maintained by the Node.js foundation.

It is the most popular JavaScript backend framework, because it is very stable, fast, solid and flexible. Express doesn't force any programming style, you are totally free t use your own style and your favorite programming paradigm.

#### AdonisJS

![AdonisJS logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/minoe50rya0jzj29hr2e.png)
 
AdonisJs is a Node.js web framework inspired by Laravel. It has the Model View Controller (MVC) structure, well-written documentation, and support from maintainers. Adonis isn't a minimal framework like Express, it is more similar to NestJS, because it is a complete framework, with lots of builtin functionalities and ORM integrated.

&nbsp;

## Community

JavaScript and Python are two amazing, versatile and easy to learn programming languages, but they have another quality, their communities. The communities of Python and JavaScript are huge, you can find other JS/Python developers on discord and telegram channels, an also access forums like StackOverflow, Dev.to, Github etc.

When do you have a large community around some tech, becomes a lot easier to learn, because you can learn together, you can ask and share knowledge. Also exist specific communities, for a single library, or framework, and this helps you to precisely find the right people.

&nbsp;

## Conclusion

We have reached the end of our article, this was a very long post. Know JS and Python is essential to be a good IoT developer, because you will be able to work with web development, data analysis, mobile, machine learning and more.

Obviously this post doesn't contain everything you need to know, because it's a very dense subject, but I tried to summarize as best I could, to make the information clear and allow you to go deeper into the subject.

&nbsp;