58
Don Denoncourt [email protected] Beyond RPG

Don Denoncourt [email protected] Beyond RPG

  • View
    215

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Don Denoncourt

[email protected]

Beyond RPG

Page 2: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG a Half-Century Old

• Time to consider what comes after RPG.

• Maybe beyond RPG might be– A better RPG

• We need to move beyond RPG status quo

Page 3: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Perception of RPG as Antiquated

• Whether right or wrong…• RPG does have issues

– But the biggest are:• Old code

• Old programmers

• Antiquated coders – Don't get or use modern concepts

• Modules and Component-based Design (CBD)

• Variable scoping

Page 4: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG is Not Popular

• Job sites:– 10X more Java than RPG jobs– 5X more PHP that RPG jobs

Page 5: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Language Adoption

• Spurred by revolutionary changes in IT

Page 6: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

But no revolutionary change driving CBD, OOP, or Declarative Programming

• Component-based Design– Black box process that is able to communicate

with other components with well defined arguments and return value

• Object-oriented Programming– Components built with encapsulation,

modularity, polymorphism, and inheritance

• Declarative Programming

Page 7: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

CBD Works Well with RPG

• But CBD and ILE RPG – not widely embraced

Page 8: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Why Haven't RPGers Embraced Java?

• Green-screen apps work so darn well

• Dot-com failure put off app-starts indefinitely

• "IBM has fostered GUI inertia" – Chris Maxcer in his Maxed Out blog

Page 9: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

IBM's Roadmap to the Web

• First IBM said the solution was Java

• Then WebFacing

• Then Host Access Transformation Services (HATS)

• Now it seems to be EGL– Or is it PHP?

Page 10: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

"It's Not Easy Being Green"

• Quote by Randall Munson and Kermit the Frog

• "The green screen makes the system look old and creates a visual barrier to the acceptance of the System i."

• Even if you believe beyond RPG is a better RPG– Still need a web enablement solution

Page 11: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Ask the Experts

• Mike Otey and Craig Pelkie– Microsoft .Net

• Scott Klement, Susan Gantner, and John Paris– ILE RPG and CGI

• Joe Pluta and Dan Darnell– EGL

• Scott Steinacher and Paul Conte– Application Generators (such as Lansa)

• Trevor Perry, Susan Gantner, and John Paris– PHP

• Don Denoncourt– Groovy and Grails

Page 12: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Beyond RPG III

Page 13: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Great Things About RPG

• It works, it has always worked, and it will continue to work.

• ILE RPG has integrated modular API support• Existing staff knows RPG. • Wealth of 3rd party and in-house RPG apps.• Ancient code works in new OS releases without

recompilation. • Deep integration with DB and OS.• It has arguably the best job log in the industry.

Page 14: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Tiobe Index

18th on Tiobe Index

www.tiobe.com

Page 15: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG is the Sybil of Programming Languages

RPG

RPG III

RPG IV

RPG II

ILE RPG

/free

Page 16: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Dissociative Identity Disorder

• A side-effect of a 50-year old language– Adapt syntax to support new technologies

• Older languages often morph past their original purpose

• RPG is more complex than younger languages

Page 17: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Becomes a problem of"What Not to Use?"

• Propagate use of out-dated syntax– Subroutines– Entry parameter lists– Non-named indicators– Global variables

• Even highly paid RPG developers – Often don't use the language well

Page 18: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG is Difficult to Refactor

• Few common facilities for formalizing the refactoring process.

• Refactoring definition– Modify code without changing its behavior.

• Refactoring requirements include:– Unit and integration testing frameworks

– Source control

– Automated builds

• Lack of tooling caused the proliferation of duplicate code

Page 19: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Field Name Collision Bug

• RPG uses the same memory location for file fields with the same name– Standard 2-digit file id prefix

• Which left 4 significant digits

• RPG now supports 10 char field names– And qualified fields

• But tables have those 4-char field names– Causing a negative perception of DB2/400

Page 20: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Comparing RPGwith Younger Languages

Page 21: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG C-API

• ASCII I/O, XML manipulation, e-mail, Web Services, and TCP/IP processing– Requires C-API

• And you pretty much have to be a C programmer

• RPG C-APIs more complex than integrating Java/PHP/.NET

• Hats off to Scott Klement (and others)– For providing open-source RPG utilities to make this

easier• HTTP API

Page 22: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

WDSc and RDi

• WDSc/RDi is much better than a few years ago

• But not as good as developing with other languages– Slow to open and save files– Edit/compilation cycle is slow– Still visualize punch cards when prompting for

F- and D-specs

Page 23: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Some General Complaints

• Inconsistent syntax

• Platform specific

• Static linking

• Consumption of SQL result sets

• Prototypes klunky and C-like

Page 24: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Modern Development Practices

1. Modern IDE

2. Modular Programming

3. Take Control of Your Source

4. Test First, Code Later

5. Use Multiple Test Environments• Development, Test, and Production

6. Log, Don’t Debug

Page 25: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Modern IDE

Page 26: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Modular Programming

• Separation of Concerns– Model-view-controller (MVC)

• Service programs

• No global variables

• No subroutines

• No *ENTRY PLIST

Page 27: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Take Control of Your Source

• Start using source control software– Commercial or otherwise

• Free source control tools– CVS or Subversion– Host on any system

• Hosting sites available

– For RPG use iSeries Projects

Page 28: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Test First, Code Later

• Manual testing– Time-consuming and expensive

– Not always possible to visually prove code worked as expected

– Not repeatable

• Automated testing– Unit tests

• Which become regression tests

• Utilities:– jUnit, jsUnit, PHPUnit, iUnit

Page 29: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Test Infected Programmers

• Create the skeleton of your service program– the API

• Write unit tests for each sub-procedure.

• Run the unit tests– which will all fail

• because you haven’t yet fleshed out the skeleton of that code.

• Flesh out the sub-procedures– Iteratively run tests

• Revising the code until all tests pass

Page 30: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Multiple Test Environments

• Development, Test, & Production

• Younger languages provide flexibility– Local database– Off-line development and testing

Page 31: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Log, Don’t Debug

• Set up time for visual debugging– Lost when you complete the session

• Log statements stay in the code– Globally set logging level determines if a

statement is logged• EMERG, ALERT, CRIT, ERR, WARN, NOTICE,

INFO, DEBUG

• Log4i, Log4j, Log4js, etc.

Page 32: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Web Front-End Languages

Page 33: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Java

• The Most Obvious Pick– Pushed by IBM for 10 years– Top on TIOBE index

• Huge amount of APIs, Frameworks, and utilities

• Revolutionized application development

• Incomparable thread architecture

• "Java for multiple reasons has failed to deliver." – Paul Touhy

Page 34: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Java

• "The answer to why java is failing: It is a systems programming language, just like C++. It is not a good choice for business application programming." – Carson Soule

• Regardless…– Java is a powerful, flexible, cross-platform systems

programming language • that has been proven to work well

• in the development of highly scalable web applications.

Page 35: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Java Recommendations

• Frameworks– Spring– Hibernate

• Utilities– Log4j– JUnit

Page 36: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

PHP• Java written as a better C++

– PHP written to solve the problem of web development

• Personal Home Page– Hacked to getter Perl scripts– Rewritten and recast as PHP: Hypertext

Processor

• Most approachable Web language

• Issues:– Requires selection of frameworks– Scaling, performance, and use in no-web apps

Page 37: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Eclipse PDT Plugin

Page 38: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

PHP Recommendations• Zend Frameworks

– framework.zend.com

• IDE– Eclipse PDT– Zend

• Utilities– PHPDoc (www.phpdoc.org)– PHPUnit

• Dev/Test/Prod Environments– Dev should have a local DB

Page 39: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

.NET

• Platform hosts a variety of languages. – Microsoft's answer J2EE.

• Maybe a better J2EE.

• C# and Visual Basic high on TIOBE index – C# is very similar to Java

• but with features that I wish Java had.

• Vendor and platform-specific solution

Page 40: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

EGL

• Well-crafted language with a straightforward syntax– Easy for RPG coders to learn

• Record structures similar to Cobol– Use structs to communicate with DB and RPG

• EGL code generated in to Java• EGL is a platform, not just a language

– IDE with the EGL compiler

Page 41: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

EGL Issues• Vendor specific, commercial IBM product

– Consider Lansa and BCD

• Documentation and training– Java/.NET/PHP has books, articles, seminars,

conferences, blog and so forth

– "If you can't Google a solution to a technology, you shouldn't use that technology"

• Tied to Java Server Faces (JSF)– Over-engineered solution to HTML development

– EGL easy to learn but JSF, once you get past what drag-and-drop can do, is complex

Page 42: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Groovy and Ruby

• Declarative languages– Like PHP, Perl, Prolog, Python, and JavaScript– "Imperative programs explicitly specify an

algorithm to achieve a goal, while declarative programs explicitly specify the goal and leave the implementation of the algorithm to the support software."

• Ruby on Rails and Groovy's Grails– Amazing how quickly you can develop an

application with Rails or Grails• I've experienced productivity improvements of 200 to

500 percent with Grails

Page 43: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Groovy and Grails

• Rails does not work well with legacy databases

• Groovy is a superset of Java– RPGers: Simplifies Java syntax– Java coders: Provides powerful new options

• Grails uses industry-standard Java frameworks– Hibernate and Spring

• Philosophy:– “convention over configuration”

Page 44: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG-Java-Grails Comparison

• Read a customer record by key

• RPG:chain 23 custrec;

• Grails:def cust = Customer.get(23);

Page 45: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Java VersionConnection con = null;

Customer cust = new Customer();

try {

Connection con=dataSource.getConnection();

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(

"SELECT * FROM CUSTDB"+

" WHERE CUSNUM = 23");

rs.next();

cust.setName(rs.getString("NAME"));

cust.setAddress(rs.getString("ADDR"));

} catch (SQLException e) {

/*handle error*/

} finally {

con.close();

}

Page 46: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Build and process a list of Virginia customers

RPGdou %eof(custrec);

reade 'VA' custrec;

if not %eof(custrec);

// process a customer

endif;

enddo;

GrailsCustomer.findAllByState('VA').each {

// process a customer

}

Page 47: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Build and process a list of Virginia customers

RPGdou %eof(custrec);

reade 'VA' custrec;

if not %eof(custrec);

// process a customer

endif;

enddo;

GrailsCustomer.findAllByState('VA').each {

// process a customer

}

Page 48: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Java

ResultSet rs = stmt.executeQuery(

"SELECT * FROM CUSTDB WHERE STATE = 'VA');

while (rs.next()) {

Customer cust = new Customer();

cust.setName(rs.getString("NAM"));

cust.setAddress(rs.getString("ADDR"));

// and set all the other fields as well

// process the customer

}

Page 49: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

DDS versus Grails ValidationR CUSTREC

NAME 40A I 4 10

ADDR 50A I 5 10

STATE 2A I 6 20VALUES('VA' 'CO' 'AK')

AGE 3S OI 6 25RANGE(21 65)

COMP(NE 33)

class Customer {

String name

String addr

String state

String age

static constraints = {

name(length:2..40)

addr(maxSize:50)

state(inList:["VA", "CO", "AK"])

age(range:21..65, notEqual:33)

}

}

Constraints checked on

insert, update, or validate

Constraints checked on

insert, update, or validate

Page 50: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Grails Recommendations

• Frameworks– All required are bundled– Others installable in seconds as plugins

• Use integrated testing facilities

• Use logging heavily

• Separate business logic into service classes

• Consider DB refactoring before launch

Page 51: Don Denoncourt dondenoncourt@gmail.com Beyond RPG
Page 52: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Post-modern Language

• "RPG is what academics call a post-modern language: a classic with a lifeline that debunks the myth of obsolescence."– Tomas Stockwell

Page 53: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

RPG Here to Stay

• But keep looking beyond…– A better RPG– Consider the future is about languages (plural)

• You already know several languages– CL, DDS, SQL

• Dave Thomas– "The Pragmatic Programmer: From Journeyman to

Master"– A journeyman programmer should learn one new

language a year.

Page 54: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Beyond RPG: ILE

• Use SQL– Embedded SQL– DDS to DDL

• Move RI and constraint logic to DDL

– Stored Procedure Language (SPL)

• Follow Klement's "RPG Rules"– RPG has modern language capabilities

• But do you take advantage of them?

Page 55: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Not Sure What New Language to Learn?

• JavaScript, SQL, and CSS• JavaScript

– Browser-based, client-side language, that is the core of AJAX

• SQL – You should already be familiar with but ramp it up

• Cascading Style Sheets (CSS)– And browser user interface development in general

Page 56: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Look Beyond

• What your shop(s) have been doing for the last few decades

• Take advantage of new language features

• Use CBD

• Put on a Web front-end

• Use the latest development tools – WDSc/RDi

• Learn a new language

Page 57: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Find Out More

• "Exploiting RPG’s V5 Power Features"– Jon Paris and Susan Gantner– www.asugcle.com/LUG/AMCUAIM/articles/

ExploitingV5_NoXML.pdf

• "PHP May Be for i, but Is It for Me?" – Don Denoncourt– SystemiNetwork.com, Article ID 20796

• "RPG: Anchoring Your Team"– Jon Paris and Susan Gantner– www.ibmsystemsmag.com/i5/april07/coverstory/

12342p1.aspx

Page 58: Don Denoncourt dondenoncourt@gmail.com Beyond RPG

Find Out More

• "RPG Rules"– Scott Klement– SystemiNetwork.com, Article ID 21050

• "The Search for the Holy Web Dev Grail(s)"– Don Denoncourt– SystemiNetwork.com, Article ID 21061

• "What Gems Does Ruby on Rails Offer?"– Tim Massaro– SystemiNetwork, Article ID 21076

• "Go Beyond RPG -- With Modern RPG"– SystemiNetwork.com, Article ID 60198