151 Comments

Choosing language to write general library in@Jan - But not true about binding to non-JVM systems. There are literally thousands of ways to for Java to interface to non-JVM code and systems. There is everything from JNA (native access to C libraries etc.) to socket-based solutions to REST APIs.

Jul21

comment

Choosing language to write general library in@Jan - true that certain mobile platforms have limitations. Though mobile platforms don't really have great portability for anything (JavaScript based solutions are probably your best bet...).

I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?"Expected" is defined by not by subjective argument or convention but by the contract of the API/function (this might be explicit, but is often just implied). Different functions / APIs / subsystems can have different expectations, e.g. for some higher level functionality a non-existing file is an expected case for it to handle (it might report this to a user via a GUI), for other lower level functions it is probably not (and hence should throw an exception). This answer seems to miss that important point....

Oct17

comment

Can a beginner in programming start learning game development?@Dunk : maybe true - though some people already know how to create graphics (e.g. photoshop gurus) and it can be easier to experiment with something when you can see visually how it behaves. Plus tools like Slick2D (or even just Java2D/Swing) make it relatively easy to get graphics into a simple game. YMMV, I think....

How to significantly improve Java performance?@maaartinus: regarding final some JITs might figure it out, others might not. It's implementation dependent (as are many performance tuning tips). Agree about the allocations - you have to benchmark this. Usually I've found it is better to eliminate allocations, but YMMV.

Aug22

comment

Is it legal to imitate how an API looks?I believe this is on-topic as it is clearly a factor that must be considered in API design. A good answer could easily outline the general legal issues without going into the specifics of every jurisdiction.

Should we avoid object creation in Java?@Richard: great point - escape analysis provides some very good optimisations. You have to be careful about relying on it though: it isn't guaranteed to happen in all Java implementations and in all circumstances. So you often need to benchmark to be sure.

Will Java still be relevant in 5 years?@Erik - I'm fully aware of Node.js etc., and I still don't think it is a contender against the JVM languages (Java, Scala, Clojure) or .Net on the server side for serious applications. JavaScript is cool on the client (as I said), but the server currently has much better options. YMMV but I stand by my statements.

What would be a good first functional programming project?@Giorgio: ABCL seems like it's a decent implementation of Common Lisp on the JVM. OTOH Clojure has the advantages of being designed for the JVM, incorporating a lot more "modern" innovations, and having more community momentum. I think it really comes down to whether you care about maintaining Common Lisp backwards compatibility or not.

Apr11

comment

Why aren't macros included in most modern programming languages?@Mason - I don't think you understand the code-is-data concept. All C program source code is also data - it just happens to be expressed in text format. Lisps are the same, except they express the code in practical intermediate data structures (s-expressions) that enable it to be manipulated and transformed by macros before compilation. In both cases sending untrusted input to the compiler could be a security hole - but that's hard to do accidentally and it would be your fault for doing something stupid, not the compiler's.

Using machine learning to aim mirrors in a solar array?@Philip - good point, agree you need a gradient to work with. But maybe you can do some kind of hack to create this, e.g. add some imperfections to part of the mirror that scatter enough light to create an appreciable gradient?