terça-feira, 1 de julho de 2008

Some MUMPS dissing and a more positive respost.

I'm going to blog about what sucks, and what's good (enough) in Caché, although finally my focus will be on how I think it can be used well, rather than judging it.

But let's start with some negatives. From my perspective, after a year or so ObjectScript programming, here are the most disturbing parts :

Dynamic Scope. Yep, this is truly, awesomely fearful. Dynamic scope means that this :



f()
new x
do g()
write x
quit

g()
set x = 5
quit

do f()




will write the number 5 to the terminal.

Why? Although x is defined within the scope of f, it's visible (and writable) within g. Note, not because g() is within the lexical scope of f() but merely because it is called from it.

The potential for weird interdependencies abounds.

The "new x" at the beginning of f() can shadow (hide any x that was defined previously on the stack). So it's possible to use this mechanism to *avoid* having the effects of dynamic scoping. Unfortunately, legacy code is often FULL of the stuff. Old MUMPS coders seem to be happy to rely on it to pass values into and out of functions.

Dynamic Scoping in large systems is absolutely the number one cause of Caché hell. Especially as it prevents you even *trying* to reduce interdependency. When encountering legacy code with references to unlocalized variables, you might be tempted to add the "new" statement to make them local. However this can break entirely different parts of the code which were relying on the value of the variable being set as a side-effect of the call.

Left to right operator precedence : This is not so evil in principle. There's no reason that it's better for 2+3*6 to be 20 rather than 30. But it sure as hell catches you out if you are experienced in (and plan to stay habituated to) the way most languages do it. It's nastiest in boolean expressions, of course, where


if x = 1 && y = 2 {


is evaluated as

if (((x=1)&&y)=2) {


Significant Whitespace And I don't mean like Python, I mean in the middle or at the end of lines.

For example

kill for { quit:'$data(x) }


is OK code (bit pointless but syntactically OK, and has understandable semantics).

Whereas

kill for { quit:'$data(x) }


Is a syntax error.

Obviously.

Aaaarrrgghhhh!

OK ... more soon ...

2 comentários:

Unknown disse...

None of these items were on my list! I'll share my list with you!

Composing disse...

sure this was my list, written some time ago.

I'll bring your list soon frank