javaggravation

(12 comments)
2004.09.17
Geek Ramble of the Moment
You know, I just thought of one major lack of Java, and to be fair, most C-derived programming languages: a function can have many input parameters but only one return value. That's a really odd asymmetry to have to put up with.

Perl, for example, handles it much better...it's no problem to write something like

($foo, $bar, $baz) = somefunction($a,$b,$c);

In Java, though, you'd have two ugly workarounds: create a wrapper object that contains each thing you want to return, or if the objects are complex, sometimes you can have the calling program create an object, pass it in, and let the called function fill in the blanks. (Kind of like Oracle's "INOUT" parameters.)

Personally, I think this lack is something that provokes over use of Exceptions, which really do horrendous things to understanding a programs flow of execution.

Seriously, would it be so hard to add a syntax so something like this would work?

int foo;
String bar;
(foo,bar,String baz) = somefunction();

public int,String,String somefunction(){
   return (5,"hey","ho");
}


Does anyone know if any of the other C-derived languages handle this case better? C# or any of that? I know they're hyper-conservative about adding this kind of structure to Java, since it breaks old compilers and what not. But still, it seems like one of those things that actually is pretty stupid and only around for legacy reasons but that everyone just kind of accepts.


Quote of the Moment
The more sensitive you are, the more likely you are to be brutalised, develop scabs, never evolve. Never allow yourself to feel anything, because you always feel too much.
Marlon Brando, via Candi
An odd if depressing idea, but it seems like not allowing yourself to feel anything is a kind of scab in and of itself, a protective barrier. I guess I like the more mild message of Janeane Garofalo's line "Cultivate the Switzerland of your soul and remain delightfully detached."


Analysis of the Moment
So just how badly is Iraq going for us? What a dumbass idea the occupation has been. Neocons live in a dreamland.


Photo of the Moment

--Hurrican Ivan as seen from the International Space Station. I like how my eye misread this at first, seeing the solar panels as buildings, with the menacing cloud in the apocalyptic sky above...