How to publish your package on NPM

How to publish your own package

Several developers feel the need to use some functionality of one project in another. Normally, the developer copies code from one project and pastes in another but if it is common functionality that may be used in several projects its a better and good practice to publish your reusable codes as npm packages.

Okay, so let’s start!

  1. npm init:

When you are in your desired directory, open the CLI, and use this command:

npm init

A text utility appears and you are asked to enter a few details to create a basic package.json file such as package name, version, description, author, etc.

Enter the details of the package as you please. The defaults will be mentioned in parentheses like this →

package name: (test-package)

version: (1.0.0)

description: This is a test package

.

.

.

Just hit Enter if you want the default options.

A basic package.json will be created looking something like this :

{

"name": "test-package",

"version": "1.0.0",

"description": "This is a test package",

"main": "app.js",

"author": "ashramtech",

"license": "ISC"

}

Obviously, you can change the package.json file later if you want.

  1. Source

Now, you need to prepare the source code. If the code is not too big, it is typically just write in the main file(app.js here). Else, conventionally a src directory is used where your abstract code is stored in several files.

Remember to export the code using module.exports

  1. Test

You now need to thoroughly test your code before publishing. This is how you, as a developer, confirm that your package can actually be used.

  1. Publish

If this is your first time, you probably won’t be logged in with your npm account. If you don’t have an account, go to npmjs.com and create your account.

Now, in your terminal, log in with your npm account.

npm login

And now to publish your package,

npm publish

And you’re done!

You can now check your published project at www.npmjs.com/<username>/<pkg-name>.

The details regarding the package such as version, author name, description, etc. are extracted from the package.json file you created earlier.

Conclusion

Now you’ve got a basic idea about what npm is and how you can publish your own package to the npm registry. If you want to know more about npm and its basic commands please follow this article An Introduction to the npm : An Absolute Beginner’s Guide

 

An Introduction to the npm : An Absolute Beginner’s Guide

npm is the standard package manager for Node.js.

In January 2017 over 350000 packages were reported being listed in the npm registry, making it the biggest single language code repository on Earth, and you can be sure there is a package for (almost!) everything.

It started as a way to download and manage dependencies of Node.js packages, but it has since become a tool used also in frontend JavaScript.

An introduction to npm

  • npm is Node’s package manager. It’s a repository of hundreds of thousands of useful pieces of code that you may want to integrate with your Node project.
  • npm also has a command line tool that lets us easily install, manage and run projects.
  • npm is written entirely in JavaScript(JS) and was developed by Isaac Schlueter. It was initially used to download and manage dependencies, but it has since also used frequently in frontend JavaScript.
  • npm can manage packages that are local dependencies of a particular project, as well as globally-installed JavaScript tools. In addition to plain downloads, npm also manages versioning, so you can install any version, higher or lower according to the needs of your project. If no version is mentioned, the latest version of the package is installed.
  • You can have a more in depth overview of NPM in their documentation.

Yarn and pnpm are alternatives to npm cli. You can check them out as well.

How to use npm:

Installing all dependencies

If package.json file exists in your project root directory, all you need to do is use this command

npm install

This command will initialize the node_modules folder and install all packages that the project needs.

Installing a single package

If you just need to install a single package, you can use this command

npm install <package-name>

Often you’ll see more flags added to this command:

  • –save-dev installs and adds the entry to the package.json file devDependencies
  • –no-save installs but does not add the entry to the package.json file dependencies
  • –save-optional installs and adds the entry to the package.json file optionalDependencies
  • –no-optional will prevent optional dependencies from being installed

Shorthands of the flags can also be used:

  • -S: –save
  • -D: –save-dev
  • -O: –save-optional

Updating packages

And if you need to update the installed packages, hit

npm update

All packages will be updated to their latest versions.

Similarly, if you just need to update a single package, all you need to do is


npm update <package_name>

Note: By default, packages are installed in the local scope. If you need to install the package at global scope, you need to mention the flag -g


npm install <package_name> -g

This will install the package at the global scope in the system directory.

Versioning

npm also manages versioning, so you can specify any specific version of a package, or require a version higher or lower than what you need.

Running Tasks

The package.json file supports a format for specifying command line tasks that can be run by using

npm run <task-name>

Initialize a Project Using npm init

Several developers feel the need to use some functionality of one project in another. Normally, the developer copies code from one project and pastes in another but if it is common functionality that may be used in several projects its a better and good practice to publish your reusable codes as npm packages.

Okay, so let’s start!

  1. npm init

npm init is the first command you need to know to create a Node project. It will ‘initialise’ your project by adding a file called package.json in the root directory.

npm will ask you some questions in your terminal after you run the command — your answers will be pre-filled into the package.json.

Don’t worry, you can change your answers later by editing package.json manually.

When you are in your desired directory, open the CLI, and use this command:

npm init

A text utility appears and you are asked to enter a few details to create a basic package.json file such as package name, version, description, author, etc.

Enter the details of the package as you please. The defaults will be mentioned in parentheses like this →

package name: (test-package)

version: (1.0.0)

description: This is a test package

.

.

.

Just hit Enter if you want the default options.

A basic package.json will be created looking something like this →

{

"name": "test-package ",

"version": "1.0.0",

"description": "This is a test package",

"main": "index.js",

"author": "ashramtech",

"license": "ISC"

}

Obviously, you can change the package.json file later if you want.

Where does npm install the packages?

When you install a package using npm you can perform 2 types of installation:

  • a local install
  • a global install

By default, when you type an npm install command, like:

npm install cowsay

the package is installed in the current file tree, under the node_modules subfolder.

As this happens, npm also adds the cowsay entry in the dependencies property of the package.json file present in the current folder.

A global installation is performed using the -g flag:

npm install -g cowsay

When this happens, npm won’t install the package under the local folder, but instead, it will use a global location.

Where, exactly?

The npm root -g command will tell you where that exact location is on your machine.

Conclusion:

Now you’ve got a basic idea about what npm and its important commands. Several developers feel the need to use some functionality of one project in another. Normally, the developer copies code from one project and pastes in another but if it is common functionality that may be used in several projects its a better and good practice to publish your reusable codes as npm packages. We will cover in next article How to publish your own package to the npm registry.

MEAN stack or MERN stack : Which is best

Within the JavaScript ecosystem, a particular app will consist of a combination of technologies, called a “stack.” The MEAN, MERN, and MEVN (pronounced “Mevin”) stacks are among the most popular technology stacks that developers use to create websites and mobile applications. But, what are the major differences between these stacks? And, do developers prefer one over the other?

To understand which stack is the better one, we need to understand the underlying differences between them.

What is a technology stack?

First things first, tech stacks are comprised of the many components which work together to produce an application which serves the needs of users and businesses:

  • A front-end framework does most of the “heavy lifting” of building a complex website or mobile app, so the developers and designers can focus on providing the specific features and fixes needed by the users and the business.
  • Often a CSS framework helps translate the design decisions of designers to easily-achievable and reproducible steps for developers.
  • A back-end framework does most of the “heavy lifting” of communication between the website or mobile app and the database and business logic.
  • Miscellaneous back-end technologies used for a variety of tasks, such as organizing the gradual release of experimental features, tracking and reporting errors in the system, or accommodating sudden increases in usage (such as when something goes viral).
  • Database technologies store and organize data, as well as provide features for searching, filtering, and reporting data.

What are the MEAN, MERN, and MEVN stacks? 

MEAN stack: MEAN is an abbreviation that stands for MongoDB, ExpressJS, AngularJS, Node.js. This framework provides quick and easy development of web and mobile applications. The main components of MEAN are as follows-

  • MongoDB: It is used to store the data of back-end applications as JSON files.
  • ExpressJS: It is a back-end application that runs on top of Node.js.
  • AngularJS: It is the front-end framework that runs the code in the browser.
  • NodeJS: It provides runtime system for JavaScript on the back-end web application.

MERN stack: MERN is an abbreviation which stands for MongoDB, ExpressJS, ReactJS, Node.js. This framework also provides quick and easy development of web and mobile applications using java as its main component. Main components of MERN are as follows.

  • MongoDB: It is a document-oriented No-SQL data store used to store back-end applications.
  • ExpressJS: It is a layered framework built on top of NodeJS that takes care of the website’s back-end functionality and structure.
  • ReactJS: It is a library that facilitates creating the user interface components of single-page web applications.
  • NodeJS: It is a runtime environment capable of running JavaScript on a machine

