I always found it absurd that some languages force you to write "Math.cos(...)".
I disagree. Namespaces are a good thing. The "Foo dot bar" syntax is just commonly associated with class member access. I think it's a lot better to have to explicitly refer to where a function comes from (as long as it doesn't devolve into retarded Java-style verbosity, ie "Foo.bar.baz.spam.eggs..."). Though it's nice to have a way to omit the namespace, ie C++'s "using namespace Foo" or Python's "from Foo import bar". I just think that the sane default is to use explicit namespaces.
But in this case "Math" isn't even a namespace! It's a class of which cos() is a static member. http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html...
EDIT: I see below that Java has added "import static", but at that point you're in the situation where you have two things that are almost the same but not quite, which is not a particularly clean design in my opinion.
And Math is a particularly special case of this. Ponder this: have you ever had to say
import java.lang.Math
?http://docs.oracle.com/javase/1.5.0/docs/guide/language/stat...
From the linked docs: So when should you use static import? Very sparingly!
To me, it sort of confirms the point that these inelegant features are necessary because the language doesn't support fundamental primitives like plain functions and named constants without a superfluous object definition.
"Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function."
https://twitter.com/#!/ID_AA_Carmack/status/5351230045120102...