Wednesday, August 31, 2011

Text editor - Visual basic

Today, let's see the making of our first system software - text editor. We will create it using Visual basic language and Visual Studio IDE. Incase, you don't have Visual Studio, download a free version of Visual Studio or Visual basic express from the below link

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express

I have made it using Visual Studio 2010, so it may be compatible with 2008 edition, but before that I cannot guarantee. Below is the download link for my project. If you know Visual Basic, it's very easy and intuitive to understand the commands and if you have any doubts, please post them as comments

http://www.filefactory.com/file/cd55136/n/Dileepad.zip

It does all the things that a notepad does, along with good exception handling. The only change is that, it uses " Rich text " files, instead of traditional notepad files. And one more thing, it's name is Dileepad

I have tried to implement spell checker functionality in it, by using "Keyoti Rapid spell Desktop", but it's a paid version and since the version expired, I have to remove the functionality. It's just a single one line in Form_Load, that makes the rich tex box we are using, to gain the spell checker functionality. Try to do it, if you couldn't comment, I will help you. The Dileepad looks as the one shown below

Click to enlarge

If you know Visual basic, skip the remaining post.

If you don't know Visual Basic, don't bother yourself, it's one of the easiest languages to learn and with .net frame work, it has become more subtle. Just go through the code and try to understand it. If you got doubts, clarify them by going through the msdn blog. It has hundreds of articles and forums dedicated to Visual Basic. Or alternatively you can post them over here.


I will give some hints for the beginners to grasp the code. Unzip the file. Open Visual Studio. File->open->Project/Solution. Navigate to the unzipped folder. If the unzipped folder's name is dileepad, go to dileepad->dileepad->dileepad and now you must be seeing a folder with the first subfolder as bin. If not  navigate into one more dileepad subfolder. Finally there will be a Visual Studio Project file named "Dileepad" in the same folder which contains "bin" subfolder. Click on it and the whole project get's opened.


Form1.vb is the heart of the system and it contains the main interface of notepad while form2 is just created to tell about the software for "About" or "Credits". Form1.vb contains usable controls that I dragged and dropped from the tool box on the left hand side. And the things that the control does when a user presses it, is presented in the code behind it. Just double click the control and you can see the code behind it. Very simple and easy to grasp. To run the file, just press "F5".


I have two more system software codes to give you, they are of pure C-language and what those softwares are is a suspense for now.

Thursday, August 25, 2011

Operating Systems - Device drivers

You install XP or Vista or windows 7 in any computer, the prime thing that is done, immeditely after installing the operating system is installing of device drivers. Ever wondered what exactly are they ?

" A device driver is a piece of software, that acts as a translator "

You may look at some of my previous posts and there I told you, a compiler is a translator. So, a device driver converts one language code to another language code, hence's it's also a typical compiler.


Consider, we insert a pendrive, the first thing that the operating system does is check for the device driver. If it's not present, then the OS installs it, you can see the pop up on the left bottom corner showing "Installing device driver software" and when it's successfully installed " Your pen drive is ready to use" pops. The reason, why the operating system first checks and does this, is because of the fact that device drivers helps it, to talk with the hardware of the device. Consider the computer passes a high level instruction "copy file - mog.avi". Now our intelligent device driver, converts this into a language that the harware controller that interfaces the pendrive with the computer understands and the task gets done.

Before the invention of device drivers, the task that needs to be done, needed to be partitioned and carried onto different hardware, since there is no communication between them. But now, with a translator, the task can be done smoothly.

Almost every piece of hardware, that is connected to the mother board has a device driver software and they get installed as soon as they are connected. And now a days, most of the device drivers, come bundled with operating system. Windows 7 has almost removed the need for all drivers, except the wifi, and one or two others. And Ubuntu from the beginning had no need for them except the wifi and graphics drivers.

Tuesday, August 23, 2011

Operating Systems - 3

In case you missed part-1 and 2, below are the links for them

http://systemspro.blogspot.com/2011/06/operating-systems-win-or-loss-of.html

http://systemspro.blogspot.com/2011/06/operating-systems-2.html

Also, the code for different problems related to operating systems, that you come across in your under graduate studies, is made available in the link below

http://operatingsystemscode.blogspot.com/

Today, let's discuss about Kernel

Kernel is a piece of software, that generally comes bundled with operating system and is more closer to the hardware. It provides an abstract layer for the user programs to interact with the hardware and allocate apropos resources to them. In short, it is the heart of any operating system.