What is the difference between them ?

In those stacks there are common letters which are M – E – N .

  • M: MongoDB
  • E: Express.js
  • N: Node.js

Those are the Backend technologies be while the Frontend technologies are A – R – V for MEAN – MERN – MEVN .

Then Obviously,

  • A: Angular
  • R: React
  • V: Vue

So, what’s the difference between Angular, React, and Vue? 

Since the primary difference between these stacks lies in their use of Angular, React, and Vue.js, let’s explore what those frameworks do.

  • Angular is a front-end framework led by the Angular team at Google. It is Typescript-based by default and used for web, mobile web, native mobile, and native desktop development. Angular is popular in the business world and is often used by traditional organizations, like hospitals and banks. Angular is a more opinionated framework in that it isn’t as customizable as frameworks like React or Vue.
  • React is a front-end framework for creating web applications to be run inside the browser. It was originally designed by Facebook to be able to support many millions of users. React is the most popular among the startup, freelance, and software consultancy crowds. It’s highly customizable and really good at scaling for massive numbers of users, which makes it easy for teams to be confident about future growth.
  • Vue.js is an easy-to-learn JavaScript framework. It’s known for its approachability, versatility, quality documentation, and speed. Vue was released in 2014 and is considered an up-and-comer as it doesn’t have the same market reach as frameworks like Angular and React just yet—but it is a fan favorite!

Which is better MEAN, MERN, or MEVN? 

MEAN stack vs. MERN stack vs. MEVN stack… which one is best? These stacks are all very similar. Once a developer knows one of these 3 stacks, it won’t be too difficult to learn the others. All of these stacks are useful – it just depends on the type of project you’re taking on.

In short, one isn’t necessarily better than another. Choosing the right stack for your software development process depends on the front-end framework or related tools you’d like to use. If a developer or team prefers to work with Angular, they may choose to work with the MEAN stack. Meanwhile, a developer or team who enjoys working with React will gravitate towards MERN.

Conclusion:

Companies like Accenture, Raindrop, Vungle, Fiverr, UNIQLQ, and Sisense among others use MEAN in their tech stacks. Brands such as UberEats, Instagram, and Walmart use MERN stack. Both the stacks provide an incredible user experience. Stability and scalability can be achieved with both stacks.

From this we can conclude that enterprise level projects require MEAN over MERN. MERN makes rendering UI simpler. Both are reliable for a quick front end development.

MEAN is good for large scale application. MERN is good for faster development of smaller applications.

v8 JavaScript engine

The V8 JavaScript Engine : A high-performance JavaScript engine

In this V8 introduction, we will ignore the implementation details of V8: they can be found on more authoritative sites (e.g. the V8 official site), and they change over time, often radically.

What is V8 javascript engine?

V8 JavaScript engine was initially developed for Google Chrome and Chromium web browsers to improve the performance of JavaScript execution. The project’s creator, Lars Bak, created the first version that was released at the same time as the first version of Google Chrome in September 2008. The engine was initially designed solely for execution by web browsers, but the latest versions also execute JS code outside of the browser, enabling server-side scripting.

Other JS engines

Other browsers have their own JavaScript engine:

and many others exist as well.

A high-performance JavaScript engine

V8 is written in C++, and it’s continuously improved. It is portable and runs on Mac, Windows, Linux and several other systems.

This might seem counter-intuitive, but since the introduction of Google Maps in 2004, JavaScript has evolved from a language that was generally executing a few dozens of lines of code to complete applications with thousands to hundreds of thousands of lines running in the browser.

Our applications now can run for hours inside a browser, rather than being just a few form validation rules or simple scripts.

Compilation

  • JavaScript is generally considered an interpreted language, but modern JavaScript engines no longer just interpret JavaScript, they compile it.
  • This has been happening since 2009, when the SpiderMonkey JavaScript compiler was added to Firefox 3.5, and everyone followed this idea.
  • JavaScript is internally compiled by V8 with just-in-time(JIT) compilation to speed up the execution.

How V8 JavaScript Engine Works

