Is Powershell a Programming Language?
Originall Posted here: https://itblogpros.com/is-powershell-a-programming-language/
Is Powershell a Programming Language? Yes it certainly is, no matter what anyone tells you. Many people that work in dev environments might scoff at the idea that your Powershell creations, are anything more than scripts, but they are dead wrong, and we’ll flesh out the details in our blog post as to why that is the case. But if you are here for a yes or no answer, then here it is: yes Powershell is a programming language! Furthermore, Powershell is an incredible tool that can can do just about anything. With Powershell you can perform basic command line queries just like you can from the Windows built in CMD shell, or you can build full blown applications with Windows Forms, your imagination, and Googling skills, are the only limitations.
In this article we want to go through some of the most asked questions regarding Powershell and its capabilities, and if you can even consider it to be a programming language in the first place. I have worked with Powershell for many years, and I haven’t even scratched the surface of its capabilities, so I’m sure that we will both learn something on our journey as we discover more about this fantastic tool. Today we hope to answer the burning question: Is Powershell a Programming Language?
Why Learn a Programming Language in the First Place?
It’s a fair question, what’s the point in trying to learn how to program anyway, its so hard and you’ll probably never even use it in your day job working in IT. You are sadly mistaken if you think that is true. It is actually easier than ever to get into a programming language, regardless of what you are doing.
There has never been so much free and detailed information available to us like there is presently thanks to Google (most used website in the world) and YouTube (second most visited website in the world) You can literally be set up and writing your first “Hello World” app in less than an hour if you find a course that you like.
Maybe you have your eye on climbing the ladder in your career, and you think that something in the DevOps field would be something that you would like to get into. Top Programming Languages for DevOps at the moment are Golang, Python, Ruby, C#… The list goes on and on. (Notice any omissions there?)
There are tons of reasons to learn how to write a computer application. Maybe you have always wanted to build a web application for your department, or you have dreams of creating a hugely successful mobile game that you can retire on, or you would like to automate your daily tasks so that you can watch more cat videos while meeting all your work commitments. All of these things are possible.
What is a Programming Language?
Before we can define Powershell as a language or a scripting environment, we should probably find out what a programming language is in the first place. Simply put, a programming language is a series of instruction sets that interact with the rest of your operating system.
You can think of these instructions as a way to translate what we humans want the computer to do, without us having to learn advanced assembly languages or programming in low-level machine code like hex or binary (although there are some people that can and do this with no problem, we salute you!)
There are different kinds of programming languages but we’ll just give them a mention:
- Procedural Programming Language: This uses code in a linear way in steps. This means that the application that is created needs to run from start to end and then complete when done, or be canceled half way through if there are issues.
- Functional Programming Language: This uses symbolic computation representations and is not entirely dissimilar to mathematical functions.
- Object-Oriented Programming Language: This language type was designed to contain both data in the form of attributes and properties, as well as functions that work together.
- Scripting Programming Language: Scripting languages don’t need a compiler to run, instead they use something called an interpreter. Scripting uses preexisting commands and functions to accomplish tasks, although the logical thought processes are similar to ‘standard’ programming.
- Logic Programming Language: Logic programming languages use logic (surprise) and inference to arrive at the results of their operation.
Those are some pretty dry explanations, but I think we have pretty much covered the most popular programming language types, and briefly what each one is about. Now we need to see what Powershell is all about, and, is Powershell a Programming Language?
Powershell in a Nutshell (See what I did there?)
Before Powershell, there was VB Script in the world of Microsoft Windows environments. You can do a lot with VB Script, but there are probably equal measures of things that you can’t do with it in 2021. Powershell was envisioned as a tool that would leverage the best parts of the .Net Platform and use some of the integrated functionality that that would entail.
Jeffery Snover, the inventor of PowerShell actually went into great detail in his Monad Manifesto which he wrote in 2002. It is a fascinating read and it clearly outlines his vision for the product that would become Powershell.
Powershell has grown in leaps and bounds in the nearly 20 years since its inception, and the maturity of the product is apparent to all that use it and rely on it to get the job done on a daily basis, regardless of what it is. There is a vast gallery of cmdlets that are being created and updated to give you an ever growing tool set that is unbelievable flexible and powerful.
Well, Is Powershell a Programming Language or Not!?
So, where does Powershell fit into all of this? You might have guessed by now that Powershell actually fits into multiple categories. Purists will brush off the idea that Powershell is a legitimate programming language, and I can see where they are coming from.
Powershell relies on system hooks in the Windows operating system to complete a lot of its built in commands, or cmdlets as they say in the Powershell-o-sphere (I made that up, can you tell?) Each of these cmdlets can perform very useful, or in some cases, very powerful operations.
Powershell uses objects to sent variables and data down the pipe, so in that sense it shares many of the Object Oriented features that we see in OOPLs. Many people consider Powershell to be a scripting language, which lets face it, it is in many respects. However it is also capable of operating like a legitimate application. Like Python and so many other languages you can write scripts that make is of:
- loops for continued operations
- foreach , for data processing
- while for conditions
- if/else statements
- so much more
All of these features allow you to make some pretty powerful applications that can be run as Scheduled Tasks in Windows, compiled as .EXE files for easy execution, or run as Windows Services in the background. I do all three on a regular basis an I can honestly say that I have saved myself months of manual tasks and the praise of my fellow colleagues and managers. Only kidding, nobody really notices, but I do.
In all seriousness, there is a ton that Powershell can do for you, and not only at the office. I will be releasing a multipart series that details how I created a basic Winform application for my mom who is in her 70s. This application allows her to switch mail server settings wherever she is in the world (when traveling isn’t restricted by the current global situation we are all struggling with) with just a few mouse clicks.
I hope that this little application will help inspire you to build something similar if you have never tried to write anything before, and maybe you might have fun while doing it. Watch this space and be sure to check in regularly. If you’d like to checkout our first Powershell blog post about checking your installed Powershell version then head on over to our blog section and read this article next.
So there we have it, yes Powershell is a programming language, but it wont be the main one that you use in a dev role. The chances are good that you might use a few powerful scripts on the backend of your applications to perform some tasks but the reality is that there are some performance gains to be had when using a compiled application that runs on an operating system, as opposed to one that hooks into the shell of the Windows operating system.
We hope you have found this little foray into the world of programming languages interesting and educational, to a point. I don’t pretend to be an expert in any of the fields that I have mentioned today, but I am an enthusiast that wants to learn, I think that is the main thing that you should take away from topics like programming, scripting and automation — you must have a desire to learn new skills and develop as you go.
It is that kind of curiosity that will ultimately help you to learn more about the systems that you work with and build something great that adds value and makes your life that much easier. And as for the question, ‘Is Powershell a Programming Language?’, I think it’s safe to say that yes, it certainly is!