General Talks

Dive Deep Into Python Vs Perl Debate – What Should I Learn Python or Perl?

Dive Deep Into Python Vs Perl Debate &-8211; What Should I Learn Python or Perl? &-8211; this Article or News was published on this date:2019-05-28 17:15:56 kindly share it with friends if you find it helpful

Often when a new programming language is introduced, there is a debate which starts amongst some of the genius minds in the industry wherein the language is compared with the one already spreading its roots. A kind of buzz often spreads in the IT industry and the new one is often compared on every aspect may it then be features, syntax or core cpu and memory aspects including GC time and all, with the existing one of its kind.

Many examples of such cases can be picked up and investigated from past including the debate between Java and C-, C++ etc. One of such case which drew a significant amount of attention was the debate between two languages which came out one after the other in short span i.e. Python and Perl.

Whereas Python was invented initially as a successor to ABC language merely as a “hobby” programming project (which would attract Unix/C hackers) for the author who named it after the series of his biggest star Monty Python.

Suggested Read: Getting Started with Python Programming and Scripting in Linux

Perl was just nearly around 2 years earlier as a Unix scripting language which intended to make report processing easier. It was a mixture of combination of many languages including C, awk, sed and shell script.

The thing which is worth noting is that these languages which evolved of different intentions are being constantly compared, which has made me study and figure out the reasons, of which some important ones are listed as below:

  1. Both targeted Unix Operating System, one for hackers and other to process reports.
  2. Both are object oriented (Python being the more) and interpreted, with one being strongly typed and clear when it comes to coding i.e. Python, and other allowing ugly typing with braces for representing a block i.e. Perl
  3. Both are opposite in principle when we say, Perl has many ways of doing a single task while python focuses on one and only one way of doing things.

Python vs Perl – Features Compared

Let’s dive deep into this debate and try to figure out the overall aspects where these two languages differentiate with one another. Also let’s try finding out the source of truth for many cliches which can be heard in the industry saying “Python is perl with training wheels” or “Python is similar to perl but different” so that we can try and conclude with an accurate solution to this never-ending debate.

1. Python’s Clean vs Perl’s Complex Syntax

Python takes huge advantage over Perl when it comes to code readability. Python’s code is lot more cleaner to understand than that of Perl even when reading code after years.

With indentation representing the block of code, and proper structuring, Python’s code is a lot more cleaner. On other hand Perl borrows its syntax from various programming languages like: C, shell scripting and even awk and sed filters when it comes to regular expressions.

Suggested Read: 15 Useful ‘sed’ Commands for Daily Linux System Administration Tasks

Apart from this, with ‘{‘ and ‘}’ representing a block of code and unnecessary addition of ‘;’ at end of each line, code in Perl could become a problem to understand if you read it after months or years because of its allowance of ugly scripting.

2. Perl’s Built-in Vs Python’s 3rd Party Regex and OS Operations Support

Perl language borrows its syntax from C and other UNIX commands like sed, awk etc. due to which it has way powerful and built in regex support without importing any third-party modules.

Also, Perl can handle OS operations using built-in functions. On the other hand Python has third-party libraries for both the operations i.e. re for regex and os, sys for os operations which need to be ensured before doing such operations.

Perl’s regex operations have ‘sed’ like syntax which makes it easy not only for search operations but also replace, substitute and other operations on string can be done easily and swiftly than python where a person needs to know and remember the functions which cater to the need.

Example: Consider a program to search for digit in the string in Perl and Python.

Python
Import re
str = ‘hello0909there’
result = re.findall(‘d+’,str)
print result
Perl
$string =  ‘hello0909there’;
$string =~ m/(d+)/;
print “$& n”

You see the syntax for Perl is way easy and inspired by sed command which takes advantage over Python’s syntax which imports third party module ‘re’.

3. Python’s Advanced OO Programming vs Perl’s One Liners

One feature where Python overshadows Perl is its advanced OO programming. Python has extensive object oriented programming support with clean and consistent syntax while object OOP in Perl being outdated where package is used as a substitute for classes.