When a developer runs a JS script on V8, the following steps are taken by the engine:

  • The engine compiles and executes the JS code
  • The engine handles the call stack
  • The engine manages the memory heap
  • The engine handles the garbage collection
  • The engine provides all the data types, objects and functions
  • The engine also provides the event loop (sometimes implemented by the browser as well)

Key Notes:

  • V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and Node.js, among others.
  • It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors.
  • V8 can run standalone, or can be embedded into any C++ application.
  • V8 is the name of the JavaScript engine that powers Google Chrome. It’s the thing that takes our JavaScript and executes it while browsing with Chrome.
  • V8 provides the runtime environment in which JavaScript executes. The DOM, and the other Web Platform APIs are provided by the browser.
  • The cool thing is that the JavaScript engine is independent of the browser in which it’s hosted. This key feature enabled the rise of Node.js.
  • V8 was chosen to be the engine that powered Node.js back in 2009, and as the popularity of Node.js exploded, V8 became the engine that now powers an incredible amount of server-side code written in JavaScript.

 Conclusions:

On the web, there is a race for performance that’s been going on for years, and we (as users and developers) benefit a lot from this competition because we get faster and more optimized machines year after year. V8 provides the runtime environment in which JavaScript executes. The DOM and the other Web Platform APIs are provided by the browser.

V8 is always evolving, just like the other JavaScript engines around, to speed up the Web and the Node.js ecosystem.

 

 

 

node.js

Why use node.js for backend : A complete case study with pros and cons

With so many frameworks available, sometimes it is hard to decide on something new and different. In the case of Node.js, you probably have heard sentences like ‘JavaScript runtime’ or ‘event-driven’ or ‘operates on a single thread event loop’ and have been wondering what it all means.

After over 20 years of stateless-web based on the stateless request-response paradigm, we finally have web applications with real-time, two-way connections. So, what is all this recent excitement around Node.js we’ve been all hearing lately? Why is it so popular? Let’s look at all this and more.

What is Node.js?

The definition of Node.js is quite complex. It’s not a programming language nor is it a framework or a library. On their official website, Node.js is defined as a JavaScript runtime built on Chrome’s V8 JavaScript engine. So Node.js is an open source, a server-side script which runs on the top of Google’s open-source scripting engine V8. Node.js can be simply referred to as a technology.

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is mainly used for backend operations and is/can be used together with frontend JavaScript frameworks like AngularReactVue and others. Node.js is similar in design to Ruby’s Event Machine and Python’s Twisted.

How and why did Node.js get popularity?

Node.js was introduced into the world in 2009 by the initial writer Ryan Dahl. Back in 2009, Apache HTTP server was a popular web server. But, it had a major problem; it could not handle a lot of concurrent connections.

When Node.js was created it was able to solve the problem Apache had. It offered scalability and parallel code execution. It introduced a new logic and approach for JavaScript server-side development. It introduced use of a single threaded event loop model. A single thread is used to perform all requests.

Since then its popularity has wildly grown. For instance in Github, Node.js has 81.9k stars and 21.4k forks. In Stackshare it has 96.2k followers and 8.4k votes. These numbers alone can show how popular Node.js is. To the date 7509 companies reportedly use Node.js in their tech stacks, including Uber, Netflix, Paypal and Twitter.

Why Node.js is so popular among developers.

  1. Easy to learn.

This is one of the major contributors to its wide usage. Among many developers, JavaScript skills are common. Node.js uses JavaScript. So, learning Node.js is relatively easy and few weeks of learning can get you up and running. Without JavaScript Knowledge, learning Node.js will take a bit longer but still manageable. Therefore, learning Node.js is not that tricky.

  1. The scalability offered.

Node.js is designed with scalable network applications in mind. Node.js can handle many concurrent requests. This is the main reason it quickly became popular among developers and large companies. It can handle many simultaneous requests without straining the server. A callback is fired only after a request, but if there are no more jobs to be done, Node.js will go to sleep. Node.js is only online when needed. This avoids unnecessary usage of your RAM.

  1. The Mobile-friendly, Cross-platform, and Dev-Friendly nature.

