scripting and codes

Upload: rakesh-rao

Post on 16-Oct-2015

8 views

Category:

Documents


0 download

TRANSCRIPT

There has been little publicity about it and no big headlines but were in the midst of a programming revolution.

For years the computer industry has promoted object-oriented programming. And no one doubts the importance of OOP or languages like Java. But youll see as much scripting going on as object-oriented programming, yet scripting has garnered zero attention in the trade press. Do a quick Google search on scripting versus object-oriented programming and check this out yourself. Scripting is quietly, relentlessly gaining adherents -- with little publicity.

Of course, object-oriented programming and scripting are not mutually exclusive. Many languages fit in both categories. Python and Ruby are good examples, as are the object-oriented forms of Rexx and Perl.

This page explores why scripting languages have become so important. It analyzes the languages and provides basic descriptions of the major ones. It offers links for learning more.

No hard-and-fast definition of what a scripting language is exists, but generally scripting languages are interpreted programming languages that feature higher productivity than more traditional systems languages like Java, C++, C, or COBOL. A line of code in a scripting language typically does more than a line of code in a traditional systems language. In part this is due to the dynamic nature of interpreters, which allows for a higher level of automation in the language. This gives scripting languages high-productivity features like variably-sized data elements and structures, dynamic variable definitions, built-in interactive debuggers, automatic memory management, dynamic extensibility, and more. Scripting languages are glue languages. They tie together existing software, such as objects, components, widgets, operating system commands, programs, functions, modules, and other forms of existing code. Scripting languages are higher-level than traditional programming languages because they more easily leverage existing software.

Key benefits to scripting are: Higher programmer productivity Less concern about machine details Ability to tie together and build on existing software Faster, easier debuggingDrawbacks include: Slower run times -- not the best choice for machine efficiency. Large projects that demand the highest performance (for example, a large online transaction processing or OLTP system) make it worthwhile to code in less productive systems languages like Java, C, C++, or COBOL. Usually not suitable for low-level machine-specific coding (like writing a device driver, for example)

Scripting fulfills many programming needs, and the scripts themselves reside and run in various places. Examples of the major roles played by scripting languages include -- Web browser programming -- applications programmers immediately recognize scripting languages as the means to program browsers. Server-side web applications --scripts also run server-side in many web applications. Glue languages -- most scripting languages are very good at building upon and reusing existing software components (objects, widgets, operating system commands, programs, modules, functions, components, etc). This gives them high programmer productivity and a special role as glue languages. GUI programming -- their role as glue languages leads directly to their use as highly productive vehicles for programming graphical user interfaces (an otherwise detail-oriented task). Applications programming -- general-purpose scripting languages can easily be used as the primary or sole programming language for a project -- and often are. Job control or command languages or shells -- there has always been a requirement for high-level languages that can drive larger applications written in traditional system languages. Over the years and in different contexts these have been called job control languages or command languages or shells. Many scripting languages have either been designed for this specific role or function well within it. Systems administration -- scripting languages support the need to develop system administration scripts. This includes network, client, and server administration scripts. Text processing -- because of their interpreted, dynamic nature many scripting languages are excellent at text processing (long a weakness of some traditional compiled languages). Macro programming -- scripting languages are often the application language or macro language used with a specific product, to animate it and make its features programmable. Embedded programming -- embedded languages and product-extension or extensible languages are yet another role for scripting.Since scripting fulfills these many needs, this leads to one key distinction among scripting languages -- between general purpose scripting languages and those special-purpose languages designed for more narrow specific uses. This chart gives some idea of how scripting languages categorize in this respect --

General Purpose:Special Purpose:

Perl, Python, Rexx, Tcl/Tk, Ruby, Korn, Bash, Visual Basic, VBScript, AppleScript, Windows PowerShell, othersPHP, JavaScript, JSP, JScript, ASP, ASP .NET, others

The chart shows that it is not always easy to classify scripting languages. For example, some might consider VBScript general-purpose, while others view it as special-purpose. PHP faces the same controversy. Modern releases have generalized the language, yet many still consider it strictly a vehicle for web application programming. Tcl/Tk underwent a similar expansion in features and evolution in purpose. So take this chart with a grain of salt, even though the idea of categorizing scripting languages in this manner is useful.

Another distinction among scripting languages is between those that are open source and those that are proprietary, commercial products. The former run across a very wide variety of operating systems and platforms while the latter address only a limited number of proprietary systems.

Open source scripting languages predominate -- except for the scripting languages from Microsoft. We thus have a split of the scripting universe into two camps -- open source versus Microsoft-led.

Open Source:Proprietary:

Perl, Python, Rexx, Tcl/Tk, Ruby, Korn, Bash, PHP, JavaScript, JSP, othersVisual Basic, VBScript, Visual Basic for Applications (VBA), VB.NET, JScript, ASP, ASP .NET, Windows PowerShell, the Windows Script Host (WSH) framework,the .NET framework, AppleScript, others

