programming language • Dynamic typing rather than Static typing • Strong and weak typing do not matter • Executes at runtime rather than at compilation • Generally Interpreted • Automatic memory management – That’s right, no malloc! • Some dynamic languages – Perl – Python – Ruby – Javascript – Tcl – Smalltalk – Lisp
Typed languages checking is done at compile time • Variables know the type of their objects • “Unsafe” operations rejected at compile time • Objects have one immutable type and must be cast to change type • Languages • C, C++, Java • With Dynamic Typed languages checking is done at run time • Objects know their types; variables don't care • “Unsafe” operations rejected at runtime • Objects can change type • Languages • PHP, Perl, Python
Pros • IDEs can be more helpful: code completion, refactoring • Avoid errors due to mismatched types • May run faster because the compiler can optimize for types • Cons • Lots of machinery to put in place to get a program moving • Code is verbose: you have to manually specify types for variables
Pros • Code is less verbose • Faster development cycle edit -> compile -> test -> debug • Since the compiler is not doing error checks and errors must be run explicitly testing is part of development • Cons • Code completion is harder • No type checking at compile time • TESTING IS MORE IMPORTANT • May be lots of implicit code
Probably not going to scale to an enterprise level tool • Eg: not for handling banking transactions • Perl good for: • Batch processing • Report generation • Small to midsize projects • PHP is good for: • Web Applications • Easier to maintain code • Small -> Large projects • Python is good for: • All of these things … just not on USS • from gluing together backend systems • to network-aware applications to • desktop and web user interfaces. • embedded devices • controlling large manufacturing systems.
IBM Ported Tools for z/OS: PHP for z/OS • Provides PHP 5.1.2 for USS • PHP (PHP: Hypertext Preprocessor) is a general purpose language well suited to web development. • Preconfigured / Precompiled to address ASCII/EBCDIC conversion • Unpriced feature of IBM Ported Tools for z/OS • Requires z/OS.e V1.6 or higher • Using IBM's version saves you the pain of compiling it yourself • http://www- 03.ibm.com/servers/eserver/zseries/zos/unix/ported/php/index.ht ml
IBM Ported Tools for z/OS: Perl for z/OS • Provides Perl 5.8.7 for USS • Perl (Practical Extraction and Report Language) is a popular general purpose language widely used in UNIX environments • Preconfigured / Precompiled to address ASCII/EBCDIC conversion • Unpriced feature of IBM Ported Tools for z/OS • Requires z/OS.e V1.4 or higher • Using IBM's version saves you the pain of compiling it yourself • http://www- 03.ibm.com/servers/eserver/zseries/zos/unix/ported/perl/index.ht ml
version was available from IBM • Current version 2.4.1 is available from a third party • Major port issues were due to classic EBCDIC / ASCII pitfalls • Binary and source packages available, no need to build yourself • Not a complete port • Mostly addresses explicit conversion between ASCII/Unicode and EBCDIC • http://www.teaser.fr/~jymengant/mvspython/mvsPythonPort.html
syntax is similar to the bad parts of C, making it familiar for people with C programming skills to learn • Particularly suited for text / batch processing • AMAZINGLY Rich set of API's available • I would love to fill out a bulleted list but it would be huge • Perl for z/OS includes an extension to access DB2 for z/OS via standard perl modules allowing access to DB2 data on z/OS
the first line of a php script looks like this: • #!/usr/bin/perl • However the default installation path of php is /usr/lpp/perl/bin/perl • Create a symbolic link from /usr/bin/perl to the default installation path • to ensure compatibility • to prevent script changes between systems
Control Language is the heart of every job running on a z/OS system • Even if a Perl program is running on USS it is quite likely that it will be controlled from within a JCL environment • Running such a program involves more than just starting a task: • Execute the Perl program in the USS environment with output redirection using BPXBATCH • Define characteristics of datasets to hold stdout and stderr, so that these will be available on the z/OS side. • Copy the redirected output to the datasets defined before • Interpret the return code and take appropriate actions
USER=&SYSUID,NOTIFY=&SYSUID,CLASS=T //***************************************************************** //* // SET SYS=’development’ // SET DIR=’test’ // SET PRG=’db2_test.pl’ //* //***************************************************************** //* //RUNPERL EXEC PGM=BPXBATCH, // PARM=’sh perl /usr/local/&SYS/&DIR/&PRG..pl &SYS..ini’ //* //* Set environment variables //STDOUT DD PATH=’/tmp/&PRG..out’, // PATHOPTS=(OCREAT,OTRUNC,OWRONLY),PATHMODE=SIRWXU //STDERR DD PATH=’/tmp/&PRG..err’, // PATHOPTS=(OCREAT,OTRUNC,OWRONLY),PATHMODE=SIRWXU //* //* Since BPXBATCH can only redirect stdout and stderr into //* HFS-files these will now be copied back to the MVS environment //CPOUT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN //SYSTSPRT DD SYSOUT=*
• All in all accessing DB2 from within a Perl program running in the USS environment is very straightforward. #!/usr/bin/perl use DBI; use DBD::DB2::Constants; use DBD::DB2; my ($username, $password) = (’DB2USR’, ’SOMEPASSWORD’); my $dbh = DBI -> connect ("dbi:DB2:ENV", $username, $password) or die "Could not connect to database! $!\n" if !defined ($dbh); my $sth = $dbh -> prepare (...); $sth -> execute (...) or die "PANIC!\n"; $sth -> finish; $dbh -> disconnect;
syntax is similar to C and Perl, making it easy for people with basic programming skills to learn • Particularly suited for web development and can be embedded directly in HTML • Rich set of API's available, including Perl compatible regular expression library • PHP for z/OS includes an extension to access DB2 for z/OS via ODBC allowing access to DB2 data on z/OS
the first line of a php script looks like this: • #!/usr/bin/php • However the default installation path of php is /usr/lpp/php/5.1.2/bin/php • Create a symbolic link from /usr/bin/php to the default installation path • to ensure compatibility • to prevent script changes between systems
Enable .IHS to execute a CGI application • Configure a directory in httpd.conf to allow execution • Exec /cgi-bin/* /usr/lpp/internet/server_root/cgi-bin/* • If not set scripts will be displayed as normal files • Set the PHPRC environment variable • Makes the php.ini file accessable to the .IHS server • Set in .IHS configuration file httpd.envvars • PHPRC=/etc • Restart .IHS server • Set permissions of the php file to 0755
z/OS DB2 Version 8.1 is the recommended version for PHP use • PDO provides a data-access abstraction layer • First set up the two following items • z/OS DB2 userid and password • DSNAOINI (DB2 ODBC initialization file) • Set the environment variable DSNAOINI like so: • putenv(“DSNAOINI=user_dir/DSNAOINI”); • user_dir is the directory where you place the DSNAOINI file • Make the following change to /etc/php.ini • [PDO] • pdo.dsn.yourdsnname=”odbc:DSN=DBW9L0C1;UID=userid;PWD=password
syntax is somewhat similar to the others, there are core differences like whitespace delimitation, no braces, etc • Normally well suited to most any task, however on USS only the CORE functionality has been ported. This is due to ASCII EBCIDIC issues • Rich set of API's unavailable, batteries not included… • Can access DB2, only sniff tested, at this point it can only be considered a toy
very skeptical of the viability of any OS that uses an encoding that is not a superset of ASCII.” - Guido Van Rossum • “As a non-ASCII platform, z/OS is certainly challenging for people used to modern conventions, and that is exactly why a familiar and easy-to-use tool like Python is so valuable there.” - Lauri Alanko
lines of code • You can only manage so much complexity in a project • Many dynamic languages hide complexity in the language • The hidden cost here is the level of abstraction • So yes, you’ll have less lines of code for a ‘bigger’ project • IF YOU DO IT THE LANGUAGES WAY • Capacity handling, it needs to scale to X requests per second • Well, it depends on X … • Terrible answer but use it • If you need a certain functionality with a lower upfront cost • You don’t have time to develop scaffolding • Batteries Included comes at the cost of speed – just measure that cost
factor between these languages • When it comes to core qualities they all add, subtract, divide and fetch URLs for you • Structure and style of the code does vary • Some languages do have features that make them more suited for particular tasks • Bigger differences often come in the libraries and frameworks (quantity and quality) that are available for the language. • A developer must weigh their project needs against the available frameworks, along with their personal preferences