Suggested Read: Getting Started with Python Django Web Framework

Also, writing OO code in Perl will add a lot more complexity to the code, which would eventually make code difficult to understand, even subroutines in Perl are very difficult to program and eventually difficult to understand later.

On other hand Perl is best for its one liners which can be used on command line for performing various number of tasks. Also, Perl code can eventually do various tasks in less lines of code than python.

A short code example of both languages which highlights Perl ability to do more in less LOC:

Python
try:
with open(“data.csv”) as f:
for line in f:
print line,
except Exception as e:
print "Can't open file - %s"%e
Perl
open(FILE,”%lt;inp.txt”) or die “Can’t open file”;
while(FILE>) {
print “$_”; } 

Pros and Cons – Python vs Perl

In this section we will discuss about Pros and Cons of Python and Perl.

Python PROS:

  1. Has a clean and elegant syntax which makes this language a great choice as first programming language for novices who want to have a hands-on on any programming language.
  2. Has very advanced and inherent OO Programming, also thread programming in Python is way better than Perl.
  3. There are many application areas where Python is preferred and even it outperforms Perl. Like: Perl is preferred for CGI scripting but now a days Python’s Django and web2py like web scripting languages are becoming more popular and have huge attraction from the industry.
  4. Has several SWIG wrappers for different programming languages like: CPython, IronPython and Jython and development of these has preceded the development of SWIG wrappers for Perl.
  5. Python code is always well indented and easy to read and understand even if you are reading someone else’s code or even your code after years.
  6. Python is good for various applications like: Big Data, Infra Automation, Machine Learning, NLP etc, is has huge support of active communities because of being Open Source.

Python CONS:

  1. There are few areas where execution in Python is usually slower than that of Perl including: regex and string based operations.
  2. Sometimes it is difficult to get the type of variable in Python as in cases of very large code, you have to go till the end to get type of the variable which gets hectic and complex.

Perl PROS:

  1. Perl has powerful one liners and even ensures UNIX piping like syntax which can be used on command line to perform various tasks, also it is influenced by Unix and its command line programming so integrates many UNIX influenced commands in its coding.
  2. Perl is known for its powerful regex and string comparison operations as it is influenced by sed and awk like powerful UNIX tools. In case of regex and string operations like: substitution, matching, replacement, Perl outperforms python which would take few lines of code to achieve the same. Also many file I/O operations, exception handling are done faster on Perl.
  3. When it comes to a language for report generation, Perl has always been in the fame since its introduction as one of the main reasons for author to develop language like Perl was for report generation.
  4. Many application areas where Perl finds its use are Network Programming, System Administration, CGI Scripting (here Python is overcoming Perl with Django and web2py) etc.
  5. It is easy to identify type of variable with the symbols that Perl uses before them, like: ‘@’ identifies arrays and ‘%’ identifies hashes.