The ability to build flexible apps that run smoothly on any platform, be it Linux, Windows, or Mac OS gives Node.js a big thumbs up. There has been a rise in cross-platform app development in the last few years. The fear of apps not running on other operating systems is gone, as Node.js helped take care of that. It has enabled developers to write apps that run on different platforms with little or no modifications being made.

  1. Lightweight and fast.

Node.js uses Google’s V8 JavaScript engine which is built in C++. The engine is an open source and high-performance JavaScript and Web Assembly engine. The engine was developed for Google Chrome and Chromium browsers by The Chromium Project. V8 engine handles memory allocation, compiles, and executes JavaScript. It compiles JavaScript into machine code using a just-in-time (JIT) compiler before executing it.

More about Google’s V8 JS engine can be found in the V8 docs. Node.js uses a non-blocking model in performing operations. Node.js has published a full article on blocking and non-blocking models here. It handles requests made in a single asynchronous thread. This reduces CPU workloads as well as memory. This makes your app lightweight.

  1. The many hosting providers available.

As a result of its growth in recent years, many cloud-based hosting providers and web servers have added quite simple ways of hosting Node.js code. Some of these hosting providers include Heroku, Amazon Web Services, Azure and Digital Ocean among others. There are also many detailed and simple guides on this.

  1. Highly extensible

Node.js does not provide everything that you need all at once. Instead, you customize or add what you need over time. This prevents having unnecessary libraries. NPM – Node package manager is the default package manager in Node.js. Here, you can browse and install over 1 million open source packages. You can also use it to identify and install project dependencies.

  1. Its caching ability

Node.js provides the ability to cache single modules. Caching is the storage of data for future requests. When a request involving the module is made, it is fetched from the cache instead of the main servers. Thus, the app loads faster and responds quicker.

What apps we can develop with Node.js?

You may be asking, what kind of apps we can develop with Node.js. The answer is: Node.js can be used to make almost any kind of app. Below are some of the apps you can develop using Node.js.

  • Single-page applications (SPA). e.g. portfolio etc.
  • Social media applications. LinkedIn uses Node.js.
  • Real-time apps like chat apps.
  • Streaming apps. For example, Netflix.
  • Ecommerce apps. For example, Walmart.
  • Blogs.
  • Online Payment systems. For example, PayPal
  • APIs
  • Mobile apps. Node.js can be used together with other frameworks eg. ExpressJs to build mobile apps.
  • Many more.

The advantages of using Node.js.

  • Node.js modules and tools are easily available via NPM.
  • Node.js developers are easily available.
  • Strong community and bug tracking team.
  • It can be used to build a wide range of apps.
  • It’s Cross-platform and mobile-friendly.
  • Hosting Node.js code is not a hassle due to many of its supported hosting platforms.
  • It’s lightweight.
  • It’s ability to handle many simultaneous requests.
  • Fast code execution.

What are the disadvantages of Node.js?

  • Decreased performance during complex & heavy computation tasks

As we have mentioned before, Node.js is single-threaded and event-driven, and that is why it isn’t suited for heavy computational tasks. Receiving a massive computational task, it uses the CPU power to the fullest to handle that task, leaving other tasks running in a queue. That means slowing down the entire thread of events, which impedes the interface. “Worker threads” have been introduced to remedy this problem, but this solution isn’t absolutely effective at handling CPU-related computational tasks.

  • Callback hell puts code quality at risk

Node.js is reliant on callbacks due to its asynchronous approach. Typically, this function works after executing a task. If multiple tasks are running in the background, each having a callback, it might cause callback hell, an unwieldy number of nested “if” statements or functions. It impedes performance and lowers the quality of code.

  • Lack of library support

While the npm library seems rich, the quality of many packages leaves much to be desired. Lots of them don’t have proper documentation. Since it’s an open source system, professional monitoring here is scant, so many packages don’t meet the coding standards. The good news is that Joyent supervises the key Node.js technologies.

Conclusions:

Node.js can be used for applications of various sizes and needs thanks to its high level of scalability. By offering security, scalability and performance among other things, Node.js has become a solution to many problems. It is a type of technology that works without any unnecessary effort.

Node.js is not a one-size-fits-all solution, but it’s a good solution for creating fast and scalable web applications with less engineering effort.

