Alternative Java-based languages

I kind of agree that methods shouldn’t have to be part of a class, but how are you going to call them from other classes? Let’s say I have the file MyFile.java that contains the method void myMethod() that isn’t in a class. When I import MyFile, do I just call it as myMethod()? I wouldn’t want to get it confused with a class (or, even worse, another classless file) that happened to contain another myMethod() method.

I guess you could do something like make each “free” method name start with #, a character that isn’t used elsewhere in Java. That would separate all such methods from class methods, but not resolve naming conflicts with eachother.

I kind of long for a Java-ish version of delegates, one of the few features of C# I actually like. I want to be able to implement interfaces in a delegate-ish way, but I don’t want to pass a bunch of method pointers around to use willy-nilly.

Meh, I think you’re overexagerating the problem. You can already get name collision issues when you’ve got two classes with the same name, or a local method in an inner class with the same name as a method in the outer class (and probably a whole bunch of other ways I can’t think of right now). The situation is the same - just specify it in shorthand “foo()” if theres no collisions, otherwise you need the fully qualified name “net.orangytang.foo()”.

setting the actual discussion aside what is this need for using weird characters everywhere? for the sake of avoiding reserved names? Are we fooling our selfs?

yeah, maybe I’m just ranting but I really hate icky freaky weird meaningless characters. Like the => proposed in the closures.

The # thing might be going a little overboard, but using strange symbols can make things alot simpler (though somewhat more cryptic at the same time). Personally, I think the ? : operator is a little cryptic, but it’s a great operator. And it does sort of make sense. The ? means there’s a choice, and the : separates the 2 choices like with the cases in a switch statement.

Yeah but we’re all used to the ? operator. It’s when people start wanting to add all the other crazy stuff and it ends up just being as unreadable as C++. Just look at any really hairy bit of generic code.

Cas :slight_smile:

[quote]The thing that normally catches me out is NPEs. So I’d really rather like a “not null” modifier for variable declarations. Eclipse already goes some way to detecting that something may be null when referenced but I want to be able to declare that at the interface level.
[/quote]
Intellij has a “not null” and nullable annotation which work well.

http://www.jetbrains.com/idea/documentation/howto.html

Although generally I try and use NullObjects and avoid using null as much as possible. This is particularly true when returning collections or strings. It’s rare that there is a semantic difference between returning a null and an empty collection or string, so I like to avoid the null and prevent the possible NPE.

YMMV.

D.

I am trying to decide between

  • Java 1.6
  • Nice
  • Scala

I really like the extra features of Nice and Scala but not sure if its worth using something less people are familiar with. Does anyone here have any experiences with using Nice or Scala as the main programming language for game programming?