Tuesday, September 27, 2016

Which programming language should I Start Learning for Automation?

Do I need to be programmer before learning Automation, SDN and NFV technologies: Gave a clear picture that you don’t need to be a programmer to learn these technologies? But knowledge of any basic scripting or programming language is always beneficial for carrier growth. Now the question arises which programming language to select out of the following:-

1. Python
2. XML
4. C/C++
5. Visual Basic
6. Perl
7. TCL
8. Ruby On Rails

Before the selection of any language we should understand that what the common among the languages are. As per my understanding, logic will remain be the same while implementing any of the languages. Secondly, all the languages have common understanding of defining variables, strings, functions, classes, inheritance, conditional statements, for and do-while loops, dictionaries, sockets, importing modules, file opening, error and exception handling. So it would be better if we first select any language and get the understanding of the basics functions. Once it is done, after that it would be very easy to become master in any of the language from understanding perspective. (Please mind that we are network engineers not programmers. The intent is to learn and understand the different puzzles with various buzz words and not to become master). Let the programming masters do their jobs. We will be helping them by extending the support.

Which programming language to select first and why?
I started my journey with C, C++, Visual Basic and Networking. After over period of time I can clearly differentiate among the languages. C is the mother or father of every language. During its writing time, it was designed to be very light. C++ was successor of C. It came with a concept of objects oriented programming. The basic problem with both the languages are platform dependent. That would be the reason it was used to build as base of other programming languages but never ever gain popularity over the web.

Java is widely opted because of its platform independent feature but it has lot of problems at server side. It was mainly a server side language rather than client side.

Python gained popularity in the last few years because of platform independent. Secondly it is very light in weight and have interactive shell too which most of the languages don’t have. It’s an easy to learn language and heavily adopted by every field. It has almost 88000 libraries available which can be used freely by anyone. Now even the lighter python version are also available which are called as PyEz (Python Easy). PyEz makes the code shorter by almost 85%. I have posted My First Step towards Automation: Controlling Junos with Python & PyEZ. Let’s understand how does it works with the help of an example.

A raw python script uses the paramiko library for the ssh connection and you have to define the rpc for show version (get-software-information), then open the socket to the device on the right port (830) and create the transport using that socket as the connection. Once it’s open, you can then send the rpc and then wait for the end of the rpc-reply. Then close the open session, close the transport and then close the socket. This python code is roughly about 50 lines.

The example can be implemented by writing 6 lines in PyEz.

Subsequently you can follow my already written post of My Second Step towards Automation: Install the PyEZ Library and Connect Your Remote Device and My Third Step towards Automation: How to map Junos Commands to PyEZ RPC.

So finally as closing comments I am not expert and can't explain the pros and cons each and every programming language but would suggest to start your learning with Python or PyEz and start writing your first famous “Hello World” program.

People who read this post also read :

No comments: