|
In Part II, we'll address the challenges of server-side programming.by Duncan Kenzie In Part I of this two-part series, we looked at essential skills for client-side Web development. In this installment, we'll look at server-side programming. Server-side programming involves writing business logic, database access logic, validations, and interfaces to the client (usually a browser of some sort, although with Web services applications, it could be another Web server). Server-side programming can be done using a variety of development environments and languages, depending on a number of factors, such as the choice of Web server middleware, hardware, operating system, and development language. For example, on the System i, some of the choices are CGI programs that run in the Apache Web server, PHP running in the Apache Web server with the PHP module installed, Java servlets, or JavaServer Pages (JSPs) running in WebSphere WAS. Note that CGI is a protocol, not a language or development tool. Several tools use CGI as the basis for delivering Web apps, with varying approaches to implementation of the protocol. These include open-source tools such as CGIDEV2, commercial "kits" (suites of APIs to make programming in the CGI protocol easier), and commercial development environments. Most of these exploit RPG as the primary development/generation language, but it is possible to write CGI-protocol-based code in most any ILE language, such as Cobol, C, or C++. On platforms other than the System i, besides PHP and Java-based solutions, you may encounter CGI scripts, usually written in Perl or early versions of PHP or ASP .NET, Microsoft's equivalent to JavaServer Pages (JSP), running on IIS, Microsoft's proprietary Web server. Another popular server-side Web technology is Adobe's ColdFusion, originally produced by Allaire. ColdFusion consists of both a development tool and a deployment environment. It uses its own server, which sits on top of other Web servers. ColdFusion had a strong presence in the early days of database-driven Web programming (circa 1999-2000), but its popularity is declining due to the success of PHP, Microsoft's inroads into the marketplace, and the adoption of Java-based solutions. A ComparisonLet's look at the advantages and disadvantages of some of these approaches. CGI on System iAdvantages
Disadvantages
PHPAdvantages
Disadvantages
JavaServer Pages (JSP)Advantages
Disadvantages
If you are interested in learning about J2EE, which is the umbrella technology for Java servlets and JSP (and a lot of other Java-based technologies), Sun Microsystems has a great Web site for that. ASP.NETAdvantages
Disadvantages
Because ASP.NET runs on a Microsoft platform, why would you consider it for System i Web development? Well, there are ODBC drivers for connecting to the System i database, so you can write ASP.NET applications that access System i data. Organizations that are nervous about exposing their System i to the Internet sometimes take this approach, although I think this is an unnecessary concern, given System i's robust security features. What IBM Could Learn from MicrosoftOne area that Microsoft really excels in is its development tools. There is really no comparison between IBM's tools and Microsoft's Visual Studio and similar tools. For example, Microsoft's tools are easy to find on the Microsoft Web site, are easy to install, and are not PC resource hogs (compared to WDSc, which requires much more memory). And some developers consider IBM's developer tools to be less intuitive than Microsoft's tools .Compared to IBM, Microsoft also does a great job of promoting its tools. For example, on the developer's Web site, you can easily download free Express versions of Microsoft software; just click the Downloads tab. From there, you can download Visual Web Developer 2005 Express in just three clicks - no forms to fill in, no email addresses required. Just click and install. Contrast this with IBM's WDSc page. IBM would do well to make it easier for developers to figure out how to get a free trial download. In addition, Microsoft does a superb job of selling programming as a fun and exciting pursuit. For example, on that same developer's site, there's a "Facebook developers kit." Microsoft makes its products relevant and interesting to the younger crowd. The site is covered with great images, screenshots, video demos, and more. In contrast, IBM's is... well, dull. No pictures. No videos. Just the IBM logo and lots of text and links. What These Approaches All Have in CommonAll the solutions I've described use a common Web programming concept, to one degree or another. The idea of interleaving HTML with server-side code is quite different from traditional green-screen programming, where you clearly separate UI design (display file DDS) from programming logic (RPG code, for example). This can present a problem in terms of coding; it makes it difficult to design your screens separately from your programming logic. Each technology addresses this problem with different degrees of sophistication. For example, CGIDEV2 uses "sections," which let you write large chunks of HTML with server-side variables embedded. JSP supports the use of JavaBeans, which are self-contained objects consisting of both presentation layout and server-side code. For example, you can easily hook in an HTML calendar that is created as a bean. The bean draws the calendar on a designated place on the page. The programmer might set properties for the bean that control whether or not the current day is highlighted, for example. Microsoft's ASP.NET supports the same concept. Visual Studio .NET comes with a suite of pre-built server-side controls that you can easily plug in to your pages. One of the most powerful is the datagrid. This is like a subfile on steroids. It produces a scrollable table of values from any SQL select statement, with resizeable and sortable columns, plus many more features. As a programmer, you do not need to know the innards of the control - how the requisite HTML is produced, for example. You simply place the control on your page using Microsoft's design tool and then set properties for it. Zend also has something similar, called Zend Frameworks, which includes an object-oriented library of components written in PHP 5. Which Approach Should You Choose to Learn Server-Side Technology?With the advent of strong PHP support on the System i, it really makes sense to start with PHP:
PHP's Object-Oriented Capabilities Although PHP is typically coded using procedural coding styles that employ function calls, etc., PHP 5, released in July 2004, also supports a robust object-oriented coding model. Zend Frameworks is a set of object-oriented components written in PHP 5 that provide a high degree of Web functionality that's easy to plug in to your own applications. Having the ability to write PHP in an object-oriented architecture gives you room to grow with the language. You can start out learning to code PHP procedurally, using concepts that are familiar to you, and then eventually move to using an object-oriented methodology to write more robust and reliable code. Learning PHP Literally hundreds of Web sites teach PHP. As I mentioned in my previous article, W3 Schools is one of my favorite sites, especially for basic introductions to Web technology. Other sites include PHP.net. A Google search for "PHP tutorials" returned 808,000 hits! Also, there are many good books on PHP. One Web site I have found particularly helpful is O'Reilly's Safari Books Online. This is a subscription-based site that gives you access to O'Reilly's library of publications, as well as technology books from other publishers. You get to read complete online versions of the books. You can also download sections, or buy hardcopy versions directly from the site. Compared to the comparable cost of the print versions, the subscription fees are very inexpensive. Perhaps one of the major reasons to use PHP is that you can be comfortable knowing that PHP is a major technology that is here to stay. Investing in PHP training for yourself or your staff is a long-term value proposition. It's an investment that you will leverage for years. In addition, PHP is widely taught in colleges and universities, so finding new talent who can code in PHP is relatively easy compared to other languages, especially RPG. Putting It All TogetherYou will need the skills from both of the articles in this series in order to write commercial-quality Web applications:
While this sounds daunting, it doesn't have to be. Read a couple of books, grab some sample code, and get going! Web programming is tons of fun, and once you get started on it, you'll never want to see another green-screen again! Duncan Kenzie is President and CTO of BCD Technical Support, the development and support group for WebSmart a popular iSeries Web development tool, and Nexus, a portal product specifically designed for iSeries, i5, and AS/400 servers. Duncan has 29 years of experience on the midrange systems platform creating software for both green-screen and native Web environments. |
|
|||||||||||||||||||