Windows operating systems use Windows NT Kernel which was developed and released along with NT based OS in the year 1993, that made windows, a more generic player in the operating systems field. It's success was so huge, that Microsoft never dared to remove "NT" from it's OS names. But in 2000, with the release of Windows 2000, it dropped NT, but gave it a tagline "Built on NT technology". With XP, it dropped that tag also. Presently windows operating systems like Windows 7 and Windows Vista use a hybrid version of the same kernel.

Linux distributions like Ubuntu, Red hat use Linux Kernel, that was first developed by Linus Torvalds in 1991. No one thought that a college kid could invent it. Even the professor who taught him, damned it. And the remaining story, need not be told..

Another Linux kernel called "Hurd" was in the development stages, before 1991, but it  never reached it's completion due to the invention of Linux

Monday, August 22, 2011

Internet bubble or dot com bubble

Today, let's speak of a partly off beat topic.

Before I start, there is a common place, where this dot com bubble happened. Many businesses were born in that area. I think it's some place in california, I am not sure. So for time being, I will use "silicon valley". 

Everyone tells you, that internet bubble got blasted in the early 2000. But no one tells you the reason, I will tell you.

" Netscape "

You may not have heard of this name, but 16 years ago (1995), it captured the whole browser market share - 100 %
I will not tell you the story, after how Microsoft introduced IE, sold it along with their OS and did some other secret things, until Netscape's market share fell to 10 % by 1999 and eventually how the company got closed.

The inventors of netscape, were just a bunch of kids from an American university, who were funded by a person, taking them to silicon valley and eventually got huge profits from it.

Ebay (1997), the same story, kid going college, starts an acutioning site, people throng to it. A venture captalist invests and finally gets profits in bulk. 
Amazon is some what a different story. It was started and run by a completely planned and business minded individual, during the Ebay time.

Amazon and Ebay, when they went for IPO, made huge profits. 
One more common thing - Both were websites. 

This has started an enormous competition among the venture capitalists, who would invest more and become billionaires overnight. And college kids, started coming to silicon valley, envisioning a future, with as simple as a website.

Yahoo's share rose like never before and a lot of websites were born, and the bubble started growing. The capitalists, in liu of the profits, forgot the term "intelligent investing" and started believing every kid, who comes to them, with a website. 

And suddenly the bubble got blasted. A lot of money evaporated, a lot and lot in stock........

This is from a single documentary I remember, from a series of four documentaries I have seen. Accurate information is available in that, and I have shared the Amazon link for you of the documentary for you. They are really excellent.

Don't forget to hit the "+1" below this post

Saturday, August 20, 2011

Compilers - 4

This is the last post on compilers. Today let's take a careful look on how GCC compiler works.

GCC Compiler :
Before I start, let us look back into how GCC came into existence. GCC stands for GNU C- compiler. It is a compiler, developed as part of the GNU project.

What is GNU ?

GNU stands for GNU is Not Unix. It is a project started by Richard Stallman, to create a Unix like operating system in 1985. In those days, the source of the Unix is proprietary, so they thought of making a Unix like operating system, with it's source code open. Before the creation of the OS itself, they envisioned how it might be and parallely started creating software for the same. One of the brain child of GNU project, that came into existence during that time is "GCC".

A GCC compiler has the following steps
1. Preprocessing is done - macro expansion
2. The expanded source program, is converted into an assembly language program for the underlying machine architecture
3. The assembly language is later converted into a machine language and stored in the form of an object file
4. Finally, the object file is linked with libraries to form the final executable.

Harry Potter and the Deathly Hallows - Part 1


Also, during any stage, you can stop the execution and see how the output of each stage looks like. For the detailed commands, you need to do so, follow this link

Friday, August 19, 2011

Compilers - 3

Ever wondered, how a .net compiler works. I will show you how

.NET compiler :
.net is the framework designed by Microsoft for their windows based operating systems. It gives a great edge for software developers of windows with it's software Visual Studio, the best in class IDE that is available, till date. The IDE is so flexible and intuitive, that even a person with no knowledge of a single programming language, can design softwares in minutes.

Unlike netbeans, the .net framework allows us to use the language of our choice in designing software. Two of the famous languages in .net community are Visual basic and Visual C#. But support for other languages such as Visual F# etc., is also available.

Enough talking, let's see how the program you write, get's compiled and finally runs.

We write a program in the language of our choice in the IDE of Visual Studio. Now in the underlying architecture, it contains the compilers of different languages. Consider we have written the program in Visual C#. The corresponding Visual C# compiler takes the responsibility of compiling the program we have written into a language that is well understood by .net frame work called Microsoft Intermediate Language (MSIL) along with some meta data.

