Atom Atom feed

Friday Java Quiz: Null Character In Strings

The usual rules (no Googling, no compiling, etc.)

Q: True or false? In Java, a java.lang.String may contain the null character.

Tags :

The New Bloglines Beta: Habit Breaking Changes

I tried the new Bloglines Beta today. Two of the most obvious changes (changes that I noticed within 10 seconds of using it) are:

  • The "Keep New []" checkbox is gone. In its place is a "[] Read" checkbox, just like Google Reader.
  • Whin I click on an empty feed in the left nav, instead of getting a regular feed page (only with zero entries) on the right panel, I get a generic feed independent page.

These improvements break a couple of my blog reading habits, which I'll state as use cases:

Use Case 1: Marking a feed as read

  1. Click on the feed in the left nav

Use Case 2: Visit the website of a feed

  1. Click on the feed in the left nav
  2. Click on the title link in the right panel

Granted, these two use cases must have not been the original use cases for the developers of Bloglines. Otherwise they won't be broken in a new version. However, these are implied use cases from the overall behavior of the current version of the software. I just happen to depend on these implied use cases.

Back when I did a comparison between Bloglines and Google Readers, Use Case 1 was one of the reason I favored Bloglines. I'm not sure if I should redo that evaluation.

One thing that I liked is the new "3-pane view" that's available in Yahoo!Mail:

Tags :

Log4j Must Die

Logging frameworks are the center of some discussions lately. See here and here.

Five years after the Java Logging API appeared in Java 1.4, and with the availability of the LumberJack implementation of the Java Logging API for prior versions of Java for just as long, I feel sad that Java people are still arguing about logging frameworks and the use of ill-conceived wrappers, and wrapper-wrappers.

Here's a simple truth that people who are still talking about logging frameworks are missing:

There is an adequate logging framework in the JDK for @#%*-ing five years.

Use it directly. Or, if you like wrappers, write a wrapper yourself. It can be done in less than a day. This is the path of least resistance.

Of course, if after careful consideration, the Java Logging API just isn't going to work for your project, then, yeah, go ahead and use whatever is out there that you like. You have my sympathy. But please keep the complaining to yourself.

Tags :

New Language Features Galore

Just as Java's new language features buzz is dying down (reified generics no longer being mentioned, etc.) the C++0x standards is nearing completion.

In today's OCI internal C++ lunch, Adam Mitz (who apparently needs a more updated homepage) talked about the new C++ language features that may become available in the updated standard. We've covered the new library features in a previous C++ lunch.

Here's some of the more interesting features.

Raw strings

R"$
A string that may contain embedded
new line characters.
$"

Lambdas

<>(int x, int y) -> int {return x + y; }

Closures

std::cout& os = ...;
setCallback(<>(int i) extern(os) { os << i; });

RValue References

A&& r = getA();

Variadic Templates

template <class... Elements> class tuple;

Alternative syntax for typedef

using callback = void (*)(void*, int);

Type inference

auto pi = 3.1415926535;
const auto& v = map["key"];

Concepts

template <LessThanComparable T> class ...;
auto concept LessThanComparable
<typename T> { bool operator<(T, T); };

Range based for loop

for (int i: vector_of_ints) {
  std::cout << i;
}

String enums

enum class E : unsigned long long {A, B, C};

And the quote of the day came when Adam answered the question "is this a hack?" with

It's all a hack, but so is the whole language.

For detailed information, Adam points us to JTC1/SC22/WG21 - The C++ Standards Committee Home Page.

Tags :

SUNW Is Now JAVA

I was off the internet for a couple of days and missed this announcement from Sun:

Jonathan Schwarz: And so next week, we're going to embrace that reality by changing our trading symbol, from SUNW to JAVA.

Shouldn't it read "Java technology-based ticker symbol"?

:)

Tags :

Quote Of The Day

"Just because we are done, doesn't mean that we are done."
Tags :

Printer-Friendly CSS

Terence Tao: I recently discovered a CSS hack which automatically makes wordpress pages friendlier to print (stripping out the sidebar and header), and installed it on this blog (in response to an emailed suggestion). There should be no visible changes unless you “print preview” the page.

