Monday, November 28, 2011

The loss of WYSIWYG in programming languages

As programming languages have evolved, we have moved from static languages to dynamic languages. These new languages offer new capabilities, but at a price. That price includes performance (perhaps not a great cost, given advances in hardware) but also the ease of understanding code.

Early programming languages of FORTRAN and COBOL were quite easy to understand. They did not allow for recursion (the early versions, at least), and offered static, up-front at compile/link time memory layout. You knew (or the linker knew) the location of every variable and every subroutine when the program was built. You knew the destination of every jump and the meaning of every statement. (Yes, COBOL had the 'ALTER' keyword, and FORTRAN had the "assigned goto", but they were proscribed in civilized shops.)

Of all languages, BASIC (prior to Visual Basic) was probably the most easily understood. It had a specific set of keywords, no pre-processor, strongly-typed variables, and no dynamic aspects.

The C language was one of the last languages in which "what you saw was what you got". A colleague referred to his "cortex compiler" when discussing the clarity of C code. One could look at source code and know the actions performed by the computer. (I am ignoring the effects of the pre-processor here. Poorly-design -- or even well-designed -- #define macros can change the normal meaning of C code and stymie all but the most careful analysis.)

Things changed with object-oriented languages. In object-oriented languages, one can look at the source code, but the action taken by the computer is not always obvious. To understand polymorphic code one must understand the inheritance hierarchy. To understand operators one must understand the class and its ancestors. Multiple inheritance (multiple implementation inheritance, as in C++) is rife with ambiguity.

(I'm ignoring LISP in this sequence. LISP, which dates back to the days of FORTRAN and COBOL, offered the same flexibility and dynamic constructs that it does today. But most programmers ignored it then, too.)

Java kept object-oriented programming but mercifully implemented multiple interface inheritance (and not multiple implementation inheritance) and eliminated the pre-processor and operator overloading, all which made it more obvious than C++.

Dynamic languages are now in the ascendant. Perl allows for lots of un-obvious constructs (some will snarkily comment that the entire language is un-obvious). Ruby lets one define or modify classes -- even the "standard" classes -- during run-time. (The shades of COBOL's 'ALTER' haunt us still.)

The trend may be towards dynamic languages, but not everything is moving in that direction. The up-and-coming functional programming languages (Haskell, Erlang) take a different approach and enforce strict definitions of functions and their results. Their syntax and organization is different from object-oriented programs, and can be difficult for those trained in O-O programming constructs. Despite the differences, I expect that these languages will, in the long run, be considered the more "obvious".

And we may, once again, have programs that are obviously understood, capable of being processed by our "cortex compilers".

Sunday, November 20, 2011

Android success

I successfully wrote an Android app today, and downloaded it to my tablet. It installs and runs! Woot!

OK, the app is simple -- trivial, really. It is a simple "Hello, world!" app that displays the "hello" message and the screen resolution.

I was impressed with how easy it was to test the app in the Eclipse simulator. I was also impressed with the ease of installation: on the PC copy the .apk file to the tablet and then on the tablet click on the .apk file.

Sunday, November 13, 2011

Playing with X

I took some time this week-end to play with X and remote access to computers.

First, I set up a virtual machine running Ubuntu Server edition 11.11. The server edition is plain Ubuntu without the Gnome front-end. It's a much better configuration for a server -- although it does require that one perform administration tasks on the command line. I had to refresh my memory of the 'apt' and 'aptitude' commands.

Second, I configured the virtual machine with a bridged network connection, so it will appear on my local network.

Then I configured Ubuntu Server to use a static IP address. That took some research (a minimal amount, thanks to Google) and some experiments (keep the "auto eth0" line in /etc/network/interfaces) and some tests with 'wget' to ensure that the configuration was correct.

Finally I installed ssh-server and 'xclock' on the Ubuntu Server and tried some connections. Connecting from a Windows PC running Xming and putty worked, and I was able to see the clock. Connecting from an Ubuntu PC failed at first; I had to use the 'ssh -X' command to connect, an 'export DISPLAY=192.168.1.102:0.0' command to identify my display, and also the 'xhosts +' command to allow connections.

I want to create an /etc/X0.hosts file; that should eliminate the need for the 'xhosts +' command. I'm not sure how I can auto-configure the DISPLAY variable... or if that is even desirable.

All in all, I feel pretty good about my accomplishments. Remote access with Linux is quite different from sharing desktops in Windows. The Linux approach has more possibilities: run X applications in my local display, share a KDE session, or share the whole desktop. Windows seems to be limited to the 'share a desktop' approach. (Can one SSH into Windows? That is, get just terminal -- a CMD.EXE terminal -- session?)

Tuesday, November 1, 2011

Looking at HTML5 and CSS3 with the .NET folks

I attended tonight's CMAP meeting, with a presentation on HTML5, CSS3, and Javascript. The meeting was well-attended, perhaps the best attendance I have seen. Apparently lots of Microsoft tech fans are interested in the subject.

And they should be. Microsoft let the cat out of the bag earlier this year, announcing that their new development platform supported HTML5 and Javascript. (That announcement may have been premature, but the direction seems correct.)

Tonight's meeting was about HTML5 and CSS3 and Javascript, and had very little about Microsoft tools. (It was given by a Microsoft employee and evangelist, so it seems credible.) The programming paradigm of HTML5 and CSS3 is very different from the old world of WPF and XAML. It is not specific to Windows or Internet Explorer -- it is cross-platform.

Interestingly, the presenter mentioned "inkscape" as a tool for experimenting with SVG. (Apparently Microsoft has no SVG editor.)

We are in a new world, a world of multiple technologies and multiple environments. Mobile phones, tablets, desktops, and servers all interact as part of your system. This new configuration is bigger than any one company.