Programming
(I retired in 2018 from computer programming and I am no longer updating this page so it may get outdated.)
See also my pages for:   JavaScript
Online Tips
Windows
"The computer programmer ... is a creator of universes for which he alone is the lawgiver ... No playwright, no stage director, no emperor, however powerful, has ever exercised such absolute authority to arrange a stage or field of battle and to command such unswervingly dutiful actors or troops." — Joseph Weizenbaum, Computer Power and Human Reason

Coding standards | Perl | Java | OOP | Alternatives | Visual Basic | Miscellaneous links | Newsgroups

  I retired in 2018 and most of my career has been as a computer programmer in business applications, starting out in the early 80s with COBOL, which was a hot new programming language at that time. After many years of college, I graduated in 1983 from The Center for Computer Education (CCE), a school in Newton that has since merged with Grumman Data Systems Institute and I think relocated to New York. I studied at MIT decades ago and learned C and it was the basis of many languages I've used including COBOL, Perl, Java, and JavaScript. I also took classes in Visual Basic, my first experience with GUI programming and loved it! Back in the 1980's I was an RPG programmer for years on IBM mid-range systems (System-38 and AS-400). In the 1990s I learned HTML and created this website. The last 15 years of my career I was a Perl programmer creating web applications. Most of the code I've written has been PC-based and I used Textpad as my editor, which is an MDI editor that allows multiple files to be open on tabs and provides language-specific color-tokenizing. I still use it at home to edit the html on my website. When I was coding for a living I frequently shared things on this page, but since I retired it has gotten much less of my attention.

The quote at the top describes pretty well why I have loved my profession. I may sound like a real control freak but my left-brain needs an environment where it can exercise its desire for logic and order without causing too many waves, and programming is it.


Coding standards
  The following quote is from a Perl book but it applies to all languages.

"You will typically spend at least four times longer maintaining code than you spent writing it [Boehm's Law]. So it makes sense to optimize your programming style for readability, not writability. Better yet, try to optimize for comprehensibility: easy-to-read and easy-to-understand aren't necessarily the same thing." — Damian Conway, Perl Best Practices

I strongly stress the importance of making your code readable by others. In some languages (HTML and Perl are a couple of examples) you can combine multiple elements in the same line (you could theoretically write all the code for a webpage or script in a single line), but this makes it difficult to decipher the logic when your code is being worked with. I always make my opening and closing tags and any lines in logic blocks line up vertically and indented, and opening and closing braces, { ... }, line up in a consistent, fixed pattern. This makes it so much easier to interpret the structure of the code when you are looking at it. You can see this in any code examples (view this page) I provide on my website. Just spending a little extra time to do this when creating code can save a tremendous amount of time for anybody (including yourself) who modifies it later.

And remember:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. — Damian Conway, Perl Best Practices



Perl
  Professionally as a web programmer Perl was my primary language. One of my first projects using Perl was to make the listings of current job openings on our company website dynamically load instead of being typed into a static webpage. Previously, the Human Resources (HR) department would email information for new job openings to the web development department, where it would be formatted in HTML, and when the job was filled the page would have to be edited again to remove it. I wrote an application that enables the HR department to enter the job descriptions into a database, and then I modified the Current Openings page of the website to run a script that querys this database and lists the available jobs. If you click on a specific job title on the list it will read the database and display the job description. (I think this has been replaced since my version.) When the job is filled the database is updated and the job will not longer display on the webpage. Both the web-based maintenance application and the listings pages were done in Perl. All my Perl scripts run in the cgi-bin directory.

Perldoc – Perl documentation
CPAN – Comprehensive Perl Archive Network

 Perl tips & examples
I thought an easy way to show some Perl how-to info was to display some scripts I have created.
  • Click on the Title (green color) to run the application
  • Click on the name.pl (red color) to view the source

print_source.pl I wrote this perl script and I'm using it on my website wherever you see the option to click on a title to see the source-code (e.g. program.html—this page). The way it works is that it reads in the parmed source-file and modifies some of the elements to make them browser-friendly—for example, substituting entities for < and > brackets, <br> for newline, and spaces for tab—then displays it in the browser to look just like it does in the editor.
Create link
create_link.pl
At times I have wanted to download a file that is embedded in the HTML of a webpage and I would have to create a little webpage with a link to the file so I could use the Save Target As option on the the right mouse button context menu. This script will allow you to just type in the URL and a web link is created automatically. Since creating it I have found it useful for other things, for instance, at work I wanted my initial Perl script in one application to show a button to go back to the previous webpage if the script is called from a link (using $ENV{'HTTP_REFERER'}), but not if the script was run from a shortcut or typed into the address bar of the browser. I used the Create link script to quickly create a link to call my script for the test.
My songs