The MSIL and metadata are wrapped into a Portable Executable (PE) and are made available for the later stages.The Just in time (JIT) compiler that is present below it, doesn't compile the whole code into native code, at a time, but compiles it on demand during the execution of code. This gives the justification for it's name Just in time


Tommorrow let's see the working of a GCC compiler

Thursday, August 18, 2011

Compilers - 2

Different types of compilers
Depending on the number of stages, compilers are divided into two types

1.One-Pass compiler : This compiler does the compilation process in a single stage. Faster, but not a good one for development.
eg: PASCAL compiler

2.Multipass compiler : This compiler takes more than one stage. Slower, but very good for development
eg: GCC

Depending on their functionality, the following are the different types of compilers

1. Threaded code compiler ( interpreter), used in FORTH. It replaces the given strings in the source with the binary code and gives an error, if it cannot do so

2. Stage compiler, that compiles the assembly language of a theoretical machine, like some Prolog implementations. This Prolog machine, is also known as the Warren Abstract Machine (WAM)

3. Incremental compilers, used in LISP systems, that do a step by step compilation of individual functions

4. Just-in-time compiler, used by small talk and Java systems

5. A retargetable compiler, that can be relatively be modified with ease to generate code for different CPU architectures. All the cross compilers such as GCC, are examples of this type

6. A parallelizing compiler, that converts a serial input program, into a form suitable for efficient execution on parallel computer architecture. Example is the most famous "Open MP compiler"


Tommorrow, let's see the details of two famous compilers, GCC and .net in a step by step manner

Compilers - 1

Today, let's talk about, one more interesting topic called compilers. The def goes like this

"A compiler is a program, that converts a source program in one language into a target program in another language"

The source program may be in any high level language like C, C++ or Java while the target program may be a native code like byte code or machine code that can be understood by the computer.

If you want to design a compiler in the future, you definitely should know about the Bible of Compiler Design. The book is called "Compilers : Principles, Techniques and Tools" by the authors "Aho, Ullman". You can check out the Amazon link on the left side, if you are interested.

For today let's see the difference between interpreter and compiler.

"An interpreter is a program that simply replaces the code present in the source program with the available machine code"

Examples of interpreter include the famous "Basic" language interpreter. In that, when ever you do a mistake, while typing the code, you will immediately get an underline, even before you compile the code, telling, you are wrong and some IDE's (Integrated Development Environment) provide suggestions also.

If you are familiar with the SQL (Structured Query Language), it is similar to the update command. Compiler also does the same thing, replacing the code. So what's the difference ?

The difference is that a compiler is generally capable of translating the whole code at a time, while the interpreter does this line by line. Also, the interpreter takes care of mainly syntax and logical errors, while the compiler is capable of reporting runtime errors also, along with the former. For rapid error checking, interpreter is the best option, since most of the errors can be corrected before running the program, but this alone cannot save us from errors. That is the reason, why languages like "Visual Basic" or "Visual C#", make use of both compiler and interpreter for efficient writing of code and efficient run time error checking.

Tommorrow, let's see different types of compilers and their examples.

Thursday, August 11, 2011

Linker

I will try to be as brief as possible about this topic

"A linker is a program that links the object files generated by the compiler and makes them into a single executable file"

Simple and straight forward. But let us discuss, some what more ....

 Consider you are installing Adobe Photoshop or Vice City or NFS most wanted game or any other bigger program. By default, the installer installs a lot of files in the Operating systemdrive:\\programfiles\Adobe\Adobe Photoshop CS3 for Photoshop and in similar folders for others.

Now as per our definition, since a single executable can be made with a linker, why all the remaining object files ( Files ending with .dll .....)

This is due to the fact that the whole program's size will be of some 2-4 GB. If all of it is loaded at a time, the RAM may get overloaded, leaving the system in the busy state. So some intelligent people found a solution to this and implemented as above, naming the new technology as "Dynamic Linking"

Dynamic linking, takes advantage of the fact that the program in execution, doesn't need all the related libraries at a time, but needs them when the user enters a specific area or clicks a button. So it just appears that all the files are loaded when the game starts, but the DLL's (Dynamic Link Libraries) are loaded on demand by the game, so that a lot of RAM is saved.

That's all to say about linker.

I err and I guess most of you do the same, when it comes into using of Programme and Program


Actually Programme is a word present in British English, but absent in American. Also Programme refers to a concert or TV show strictly while Program strictly refers to our Computer science program or software. So be careful and don't go into ambiguity while using these two words