Being a print-it-out kind of person, I ran into the "weblogs (or other web pages) not printing properly" problem way too often. Typical problems are: i) words being cut off on the right hand side; ii) only one page of real content is printed (example: Neal Gafter's blog).

I hope that someone can take the idea from the above link and make it work with other blogging engines/providers. It doesn't look very hard. (Pebble, the engine behind this blog, already uses a separate stylesheet for printing.)

Tags :

Jython 2.2 Released

Frank Wierzbicki: On behalf of the Jython development team, I'm pleased to announce that
Jython 2.2 is available for download. See the installation instructions.

This is the first production release of Jython in nearly six years, and it contains many new features:

  • new-style classes
  • Java List integration
  • PEP 302 implementation
  • iterators
  • generators
  • __future__ division
  • support for running on modern JVMs
  • a new installer
  • ssl and non-blocking support for socket

This gives Jython the same set of language features as Python 2.2.

For a more complete list of the additions from 2.1 to 2.2, see the NEWS file in the release. Only the version numbers changed in the code from 2.2rc3 to this release.

Woohoo!!

Woohoo!! indeed.

Tags :

HTML Needs New Tags

I am a firm believer of standard based software development. When it comes to web standards such as HTML and JavaScript, I should also add that the standards need to evolve. The way the web standards evolve is through experiments of their implementations. That's why I was excited about the Mozilla canvas tag when it first appeared. That's why I'm excited about the video tag that Brendan Eich, the King of Mozilladom, mentions in his blog:

Brendan Eich: From the inimitable Chris Double of Mozilla's New Zealand brain trust: moving, rotating, scaling <video> in SVG (so who needs yet another non-standard plugin?).

It is true that these tags are not part of the HTML standard, yet. But there is no reason why they can't be. It may take some time before all the vendors agree on the exact syntax. Some vendors may even resist the incorporation of such innovations. But at the end of the day, it is the usefulness of these new tags that will attract web content developers, and through them, the web content consumers.

As to the comment "Why needs yet another non-standard plugin?" The answer is "Mozilla has always needed non-standard plugins." Try removing all non-standard plugins from your browser and see if the web still "works"? The trick is to standardize the access to such plugins in a way that promotes competition and prevents lock-ins.

Tags :

My Shrinking Blogroll

A few people I know stopped publishing their blogs. Eric Burke even went so far as to remove his blog from the internet (after a "I'm going to remove it" next-to-last post).

As a result, some of the links in my blogroll become stale. So I went ahead and cleaned it up yesterday. The number of feeds went from almost 300 down to 69. If you are watching the number of subcribers to your feed from Bloglines or NetNewsGear, and see it being decremented, that's me unsubscribing from your feed.

I unsubscribed from the feeds that are gone or sparingly published. And I also unsubscribed from the feeds that I'm no longer interested in. Just as Eric felt it right to remove a blog that he's not motivated to continue to publish, I have overcome the tendency to not unsubscribe from less-than-frequently published feeds to not hurt the author's feelings. (If you've been meaning to delete your blog, but are thinking "What about all my subscribers?" There is one less subscriber for you to worry about today.)

Given that this blog was started after Eric told me all about blogging, Eric's departure from blogging also made me reflect a bit about the future of this blog. And here's what I am certain:

  • Like everything else, this blog won't last forever
  • I'm still motivated to write a few times a week, so I'll continue to write
  • I have found (as a few others have found) a few of my past entries useful. So I'll try to keep this blog up for as long as I can support it.
  • I'll keep an eye on what the smart people are doing, and jump to that if I can emulate it.

Given my tendency to be extremely retro (do a Google image search for "Windows 3.1", and you will find my blog at the number one spot), I'll probably be among the last few bloggers remaining when everyone else have moved on.

But that's fine with me.

Tags :

Friday Java Challenge: Write A Regular Expression Parser

Instead of a Friday Java Quiz, I'll pose a challenge. And it is not a challenge to your Java skills, but a challenge to the Test-First Design doctrine, which holds that a test-first approach can result in a better or simpler design.

I first witnessed this principle at work at the first No Fluff Just Stuff conference in St. Louis several years ago, where I sat in on Uncle Bob's session on test-first design and followed his "score a bowling game" demonstration.

I have been following a test-driven approach ever since, and I have benefited enormously from this approach: this is true especially in the responsibility allocation among cooperating classes, untangling tightly coupling, and API designs.

However, I have always felt that certain systems can only be designed with enough knowledge about the domain that might not be gained through the mere writing of tests. This is particularly true in areas where non-trivial theories are involved in the solution of a problem. My usual example is "You can't write Math.sin() with a test-first approach."

It seems to me that the test-first design is applicable for trivial problems, but not for complicated problems where the naive solution is the wrong solution.

With that in mind, here's today's Java challenge: Using a test-first approach, and without resorting to any text books, or Google, or looking at the sources of existing regular expression implementations, write a simple regular expression matcher that supports the following features:

  • c: literal character c
  • . (period): any single character
  • ^: beginning of input string
  • $: end of input string
  • *: zero or more occurrences of the previous character

Friday Java Quiz: What Is Integer.TYPE?

Of course you know what Integer.TYPE is. Now fill in the blank in the following class:

public class Foo {
  public static void main(String[] args) {
    System.out.println(________ == Integer.TYPE);
  }
}
with something other than Integer.TYPE so that the program will print "true" when compiled and run.

Tags :

IntelliJ IDEA License Give away At The JUG

I've mentioned it a couple of times in passing a couple of times, but never called it out.

For the past several months, JetBrains has been a sponsor of the St. Louis Java Users Group. They have been giving away one(1) IntelliJ IDEA 6 license to a lucky member of the audience every month. They also give one to the presenter.