I am always telling people about songs I have on my smartphone (previously iPod), so to share some of these songs with others I uploaded them to a folder on my web server and wrote a script to show a list of the songs in that folder.

Please note:   I used to share these as playable MP3s playsongs.pl. but they had to be removed from the server (see explanation) so the My songs page has been changed.

All the songs on my smartphone are stored in a folder on my PC (named "ipod" because before my smartphone these songs were played on an iPod), and to show a list of those songs I wrote two scripts:
  listsongs.pl ··· builds a file of the songs which I then upload to the server
  viewsongs.pl ··· displays that uploaded file as a list of songs (display only, not playable)

I am also using this same process to display a list of the eBooks I have on my phone.
Expand/contract list
plus_minus.pl
I wanted to try to emulate the old Windows Explorer, where if a folder has a sub-folder you get a button in front of it that you click on to expand the tree. This changes to a (minus) which you can click on to contract it. Because of the stateless nature of Perl, coding this was a little more elaborate than I anticipated when I started working on it, but I accomplished it.
Mypics
showpics.pl
show_thumbs.pl
When I started taking digital photos, first with a camera then with my phone, I wanted to show some friends the photos I was taking so I made a script to list them dynamically as links. When I present photographs on a webpage I usually create a thumbnail of the photo to click on to see an enlargement, so I wrote a Perl script (show_thumbs.pl) to create the thumbnails dynamically, specifying a width attribute on the <img> tag for the thumbnail which creates a height with the same aspect ratio as the original image. One consideration when using this technique is that all the image files have to download completely before the page is entirely formatted with the thumbnails, but most people I know have high-speed Internet connections now so that was not a problem. The Mypics webpage runs both of these using Ajax (that is one of the best methods to embed Perl in HTML pages). I have since cloned these scripts to show photos I take with my cellphone.
Reunion Photos
skip.pl
My high school classmate Skip sent me 68 printed photos from a class reunion, which I had offered to scan in and put on my Class Reunion page. There were so many photos that rather than create thumbnails individually like I had done for all the rest of the photos on my Reunion page I decided to clone show_thumbs.pl above to create them, and I am using Ajax to put them on the reunion page.
Perl/Ajax/HTML
One technique I like to use on my website is having a simple HTML template use Ajax to call perl to format the content. This is especially useful when you have a lot of items you wish to list or display and you don't want to tediously create all the HTML to present them. You can put them in a single folder and have perl read and list them. You can even dynamically create thumbnails (show_thumbs.pl) for photos, which I do on some of these pages.
log_visits.pl
I log visits to pages on my website.
view_log.pl
I wrote this script to display the logs of visits to my website. I cloned print_source.pl but modified it to reverse the order of the log data to display the most recent visits at the top.
Videos
I used to show all videos on my website in popups using Perl scripts.
(I now show each video in a webpage template using Javascript that gives you a URL for the video you can share with others.)

Using Popups
play_flv.pl ··· I wrote this script to play Flash videos (flv files) on my server with this Flash Video Player.
Example usage: <a href="cgi-bin/play_flv.pl?filename=somefile.flv&width=400&height=360&title=Window%20Title">

To see local flv in popup . . .

Letterman Top 10

Now see using my template.

show_video.pl ··· I wrote this script to play other video formats, including mpg, wmv, and avi.
Example usage: <a href="cgi-bin/show_video.pl?filename=somefile.wmv&width=400&height=360&title=Window%20Title">

To see local wmv in popup . . .

Granny air bag

Now see using my template.

