Sunday, April 19, 2009

Shell/Perl scripting versus Java programming

Here's a little write-up I have written for a team for which I am consulting. I am helping this team to migrate their existing c-code driven cgi scripting to java. This team wanted everything they have i.e. c-code and scripts to be migrated to java. They had exposed CGIs developed using c so that other systems can call them. They rightfully wanted these to be migrated to Web Services using java. They also have scripts that work in silos that either generate reports or manipulate files/folders and execute some commandline executables. They want to migrate these too to java. This write-up is meant to be a heads-up for them to see that migrating to java blindly is not a good option. They can reduce their costs by letting somethings be the same without much impact to their overall goal.

What are shell scripts most suited for?

Typical operations performed by shell scripts include file manipulation, program execution, and printing text. In their most basic form, shell scripts allow several commands that would be entered "by hand" at a command line interface to be executed automatically and rapidly. Most shells implement basic pattern matching capabilities like this, which allow them to perform commands on groups of items with similar names and sometimes parse simple strings of text.

What are java program most suited for?

Like any other full-fledged programming language java is widely embraced by Enterprise architects for the following reasons:

  • Make programming easier by being simple, object-oriented and familiar.
  • Leave less ambiguity by being a strongly-typed language.
  • Ability to do any programmatic task like socket programming, file manipulation, streaming bytes, providing security, database operations, providing user interfaces among other things
  • Ability to interact with other totally disparate systems with the use of Web Services by providing APIs.
  • Ability to provide robust, fault tolerant, fail safe and scaleable systems with the help of industrial strength Application Servers and frameworks that promote distributed applications.
  • The ability to code quickly and easily by providing multiple coding platform options like Jdeveloper, Eclipse, etc.

Why are most tasks in the FUP module of Orion being ported to Java?

Following are the reasons, IMO, why FUP is being ported to Java:

  • Other systems in Orion need to call actions in FUP which require FUP to expose this functionality in a universally accepted way i.e. by exposing Web Services.
  • FUP calls functionality in other modules of the Orion system. This requires FUP to be able to call the Web Services exposed by the other modules in a universally accepted way.
  • To conform to the standards being adhered to by the other systems in Orion i.e. Java & JEE architecture.
  • To become easy to extend and maintain. Java & JEE are already used by other teams other than FUP. Use of Java/JEE by FUP will enable other teams to understand and extend it better.

Why must script files not be migrated to java?

Most of the existing FUP commandline scripts, which include shell and perl scripts, are performing the following operations:

  • Creating new folders.
  • Moving/Copying files from one folder to another.
  • Executing certain command-line commands.
  • Outputting some debug statements while executing.

Following are the reasons why a few FUP scripts must not be migrated to java:

  • These scripts are not being called by other modules of Orion. But they do call WS exposed by other modules. A java command line may be provided wherever an external WS is being called.
  • File manipulations like moving & copying of files and creation & removal of folders is something which is a strength of shell scripts.
  • Calling of command line executables too is a strength of shell scripts.

Therefore, as long as a piece of code is not being accessed by other modules in the Orion system one may keep using the same scripts. Places where other modules are being called in these scripts may be modified to use java functionality.

What are the scripts that do not qualify for porting to java?

  1. Daily/Weekly/Monthly reporting cronjob.
  2. ADR cronjob.