Node.js is perfect for creating streaming web applications, server-side apps or microservices. Being built on Chrome’s V8 engine, using asynchronous execution and operating on a single thread event loop Node is recognized as an amazing and scalable framework for many businesses.

Pros and Cons of Python programming that every beginner must know

Python, developed by Guido van Rossum, is considered one of the major programming languages in the world that is highly popular among developers. It is a great open-source platform that covers all the major requirements of the developers that include backend web development.

However, it is not as simple to work on Python as one would like to believe. Just like other platforms or programming languages, Python has its own set of benefits and challenges that makes it a great platform for development.

Here are the major benefits of Python as the programming language followed by its challenges.

Pros of Python

  1. Beginner-friendly – Python is an ideal platform for beginners since it is easy to learn and understand. It is a great programming language that doesn’t include a lot of technicalities or big problems cause of small mistakes. It includes a few complexities that can be tried by developers with zero background in coding.
  2. Large Community – Python has a large community of developers, professionals, and students helping each other to bring out the best in the platforms. It is a great platform for beginners since they will have all the help from knowledgeable developers with years of experience.
  3. Flexibility – Python is an extremely flexible language that makes it ideal with minimum complexities and helps in keeping the worries of developers aside. It also is flexible enough for learners, developers, and users that is easy to take actions and build new features as the dynamically-types languages.
  4. Integrated Development Environment – This is another aspect that makes Python an ideal platform since it includes the IDEs and Integrated interactive shell. It makes it easier to code and run in a single place. This makes it easy for auto-complete, syntax highlighting, and automatic datatype assignment.

Cons of Python

  1. Work Environment – It is not easy to fulfill or practice Python without a work environment. However, it is essential to set up the environment which is not easy at all. Some many troubles or issues can come up while setting up such environments that can affect the programming experience for beginners. Hence, it is best to go for Python IDEs and then set up the environment using official guides.
  2. Compiler Error – This is a real thing if you don’t know how to use the IDEs properly. It can demotivate the developers while executing the code. However, Python has inbuilt features like a shell script that helps in accessing the code in the less complex process.
  3. Coding – If you are a beginner, then the worst thing that will happen is that you have no idea where to begin from. What you will code to learn the platform is something that all the developers struggle with. Ti is essential to find something that can be easy and interesting to code that can give a better understanding of what to do and what not to do while starting the first code.

Top 5 Programming languages to start your tech career in 2021

Around two decades ago, coding was considered as the future of the technical world that is now true. The sentimental value of coding has increased at a remarkable rate and is even going high with time.

Now, as we are stepping into 2021, we must be aware of the coding languages and the growth of the platform with time. The average salary of coders, nowadays, is more than $22,000 annually. Hence, it is time to solidify your future goals of building a career in programming and dive deep into the coding world.

1. Python
For the last few years, we have witnessed remarkable growth with a broad spectrum of future. It has become a popular programming language that is opening endless opportunities for the coders including AI programmers, engineering, data scientists, and many more. It is a great platform if the coders want to kickstart their career in robotics and artificial intelligence.

2. Ruby
If you want to dive into some new mobile application idea then it is best to go ahead with Ruby that allows developers to work on several frameworks. It helps the developers to work on the development with a solid base on the idea and walk into the development process.

3. Java
Java is a great platform for mobile app development that is now growing at a vast rate. It is a leading programming language that is used for website and Android app development for years. Hence, it is best to dive into the platform and pick up a course to learn more about this platform for building blocks to be a full-fledged developer.

4. Javascript
Javascript is currently one of the most popular web programming languages and can run for almost any type of application (e.g. server, mobile, cloud, micro-controllers, etc…). Javascript reached it’s a peak in popularity during the early days of web-development and since then has had a quite steady trend during the last decade.

5. PHP
This programming language is famously known for web development and as a scripting platform. It is ideal to develop home phases, set up a server, and work on some amazing design ideas. It includes several courses that allow developers to understand with the combined knowledge of PHP and Python for maximum capabilities.

Conclusion

Overall Python and Javascript are certently two of the most popular programming languages right now. Although, different alternatives such as Julia, Go and Scala are now starting gaining more and more attention from the job market thanks to their various benefits (potentially in the same way like Python did during the last decade).

5 Best Python frameworks to enhance coding experience in 2021