video_embed.pl ··· Most of the videos on my website are on my server, but sometimes I like to link to videos on a remote site like YouTube, showing them in my own popups. Some browsers don't like linking directly to the videos in JavaScript, so I wrote this script to play the videos using <object> and <embed> tags.
Example usage: <a href="cgi-bin/video_embed.pl?video=http://www.youtube.com/v/6gmP4nk0EOE?autoplay=1&width=400&height=360&title=Window%20Title">
You have to know the path to the video ("http://www.youtube.com/v/..."), which is often shown in the <embed> instructions on the remote video page.
If the URLs to videos already have CGI characters (which would be confused with my usage), I replace ? with | and & with ` and they will be restored in video_embed.pl.
Please note. Sometimes you are prohibited from embedding an uploaded video in a webpage so this will not work with those.

To see remote video in popup . . .

Monty Python

Now see using my template.


This HTML link calls the popup function with the video to play.
<a href="cgi-bin/play_flv.pl?filename=somefile.flv&width=500&height=375&title=Window%20Title" onClick="showVideo(this.href,520,385);return false;">
This JavaScript creates a popup containing the output from the Perl script that is specified in the first parameter in the link.
function showVideo(ref, width, height) { var parms = 'width=' + width + ',height=' + height + ',left=200,top=200,resizable=yes' var target = 'myvideo'; // using the same target name makes all videos use the same window object popupWindow=window.open(ref, target, parms); // make the window dimensions slightly larger than the video var wplus = 10; var hplus = 55; // increase height for IE7 to accomodate location toolbar var ie7 = ((document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1)); if (ie7) { hplus = 90; } var rwdth = width + wplus; var rhght = height + hplus; popupWindow.resizeTo(rwdth,rhght); popupWindow.focus(); }


Java
 
For years I had a Java page on my website (back when I was a Java programmer) that is no longer linked on my main page. Maybe some day I will just put all the content here.


Object-oriented programming
  What is object-oriented programming? OOP could be described as a collection of objects (called classes) exchanging messages to achieve a common objective. This might seem a little vague without a good metaphor. The following is from the book, Teach Yourself Java in 21 days, by Laura Lemay and Charles L. Perkins.

   "You can walk into a computer store and, with a little background and often some help, assemble an entire PC computer system from various components: a motherboard, a CPU chip, a video card, a hard disk, a keyboard, and so on. Ideally, when you finish assembling all the various self-contained units, you have a system in which all the units work together to create a larger system with which you can solve the problems you bought the computer for in the first place.

Internally, each of those components may be vastly complicated and engineered by different companies with different methods of design. But you don't need to know how the component works, what every chip on the board does, or how, when you press the A key, an "A" gets sent to your computer. As the assembler of the overall system, each component you use is a self-contained unit, and all you are interested in is how the units interact with each other. Will this video card fit into the slots of the motherboard and will this monitor work with this video card? Will each particular component speak the right commands to the other components it interacts with so that each part of the computer is understood by every other part? Once you know what the interactions are between the components and can match the interactions, putting together the overall system is easy.

What does this have to do with programming? Everything. Object-oriented programming works in exactly the same way. Using object-oriented programming, your overall program is made up of lots of different self-contained components (objects), each of which has a specific role in the program and all of which can talk to each other in predefined ways."
  

Popular object-oriented programming languages are C++, Smalltalk, Visual Basic, and Java. The concepts which I think most define OOP languages are:
   Encapsulation - including in an object everything it needs, hiding elements that other objects, which communicate with it through public interfaces¹, needn't know about
   Inheritance - creating a new type of object from an existing one, in which the new object (subclass) inherits all the elements from the existing one (superclass)
   Polymorphism - different objects, with their own, unique versions of the same methods, responding to the same message in different ways
This cup of coffee example illustrates these three principles using the interaction between customer, waiter, and kitchen.

¹ "VCRs, watches, cars, and other real-world objects are excellent examples of the kind of objects we wish to emulate, because they successfully hide all the myriad complexities behind really simple interfaces."   -- Sriram Srinivasan, Advanced Perl Programming

 
     OOP links
Object-Oriented Programming Concepts – from The Java Tutorial at Sun
Object-Oriented Programming – from whatis?com
Object-Oriented Programming – from FOLDOC
Object-Oriented Programming Jokes
What is Object Oriented Programming?- writer/teacher Elliotte Rusty Harold
Links on OOP – from SUMit, a Dutch company
Comparing OOP Languages: Java, C++, Object Pascal


Alternatives . . .
  Sometimes it may seem as if it's a Microsoft world where software for IBM-compatible computers is concerned. However, there is alternative software that is quite resilient, and even superior to Windows products. As operating systems go, as I mentioned above, I used to write for OS/2, and I re-booted much less frequently than I do in Windows. My company switched to Windows when IBM moved from OS/2 to Windows 95 as the development environment for VisualAge-RPG (for creating GUI client-server apps but discontinued by IBM). Another operating system, Linux, has a reputation for being very stable, and servers running Linux can operate for months without being re-booted. When I was working (I retired in 2018) we had Linux on our servers at work, and my website runs on a Linux server, so I have to understand the basics of the language (particularly using permissions and being aware of it being case-sensitive).

I believe strongly in the Open Source concept of programming. In the early 90s, when I first became interested in learning HTML, there were not that many books on the subject, but I was able to review the code in the browser and see how the various tags performed. You may say that HTML is only an interpreted lanquage, and the source-code must be present in the browser at run-time, but the concept is the same, and I have always been stirred up by those who make postings to web-authoring newsgroups about wanting to hide their JavaScript source-code from others, probably for some selfish, profit-oriented motive. Linux is getting all the press as the current darling of the Open Source movement. However, I still prefer to work in a graphical environment, and even though there are graphical front-ends for Linux, that still smacks of running Windows 3.1 on DOS. Anyway, as I said, I support the concept, and I am proud to be in the brotherhood of programmers that are subscribing to it. I even put a (Copyleft) sticker on the back of my car.

When I was writing Java applets I was creating objects that are not fully supported by Microsoft (MS has their own version, which has gotten them into trouble with Sun), but thanks to plug-ins and runtimes by Sun and others these objects can run on a Windows platform. Java is aligned with the Open Source movement and there are some links relating to this on my Java page.

Open Source Initiative (OSI) – an idea whose time has come
Richard Stallman's Personal Page – leader of the free software movement
GNU's Not Unix! – the GNU Project and the Free Software Foundation
Alternative Operating Systems – from Consumer Project on Technology (CPT)
The FreeBSD Project – an advanced free OS from UC Berkeley
Copyleft.netGeek chic!
Slashdot – News for Nerds. Stuff that matters.
The Apache Software Foundation
Perl Mongers – the Perl advocacy people
The Mozilla Organization
     Linux
Red Hat -- Linux, Embedded Linux and Open Source Solutions
IBM Linux Portal
     Linux links
Linux Online
     How to Pronounce "Linux" – audio clip of Linus Torvalds pronouncing the word "Linux"
Linux Journal
Linux Documentation Project
LinuxProgramming.com
Linux Center
Red Hat Linux User's FAQ
LinuxQuestions.org
     OS/2  (I guess this is a little dated now)
IBM OS/2 Warp
The OS/2 WWW Homepage – MIT site includes links to many other OS/2 sites
Yahoo! Computers and Internet > Software > Operating Systems > OS/2


Visual Basic     VB
  Back in the 90s I studied VB at MIT and it was my first experience with GUI programming and a visual-programming IDE.

Microsoft Visual Basic Home
VBRun Drivers
Visual Basic Jobs - Job Listing Service for Visual Basic
VBxtras – other Visual Basic sites on the web
VB Help at DevX
searchVB.com
VBnet – developers resource centre
vbip.com – Visual Basic Internet Programming
VBWire – Visual Basic News & Information Source
Visual Basic Code at VBCode.com


Miscellaneous programming and computer links
(see more at Internet & Technology links)
     IBM
iSeries and AS/400: e-servers from IBM, Integrated Application Servers
IBM Corporation
    IBM Search – search IBM's sites
WebSphere MQ (formerly MQSeries)
iSeries NetworkiSeries forums (formerly News400.com)
AS/400 FAQ – uses Faq-O-Matic
MIDGRANGE.COM Mailing List Archive – years of searchable threads
search400.com – the iSeries-specific search engine
    Best iSeries websites
searchDomino.com – the Domino-specific search engine
     Other
MQSeries.net
RocketAware – Programmer's Webliography and Index
Developer.com
Netscape Home Page
Microsoft Homepage


Newsgroups
  I used to have all the related usenet groups listed here but they don't seem to function in browsers anymore, so I am just providing links to Google Groups, where they are offered in a web format.
     Windows
comp.os.ms-windows
     Linux
comp.os.linux
     Perl
comp.lang.perl
     Java
comp.lang.java

  There are more programming newsgroups on my pages for JavaScript, Windows, and Online Tips.