Perl CONS:

  1. Perl has very complex code which makes it difficult to understand for a novice. Subroutines, and even other symbols like: ‘$`’, ‘$&’ etc are hard to understand and program for a less experienced programmer. Also, Perl code when read would be difficult and complex to understand unless you have a quality experience.
  2. OO Programming in Perl is a bit out of date as it has never been known for OO programming and many operations like: threading is also less pronounced on Perl.

Conclusion

As seen above where both languages are good on their regard as per the applications they target, Python takes a bit of advantage over Perl as a first choice for a novice due to its clean and easy to understand code, where as on other hand Perl outperforms Python when it comes to string manipulation operations and some advanced one liners for UNIX like OS and various other operations it is known for.

So at the end it’s all upon the specific area you target. All your comments on this article are welcome and would request you to give your views on the topic if according to you Python wins or Perl.

5 Reasons To Install Linux Today

5 Reasons To Install Linux Today &-8211; this Article or News was published on this date:2019-05-28 17:02:26 kindly share it with friends if you find it helpful

If you are reading this article, chances are you are a new or prospective Linux user. Or perhaps you’re not – and are curious as to what I consider the 5 top reasons why someone would want to install Linux today.

Either way, you are welcome to join me as I do my best to explain. If you bear with me enough to reach the end of this post, feel free to add your own voice using the comment form below.

Suggested Read: 5 Things I Dislike and Love About GNU/Linux

DISCLAIMER: The reasons below are not listed in any specific order of importance. That said, you can read them from top to bottom or the other way around – your choice.

Reason -1 – Linux is Free

In the Linux ecosystem, the word “free” has two meanings: 1) Free as in freedom, and 2) Free as in beer. The first one refers to the freedom of doing whatever you wish with the operating system (for example, personal or commercial use).

The second is indicative of the fact that most (99%) Linux distributions (the “flavors” of Linux, so to speak) can be downloaded and used on as many computers at absolutely no cost.

Suggested Read: Top Most Popular Linux Distributions of 2016

Commercial distributions are sometimes preferred on enterprise environments due to the available support contracts offered by the companies behind them. Red Hat, Inc. with its superstar Red Hat Enterprise Linux is just an example.

Linux is FreeLinux is Free

Linux is Free

Reason -2 – Linux can Bring old Hardware back to Life

Yes, you read that right. If you have an old computer gathering dust because it no longer can afford the system requirements of other operating systems, Linux is here to save your day. And I speak out of experience on this: my first computer (a high school graduation present my mother gave me near the end of 2000) has now been running as a home server for 5 years now – always with the latest Debian stable release.

Suggested Read: 6 Linux Distributions to Try on Old PC’s and Laptops

Linux is FreeLinux Supports Old Hardware

Linux Supports Old Hardware

Reason -3 – Linux is the Best Tool to Learn How Computers Work

Even for new users, it is relatively easy to access information about and interact with the computer’s hardware. With command-line tools such as dmesg (which lists messages from the kernel) and a little patience, you can easily learn what happens internally since you press the power button until you get a fully-usable operating system. And that is just one example.

Linux is FreeLearn Linux

Learn Linux

Reason -4 – Linux is the Best Tool to Get Started with Programming

I always say that I would have loved to have been introduced to Linux much earlier than I was. When the operating system is installed, it includes all the necessary tools to get started with Python programming. One of the most popular object-oriented programming languages in use today, Python is used to introduce computer science majors to programming in several top-notch universities.

Linux is FreeLearn Linux + Python Programming

Learn Linux + Python Programming

Reason -5 – Lots (and I mean LOTS) of Free world-class Software

I know, I know. This item is closely related to -1 but I decided to make it a separate one. Why? Because it highlights the fact that the software available for Linux today is mostly made possible by a large army of volunteers.

Yes – people who write outstanding software without making a quarter out of it. In some cases, there are companies providing the funds for the development and maintenance of the software.

Suggested Read: 20 Free Open Source Software I Found in Year 2015

The operating system is so stable that they want to make sure their software runs on it. That is why large companies make substantial contributions (in terms of donations or manpower) to the Linux ecosystem.

Linux is FreeFree Open Source Software

Free Open Source Software

Summary

Thank you for taking the time to read this post! Please note that I’ve done my best to describe the reasons I would give to someone considering using Linux for the first time.

If you can think of other reasons not present in this article, feel free to share them with our community using the comment form below.

6 Reasons Why Linux is Better than Windows For Servers

6 Reasons Why Linux is Better than Windows For Servers &-8211; this Article or News was published on this date:2019-05-28 16:38:24 kindly share it with friends if you find it helpful

A server is a computer software or a machine that offers services to other programs or devices, referred to as “clients“. There are different types of servers: web servers, database servers, application servers, cloud computing servers, file servers, mail servers, DNS servers and much more.

The usage share for Unix-like operating systems has over the years greatly improved, predominantly on servers, with Linux distributions at the forefront. Today a bigger percentage of servers on the Internet and data centers around the world are running a Linux-based operating system.

Read Also: 5 Reasons to Install Linux Today

Just to make you further understand the power of Linux in driving the Internet, companies such as Google, Facebook, Twitter, Amazon and many others, all have their servers running on Linux-based server software. Even the world’s most powerful supercomputer runs on a Linux-based operating system.

There are a number of factors that have contributed to this. Below, we have explained some of the major reasons why Linux server software is better than Windows or other platforms, for running server computers.

1. Free and Open Source

Linux or GNU/Linux (if you like) is free and open source; you can see the source code used to create Linux (kernel). You can check the code to locate bugs, explore security vulnerabilities, or simply study what that code is doing on your machine(s).

Additionally, you may easily develop and install your own programs into a Linux operating system because of numerous available programming interfaces you need. With all the above features, you can tailor a Linux operating system at its most basic levels, to suit your server needs unlike Windows.

2. Stability and Reliability

Linux is Unix-based and Unix was originally designed to provide an environment that’s powerful, stable and reliable yet easy to use. Linux systems are widely known for their stability and reliability, many Linux servers on the Internet have been running for years without failure or even being restarted.

The question is what actually makes Linux systems stable. There are many determinants which include management of system and programs’ configurations, process management, security implementation among others.

In Linux, you can modify a system or program configuration file and effect the changes without necessarily rebooting the server, which is not the case with Windows. It also offers efficient and reliable mechanisms of process management. In case a process is behaving abnormally, you can send it an appropriate signal using commands such as kill, pkill and killall, thus dealing away with any implications on the overall system performance.

Linux is also secure, it highly restricts influence from external sources (users, programs or systems) that can possibly destabilize a server, as explained further in the next point.

3. Security

Linux is without doubt the most secure kernel out there, making Linux based operating systems secure and suitable for servers. To be useful, a server needs to be able to accept requests for services from remote clients, and a server is always vulnerable by permitting some access to its ports.

However, Linux implements a variety of security mechanisms to secure files and services from attacks and abuses. You can secure services using programs such as a firewall (for example iptables), TCP wrappers (to allow and deny service access), and Security Enhanced Linux (SELinux) which helps to limit the resources a service can access on a server.

Read Also: 5 Reasons Why I Hate Gnu/Linux

SELinux ensures for instance that a HTTP server, FTP server, Samba server, or DNS server can access only a restricted set of files on the system as defined by file contexts and allow only a restricted set of features as defined by Booleans.

A number of Linux distributions such as Fedora, RHEL/CentOS, and a few others ship in with SELinux feature included and enabled by default. However, you can disable SELinux temporarily or permanently, if need be.

All in all, in Linux, before any system user/group or program accesses a resource or executes a file/program it must have the appropriate permissions, otherwise any unauthorized action is always blocked.

4. Flexibility

Linux is so powerful and flexible. You can tune it to meet you server needs: it allows you to do whatever you want (if possible). You can install a GUI (graphical user interface) or simply operate your operate your server via a terminal only.

It offers thousands of utilities/tools which you can choose from to do such things as perform system start up and manage services, add users, manage networking and disks, install software, monitor performance and generally secure and manage your server. It also enables you to choose either to install binary files or build programs from source code.

One of the most powerful standard programs present in Linux is the shell, is a program that provides you with a consistent environment for running other programs in Linux; it helps you interact with the kernel itself.

Importantly, the Linux shell provides practical programming constructs that let you make decisions, execute commands repeatedly, create new functions/utilities/tools, and automated daily server administration tasks.

Basically, Linux gives you absolute control over a machine, helping you to build and customize a server just the way you want (where possible).

5. Hardware Support

Linux has a rock-solid support for a mix of computer architectures, on both modern and moderately old hardware. This is one of the most significant factors that make Linux better than Windows for servers, that is if you have a small budget for hardware acquisition.

Linux remarkably supports relatively old hardware, for example the Slackware Linux site is hosted on Pentium III, 600 MHz, with 512 megabytes of RAM. You can find the list of supported hardware and related requirements for a specific distribution from their official websites.

6. Total Cost of Ownership (TCO) and Maintenance

Finally, the total cost of owning and maintaining a Linux server is lower compared to a Windows server, in terms of licensing fees, software/hardware purchase and maintenance costs, system support services and administrative costs.

Unless you are running a proprietary Linux distribution such as RHEL or SUSE server Linux which require subscription, for you to receive premium support and services, you will encounter affordable costs while running a Linux server.

Studies by Robert Frances Group (RFG) and similar companies, have in the recent past found Linux to be less expensive in a typical server environment comparable to Windows or Solaris, notably for web deployments.

Read Also: 10 Best Linux Server Distributions of 2017

In Conclusion

Linux has today become a strategic, efficient and reliable platform for business systems at many small, medium to big companies. A larger percentage of servers powering the Internet run on a Linux-based operating system, and this has been attributed to the above key reasons.

Are you using Linux on your servers? If yes, tell us why you think Linux beats Windows or other platforms for servers, via the comment form below.

Why I Find Nginx Practically Better Than Apache

Why I Find Nginx Practically Better Than Apache &-8211; this Article or News was published on this date:2019-05-28 16:35:25 kindly share it with friends if you find it helpful

According to the latest web server survey by Netcraft, which was carried out towards the end of 2017, (precisely in November), Apache and Nginx are the most widely used open source web servers on the Internet.

Apache is a free, open-source HTTP server for Unix-like operating systems and Windows. It was designed to be a secure, efficient and extensible server that provides HTTP services in sync with the prevailing HTTP standards.

Ever since it’s launch, Apache has been the most popular web server on the Internet since 1996. It is the de facto standard for Web servers in the Linux and open source ecosystem. New Linux users normally find it easier to set up and use.

Nginx (pronounced ‘Engine-x’) is a free, open-source, high-performance HTTP server, reverse proxy, and an IMAP/POP3 proxy server. Just like Apache, it also runs on Unix-like operating systems and Windows.

Well known for it’s high performance, stability, simple configuration, and low resource consumption, it has over the years become so popular and its usage on the Internet is heading for greater heights. It is now the web server of choice among experienced system administrators or web masters of top sites.

Some of the busy sites powered by:

  • Apache are: PayPal, BBC.com, BBC.co.uk, SSLLABS.com, Apple.com plus lots more.
  • Nginx are: Netflix, Udemy.com, Hulu, Pinterest, CloudFlare, WordPress.com, GitHub, SoundCloud and many others.

There are numerous resources already published on the web concerning the comparison between Apache and Nginx (i really mean ‘Apache Vs Nginx’ articles), many of which clearly explain into detail, their top features and operations under various scenarios including performance measures in lab benchmarks. Therefore that will not be addressed here.

I will simply share my experience and thoughts about the whole debate, having tried out Apache and Nginx, both in production environments based on requirements for hosting modern web applications, in the next section.

Reasons Why I Find Nginx Practically Better Than Apache

Following are reasons why I prefer Nginx web server over Apache for modern web content delivery:

1. Nginx is Lightweight

Nginx is one of light weight web servers out there. It has small footprints on a system compared to Apache which implements a vast scope of functionality necessary to run an application.

Because Nginx puts together a handful of core features, it relies on dedicated third‑party upstream web servers such as an Apache backend, FastCGI, Memcached, SCGI, and uWSGI servers or application server, i.e language specific servers such as Node.js, Tomcat, etc.

Therefore its memory usage is far better suited for limited resource deployments, than Apache.

2. Nginx is Designed for High Concurrency

As opposed to Apache’s threaded- or process-oriented architecture (process‑per‑connection or thread‑per‑connection model), Nginx uses a scalable, event-driven (asynchronous) architecture. It employs a liable process model that is tailored to the available hardware resources.

It has a master process (which performs the privileged operations such as reading configuration and binding to ports) and which creates several worker and helper processes.

The worker processes can each handle thousands of HTTP connections simultaneously, read and write content to disk, and communicate with upstream servers. The helper processes (cache manager and cache loader) can manage on‑disk content caching operations.

This makes its operations scalable, and resulting into high performance. This design approach further makes it fast, favorable for modern applications. In addition, third‑party modules can be used to extend the native functionalities in Nginx.

3. Nginx is Easy to Configure

Nginx has a simple configuration file structure, making it super easy to configure. It consists of modules which are controlled by directives specified in the configuration file. In addition, directives are divided into block directives and simple directives.

A block directive is defined by braces ({ and }). If a block directive can have other directives inside braces, it is called a context such as events, http, server, and location.

http {
	server {
		
	}
}

A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;).

http {
	server {
		location / {
				
				-- this is simple directive called root
			   	root  /var/www/hmtl/example.com/;

		}
		
	}
}

You can include custom configuration files using the include directive, for example.

http {
	server {

	}
	-- examples of including additional config files
	include  /path/to/config/file/*.conf;
	include  /path/to/config/file/ssl.conf;
}

A practical example for me was how I managed to easily configure Nginx to run multiple websites with different PHP versions, which was a little of a challenge with Apache.

4. Nginx is an Excellent Frontend Proxy

One of the common uses of Nginx is setting it up as a proxy server, in this case it receives HTTP requests from clients and passes them to proxied or upstream servers that were mentioned above, over different protocols. You can also modify client request headers that are sent to the proxied server, and configure buffering of responses coming from the proxied servers.

Then it receives responses from the proxied servers and passes them to clients. It is mush easier to configure as a proxy server compared to Apache since the required modules are in most cases enabled by default.

5. Nginx is Remarkable for Serving Static Content

Static content or files are typically files stored on disk on the server computer, for example CSS files , JavaScripts files or images. Let’s consider a scenario where you using Nginx as a frontend for Nodejs (the application server).

Although Nodejs server (specifically Node frameworks) have built in features for static file handling, they don’t need to do some intensive processing to deliver non-dynamic content, therefore it is practically beneficial to configure the web server to serve static content directly to clients.

Nginx can perform a much better job of handling static files from a specific directory, and can prevent requests for static assets from choking upstream server processes. This significantly improves the overall performance of backend servers.

6. Nginx is an Efficient Load Balancer

To realize high performance and uptime for modern web applications may call for running multiple application instances on a single or distributed HTTP servers. This may in turn necessitate for setting up load balancing to distribute load between your HTTP servers.

Today, load balancing has become a widely used approach for optimizing operating system resource utilization, maximizing flexibility, cutting down latency, increasing throughput, achieving redundancy, and establishing fault-tolerant configurations – across multiple application instances.

Nginx uses the following load balancing methods:

  • round-robin (default method) – requests to the upstream servers are distributed in a round-robin fashion (in order of the list of servers in the upstream pool).
  • least-connected – here the next request is proxied to the server with the least number of active connections.
  • ip-hash – here a hash-function is used to determine what server should be selected for the next request (based on the client’s IP address).
  • Generic hash – under this method, the system administrator specifies a hash (or key) with the given text, variables of the request or runtime, or their combination. For example, the key may be a source IP and port, or URI. Nginx then distributes the load amongst the upstream servers by generating a hash for the current request and placing it against the upstream servers.
  • Least time (Nginx Plus) – assigns the next request to the upstream server with the least number of current connections but favors the servers with the lowest average response times.

7. Nginx is Highly Scalable

Furthermore, Nginx is highly scalable and modern web applications especially enterprise applications demand for technology that provides high performance and scalability.

One company benefiting from Nginx’s amazing scalability features is CloudFlare, it has managed to scale its web applications to handle more than 15 billion monthly page views with a relatively modest infrastructure, according to Matthew Prince, co-founder and CEO of CloudFare.

For a more comprehensive explanation, check out this article on the Nginx blog: NGINX vs. Apache: Our View of a Decade-Old Question.

Conclusion

Both Apache and Nginx can’t be replaced by each other, they have their strong and weak points. However, Nginx offers a powerful, flexible, scalable and secure technology for reliably and efficiently powering modern websites and web applications. What is your take? Let us know via the feedback form below.