Microsoft has fragmented its own scripting community by continually introducing new scripting languages and frameworks. DOS had its DOS command or batch language, which Microsoft extended for Windows NT. At the same time the company added Rexx to the Windows administation tools packs to placate system administrators who demanded a full-powered administrative scripting language. Microsoft then expanded Visual Basic as a macro language for Microsoft Office (as Visual Basic for Applications or VBA), building on the strong Visual Basic community but forking the administrative versus macro/application-extension scripting languages.

In the administrative realm, Microsoft eventually dropped Rexx and replaced it with their own proprietary languages in the form of VBScript (and JScript) and the Windows Script Host or WSH framework. In 2006 Microsoft superceded the VBScript strategy with PowerShell, yet another language for this purpose.

Meanwhile Microsoft was evolving a related but distinct universe of scripting languages and frameworks for client- and server- side web applications. The COM, DCOM and OLE technologies gave way to ActiveX as the reusable software component model. The .NET Framework became more important with the rise of Active Server Pages and later ASP.NET. VB.NET replaced earlier forms of Visual Basic.

Microsoft scripting hosts from Windows Script Host to the .NET framework and Common Language Runtime or CLI are architected such that one can program in languages other than Microsofts own. But in practice very few people do -- almost everyone uses Microsofts proprietary languages like VB.NET (or C# or maybe even JScript.NET).

This is by design, of course... the openness in Microsofts architectures is intended for sales purposes rather than for customer use. Microsoft considers it critical to their corporate strategy to keep their customers using scripting languages the company controls.

The bottom line -- use Microsofts scripting languages and frameworks if you are a Microsoft-only shop, and if you want to take advantage of all Windows facilities and Microsoft paid support. Use open source languages when you want portability, open standards, and non-commercial software. Only the open source scripting languages run on operating systems than Windows.

Open source also frees you from the instability of Microsofts scripting strategies. Microsoft shifts focus among its scripting tools so frequently that you should not expect this code to have a very long lifespan as state-of-the-art, supported applications.

Here are descriptions of the most popular general-purpose open source scripting languages. The descriptions are objective but brief. In using most of the languages in the chart, Ive found that all languages have their own strengths and shortcomings -- there is no best scripting language. There are only languages are that better-suited or not-so-well-suited to the particular projects or goals you have in mind.

Language:Profile:

PerlOne of the most popular scripting languages in the world, Perl claims millions of users. Its an extremely powerful language, but it takes a while to learn and scripts can be difficult to maintain. Perl features a huge library of free tools and extensions called the Comprehensive Perl Archive Network (CPAN). Perl is a general-purpose scripting language that fulfills every scripting language role.

PythonPython has a large user base, especially among those who prefer a thoroughly object-oriented scripting language. Like most of the languages in this chart, Python runs on almost any operating system or hardware platform. It features tons of freely-downloadable tools and interfaces. Python offers an easy syntax compared to Perl and the Unix/Linux shell languages and most people find it easier to learn and maintain.

RexxRexx combines ease of use with power. It uses special techniques to bring these two normally-contradictory goals together. Originally known for its dominance on mainframes, there are today 10 free Rexx interpreters that run on every operating system and platform. There are also thousands of free tools. Rexx is easy to work with and maintain. Like Perl, Rexx is general-purpose and fulfills every scripting language role.

Tcl/TkTcl/Tk was originally designed as a special purpose embedded command language but quickly evolved into a well-rounded, easy-to-learn general purpose scripting language. Tk is an especially popular toolkit for building graphical user interfaces. Other free scripting languages (Perl, Python, Rexx) interface to Tk to leverage its superior GUI-development capabilities. Tcl/Tk is powerful yet easy to learn and program.

RubyRuby is thoroughly object-oriented and relatively new. Like Rexx it offers power within syntactic simplicity. Ruby enjoys great buzz but has a smaller user base than Perl or Python. Enthusiasts especially like Rubys development environment, Ruby on Rails.

PHPPHPs use has exploded because the language is increasingly seen as the open source alternative to proprietary web-development scripting languages from Microsoft. PHP is very easy to learn and quick to code. Though originally strictly for web page programming, PHP has been generalized in recent years and is now a general-purpose language. Nevertheless nearly all use of the language is still for web application scripting.

KornShellThe KornShell was developed for Unix systems over twenty years ago. Its use spread along with Unix -- with which it is still almost exclusively associated. Korn is like Perl in that it is extremely powerful but also cryptic and very syntax oriented. It is mostly used for Unix system administration (esp. for Oracle/Sun Solaris and IBM AIX Unix) and occasionally for application programming.

BashBash is another evolution of a Unix shell language that finds its greatest use as the default shell in most Linux distributions. Bash features the same blend of power and awkward syntax as KornShell and Perl. Bash is a further evolution of the original Unix shell, the Bourne shell (there are many other shell variants). Like KornShell, Bash is probably mainly used for systems administration but is also sometimes used for applications development.

JavaScriptJavascript is usually considered a special-purpose scripting language for web development, rather than general-purpose. Ive included it in this table anyway due to its very high popularity for client-side (inside-the-browser) scripting. JavaScript also runs server-side.

Its difficult to determine the relative popularity of different scripting languages. The distribution and licensing model of open source makes it impossible to rate the popularity of the open source languages. And if Microsoft knows how many people or licensees use its scripting languages, theyre not telling. Most would agree with these assertions --

PHP -- PHP has breakout popularity, based on its role as the open source tool for scripting in browsers and web sites. Its use has been increasing steadily for years.

Perl -- Many would argue that Perl enjoys the greatest popularity overall, but web sites that track the language usually depict Perls popularity as in a long gentle decline. Its still probably the second most popular scripting language after PHP.

Python -- Python is the third scripting language whose numerous devotees separate it from the pack. Surveys often show its use rivals that of Perl.

The Pack -- All other scripting languages coalesce in the pack. Most of those listed on this web page (open source or proprietary) collect together in this range.

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. It has also evolved to include a command-line interface capability and can be used in standalone graphical applications.[6]PHP is free software released under the PHP License. PHP can be deployed on most web servers and also as a standalone shell on almost every operating system and platform, free of charge. Advantages of PHP Open SourcePHP is freely available for use. The community of open source PHP developers provides technical support and is constantly improving updating the core PHP functionalities. PHP is available at free of cost under PHP General Public License and most of its associative required software's like MySQL, Text Editors and Apache Server are also freely available, so it proves very cost effective for the developers.Cross-PlatformPHP provides high compatibility with leading operating systems and web servers such as thereby enabling it to be easily deployed across several different platforms. PHP scripts can run across operating systems such as Linux, Windows, Solaris, OpenBSD, Mac OSX etc and also provide support for all major web servers such as Apache, IIS, iPlanet etc.PowerSeveral web tasks can now be easily perform using PHP. For example now we can develop from small websites to giant business and organizational websites, informative forums, chatting platforms, CRM solutions, e-commerce shopping carts, community websites, e-business, shopping carts and gigantic database driven sites.User FriendlyDesigned in a user friendly manner, PHP gives more flexibility than C, C++ and ASP and overall helps in increasing traffic to the site.

QuickPHP is designed to work well with the web, and so things like accessing the GET and POST and working with HTML and URLs are built-ins in the PHP language. This makes it really concise and straightforward to make a website.ExtensionsBeing an open source language, a large number of libraries and extensions, to extend its core functionalities, are available for download. The source code of PHP can be modified to include custom created extensions and components thereby increasing its extensibility.Easy DeploymentThere are many hosting companies that will, for a few dollars a month, give you a server running PHP so you can make a website really easily.Automatically RefreshesNowadays developing dynamic websites are in the huge demand due to its specific characteristics like it automatically refreshes and does not need to make much changes manually.Community SupportA huge advantage that PHP offers is its community. If you are looking for a particular script, chances are another user has already created something similar. Check within the PHP community for availability. Likewise, if you have created a function that others might enjoy, be sure to post the code for others.Other ToolsIf you need to access other web based tools like Google maps (which is always advisable for a business website), or any other, PHP makes it easy to access.SecurityPHP offers security as well that helps prevent malicious attacks. These security levels can be adjusted in the .ini file.Talent AvailabilityYou can hire PHP programmers more easily than any other language programmers since so many people know the language.Summary Open Source, PHP is completely free. PHP can be easily embedded directly into HTML. Platform independent can run on Windows Linux or Mac servers. Run faster on the internet and easily integrate AJAX, Callback etc. Interfaces very easily with Apache/MySQL Lots of good books and on-line help. It's available with documentation in many languages. Easy to learn compared to many other scripting languages. It has a syntax that is easy to parse and is actually rather human-friendly. Lots of hosting services have it ready to use, no special configuration. Pretty easy to access other web-based tools through PHP i.e. google maps, etc. Lots of good source code out there to use and/or learn from, as well as many useful libraries for working with PDFs, graphics, etc.

Basic Tasks using PHP MYSQL and HTML:

1.validation of ip and inserting in sql

IP address validation

var octet = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; var ip = '(?:' + octet + '\\.){3}' + octet; var quad = '(?:\\[' + ip + '\\])|(?:' + ip + ')'; var ipRE = new RegExp( '(' + quad + ')' );

function validate( value ) { if ( ipRE.test( value ) ) { alert( '"' + RegExp.$1 + '"' ); } else { alert( 'invalid' ); } }

Untitled Document

First Name:
Surname:
Username:
Password:
Verify Password:

?>