archives

SSA + Type Inference = "Compile time" dynamic typing, "runtime" static typing?

If we SSA transform our program and _then_ perform type inference (glossing over issues like if we get always infer somethings type), do we get strong static dynamic typing?

e.g.:

a = 1
b = a + 1
a = "hello"
printLine a
.
.
.
a0 = 1
b0 = a0 + 1
a1 = "hello"
printLine a1 

Of course there are scenarios like:

if condition then a = 1
else a =
"Hello"
end if

But I believe that these scenarios can be overcome. My question is then, is this impossible for any reason?

Ruby metaprogramming techniques

Back when Python was all the rage, we often discussed metaprogramming tricks in Python. Well, it seems the metaprogramming action has moved to Ruby, just like everything else... ;-)

Designing a Programming Textbook

This is a repost from my blog at Artima.com. In this forum, I am sure that I would have an interesting and differing point of view from those posted at Artima.
I've started work on a rather ambitious book called Fundamentals of Programming which will be intended as a programming book for people starting at the very beginning. I thought I would invite some feedback about my proposed structure.

I plan on breaking the book up into the following sections, with the primary example language for that section.

  1. Programming Basics - Cat
  2. Pointers and Memory Addressing - C++
  3. Object Oriented Programming - Java
  4. Functional Programming - Scheme
  5. Mixed Paradigm Programming - Scala
  6. Software Design - Cross Language
The language I associated with each section would be by no means exclusive. I would introduce that particular language, familiarize the user with it, and use it for the bulk of the examples.

One reason for using multiple languages is that I want beginners to be exposed to a wide breadth of languages, and ways of thinking. I want people to feel they are getting their money's worth by becoming familiar with several different major languages.

The usage of the Cat language is risky, since no one has heard of it. However, I really like the idea of starting a lesson on programming using the example of postfix calculators. This leads naturally to an interpreted stack based language.

The choice of Scala, is potentially contentious because Scala isn't as mature as Haskell or OCaml. However Scala is chock full of support for advanced programming techniques, it is type safe, and it has a sane syntax.

The final section would introduce the concept of using the appropriate language(s) for the job. As such I would be sure to mention languages like: Perl, PHP, Python, Assembly, TCL, and others.

The order of these sections are not intended as hard and fast rules. I am hoping to design the book such that entire sections can be skipped or moved. For example, Pointers and Memory Addressing can be placed at the end, or left out entirely. Another possibility is that Functional Programming can be placed before Object Oriented Programming.

What languages would you use, and how would you structure your ideal programming text? Do you already have a favourite introductory text that can't be improved on?