That doesn't sound to much. After all, Microsoft has been known to give away XBoxes at C#/.NET meetings. But if you think about it. the St. Louis JUG is regularly attended by 20-40 people, some of them already have an IDEA license. We've had people declining the offer because they already have one at least twice. (I have to decline the offer last month when I presented on JavaFX, because I already bought an IDEA 6 license.)

So come to the JUG meeting this evening, when Jay Meyer (of Harpoon Technologies Inc.) will talk about tools and techniques that developers can use write a secure application from scratch, or test an already-installed application.

The line-up the the next few months also look interesting:

September 13, 2007 Apache Maven - Eric Redmond (Sonatype)
October 11, 2007 Concurrency With Mandelbrot - Alex Miller
November 8, 2007 Javelin Stamp - Andrew Prunicki (OCI)
December 13, 2007 Scala - Tim Dalton
Tags :

Widening The JVM Language Group: They Need Us!

(Via Tim Bray)

Widening the JVM Languages Group: We Need You!

Charles Nutter: We need diversity in the JVM Languages group, and it's been brought to my attention that some popular/key/interesting languages may not have representation. So we need to change that.

If you are interested in the future of non-Java languages on the JVM, you should be on this list. Yes, we talk about a lot of JVM lanuage implementation challenges, we discuss compilers and stack frames and call-site optimizations, but we also talk about features peripheral to language implementation like package indexing and retrofitting Java 5+ code. We need your help.

Once you've joined, or if you're already member, you have a second task

I respectfully request that each of you search out one individual you think would be interested in the list and try to get them involved. Toss them a quick email, invite them to describe their project or language or implementation to us, and promise them they're joining a very interesting and entertaining community. History will thank you, and so will I.

I joined the JVM Language Group project when Charles announced it the first time around 74 days ago. Although language design and implementation is not my specialty, watching others discuss it is still a lot of fun.

One thing I noticed, for a long time now, is Charles's healthy respect for the other JVM languages, especially Jython, which has been around for more than ten years now. That is so unlike the other Ruby guys that I encounter online.

The goal of the group is to come up with something, some sort of a library or <shudder>framework</shudder>, that would aid the implementation of JVM languages, as well as a forum for other discussions.

I think you want to join even if you are not a language guy. After all, JRuby, (or Jython, or Groovy, or whatever), is just a big Java program.

The Amazon.com Spam Inference Engine

Have I told you I love Amazon.com spams? They keep on getting more and more creative and suggesting books in areas I have not the faintest interest in buying:

Back in the old days, when they told me people who bought a HP LaserJet 1100 ink cartridge also bought ink cartridges for the Canon C-120, I can at least see the logic in their inference.

But how could they jump from network programming to system on silicon is beyond me.

My guess would be Joe, who developed the inference engine, left Amazon.com. And he did not tell his colleagues in Bangalore that they are not supposed to crank the "stretch.imagination" parameter up to beyond 1:

  • 0 is lame
  • 1 is reasonable
  • 2 is hilarious
  • 3 is universal

You just wait. One of these days they are going to crank that number up to 3, and the internet will be filled with Amazon spams for forty years:

foreach (book1 in the catalog,
         book2 in the catalog,
         dummy in customer)
where (dummy bought book1) {
  sendEmail(to: dummy,
            youBought: book1,
            youWillLove: book2);
}
Tags :

The Number One Ill Of Java ...

... is its stupid "directory structure reflecting the package hierarchy" (mis)feature.

I was "helping" 20-year programming veterans to "understand" this (mis)feature in 1998. I'm still "helping" people to understand it now.

"I have a directory full of Java sources right here. Why do I have to tell javac or my IDE that the sources are three directories up?"

There is no good answer to this question. Sure, you can get use to it. You can even be proud that you are among the 5% programmers who persevered in understanding it. But it doesn't make it right!

You can label the on switch "off" and the off switch "on". People will get used to it. But that doesn't make it right.

It causes unnecessary problems. And its another barrier to true understanding.

That, and zero-based array indexing, have got to go.

Tags :

Alexander Stepanov: Notes On Programming

(Via Reddit.)

Alexander A. Stepanov: This book does not attempt to solve complicated problems. It will attempt to solve very simple problems which most people find trivial: minimum and maximum, linear search and swap. These problems are not, however, as simple as they seem. I have been forced to go back and revisit my view of them many times. And I am not alone. I often have to argue about different aspects of the interface and implementation of such simple functions with my old friends and collaborators. There is more to it, than many people think.

I do understand that most people have to design systems somewhat more complex than maximum and minimum. But I urge them to consider the following: unless they can design a three line program well, why would they be able to design a three hundred thousand line program. We have to build our design skills by following through simple exercises, the way a pianist has to work through simple finger exercises before attempting to play a complicated piece.

... and I thought all I have to do was to write millions of tests! And write the simplest thing that will make the tests work.