Friday, August 31, 2007

The Fundamental Theory of Ada

About 20 years ago, in the late 80s, I was at an Ada Conference attending a seminar being taught by Doug Bryan, who was then at Stanford University. Bryan was talking about how to get the most out of Ada, of which a critical aspect is understanding the underlying design principles of the language. The key concept he was trying to get across in this seminar was that Ada's design centered around a "type model". If you understood how Ada's type model worked, he said, then you understood why the language came out the way it did, and how to work with the language, instead of fighting against it.

While I'd been programming in Ada for a few years by then, this was the first time that I truly realized there might be something underlying and guiding the definition of a programming language, that there might be more to creating a programming language than getting a bunch of people together to make up declaration and statement and packaging syntax and semantics.

The realization that a type model for Ada existed turned out to be the genesis of what eventually coalesced into my idea of a programming language's Fundamental Theory. Today I recognize that the Fundamental Theory of Ada is its type model.

By enshrining the type model as its FT, Ada allows a huge amount of information to be intrinsically embedded within Ada programs with a simple type definition. This information is then readily accessible to the developer through the use of Ada's attributes.

Take a simple example:

type Speed_Range is range 0 .. 1000;

With nothing more than a reference to an object of that type:

Speed : Speed_Range;

One can know its minimum value (Speed_Range'First), maximum value (Speed_Range'Last), the minimum number of bits needed to represent all possible values of the type (Speed_Range'Size), the actual number of bits representing a variable of that type (Speed'Size, which is often larger than the type size since objects almost always occupy a whole number of bytes), the number of characters needed to represent the longest possible string representation of values of that type (Speed_Range'Width), etc. You can convert values to and from strings (Speed_Range'Image, Speed_Range'Value), do min/max comparisons (Speed_Range'Min(100, Speed), Speed_Range'Max(Current_Max, Speed)), and use the type as a loop controller ("for S in Speed_Range loop" and "while S in Speed_Range loop"), and more. And none of this information needs to be explicitly programmed by a developer, it is all implicitly provided by the mere definition of the type.

Different kinds of scalar types may have these and other attributes appropriate to the nature of the type: floating point types have attributes for identifying the underlying constituents, accuracy and representational limitations of a floating point type definition, while enumeration types also have attributes to access all positional aspects of the type's values.

Ada's type model extends well beyond simple scalar types: inheritance is obviously based on inheriting from other types via the "tagged" modifier, static polymorphism comes through generic (template) instantiations with the desired types, and dynamic polymorphism is provided by tagged, "abstract" types. Even Ada's concurrency constructs are type-oriented, i.e. task types and protected types (while singletons of each of these can be declared, what goes on under the surface is that a corresponding anonymous type is implicitly defined of which the singleton is the only object). By declaring a subprogram profile type, subprograms themselves are treatable as type objects.

The supporting infrastructure of executable constructs, i.e. the statements, are all then integrated with this type model, and able to exploit the information that is an implicit part of each type, for example in the "loop over the type" statements mentioned above, as well as is done with array handling:

for I in Race_Speeds_List'Range loop ...

There is one area of non-conformance, though. For some reason the whole exception mechanism was not well integrated with the type model. There's nothing that can be construed as an "exception type" in the language (although an exception type mechanism was proposed for the Ada 2005 language revision, it was rejected). So there's no hierarchy of exceptions, no inheritance, and while the Ada 95 revision did incorporate the creation of exception "objects" to which data could be attached (which must, though, be in the form of a string), exception handling is recognized as admittedly inferior to that of most other commonly used languages.

Despite the exception deficiencies, the Ada standard has conformed very well to its fundamental type model theory throughout its evolution. Even when major revisions were made during the Ada 83 to Ada 95 revision process to incorporate full object orientation, that capability was defined as an extension of the existing type mechanisms. (And the fact that improvements to the exception mechanism center around "type-ifying" exceptions show that the type model is recognized as the driving factor of the language's design.)

Understanding and exploiting the Fundamental Theory of Ada leads to more reliable and more efficient software. One issue programmers new to Ada invariably run into and complain about is the preponderance of compilation failures due to "type mismatches" in their code. "Why can't I multiply velocity by a time interval and add it to distance? They're all just numbers!" That's just it, they're not just numbers, they are abstracted entities, each with their own characteristics and constraints, modeled in the language's typing system, and that are only allowed to interact in well-defined ways. Other languages model entities this way, too, except that they require the developer to explicitly model them as classes, while in Ada the language itself effectively performs the type modeling for these kinds of quantities.

By understanding and exploiting the Fundamental Theory of Ada, by understanding what an Ada type represents, an abundance of information about the problem domain can be embedded within the software, can be easily exploited, and can lead to the efficient production of reliable software.

Thursday, August 30, 2007

Fundamental Theories of Programming Languages

A well-designed programming language will have a coherent and consistent design philosophy underlying it. This design philosophy governs what features should, and should not, be explicitly included within the language, and therefore also guides the evolution of the language over its lifetime of use. The syntactic and semantic form and function of language features, and how they interoperate with one another, should reflect that philosophy, both in the initial language definition and in the features that accrue to it over time.

Because understanding this design philosophy explains how a programming language is supposed to work and be used, we have what amounts to specific theories for specific programming languages. Languages having a theory (or design philosophy) thus have an overarching principle around which the programming language was designed. That principle is The Fundamental Theory of that language, because it explains (or should explain) why all the pieces of the language are the way they are.

A developer who is aware of the Fundamental Theory of the language they're working with (assuming it has one, not all do) then has a guide on how best to exploit the language and its features. Rather than struggling with the structure of the language, a developer can get in sync with its FT and understand how best to fit together and exploit its pieces to accomplish a given task. While coding standards for programming languages are common, they're rarely conciously derived from the language's FT and instead end up being a collection of formatting strictures and illustrations of how to write code in the particular language that embody "good practices". All well and fine, but these usually end up being ad hoc collections based on developers' past experiences and preferences, and don't reflect a deep understanding of the language's design philosophy--i.e. its Fundamental Theory.

In upcoming "Fundamental Theory of Language X" postings I'm going to identify what I believe to be various programming languages' FTs, how well the definition of the language conforms to that Theory, and what's happening to the language's conformance to its own fundamentals as it evolves over time. Some languages have little or no evidence of an FT, and some of those will be called out as well.

As opposed to most punditry, I'm going to limit myself to those languages that I've actually used, rather than make assertions and draw definitive conclusions in areas about which I know little or nothing. (Though I may make a few comments on some languages from the perspective of one looking to learn them and whether I perceive them to have an identifiable Fundamental Theory that would aid learning and exploiting them. :-)

Tuesday, August 28, 2007

Smackdown for the Window Cube

It's unfortunate that I get along with all my co-workers, otherwise I could've tried out for this reality show.

Monday, August 27, 2007

"Some People Out There In Our Nation Don't Have Maps"

This is just...breathtaking.

God is Rational/God is not Irrational

God is a rational being.

I want to define the term "rational" so that there's no confusion about what I mean by that, since being rational and "making sense" is going to come up from time to time.

Sometimes there's this notion of rational meaning cold, calculating, machine-like, as in "coolly rational". That's not what I mean when I use the term. The definition provided by WordNet: "consistent with or based on or using reason; 'rational behavior'; 'a process of rational inference'; 'rational thought'", pretty much nails the way I would use the term. (And there's plenty of room for mercy, forgiveness, and self-sacrifice in a rational world.)

It should go without saying that Of course God is a rational being. But that's isn't how you'll hear Him described by the anti-theistic (in a future post I'll get into the fundamental misunderstandings of the nature of God held by anti-theists that cause them to see God as arbitrary, callous, and capricious).

Simply put, God does things for a reason, an understandable reason. Sometimes He does so explicitly: Why did God "send his only begotten Son, that whosoever believeth on him should not perish, but have everlasting life"? Answer: Because He "so loved the world". (John 3:16)

Sometimes the reason is implicit: Why does a rock fall? Because gravity acts on it. (Bonus question: How does gravity work? Answer: Still working on it... :-)

When you study the world and the universe, cause and effect is clearly the Law of the land. Every effect has a cause, and the relationship between that cause and its effect can be uncovered and understood. Sometimes the cause, or the relationship between the cause and effect, is extraordinarily complicated, but we persevere because there has not been a single known instance of an effect for which a coherent cause was not eventually found.

In human and spiritual relationships, cause and effect operates there as well, though because of the marvelous complexity of the participants in these relationships the exact cause and its relation to actions (the effects) is not always so clear. Think about everything you do--isn't there always a reason for every single act you perform? Most of these are mundane: I'm hungry, therefore I'll grab some chips; I'm having a hard time seeing, I'll turn on a light. Sometimes the act is ill-conceived, but you still had a reason that you may have to concede now is that it only seemed like a good idea at the time.

Everything we know of God as given in the Bible indicates that God does things for understandable and sensible reasons, which makes God rational. We're molded in the image of God, that makes us rational. The universe operates by cause and effect, which reflects and reinforces the idea of God's rationality.

There are two points here:
  • When there's competing candidate causes for a given effect, the one that is most consistent with the cause and effect of the universe, due to its reflection of the rational nature of God, is the cause most likely to be correct.
  • When causes have been identified that are going to execute within a certain context, the anticipated effects will be those most consistent with the rational nature of God and the cause-and-effect universe.
Everything that goes on in the universe, natural and supernatural, has to make sense to be consistent with the rationality of God, and therefore it does make sense, and now we just need to figure out the particulars.

Knowing that God is rational gives us a solid foundation for learning and comprehending everything around us, and allows us to use our senses and our intellect to make judgments about what makes sense and what doesn't, which advances us further down the path to Truth.

Saturday, August 25, 2007

1 Month/Hour

The normal rainfall total for August here in northern AL is about 2.5 inches.

Last night, between 12:12 am and 1:12 am we got the entire month's allotment, plus. 2.87 inches in one hour, as reported by my La Crosse Technology weather station.

Now it's sauna time!

Thursday, August 23, 2007

Jesus is NOT coming soon--Part 2

Civilization has existed on this planet for around 6,000 years. The industrial and modern technological civilization has been going on for about the last 250 years, and we've been a spacefaring civilization for barely 50 years. Only twelve men from Earth have visited another heavenly body, and just a handful of robotic spacecraft have gone out to explore the outer solar system: Pioneer, Voyager, Galileo, Cassini, and New Horizons.

Conservative estimates place the number of galaxies in the universe at over 125 billion. The average number of stars in a galaxy is a hundred or so billion. Extra-solar planets are now being regularly discovered (217 at the time of this posting), with the ability to detect rocky, terrestrial-like planets orbiting around other stars just a few years away.

All the matter that we can "see" via visible light, IR, ultraviolet, X-rays, gamma rays, radio and everything in-between in the universe makes up only 4% of the universe's mass. The remainder is made up of 23% Cold Dark Matter and 73% Dark Energy. We know the dark stuff is out there because we can see its gravitational effect on galactic rotation and via gravitational lensing.

Amongst the stuff we can see are galaxies colliding and tearing each other apart, monster black holes sitting at the hearts of galaxies, and a pulsating star careening through space leaving a trail of star- and planet-forming debris in its wake.

The universe has been cooking along for 13.7 billion years, constantly expanding with bits of it crashing into each other, and exploding, and collapsing, and producing just massively wonderful and puzzling things no matter which way you look in the sky. Almost everything you see in a Hubble deep-field image is a galaxy. There is so much out there that we're only now getting the tools and technology to see and begin to understand.

So there's all this wonder, this huge, colossal, UNIVERSE of wonder and mystery to see and explore, and we're only fifty years into stepping out into space, and so after waiting over 13 BILLION years to get here, God is going to say "That's it! I'm done, time for the Rapture, close it all down."

Excuse me?

If that's the case, then what was the frickin' point of putting hundreds of billions of galaxies out there? Am I hearing that 6000 years of mostly subsistence-level civilization and 12 men on the moon is a fitting way to cap off 13.7 billion years of history? Why the grandeur? Why the dark matter and dark energy? Why make us curious? Why let us just start to seriously look and explore and understand and then shut everything down?

It doesn't make any sense.

So the universe, the whole, entire universe is now going to be terminated because everything God wanted to accomplish with His creation has now culminated with events on planet Earth?

Physically speaking, the earth and its civilization are irrelevant to the universe. We're on a chunk of rock orbiting a yellow dwarf star on the outer edge of a medium-sized galaxy that's part of a Local Group of galaxies that collects together a few of those hundred or so billion. Out beyond about a hundred light years from the Sun there is no evidence of our human existence in this universe (and what evidence there is is only the faint and fading electromagnetic signals of radio and television, the latter of which has only traveled about 70 light years).

If the earth was destroyed or depopulated tomorrow, via nuclear holocaust, or genetically engineered plague, or 500 mile wide asteroid crashing into the planet, the universe wouldn't notice. At all.

If humanity had never come into existence, the universe wouldn't have noticed. At all.

So how can it possibly be suggested that it's nearly time for the entire universe to come to an end because of events that are occurring somewhere that are totally irrelevant to it? Events that have never had any effect on it?

Again, it doesn't make sense.

Millenia from now, when humanity has escaped our planet and our solar system, our descendants will discover, and explore, and begin to really understand things like the singularity at the heart of a black hole and the dark energy that is driving the galaxies apart. They'll populate nearby star systems, then spread into the galaxy, then other galaxies. Tens, hundreds, or thousands of millenia from now humanity will have had its effect on the galaxy, and we will have made a difference, for good and for ill, in the universe. And only then, maybe, would it be time to start thinking about the end of history.

SOA In CrossTalk

If you're not still keeping up with CrossTalk, the latest issue is on SOA experiences.

Wednesday, August 22, 2007

Jesus is NOT coming soon--Part 1

Back in the 70s and early 80s I was very interested in eschatology and the End Times. There was the occasional sermon on the subject, I went to the seminars at our denomination's annual Youth conferences, and sometimes a guest speaker came in to our or a neighboring church and we'd go to hear him.

So I heard a lot from the book of Daniel about Nebuchadnezzar's dream, the horns, the mouthy horn, and from Revelation with its seals, horsemen, etc. Not to mention the Rapture, the Tribulation, Armegeddon, and the Millenium.

It was also very clear from the studies these men were doing that prophecies were coming true, that we were nearing the End Times, and so needed to be watchful for the Anti-Christ ("the Antichrist [is] a male Jew who [is] probably already alive" -- Jerry Falwell, 1999), 666, and so on. As Jesus Himself said, "No one knows about that day or hour, not even the angels in heaven, nor the Son, but only the Father. So you also must be ready, because the Son of Man will come at an hour when you do not expect him" (Matt 24:36,44). It was readily apparent to everyone that Jesus' return was imminent, with the odds of making it out of the 80s unlikely. And 2000? Well, it would absolutely be a done deal by then.

For the last 30 years now I've heard how the End Times is imminent, never more than just a few years away. Now it's out at 2010, 2014, ..., but definitely soon.

But those verses that believers interpret to mean the Rapture could happen any time in the next few days, months, or years, reads equally well that it could happen any century, or any millennium. Maybe the year 2742, maybe 3496, maybe 10423. I mean, it's been 2000 years, why not 2000 more?

Yet there's all the evidence of prophecy being fulfilled--the famines, the wars, the earthquakes ("increasing in frequency and severity" as one speaker during my teens put it), the restoration of the state of Israel, the capability for instant worldwide communication, etc.

I know that the people who study this stuff are very diligent, and very serious, and try very hard to understand these prophecies. It's a difficult task, because they're trying to interpret and correlate arcane, cryptic imagery recorded in terms of a world view thousands of years old with recent and current events taking place in a fantastically complex and inter-dependent world of geology, climatology, economics, politics, and culture. So it's no wonder that so many have gotten it so wrong over so long a span of time.

We always think, though, that we're more advanced now, we know more, we understand better, so now we see what was missed before, and clearly now we're nearing the End Times. I expect that's what Whisenaut and Hal Lindsey and Charles Taylor all thought as well.

I think there's some good reasons in fact to think that Jesus is NOT returning any time soon, which I'll get to in Part 2, but either way I think we'd all be better off simply taking Jesus at His word: "No one knows about that day or hour". It's not going to be figured out by anyone, and a lot of time and effort is being wasted on something that is simply going to happen when it happens. In the meantime money is being wasted on books and movies ("Left Behind"), there's fear-mongering, and justification for trashing the environment because Jesus will be returning soon ("As for those evangelicals who believe the second coming of Jesus Christ lets them off the hook in caring for the earth, Rev. Ball says, “With most of these folks, it takes me about two minutes to punch a huge hole in [the Rapture] argument.... I also say, 'Well, you take care of your body, don't you?'”.

Maybe the alternative demands more of Believers than they're ready to bear--if you accept as a hard reality that Christ isn't returning in your lifetime, and that you're going to have to live out your whole life in this world, as will your children, and your grandchildren, and so on for your descendants for centuries or millenia yet to come, then what are your responsibilities to future generations, and how well are you performing them?

Drive around the Tarantula Nebula!

The European Southern Observatory has an incredibly detailed, zoomable image of the Large Magellanic Cloud's Tarantula Nebula. Here's APOD's writeup on "Tentacles of the Tarantula Nebula".

Tuesday, August 21, 2007

This is your father's Java

Steve Yegge of Stevey's Blog Rants was a keynote speaker at O'Reilly's OSCON recently, and spoke on branding. You can view his keynote address here. It runs about 25 minutes, and is pretty interesting.

One of his supporting points, though, really kinda caught my attention. He observed that within just a couple of years from now the new entrants into the workforce will have been born after the creation of Java. To them, Java is going to be the language their Dad uses, so it's OLD. They're going to want to program using the latest, coolest, language.

So what language is that? Steve believes the NBL (Next Big Language) is JavaScript 2.0, which he offhandedly revealed at the end of his talk. 2.0 is still undergoing standardization, but I found a paper that discusses its design goals. I'm still reading through and studying it--and I don't know, maybe it's because of my dinosaur upbringing--but I can still see developers getting into a world of hurt with it, in spite of the effort being made to reign it in a bit and address the worst of its perversities (like being allowed to call functions with the wrong number of arguments).

Once I'm done with the paper and trying out some stuff, I'll try to post some thoughts.

Monday, August 20, 2007

Oh my God I used to work here!

This so describes my former employer to a tee it's disconcerting.

Do you have a dysfunctional workplace?

"Life is not '24'"

John McCain riffing on how coercive interrogations do not work...

"Tell me where the nuclear weapon is!

"'No!'

"BOOM!

"'I'll tell you where it is.'"


More importantly, though: "I'd close Guantanamo Bay and I'd declare we never torture another person in American custody."

Here's the whole appearance:

Saturday, August 18, 2007

The Next President of the USA

Soon Americans will be electing a new leader of the United States of America. The election is about 15 months away. Already, I am sick of the rhetoric of the current candidates. The current president is as much of a lame duck as I have seen in my lifetime. It's embarrassing to have a president who is often unable to express his thoughts cleanly. It gives one the impression of extreme ineptitude regardless of the intent and possible underlying intelligence.

So, the questions are... Who will the next American President be? What moral character is required? What intelligence level is required? What leadership skills are required? and.. What experience is required?

Having spent a lot of time in Los Angeles this past summer, I have gotten a good look at Hollywood and the Beach Cities. I have seen the likes of people who say there is the east coast, the west coast, and Jesusland inbetween. Well, as someone from Jesusland, I am not very impressed with intelligence that I see displayed by the average Angeleno. There is something about Los Angeles that brings out the worst in people. One of the most noticable detractions is stunted intelligence. A lot of this is due to the incredible melting pot of cultures. My point here is not to rail on the city of Los Angeles or it's people. My point is, here is one of the most advanced cities on earth, and I am questioning the intelligence I see on the street. It begs the question, who is actually voting for the next President and what are they looking for?

Or, does it even matter what people think? It may already be decided by power brokers and people with money.

What do you think?

Dan

Post #1

Dan,

Looking forward to the conversation. Hopefully this medium will encourage me to be a more regular and reliable correspondent :-)

I've got a whole backlog of topics building up, so hopefully we'll keep this kickin' for quite awhile.

Lemme know when you're here, and we'll get things kicked off.

Ciao dude!

Marc