Image Source: https://www.javaassignmenthelp.com/blog/c-vs-c-sharp-find-out-the-most-important-differences/
Image Source: https://www.marketwatch.com/story/googles-alphabet-reorganization-is-only-a-shell-game-2015-08-11

What Is A Shell?

In computing, a shell is a computer program which exposes an operating system’s services to a human user or other program. In general, operating system shells use either a command-line interface (CLI) or graphical user interface (GUI), depending on a computer’s role and particular operation. It is named a shell because it is the outermost layer around the operating system.” (https://en.wikipedia.org/wiki/Shell_(computing)

In simpler terms, a shell is a computer program that presents a command line interface which allows you to control your computer using commands entered with your keyboard. The purpose of the shell is to act as the main user interface for a computer’s operating system. Allowing access to files and system information, the ability to read commands and run other programs, and support for automating repetitive tasks, the shell may look plain and simple on the surface but it’s quite a complex program.

How Does It Work?

The shell, along with most other programs, lives in what is referred to as ‘user space’ on your computer. Also found on your computer, there is area referred to as ‘kernel space’. This is where the kernel and select software lives. The shell program talks to the kernel through system calls, which the user inputs manually through the keyboard or by running a script they have created. Because software found in the user space must go through the kernel before performing any instructions, the kernel acts a safe guard, making sure the shell does not do anything that kernel does not want it too. This is very important because most software found in the kernel space can perform privileged operations such as dealing directly with hardware. So this safe guard helps to prevent malicious commands that could corrupt your system, from being executed.

Manipulating Processes and Managing System Calls

Although C and C# share many similarities they have just as many differences, many of which involve manipulating processes and managing systems calls.

In C you can call the fork() function to duplicate a current process. However, fork() really only works on Unix and Unix-based systems because it is Unix system call. So in order to call it you have to go some system taxing work arounds like installing an open source GNU such as Cygwin.

Now if you wanted to accomplish the same feat on a Windows machine utilizing a shell built in C# it would not be a problem. C# was developed for Windows therefor it has no problem handling system calls in Windows. If we were to look at a shell built in C vs C# there are some other differences that we need to take into consideration

Creating A Shell

While both C and C# are compiled programming languages, C is a procedural programming language, and C# is object-oriented programming language.

Built on only 32 keywords, C is a low level programming language with no garbage collection, therefor developers must take this into account when managing memory.

Using a total of 86 keywords, C# is a higher level programming language and it has garbage collection built in, removing one less thing a developer has to worry about. However, being an object oriented language C# is a larger, and less efficient, in terms of speed, when compared to C.

Overall if you were to build a shell in both languages, the shell built in C would be have the superior speed and performance. Although in terms of the speed of building the shell, C# would be superior. Since the developer does not have to factor in any memory allocation or freeing, the process of building the shell should be far quicker.

Sources: