Johnny's Software Saloon

Weblog where I discuss things that really interest me. Things like Java software development, Ruby, Ruby on Rails, Macintosh software, Cocoa, Eclipse IDE, OOP, content management, XML technologies, CSS and XSLT document styling, artificial intelligence, standard document formats, and cool non-computing technologies.

My Photo
Name:
Location: Germantown, Maryland, United States

I like writing software, listening to music (mostly country and rock but a little of everything), walking around outside, reading (when I have the time), relaxing in front of my TV watching my TiVo, playing with my cat, and riding around in my hybrid gas/electric car.

Friday, May 26, 2006

I learned Pascal when I was in my teens, C and C++ in twenties, Javascript 2 going back to Pascal more these days

There are some interesting developments on the computer languages front.

Javascript, which was pretty non-statically typed - and almost impossible to check for type-mismatch errors prior to runtime - might be in for a change.

A presentation on planned or at least seriously-considered proposed changes to the Javascript language came out this year. Javascript 2 could be out, with these features implemented, as early as next year (2007).

When I was a kid in high school, I taught myself Pascal. The structured programming things in it seemed very neat, and I was really impressed with the power of the language.

People told me the strict compile-time type-checking was a problem with the language, but I never felt that was the case. I used it a good bit in college and I used it briefly on a couple jobs I did.

When I learned C in my mid-twenties, I appreciated the terseness of the language. I badly missed the compile-time checking of function parameters and such. Pre-ANSI took the attitude that you always knew what you were doing, and never made mistakes. I pathological programming philosphy, if there ever was one.

I managed okay with old-style C, thanks to the now-defunct programming tool called lint.

When I got a chance to use ANSI C compilers, I was much happier. They added the ability to tell the compiler what the data type was for each formal parameter in the parameter list of a C function declaration or definition. When argument values were passed in a call to said function, they would all be checked to see that the values passed were apropros to the types expected.

Suddenly, the compiler could do a lot of checking at the same time it did compiles. No need for running lint. More errors got caught before the program was ever run the first time. Life was good.

Skip back in time a little. My first full-time job as a programmer was back after I knew Pascal really well, but before I new more than a tiny bit about C.

On that job, we used an interpreted language that was a dialect of M. M was called MUMPS way back then.

MUMPS had 2 datatypes: integers and strings. That was it. MUMPS was very loosely typed. No checking was done prior to runtime. There was no compiler, it was interpreted.

The thing about the programs in this MUMPS language was that it was easy for one programmer to write a pretty powerful database-oriented application program, a whole suite of programs in fact, very quickly.

The problem was, when the application got really big, a little old, and maintained by programmers other than its original authors - it quickly became a nightmare.

Which is why I switched companies and languages and avoided scripting languages for anything really big after that.

Fast-forward to present.

Now, it appears Javascript 2 may sport type declarations that are clearly lacking in Javascript 1.x. Just as ANSI C bestowed that capability on the somewhat benighted pre-ANSI C language, Javascript 2 might put its predecessor to shame as well.

I look at this as a really positive step for the Javascript language. I know this particular improvement helped C quite a lot. It became practical to write programs that were a little bigger and get them done a little faster. It really did not slow us down. The net improvement in development speed that type-checking added was pretty big.

Not only did you not make these mistakes anymore, at least without catching them - when you debugged, you knew they were not there. It sped the debugging process up, by eliminating a big part of the guess work. Suddenly a whole bunch of what-did-I-do-wrong errors were just taken off the table. Awesome!

The syntax chosen for this feature in Javascript is the Pascal syntax for type declarations. This seems apropriate for a couple reasons.

1) Javascript already uses the VAR keyword borrowed from Pascal

2) UML uses the very same syntax for declaring variables with a data type.

3) It should be easy to parse in declarations, and allow for decent backwards compatilibility.

Python, which is turning out to be a big influence for several features that will be added ino Javascript 2, waged some struggles with data type checking as well, recently.

It is kind of funny how things go.

Almost seems like a predictable pattern, does it not?

0 Comments:

Post a Comment

<< Home

Related pages & news