Python has come up as a great platform for web applications in the past few years. It has become a major choice for the developers and with several frameworks added to it, it is now becoming extremely popular in the market.

Python is also increasing in popularity with major features like functionalities, uniqueness, and general interest that have come up as relatively essential aspects. But we all know that frameworks can help in the development cycle making developers work easily on the app.

So, what are the major python frameworks that developers can use to enhance the coding experience of the developers?

1. Bottle
It is considered as a lightweight and simple micro web framework that is used to distribute the single file module. Python also has no dependencies as compared to the standard libraries. It includes several features like:

  • Templates – The framework has pythonic and fast built-in templates that support cheetah, jinja2, and mako.
  • Routing – It is a dynamic and clean URL framework that makes it easy to request function-call mapping.
  • Server – The framework includes the HTTP developer server for the fapws3, paste, cherrypy, and other WSGI HTTP server.

2. Django
This is the popular python framework that is famous for less code and better build apps. Hence, it makes Django a popular choice that is an open-source and free platform that works faster for the developers. Especially, with the application that requires flexibility and complex code that offers pragmatic designs. Several features makes Django an ideal platform such as:

  • High speed
  • Rich in features
  • Versatility
  • Secured
  • Scalability

3. TurboGears
It is a data-driven and open-source platform that is used for app development including major elements in it. The organizations are using TurboGears for several reasons since it helps in attaining direct and critical results. It also is used with database connectivities such as WebOb, Repoze, SQLAlchemy, Genshi, etc.

  • Function decorator
  • Multiple database support
  • Cross-platform OS
  • Pylon support

4. Flask
The WSGI web application framework – Flask – is a great platform that is used as an easy and quick form of development. It is a great framework that works ideally with the complex applications that use Jinja and Werkzeug as simple wrappers. It offers a robust web application that helps in development with the WSGI toolkit template.

  • Unicode based
  • Integrated support
  • Ability to plug in the ORM

5. Falcon
Another of the major Python frameworks that are extremely famous in the market is Falcon that uses the app backends and web APIS for speed development. It is also used as a top web framework that includes REST architectural style and embraces HTTP. The designers use this for a cleaner design with several other aspects like:

  • Full Unicode support
  • PyPy support
  • URI templates
  • Cython support

Credit: Techgig.com

What’s new in PHP 8 – Part 2(Breaking changes)

As mentioned in previous post What’s new in PHP 8 – Part 1(New features) : this is a major update and thus there will be breaking changes. The best thing to do is take a look at the full list of breaking changes over at the UPGRADING document.

Many of these breaking changes have been deprecated in previous 7.* versions though, so if you’ve been staying up-to-date over the years, it shouldn’t be all that hard to upgrade to PHP 8.

Consistent type errors rfc

User-defined functions in PHP will already throw TypeError, but internal functions did not, they rather emitted warnings and returned null. As of PHP 8 the behaviour of internal functions have been made consistent.

Reclassified engine warnings rfc

Lots of errors that previously only triggered warnings or notices, have been converted to proper errors. The following warnings were changed.

  • Undefined variable: Error exception instead of notice
  • Undefined array index: warning instead of notice
  • Division by zero: DivisionByZeroError exception instead of warning
  • Attempt to increment/decrement property ‘%s’ of non-object: Error exception instead of warning
  • Attempt to modify property ‘%s’ of non-object: Error exception instead of warning
  • Attempt to assign property ‘%s’ of non-object: Error exception instead of warning
  • Creating default object from empty value: Error exception instead of warning
  • Trying to get property ‘%s’ of non-object: warning instead of notice
  • Undefined property: %s::$%s: warning instead of notice
  • Cannot add element to the array as the next element is already occupied: Error exception instead of warning
  • Cannot unset offset in a non-array variable: Error exception instead of warning
  • Cannot use a scalar value as an array: Error exception instead of warning
  • Only arrays and Traversables can be unpacked: TypeError exception instead of warning
  • Invalid argument supplied for foreach(): TypeError exception instead of warning
  • Illegal offset type: TypeError exception instead of warning
  • Illegal offset type in isset or empty: TypeError exception instead of warning
  • Illegal offset type in unset: TypeError exception instead of warning
  • Array to string conversion: warning instead of notice
  • Resource ID#%d used as offset, casting to integer (%d): warning instead of notice
  • String offset cast occurred: warning instead of notice
  • Uninitialized string offset: %d: warning instead of notice
  • Cannot assign an empty string to a string offset: Error exception instead of warning
  • Supplied resource is not a valid stream resource: TypeError exception instead of warning

