The rank represents languages used in public & private repositories, excluding forks, as detected by Linguist.
No surprise at JavaScript taking the top spot. What is surprising is Java having a steady upward trend.
The rank represents languages used in public & private repositories, excluding forks, as detected by Linguist.
No surprise at JavaScript taking the top spot. What is surprising is Java having a steady upward trend.
An oldy but a goody: save the following into a file called Hello.java
. It will compile just fine and if you run it, it will print Hello, World!
to standard output.
/*u002Au002Fu0070u0075u0062u006Cu0069u0063u0020u0063u006Cu0061u0073u0073u0020u0048u0065u006Cu006Cu006Fu007Bu0070u0075u0062u006Cu0069u0063u0020u0073u0074u0061u0074u0069u0063u0020u0076u006Fu0069u0064u0020u006Du0061u0069u006Eu0028u0053u0074u0072u0069u006Eu0067u005Bu005Du0020u0061u0072u0067u0073u0029u007Bu0053u0079u0073u0074u0065u006Du002Eu006Fu0075u0074u002Eu0070u0072u0069u006Eu0074u006Cu006Eu0028u0022u0048u0065u006Cu006Cu006Fu002Cu0020u0057u006Fu0072u006Cu0064u0021u0022u0029u003Bu007Du007Du002Fu002A*/
This is because according to the Java Language Specification (JLS 3.2, specifically), Unicode escapes must be translated by the compiler before just about any other operation, including stripping comments.
Here’s what the code looks like prettified and with translated escapes:
/**/
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
/**/
Interestingly, the jury is still out on whether APIs can be copyrighted (no pun intended):
Judge Alsup still hasn’t ruled on the issue of whether APIs can be copyrighted at all. Additional briefing by both sides is due today. Alsup this morning reassured lawyers that his ruling on the issue will come sometime next week.
It’s the first major release of Java in five years; many additions have been made to the language, including Strings in switch statements and the try-with statement.
I don’t know what I’ll be working on. I expect it’ll be a bit of everything, seasoned with a large dose of grumpy curmudgeon.
Generics in Java have always been both a source of fascination and frustration for me. I’ll openly admit that I still don’t know enough about the subject, even though I’ve worked with Java for four years now.
The very first thing that puzzled me is that contrary to “regular” classes in Java, generic elements don’t really have superclasses to speak of. Consider the following example:
Object obj; String str = "Hello"; obj = str;
Naturally, a String
has Object
as it’s highest superclass. Thus, it’s legal to assign a String
to an Object
— obviously, one can only call the methods of the Object
class after such an operation.
Now consider this example:
ArrayList<Object> listOne; ArrayList<String> listTwo = new ArrayList<String>(); listOne = listTwo; listOne.add(new Integer(1)); String str = listTwo.get(0);
In this example, we attempt to assign a list of Strings to a variable with the type “list of Objects”. If this would work, we could add another type of object (say, an Integer
) to the list. After this, listTwo
doesn’t just contain Strings anymore, which leads to trouble on the last line of our code. Thankfully, Java doesn’t allow this to happen — line 2 3 in our example will give us an error if we attempt to compile the code.
The best quick explanation of generics/superclasses in Java that I’ve found is in a book called Generics in the Java Programming Language (PDF link), written by Gilad Bracha:
For example, if the department of motor vehicles supplies a list of drivers to the census bureau, this seems reasonable. We think that a
List<Driver>
is aList<Person>
, assuming thatDriver
is a subtype ofPerson
. In fact, what is being passed is a copy of the registry of drivers. Otherwise, the census bureau could add new people who are not drivers into the list, corrupting the DMV’s records.
The book is a comprehensive Java generics resource, and discusses even the most advanced concepts in a highly understandable form. Don’t forget to read The Tapir’s Tale blog post or Angela Lanker’s website, either.