The @ operator no longer silences fatal errors

It’s possible that this change might reveal errors that again were hidden before PHP 8. Make sure to set display_errors=Off on your production servers!

Default error reporting level

It’s now E_ALL instead of everything but E_NOTICE and E_DEPRECATED. This means that many errors might pop up which were previously silently ignored, though probably already existent before PHP 8.

Default PDO error mode rfc

From the RFC: The current default error mode for PDO is silent. This means that when an SQL error occurs, no errors or warnings may be emitted and no exceptions thrown unless the developer implements their own explicit error handling.

This RFC changes the default error will change to PDO::ERRMODE_EXCEPTION in PHP 8.

Concatenation precedence rfc

While already deprecated in PHP 7.4, this change is now taken into effect. If you’d write something like this:

echo "sum: " . $a + $b;

PHP would previously interpret it like this:

echo ("sum: " . $a) + $b;

PHP 8 will make it so that it’s interpreted like this:

echo "sum: " . ($a + $b);

Stricter type checks for arithmetic and bitwise operators rfc

Before PHP 8, it was possible to apply arithmetic or bitwise operators on arrays, resources or objects. This isn’t possible anymore, and will throw a TypeError:

[] % [42];
$object + 4;

Namespaced names being a single token rfc

PHP used to interpret each part of a namespace (separated by a backslash \) as a sequence of tokens. This RFC changed that behaviour, meaning reserved names can now be used in namespaces.

Saner numeric strings rfc

PHP’s type system tries to do a lot of smart things when it encounters numbers in strings. This RFC makes that behaviour more consistent and clear.

Saner string to number comparisons rfc

This RFC fixes the very strange case in PHP where 0 == "foo" results in true. There are some other edge cases like that one, and this RFC fixes them.

Reflection changes

A few reflection methods have been deprecated:

  • ReflectionFunction::isDisabled()
  • ReflectionParameter::getClass()
  • ReflectionParameter::isCallable()

You should now use ReflectionType to get information about a parameter’s type:

$reflectionParameter->getType()->allowsNull();

If the type is a single type, ReflectionParameter::getType() returns an instance of ReflectionNamedType, which you can get its name from and whether it’s built-in:

$reflectionParameter->getType()->getName();
$reflectionParameter->getType()->isBuiltin();

If the type is a union type however, you’ll get an instance of ReflectionUnionType, which can give you an array of ReflectionNamedType like so:

$reflectionParameter->getType()->getTypes();

Checking whether a type is a union or not can be done with an instanceof check:

if ($reflectionParameter->getType() instanceof ReflectionNamedType) { 
    // It's a single type
}

if ($reflectionParameter->getType() instanceof ReflectionUnionType) {
    // It's a union type
}

Next up, three method signatures of reflection classes have been changed:

ReflectionClass::newInstance($args);
ReflectionFunction::invoke($args);
ReflectionMethod::invoke($object, $args);

Have now become:

ReflectionClass::newInstance(...$args);
ReflectionFunction::invoke(...$args);
ReflectionMethod::invoke($object, ...$args);

The upgrading guide specifies that if you extend these classes, and still want to support both PHP 7 and PHP 8, the following signatures are allowed:

ReflectionClass::newInstance($arg = null, ...$args);
ReflectionFunction::invoke($arg = null, ...$args);
ReflectionMethod::invoke($object, $arg = null, ...$args);

Stable sorting rfc

Before PHP 8, sorting algorithms were unstable. This means that the order of equal elements wasn’t guaranteed. PHP 8 changes the behaviour of all sorting functions to stable sorting.

Fatal error for incompatible method signatures rfc

From the RFC: Inheritance errors due to incompatible method signatures currently either throw a fatal error or a warning depending on the cause of the error and the inheritance hierarchy.

Other deprecations and changes

During the PHP 7.* development, several deprecations were added that are now finalised in PHP 8.