- 2024-10-01
-
Stream Gatherers (JEP 485)
This article, also posted on
http://javaalmanac.io, describes gatherers, which provide a general extension point for intermediate operations in Java streams. Gatherers are particularly useful for operations that depend on neighboring elements, all preceding elements, or all elements of a stream.
- 2024-06-22
-
Core Java 13th Edition Finally At the Printer
The classic two-volume Core Java book is updated for each LTS release of Java. For many years, Dmitry Kirsanov Studio turned my XHTML files into print and ebooks, keeping all the formatting just the way I wrote it. This time, presumably in a frenzy of cost-cutting, the publisher tried to use an offshore contractor who was plainly not up to the task. I had to learn how to produce the book myself. Here is how I did it.
- 2024-02-07
-
Lessons from Advent Of Code 2023 - Part 2: Streams
In this series of articles, I reflect on what I learned from working through the 2023 Advent of Code problems in Java. This installment is all about streams. When should you use them, and when should you stick with loops?
- 2023-12-30
-
Lessons from Advent Of Code 2023 - Part 1: Introduction
This year, I was inspired to participate in the Advent of Code puzzle event and doggedly worked every problem until I collected my fifty stars. I learned a lot about algorithms that I had previously only seen in dull theory. And I reflected on effective Java programming. This is the first of several posts where I try to relate my advent experience to everyday programming.
- 2023-12-01
-
Twelve Days of Pattern Matching
Pattern matching in Java was derived from the syntax of the
switch
and
instanceof
statements in order to leverage the familiarity that programmers have with those constructs. As pattern matching has become more powerful in recent Java versions, that familiarity is colliding with the new needs of the pattern matching syntax and semantics. In this article, also published at
Java Advent, I present six puzzlers and six principles to help you understand the latest pattern matching features.
- 2023-10-30
-
What I Learned Over the Weekend About HTTP
In the 13th edition of Core Java, the sample web sites that I used for form posts no longer exist, so I decided to provide my own, and also support file upload. But my file upload example failed mysteriously. Here is what I learned about HTTP and the standard Java HttpClient
.
- 2023-10-03
-
Stop Using char
in Java. And Code Points.
As I am editing the 13th edition of Core Java, I realize that I need to tone down the coverage of Unicode code points. I used to recommend that readers avoid char
and use code points instead, but I came to realize that with modern Unicode, code points are problematic too. Just use String
.
- 2023-09-22
-
Pattern Matching for Switch (JEP 441)
This article, updated for Java 21 and also posted on
http://javaalmanac.io, describes pattern matching for
switch
, in its fifth and final iteration. Type patterns allow you to match on the type of the selector value and analyze the value further in a variable of the appropriate type. There are fiddly rules about
null
, fall through, and case ordering. At the end of each section is a “sandbox” with somewhat contrived code to try out the syntax variations.
- 2023-09-21
-
Record Patterns (JEP 440)
This article, updated for Java 21 and also posted on
http://javaalmanac.io, describes record patterns. A record pattern lets you “deconstruct” a record value, binding each component to a variable. Record patterns work with
instanceof
and
switch
pattern matching. Guards are supported. They are particularly compelling with nested deconstruction and sealed record hierarchies.
- 2023-09-19
-
Java 21: The Nice, The Meh, and the ... Momentous
When Java 17 was released in 2021 as a “long term support” version, I wrote an article dissecting its features and came to the conclusion that it had a few nice features, but none that were compelling reasons to upgrade. Except one: tens of thousands of bug fixes.
Java 21 was released today, as another “long term support” release. How does it rate on the momentousness scale? Read on for an unbiased opinion.
- 2023-06-27
-
Virtual Threads (JEP 444)
Virtual threads are one of the most significant contributions to the Java programming language in recent history. They support a “direct” style for concurrent programming, without cumbersome callbacks or async/await code transformations. After a couple of rounds of prereleases, they became finalized in JDK 21. Read on to find out when and how to use virtual threads in your applications.
This article is also published on https://javaalmanac.io.
- 2023-06-09
-
Unnamed Classes and Instance Main Methods (Preview)
When people complain that Java is too verbose, they like to point at public static void main(String[] args)
. That is a pain point when teaching beginning students. I always tell students to just copy/paste without worrying, and I never had anyone complain. But many instructors dutifully explain each syntactical element, and I wouldn't be surprised if the students' eyes glaze over. JEP 445 to the rescue. You can pick a version of main
that makes sense for your teaching style. And if you teach “objects late”, you can use what looks like global variables and functions. They are actually instance variables and methods of an unnamed class.
- 2023-06-01
-
Unnamed Patterns and Variables (Preview)
Sometimes, Java syntax requires you to specify a variable name even when you never refer to it. JEP 443 allows you to use an underscore in many of these cases. This feature is probably most useful in record patterns, where an underscore can even replace a type + name. This article shows all situations where you can use the “unnamed” underscore.
This article is also published on https://javaalmanac.io.
- 2023-05-11
-
String Templates
String templates, previewed in Java 21, are a mechanism for producing objects from templates that contain string fragments and embedded expressions. The syntax is different from that of other languages, but the differences are minor and make sense for Java. The JDK provides processors for plain interpolation and formatted output. It is easy to implement your own processors. This article is also published on
https://javaalmanac.io.
- 2023-04-09
-
An Incomplete Guide to Modern Java I/O Idioms
If you ask StackOverflow or ChatGPT, how to convert an InputStream to a String in Java, you get archaic constructs with buffered readers and tedious loops. In modern Java, you achieve this task and similar ones with a single line of code. Apparently, these one-liners are not common knowledge, so I list a few. Maybe it'll get me a mention in the the JetBrains Java Annotated Monthly newsletter.
- 2023-03-25
-
pre
-posterous Mobile Browsers
I was alerted to the fact that code on my home page looked teensy-tiny on Android. What could be wrong? It was just enclosed in pre
tags. Preposterously, and probably for prehistoric reasons, mobile browsers apply weird rules to preformatted code instead of just following CSS styles. It took me foreever to find the magic pixie dust, so I wrote it up so that the search- and chatbots can find it.
- 2023-03-02
-
A Tale of Two Stacks
I got a query about a curious incident of two recursive calls, both causing a stack overflow. But when the calls are reversed, one of them succeeds. Read on to find out how the case unfolds.
- 2023-02-23
-
Java Licensing for Education (Again)
Oracle changed the licensing terms for the “Java SE Universal Subscription”. Should you care if you teach Java? Don't panic. If your institution, perhaps out of an abundance of cluelessness, tells you to uninstall the Oracle JDK, use an OpenJDK version. That's good advice anyway. There are plenty of excellent OpenJDK distributions.
- 2023-02-07
-
The Shortest Path to Dijkstra? Practice with Immediate Feedback
Dijkstra's algorithm finds the shortest paths from a start vertex in a directed graph whose edges have positive weights. It is a classic example of a greedy algorithm. If you had a course in algorithms, you probably learned it. Could you carry out the algorithm with an actual graph? Spend fifteen minutes with this training app, and you probably can.
- 2023-01-22
-
Do Abstract Factories Occur in the Wild?
Abstract Factory is one of the 23 “Gang Of Four” design patterns. So it's got to be important. But when I was asked to produce an actual use case, I came up blank. Your favorite search engine will find you any number of examples, but all of the ones I inspected were bogus. Is it time to put this pattern to pasture?
- 2023-01-07
-
Linux High DPI Settings
I recently got a laptop with a High DPI screen. These notes document what I had to do to make it usable with OpenBox. They should be relevant to other window managers as well. If you aren't using Linux, move along...nothing to see here.
- 2023-01-05
-
Happy 0x7E7!
Happy new year! Is there anything interesting about the number 2023? I asked Open AI chat and was told no, it's just a number like any other. So I had to do the creative work myself. Here are some fun facts about 2023 (hex 7E7) of which the chatbot was unaware. I include some ideas for programming assignments, together with an analysis of the answers that the chatbot offered.
- 2022-12-01
-
JavaDoc Code Snippets and Friends
It is easy to include buggy code snippets into code documentation. Java 18 introduces an
@snippet
tag with which you can pull snippets from (hopefully) working source code. I explain how that works, and also look into a couple of alternative approaches for other forms of technical documentation.
This article also appeared in the
JVM Programming Advent Calendar.
- 2022-07-30
-
Tidbits #3 from JCrete 2022—Loom
This is the last of three articles about tidbits that I learned at the
JCrete unconference. Here is an elevator pitch about Loom for those who aren't familiar with it, followed by a couple of observations that shine some light on the essence of Loom.
- 2022-07-25
-
Tidbits #2 from JCrete 2022—TimSort
At
JCrete, I learned that the sort methods in the Java standard library can throw an exception with the curious message “Comparison method violates its general contract!”. Of course I had to dig into the gory details.
- 2022-07-20
-
Tidbits #1 from JCrete 2022 - Puzzlers
Every year, Heinz Kabutz and his merry band of disorganizers run the fantastic
JCrete conference. Well, except for the last two years, when COVID-19 put a stop to it. This year, JCrete was back with a limited number of attendees to avoid a superspreader event. This is the first of a three-part series of tidbits that I learned.
- 2022-06-10
-
No title
No description
- 2022-04-15
-
Virtual Threads and Tomcat
Virtual threads are the ideal mechanism for running mostly blocking tasks, providing a high level of concurrency without requiring asynchronous acrobatics from business logic programmers. I show that it is easy to configure Tomcat for virtual threads, provided one makes a small change to the Tomcat source code.
- 2022-04-10
-
No title
No description
- 2022-01-25
-
Loop Patterns (Java Edition)
In a presentation about teaching new Java features, I casually mentioned that my textbooks for beginning students include a list of common loop patterns (counting matches, maximum, and so on). After all, students can't realistically be expected to invent them on the spot each time they are needed. Attendees asked me about that list. Here it is.
- 2022-01-06
-
Lies, Damned Lies, and Microbenchmarks
A Fibonacci microbenchmark runs slightly faster with Java 8 than Java 17 on some fellow's laptop. Should you stick with Java 8?
- 2021-12-06
-
Java 17: The Nice, the Meh, and the Ugly
Java 17 was just released. It is a “long term support” release. Should you upgrade? In this “Java advent” article, I walk you through the nice, the meh, and the ugly.
- 2021-09-14
-
Sixteen Going on Seventeen!
Today, Java 17 is being released. It is a “long term support” release. I've been updating the Core Java books for this momentous occasion. Maybe not that momentous since the best (Valhalla, Panama, Loom) is still ahead of us. But still nice. And with a ton of bug fixes and security patches. You should upgrade.
- 2021-09-02
-
CodeCheck Now With Parsons Puzzles
Parsons puzzles are a useful tool for teaching basic programming skills. A Parsons puzzle asks students to solve a programming problem by rearranging tiles marked with code lines. This is a useful bridge towards writing code.
I just added a Parsons puzzle editor to the CodeCheck autograder that makes puzzle authoring easy and enjoyable.
- 2021-08-02
-
Unicode—One of the Two Hard Problems on the Internet
As José Paumard said, there are only two hard problems on the Internet: Time zones and Unicode. I got flustered by a blog entitled “Make sure you know which Unicode version is supported by your programming language version”. That turned out to be a red herring. The real culprit was a buggy regex implementation in Java.
- 2021-07-05
-
Book Review: Seriously Good Software
I review “Seriously Good Software” by Marco Faella, another book for intermediate level programmers familiar with Java. The
book uses a deceptively simple problem to explore data structures, algorithms, computer architecture, and software engineering topics. If you wonder what those CS courses (that you were perhaps forced to take) are actually good for, you'll find answers in this delightful book.
- 2021-05-25
-
Book Review: Java by Comparison
I review “Java by Comparison”, a book that aims to teach intermediate level java programmers to step up their game, through 70 items that are easy to digest. If you are at this level, get a copy. If you work with those who do, get them a copy.
- 2021-05-14
-
What's in a name?
Did you know that Java identifiers can contain €, a “wavy underline” ﹏ and the bell character? If not, read on for the gory details.
- 2021-03-20
-
The Perfect Backup Plan
For years, I backed up my laptop every night to a cloud provider without problems. But a few days ago, I was unable to restore a file because my account was “under maintenance”. Time to look for a new service. With a backup script that I can understand.
- 2021-03-09
-
Adding State Saving and LTI to Interactive Exercises
There is an abundance of interactive JavaScript activities that you might want to assign to your students. But how do you collect their work in a learning management system? You can try to ask the author of the activity to add LTI support. But how likely is it for that to materialize? CodeCheck Assignments use a much more lightweight feature for adding state saving and LTI support. Read on for the details.
- 2020-12-05
-
Project Loom and Structured Concurrency
Project Loom is one of the major “projects” in which Java is moved forward, alongside the perhaps better known projects Amber and Valhalla. It will bring “virtual” threads with low resource footprint and low cost of blocking to the Java plaform. Here is my annual advent season update, this time with a focus on structured concurrency and API changes.
- 2020-11-27
-
Quadratic Equations Even Easier
A while ago, I read an article about an “amazing trick” that makes it easier to solve quadratic equations. I couldn't remember the algebra, so I came up with a geometric memorization instead. I wrote a Jupyter notebook to explain it, but was never quite happy with it. When it stopped working because of a Google Colab library versioning issue, I redid it in JavaScript. Check it out—JavaScript is a good tool for story telling.
- 2020-11-23
-
Side Effect Puzzles
Inspired by Heinz Kabutz' daily
JGym workout, I present some puzzlers that show how horrible side effects in nested expressions can be.
- 2020-09-07
-
Sealed Types (JEP 360)
This article, also posted on
http://javaalmanac.io, describes sealed types, which are a preview feature in Java 15. Sealed types allow you to describe type hierarchies that are closed to further inheritance. In this article, you will see the syntactical rules and a number of examples, such as JSON nodes and directory entries.
- 2020-06-05
-
Checking Code Samples
In this blog, I describe the process that I use to extract sample programs from my latest book to make sure that the code works. Read on if you want to create an automated work flow for checking code that you describe in your blogs, slides, and so on.
- 2020-05-28
-
Text Blocks (JEP 378)
Java 15 will be released really soon now, and after two preview phases, multiline strings (AKA “text blocks”) are now a permanent part of the language. They work nicely for most common use cases. This article, also posted on
http://javaalmanac.io, dwells (perhaps excessively) on some corner cases to watch out for.
- 2020-05-20
-
The Script is Mightier...
This is a great time to be an author. It is easier than ever to produce content that actively involves the reader. In this article, I give a few examples and discuss what I learned about creating interactive materials.
- 2020-05-19
-
Corona Virus and Heron's Theorem
Corona virus quarantine. Home schooling. My teenage daughter asks: “Daddy, how do you compute the area of this triangle?” Well, that is something that I haven't done since I was a teenager. And then only as “base x height / 2”. This wasn't a right triangle, and my daughter didn't yet have trigonometry, so how do you figure the height? She googled and found Heron's formula.
- 2020-04-02
-
Strings with Zero Hash Code
Here is some light diversion for these difficult times: How to find strings with zero hash code in Java. In particular, how to find one that you can remember. Like "misjudge corona modulation".
- 2020-02-04
-
How Switch Expressions Are Explained
The four-form switch syntax is now final in Java 14. Here I look at some evidence suggesting that the feature may be harder to teach than its creators anticipated.
- 2020-01-28
-
What I learned at JSpirit—Graal
Last weekend, I joined the amazing JSpirit unconference. What a venue—a working distillery! We discussed Java, surrounded by barrels and aromatic (and presumably slightly alcoholic) vapors. Here is what I learned about Graal.
- 2020-01-20
-
Records
Records are a major preview feature of JDK 14. A record is a class whose state is visible to all—think of a Point
with x
and y
coordinates. There is no need to hide them. Records make it very easy to declare such classes. A constructor, accessors, equals
, hashCode
, and toString
come for free, and you can add other methods. Read on to find out how to work with this new feature of the Java language.
- 2019-12-05
-
Project Loom
Project Loom is one of the major “projects” in which Java is moved forward, alongside the perhaps better known projects Amber and Valhalla. It promises to bring lightweight/userland/virtual threads with low resource footprint and low cost of blocking. If blocking is cheap, then you don't need to worry about callback hell or async trickery. How well is this shaping up as we enjoy the 2019 holiday season? Read on!
- 2019-07-27
-
HttpClient Executors
At JCrete 2019, Heinz Kabutz led a session that showed a mystery about configuring the thread pool for the HttpClient
class. Setting a new executor didn't have the desired effect. It turns out that the implementation has changed (and perhaps not for the better), and the documentation is lagging. If you plan to use HttpClient
asynchronously, you really want to pay attention to this. As a bonus, there are a few more useful tidbits about using HttpClient
effectively.
- 2019-07-23
-
Down the Collector Rabbit Hole
At JCrete 2019, José Paumard gave a quiz intended to stump the Java experts. One of the questions that I got wrong had to do with java.util.stream
collectors. I know how to use them, but I never bothered to look inside what makes them tick. Read along and find out.
- 2018-12-16
-
HTML Drag and Drop—What a Drag
An article about HTML and JavaScript—what's with that? I implement user interfaces for educational tools. Java on the client isn't really an option any more. The students use the tools through browsers, sometimes on devices without a Java runtime (such as an iPad).
For what I need to do, modern HTML and JavaScript are ok. I toyed with using ScalaJS or JSweet or Elm or whatever, but in the end, keeping it simple has many advantages. It was my good fortune that Internet Explorer ceased to matter when I started. I very rarely ran into situations where I needed to worry about browser incompatibilites. Except for drag and drop, the subject of this article.
- 2018-12-05
-
Five Golden Backticks
Does 12 in “Java 12” stand for the twelve days of Christmas? If so, then on the fifth day of Christmas my true love gave to me five golden backticks. For delimiting raw strings. Or so I thought. On the 11th day of Christmas, they were gone. A bit awkward because this blog was included in the Java Advent Calendar.
- 2018-11-28
-
Give Me a break
, or: How to Make Awesome Puzzlers with Java 12
Java 12 provides, in experimental form, a switch
expression and new forms of the switch
and break
statements. There is a profusion of new syntax and semantics for constructs that may find little use—except, of course, for authors of puzzlers and certification exam questions for whom this is a wonderful gift. If you enjoy Java puzzlers and would perhaps like to create some yourself, read on.
- 2018-10-04
-
AdoptOpenJDK Open for Business
Before downloading a JDK from Oracle, you need to know two things. (1) You can't use that software in production without a paid license from Oracle (2) You can only get the current six-month release, not the long-term-support release there. For many users, the OpenJDK from http://adoptopenjdk.net is a better option. However, those downloads don't come with an installer. Here I provide simple installation instructions for Windows, Mac OS, and Linux.
- 2018-09-26
-
Java 11 Has Arrived
Java 11 has arrived, right on schedule. This is a long-term release, with welcome improvements over Java 8. When installing it, you have—for the first time—the choice between the Oracle license and an open source license for the exact same feature set. And you really want to carefully look into this if you use the JDK in production.
- 2018-09-17
-
Teaching with Java is Still Free
It's not easy to wade through the recent licensing changes with Java. It's particularly confusing for folks who use Java for education. Fortunately, it's not rocket science. If you teach with Java, relax, there is nothing to worry. Most of you will continue to use the current free version of Java, but you can also get older ones if you need them.
- 2018-07-29
-
JCrete 2018
Every year, intrepid Java enthusiasts converge upon the island of Crete to brave questionable air carriers, the intense heat, the allure of beaches, the temptation of tropical drinks, and the astounding disorganization of the conference; all in the quest for knowledge. Here is my trip report.
- 2018-06-21
-
Core Java 9/10/11 for the Impatient Video Course
As of Java 9, new versions of Java arrive at a fast and furious pace. In this blog, I write about the challenges of updating the Core Java video courses.
- 2018-06-07
-
Udacity CS046 Revived
In 2013, at the height of the MOOC hype, the president of San José State University and the CEO of Udacity struck up a partnership, to bring modern technology to crufty old higher education. Three courses, on “developmental” (i.e. remedial) math, college algebra, and statistics were produced, with predictably poor results. But there was a fourth course that did much better—CS046: Introduction to Java Programming. Udacity's business model has long since shifted to corporate training, so it was time to set the course free.
- 2018-06-04
-
Embedding Interactive Learning Elements
It used to be that my learning materials were transformed to ink on compressed cellulose sheets. Nowadays, I get to design an interactive experience where I can ask students to answer questions, trace code, compile and run programs, and draw diagrams instead of consuming them. There are many cool ways of providing those interactive experiences, and no good way of mixing and matching them. In this blog, I ruminate on my experience of delivering JavaScript-based learning activities in several learning environments, and what it might take to standardize that so that “mix and match” might become a reality. (It's not much.)
- 2018-06-01
-
Would You Like Your Strings Raw or Medium Rare?
A new feature is proposed for Java 11 (maybe): A simple syntax for strings that can span more than one line and that can contain arbitrary characters without the need for escaping any of them. No more double backslashes in regular expressions and Windows path names. But as with all things simple, the devil is in the details.
- 2018-05-30
-
Launching Single-File Source-Code Programs
A new feature is proposed for Java 11: To launch a Java program consisting of a single file, you can skip compiling it. This is proposed as a feature to make learning java easier. Having some experience in teaching Java to beginners, I explain why it does not.
- 2018-05-19
-
An Easy Solution for the Gear Ball Puzzle
My daughters keep bringing home various puzzle cubes, expecting me to solve them. The gear ball seems like an evil Rubik's cube. Rotating one face causes the opposing face to rotate in the opposite direction. At first my brain hurt watching it, but I now realize that the gears severely limit the number of possibilities. Here is a simple algorithm for solving it.
- 2018-05-14
-
An Easy Solution for the Pyraminx Puzzle
My daughter Emily knows how to solve a Rubik-style pyramid puzzle. I tried learning her method, but I am no good at spotting the patterns that she recognizes effortlessly. Here is a simple recipe suitable for dads.
- 2018-05-09
-
How is the Grand Social Experiment Coming Along?
In Java 11, the JAXB module is removed, and the “open modules” example from Core Java for the Impatient no longer works. I had to find a module in the wild to replace it. How is the grand social experiment of library modularization coming along? Not too badly, actually.
- 2018-05-08
-
Solving the Mefferts Skewb Xtreme
And now for something entirely different—solving a cube puzzle with the aid of a Prolog program
- 2018-05-04
-
Confessions of a Fallthrough-Hater
Java is getting a multi-way selection expression, and an updated switch
statement. Join in for more bikeshedding .
- 2018-04-23
-
Give Me a Break
Java is getting a multi-way selection expression. Check out the current design, and join the bikeshedding.
- 2016-10-05
-
A Play App on Google Compute Engine
Google gave my grad students some free credits to use Google Compute Engine. Here is how we set up a Play app with autoscaling and https support.
- 2016-05-06
-
Code Page 437 Refuses to Die
console: 1. to alleviate or lessen the grief, sorrow, or disappointment of; give solace or comfort. — That's what I need more of after trying to demystify the behavior of System.out
in the Windows console. Read on if you want to be consoled and enlightened.
- 2016-04-20
-
The Post Office Hates Java
I am updating the section of Core Java that explains how to make a POST request. The service that I used in the previous edition was discontinued, so I tried using the USPS ZIP code lookup. The POST redirects to a GET, but that's ok—HttpURLConnection can handle redirects. But when the user agent contains the string Java, the post office redirects to a dead end!
- 2016-02-12
-
If You Don't Want Users to Use a Class, Give it an Ugly Name!
I spent the better part of a day trying to figure out why a clearly documented API call didn't work as advertised. It turns out that the library uses the same class name, but in a different package, for an implementation class with different methods, and Eclipse auto-completed to that package. That's reprehensible. Don't entrap your fellow programmers like that!
- 2015-12-16
-
Oh Goody—My New Build System Gives Me Stack Traces
My pet peeve from Java EE is the “stack trace from hell”, when the app server shares its pain with me, showing a stack trace, instead of telling me in which source file I messed up some setting. Oh goody—I just switched my Android build to Gradle, and it acts the same way. Hello, dev tooks makers. If you can't trace back your failure to the file name/line number of my artifact, you have failed.
- 2015-12-10
-
Some Small Details About Working with Play
In my last blog, I marveled how the dull pain of Java EE stacktraces melted away after I started using the Play framework, where each error was clearly reported with the file name and line number of the offending artifact. Here are some small details that I ran into.
- 2015-11-21
-
All Work and No Play
All work and no play makes Jack a dull programmer. And I just felt the dull pain of another stack trace from hell from my Java EE app server. There has to be a better way. So I ported the troublesome code to run on the Play framework, and it was all play. No stack trace from hell, just a few screens with clear error messages, and then sweet success.
- 2015-11-10
-
Updated Refcard
Years ago, I designed a “refcard” for DZone that tried to cram all of Java into eight pages. Now a Java 8 update is available, thanks to Bulgarian JUG leader Ivan St. Ivanov. Check it out!
- 2015-11-08
-
Arrows of Outrageous Fortune
At Java One, I overheard someone mentioning an outrageous trick to abuse the arrow ->
of the lambda syntax. Of course I had to investigate. Here are the gory details...and please, kids, don't try this at home.
- 2015-11-07
-
Sayonara java.net Blog. Welcome Unblog.
For almost ten years, I had a
blog on java.net. I am grateful for having been given a platform and a community for my thoughts, but sadly java.net has fallen apart. I still want to share the occasional tidbit of useful information and rant about the latest injustice, but I don't want to find a new home just to see it fall apart too ten years from now. So, I am starting an unblog on my very own website.
- 2015-07-26
-
Back from the JCrete Unconference
Some time ago, I got an invitation from Heinz Kabutz (the man behind the
Java Specialists newsletter, to which you should subscribe right away if you haven't already), to join the
JCrete conference.
- 2015-06-22
-
The Curious Case of the char
Type
It's been almost twenty years that Gary Cornell contacted me to tell me “Cay, we're going to write a book on Java.” Those were simpler times. The Java 1.0 API had 211 classes/interfaces. And Unicode was a 16-bit code.
- 2015-05-25
-
Trying out the Java 9 REPL
A REPL (read-evaluate-print loop) is an integral part of dynamic programming languages such as Lisp or Python. It's a great tool because you can experiment with language and library features without having to write complete programs. If all goes according to plan, Java 9 will have its own REPL. In this blog, I show you how to build the pre-release version and play with it.
- 2014-03-20
-
Hello Java 8 (and how it makes GlassFish speechless...)
After all these years, Java 8 is finally available. Just make sure you don't get tripped up by the change in the classfile format!
- 2014-01-16
-
Sign Your Applets, Or Else...
Remember applets? When Java was first introduced, applets were what excited everyone. No more desktop apps! Deliver code from the server!! Run it securely in the browser’s sandbox!!! That was then. Java 7 update 51, which was released January 14, 2014 will only run signed applets. If you still have any applets and haven’t gotten around to signing them, here is how.
- 2013-12-04
-
Java 8 for the Really Impatient
Java 8 is the biggest advance in the Java language since, well, Java 1, even bigger than the addition of generics in Java 5. I figured that every Java programmer would want to come up to speed quickly with these changes and wrote a short and snappy book “Java 8 for the Really Impatient”. A “rough cuts” version is now available on Safari.
- 2013-10-14
-
Scanners Live in Vain
In the bad old days. you had to turn an InputStreamReader
into a BufferedReader
if you had the desire to read lines of text. Java 5 introduced the Scanner
class, and I never looked back. But the Scanner
class is getting no respect. Java 8 makes you use a BufferedReader
, with all that layering nonsense, if you want a stream of lines from a URL. Why not a Scanner
? Or, if BufferedReader
is so loved, why not add a few constructors?
- 2013-09-26
-
Java One for the Impatient
Here are my impressions from the 18th Java One. Java SE 8 is around the corner, Java EE 7 was just released, and both are a joy to use. NetBeans 7.4 is awesome. And yet, people were strangely blasé at the conference. I still remember how much excitement there was at Java One when Java was in its infancy, and the promises greatly exceeded the reality. (Do you remember Jini? Or the original Java EE?) Nowadays, that excitement is lavished on other technologies whose promises exceed the reality, and Java has grown up.
- 2013-02-02
-
I Didn't Ask for a Toolbar with That Java
In these unhappy days where Oracle is working hard to regain the trust of users, it seems a staggeringly bad idea that the Java updater installs the Ask toolbar by default. It's plainly bad for Java and can't possibly be worth the few clams in additional revenue. If you agree, sign the petition!
- 2013-01-21
-
An XML Macro
In my previous blog on Scala 2.10 macros, I showed you how to write a macro that can swap the contents of two variables. In this blog, visiting scholar Martin Christensen and myself try to solve a problem from our blog on dynamic types in Scala 2.10.
- 2013-01-14
-
The swap macro
The final version of Scala 2.10 was released on January 4, 2013. Martin
Christensen, a visiting scholar in our department, and myself have been playing
with some of the new features, and I'll be blogging about some of our
discoveries in my copious spare time.
- 2012-12-10
-
Dynamic Types in Scala 2.10
This blog explores Scala dynamic types, a new feature of Scala 2.10, and
provides some hopefully interesting exercises so you can try it out for
yourself.
- 2012-06-07
-
Wildcards in the Wild
Generics and wildcards have invaded Swing, and I got an error message from
hell when decorating my perfectly working code with those pesky angle
brackets. This blog a nifty and self-referential tip on how to fix such
errors.
- 2012-06-01
-
The Grand War is over, and what we can learn from it
The grand war between Oracle and Google over the Android API is over, unless Oracle prevails on appeal. The judge and jury have spoken, and this is what they said: Android doesn't infringe on the couple of patents that were at play in the lawsuit. (Other patents that Oracle asserted were invalidated by the USPTO or not included for tactical reasons
- 2012-04-10
-
BOMed out by Notepad and javac
I've been too busy to blog for quite some time, but today something
happened that seemed strange enough to break my silence. A student came to
me with a Java source file that the grading script rejected. We looked at
it and couldn't figure out why. I unearthed the error message:
- 2011-12-12
-
The Sordid Tale of XML Catalogs
In this blog, I summarize what I found out about using XML catalogs with the
Java SAX parser. I know, it's not the most riveting subject, but if your app
waits for minutes untilthe parser delivers a perfectly ordinary XHTML file, you
may find this useful. Or depressing.
- 2011-12-05
-
Operator Overloading Considered Challenging
In this article, I explain why I think that operator overloading is a good
feature, even though it is hard to get right. To illustrate my point, I go
into more detail of the operators in the Scala collection library than you
want to know.
- 2011-10-10
-
A first look at Dart
Google released details about the
Dart language today, and I am surprised how
much more it is like Java than like JavaScript.
- 2011-10-06
-
JavaOne 2011 Day 4
Another day, another keynote. A fellow from IBM talked about cloud stuff. I
sat through a lot of nebulous cloud talks, but this guy was good. He had a
sensible slide on architectural alternatives, explained why we should all go out
and buy a device for a ”data grid”—a memory device for sharing data among
VMs—and he gave a demo of some software for configuring an app to run on
their cloud server. Clear and to the point, like a tech talk should be. It had
nothing to do with the “community” theme of the keynote, but you can't have
everything.
- 2011-10-05
-
JavaOne 2011 Day 3
It's the third day of Java One. No keynote today, but I write about the
thrills of the Script Bowl, alternative languages for Java EE, OpenEJB, and the
GreenFoot and BlueJ projects for computer science education which I hope Oracle
will continue to fund.
- 2011-10-04
-
JavaOne 2011 Day 2
Here I am, on my second day of Java One. I live in the residential part of
San Francisco and get to the conference on a battered “express” bus that
stops at every block, starting from the ocean until it reaches mine. Then it
goes straight downtown, but by the time that I get on, it is standing-room
only. I make it to the keynote frazzled but just in time. Today, I realize that
the empty chairs labeled “Oracle Press” are not for the publishing division
of the Oracle corporation but for scribblers like me.
- 2011-10-03
-
JavaOne 2011 Day 1
Today, JavaOne started officially. With the traditional keynote. Except,
traditionally, the keynote is in a huge room that has space for everyone.
Today, people were shunted into overflow rooms where they could watch on
monitors. In the age of the screencast, that seems pointless—why is that
better than watching on your laptop?
- 2011-10-02
-
JavaOne 2011 Day 0
Once again, I got a blogging pass to JavaOne—my fifth year as the intrepid
reporter at JavaOne, and my 15th JavaOne attendance. Sadly, that wasn't enough
to get me the coveted Alumni badge—my email address wasn't in the right
Oracle database, and showing my previous conference blogs didn't impress the
conference staff. I complained to Sharat Chander, the marketing person at
Oracle who is responsible for the tech tracks at JavaOne, and he told me he
can't get an alumni badge either.
- 2011-09-02
-
Complexity is in the Eye of the Beholder
I just read through David Pollak's blog
Yes, Virginia, Scala is
hard. Now David has much more contact with developers in the trenches than
I do, but I was a bit perturbed by his perspective.
- 2011-08-22
-
Scala for the Impatient—Free Chapters at typesafe.com
My hard-hitting, tell-it-as-it-is Scala book draft is coming along. No
animals or fruit have been pressed into service for contrived examples. Free
chapters are at typesafe.com.
- 2011-08-14
-
Whatever Floats Your Boat
I am in the process of revising a CS1 textbook. I made changes requested by
users, added snazzy exercises and sample programs, and the publisher sent the
draft out to reviewers. A couple of reviewers said in no uncertain terms that I
was wrong, wrong, wrong in using double
for my examples. I should
use float
instead. Another professor contributed a business
problem set that used float
where I would have used
double
, or, if I had been allowed, BigDecimal
.
- 2011-08-05
-
Inner Classes in Scala and Java
When I used the Scala combinator library in earnest a few months ago, I got
confusing error messages when I used classes that are nested inside other
classes. There were several blog posts that made the feature look complicated,
so I reserved a chapter of my upcoming ”Scala for the Impatient” to explain
class nesting. It turns out that won't be necessary. It's simpler in Scala than
in Java, and I can explain it in a few paragraphs.
- 2011-07-29
-
Java 7 Unsafe at Any Speed?
Java 7 got released, but there are rumors of hotspot crashes . It's probably
a tempest in a teapot, but it reminds me of the 1994 Pentium floating-point
bug.
- 2011-06-27
-
In Praise of Language Specs
An implicit conversion is only inserted if there is no other possible
conversion to insert. If the compiler has two options to fix x * y, say using
either convert1(x) * y or convert2(x) * y, then it will report an error and
refuse to choose between them. It would be possible to define some kind of
“best match” rule that prefers some conversions over others. However,
such choices lead to really obscure code. Imagine the compiler chooses
convert2, but you are new to the file and are only aware of convert1—you
could spend a lot of time thinking a different conversion had been
applied!
- 2011-06-20
-
Handwringing about Scala
There has been a
flurry
of blogs
and email threads with hand-wringing about the fact that Scala hasn't yet
achieved world domination.
- 2011-06-16
-
There Will Be Monads
My sabbatical is coming to an end, and I just finished off my “modern
programming languages” course at the Ho Chi Minh City University of
Technology with a dose of monads. The good news is that I am not going to tell
you how monads are just like Vietnamese spring rolls. Just think of them as a
design pattern for composing actions.
- 2011-05-12
-
Easy Red-Black Trees
Users of one of my textbooks asked for a section on red-black trees. That
makes sense—just lecturing about binary search trees leaves the nagging
doubt what happens when a tree becomes unbalanced. Unhappily, the standard
algorithms are a mess of fiddly special cases. Here is a simpler way of doing
it, modifying the presentation by Chris Okasaki and Matt Might.
- 2011-05-05
-
A Dozen Concurrency Pitfalls
I needed
some filler material for my lectures on concurrency. I googled around for Java
concurrency pitfalls and came up with a nice mixture of golden oldies and new
ones (at least new to me). I cleaned them up and translated them into Scala
because that's what we use in the course. Here they are, for your puzzling
pleasure.
- 2011-05-04
-
Parallel Arrays in Scala
In my programming languages class, I have come to the point where I talk
about language and library support for concurrent programming. As I revise my
slides about the fork-join framework, I need to do something about the bullet
that Java 7 will have parallel arrays. Sadly, it won't, but Scala 2.9 does,
and they are really easy to use. Read on if you want to see how to keep your
cores busy with just a few keystrokes.
- 2011-03-22
-
Having a Racket with Pictures and Continuations
In this blog, I describe how the Racket language provides fun graphics and a
nifty web framework. The former is great for beginning students, and the
latter is helpful for grasping the mind-bending concept of continuations.
- 2011-03-11
-
A Blog Uploading Tool for java.net
In this blog, I address my grief with blog uploading, following Paul
Graham's advice about choosing technology.
- 2011-03-03
-
Ruby, Scala, and Complexity
In this blog, I ponder why Ruby and Scala are easy to learn and complex to
master, and how their cultures differ.
- 2011-01-27
-
Scala for the Impatient
My next writing project is "Scala for the Impatient". Why yet another
book? I became impatient with the books and blogs that seemed to be directed
towards language enthusiasts, not programmers who need to get a job done.
Watch out for the first drafts on Safari in a few weeks!
- 2010-11-24
-
A Report from the Sewer Hole: Cygwin, JLine, rxvt, and the Scala REPL
I have students running Windows, Linux, and Mac OS X, and I like to
encourage students to choose whatever platform makes them most productive. But
I also like to be able to give out one set of instructions, grading scripts,
etc. to everyone. Fortunately, bash is available everywhere, even on Windows,
in the form of
Cygwin.
- 2010-11-22
-
A Condensed Monospaced Font
When the time comes for my graduate students to write their project reports,
I give them a long checklist of do's and don'ts. One of the more vexing issues
is the code font. I am astonished how many people who have been programming for
years are unaware that computer code is usually presented in a monospaced
font, like this
.
- 2010-11-15
-
The Mystery of the PolicyNodeImpl Class
Google further denies that the document attached to Oracle's Amended
Complaint as Exhibit J contains a true and correct copy of a class file from
either Android or "Oracle America's Java." Google states further that Oracle
has redacted or deleted from the materials shown in Exhibit J both expressive
material and copyright headers that appear in the actual materials, which are
significant elements and features of the files in question.
- 2010-11-12
-
A Geometry Problem in Scala
I ran into
this
blog about making a pretty drawing in C# and F#.
- 2010-11-05
-
The Voters Have Spoken
The votes are in, and the people have spoken. They are mad as hell and they
want change. No, not those electionsI am talking about the
JCP elections.
- 2010-10-24
-
Scala Scripting
In this blog post, I describe how I use Scala for mundane scripting instead of monadic computations.
- 2010-09-25
-
Java One from Afar
I have been at JavaOne since 1996, its inaugural year. In 1996, JavaOne was
colocated with the Software Development conference, which has since fallen on
hard times and vanished. But at the time, half of the exhibitors were from SD,
and the other half from JavaOne. Weirdly enough, the JavaOne booths were all
yellow with a bit of red and blue, so it looked as if the SD half of the
exhibit hall represented the free world and the Java One half a totalitarian
regime. This year, JavaOne is again colocated with another conference, Oracle
OpenWorld, but I am on sabbatical in Vietnam, so I didn't get to enjoy the
show.
- 2010-09-24
-
The Next Big JVM Language
Stephen Colebourne has a
very
interesting article on the Next Big JVM Language (NBJL). The comments are
good too. (I was going to add this as a comment to his blog, but it was
rejected as spam. Maybe jroller is onto something...)
- 2010-09-13
-
PrimeFaces works great with JSF 2.0/NetBeans 6.9
In 2002, JSF was introduced at Java One as Swing for the Web.
The vision was that you would compose professionally designed components into
web pages, add a bit of Java glue code, and presto, you would have a web app
without having to worry about HTTP or the DOM.
- 2010-09-09
-
A puny Java 7 isn't the end of the world
Mark Reinhold just published a
blog stating what has
been painfully obvious to everyone following the JDK 7 development: There is no
way that it will ship 2010. He thinks that mid-2012 would be realistic. Having
followed the
Project
discussion, I can see where he is coming from.
- 2010-09-04
-
Scala, JSF 2, and NetBeans
I am working on a web site that will help students practice their Scala
programming skills. As I labored along, writing my JSF app code, I thought
this is sillywhy not practice Scala at the same time? But
I like JSF and wasn't ready to jump to
Lift
or
Vaadin.
- 2010-09-02
-
Independence Day for Java?
I am on sabbatical in Vietnam right now, and today the country celebrates
independence day. (On September 2, 1945, Ho Chi Minh gave his
declaration of
independence speech.)
- 2010-06-28
-
The Horstmann Brace Style
There is a brace style with my name attached to it. In this blog post, I describe its merits and why I had to stop using it.
- 2010-06-27
-
JSF and Power Windows
My dad is visiting, and he just picked up his rental car. He proudly
announced that he got a good deal on a compact car without
power windows.
- 2010-05-28
-
Another Java Web Start Pitfall
Yesterday, I installed shiny new Ubuntu Lucid Lynx on a shiny new laptop.
This morning, I launched a Web Start application, and I got the following
screen:
- 2010-05-16
-
Transforming an XML Tree with Scala Partial Functions
In my last blog, I outlined how I found the Scala XML library a pleasant
solution for unpleasant XML format conversion jobs. In those jobs, I had to
completely transform the document from one grammar to another.
- 2010-05-16
-
XML Processing with Scala
A few months ago, I had one of those unpleasant format conversion jobs. I
had about 1,000 multiple choice questions in RTF format and needed to import
them into
Moodle.
- 2010-03-28
-
Mercurial on OpenSolaris and GlassFish
I am working on rewriting a set of labs for our intermediate students at
SJSU. Version control is something that everyone with a CS degree is pretty
much expected to know these days, so I thought of digging up an old Subversion
lab from my open source programming class.
- 2010-01-30
-
Composite Input Components in JSF
Composite components are a great feature of JSF 2.0. The canonical example
is a login component with fields for the username and password:
- 2010-01-13
-
Project Stage and Openness
I am an observer at the JSR 314 (JSF 2.0) expert group, whose mailing list
is open (but sadly not yet archiveddon't get me going...), and we had an
interesting discussion about the project stage setting. The
expert group's efforts to extend this useful setting to other parts of EE don't
seem to go anywhere. I can't tell why, because those discussions sadly have not
been open. If you believe that an app server should be a developer platform and
not just a deployment platform, say so in the blog comments!
- 2010-01-12
-
A Flash in the Pan?
Last night, I awoke at 3 a.m. wondering whether David Geary and I should
have given more coverage to the JSF 2 flash in our Core JSF book revision. Here
is why I think your time is better spent learning about other, more powerful
constructs, together with some thoughts about CDI and REST.
- 2010-01-03
-
How to stay away from the JSF API
A few weeks ago, Ed Burns posted
a
link to a blog on the JSF expert group mailing list, commenting A
nice one, but it doesn't mention JSF 2. Ever the curmudgeon, I pointed
out that it wasn't so nice that the blog's sample code used the JSF API in
beans when it wasn't necessaryas does in fact a lot of sample code, even
in the official Sun tutorials. Ed's response: Cay, a blog comment by
such an eminent citizen as yourself would certainly be noticed. So, here
is the curmudgeonly eminence's advice on how to stay away from the JSF API.
- 2009-12-28
-
JSF 2.0 and Tomcat
As I happily wrote about new features of JSF 2.0, my coauthor David Geary
kept asking me how to run the examples in Tomcat 6. I kept putting it
offhunting down all those JAR files and web.xml
fragments
is just too much like eating soup with a fork. I finally got around to doing
the research and thought that others might benefit from the (unhappy) results,
if only to realize that this may be the time for switching to GlassFish.
- 2009-12-21
-
Is @javax.faces.bean.ManagedBean Dead on Arrival?
Java EE 6 has three different ways of defining beans that are managed in one way or another. Here is a quick recap.
- 2009-12-07
-
Running PHP Apps on GlassFish
For the upcoming semester, I want to run a
learning
management system into which I can integrate an experimental feature for
evaluating student programs. It needs to be open source so that I can modify
it. I was first going to go with
Sakai,
which is based on Java, but
just about everyone
else is going to
Moodle, and
there
are reasons for that.
- 2009-11-18
-
Closures? In Java 7???
Today, a tantalizing announcement by Mark Reinhold about closures in Java 7
has made its way through the twittersphere.
- 2009-10-20
-
Another Small Step for JSF...
In the relentless fight against configuration boilerplate, JSF and Glassfish
have taken yet another small step forward. As of Glassfish v3 build 68, you no
longer need to declare the faces-servlet in WEB.XML.
- 2009-10-20
-
Monitoring the HTTP Traffic in a JSF Redirect
I wanted to trace exactly what happens when a JSF page uses a
redirect. Here are my experiences with the HTTP and TCP/IP monitors in NetBeans
and Eclipse, and why I ended up using Wireshark instead.
- 2009-10-13
-
Recursive varargs methods in Scala
And now for something entirely different...one of my students asked how to
write a recursive function in Scala with varargs. Apparently, the internet has
lots of articles complaining about the challenge of calling
Java
varargs methods from Scala, but this particular issue did
not
google well. Here goes...
- 2009-10-12
-
Oracle OpenWorld Day 1
I got a blogger pass for Oracle OpenWorld. Here is my report from the show
floor.
- 2009-10-11
-
Oracle OpenWorld Day Zero
Aaron Houston, the fearless leader of the Java Champions, got me a blogger
pass to Oracle OpenWorld. Here is what I learned on the opening night.
- 2009-10-06
-
Java/CS1 Cheat Sheet
The next edition of my CS1/Java book is going to print soon. At the last
minute, we decided to put the real estate of the inside covers to good use and
include a cheat sheet with the most important Java control
structures and libraries. Since it would be particularly embarrassing to have a
typo here, I am hoping to enlist the aid of the community.
- 2009-10-03
-
How to draw simple diagrams the easy way (with Java2D)
When you need to produce lots of fairly straightforward graphs, Java2D is
your friend. In this blog, I show you how you can render simple images as
crisp-looking PDF or EPS files, provided you can draw them on a Graphics2D
object.
- 2009-10-02
-
Recording and serving screencasts
I just learned how to make Flash screencasts on my Linux system and deliver
them (with GlassFish) on a server that the computer science department received
as a donation (thanks Sun!!!).
- 2009-09-28
-
Alice 3, CS1, and Quaternions
This semester, I am teaching the CS1 course again. If you just teach plain
Java, it isn't easy to come up with interesting lab assignments. Some of the
students have built exciting animations with
Alice in the CS0 course. Somehow, they aren't as
excited about printing prime numbers or digits of in CS1. But the latest
version of Alice, now in beta, can be programmed in Java. This is very cool.
Students can write Java code that directs the Alice models. For example, one
assignment asks students to make a
Car
class whose
drive
method moves the car and reduces the gas in the tank. (I
couldn't find a gas gauge, so I used the cat clock. The tail moves to the left
as the tank gets emptier.) I provide the code for moving the car and rotating
the tail, and the students compute the gas consumption.
- 2009-08-10
-
A spoonful of Scala
I write my lecture slides in XHTML, using the marvelous
HTML Slidy package. I just dump
the images into the same directory as the HTML files, which isn't so smart
because it makes it hard to copy a presentation from one directory to another.
I could change my habit, but hey, what is technology for? A couple of years ago
I decided to write a script that simply generates a list of all images in an
HTML file, so I can run
- 2009-08-07
-
Are you using static import?
I am rewriting a Java book for beginners, and it seems to make so much sense
to use
- 2009-07-21
-
Add an XSD file to Eclipse and Eliminate Those Pesky XML Warnings
If you work with Eclipse and JSF 2, you too may be annoyed at the little
that shows up next
to all your faces-config.xml
files (even those that are blessedly
empty).
- 2009-07-21
-
Say Sayonara to sPAL!
When I teach my JSF crash course to my software engineering students,
everyone nods, works through the lab, and I don't hear any JSF issues from them
for a couple of weeks. Then they run into sPAL.
- 2009-07-08
-
Are Web Services the New CORBA?
I am updating the External Services chapter in
Core JSF. There is lots of new and interesting
stuff: How to use JPA, stateless session beans, and WebBeans. I ditched the
LDAP sections (for which I hadn't received very few queries, even though the
examples are notoriously hard to set up). I reimplemented the authentication
example with a JDBC realm, which was
no
fun. Now I am at the web services section.
- 2009-07-06
-
WebBeans in Glassfish v3
As I am updating my share of chapters in the Core JavaServer Faces book
(with the hard parts fortunately being tackled by my coauthor, David Geary), I
started playing with WebBeans, erm, Java Contexts
and Dependency Injection.
I'll keep calling it WebBeansthe alternative JavaCandi is more than I
can take. There are two features that are crucial for JSF users: Conversation
scope and access to stateful session beans from JSF pages. (Seam users know all
about this and can skip this blog.)
- 2009-06-29
-
A First Look at NetBeans 6.7
A few days after Eclipse Galileo, Netbeans released its latest offering,
Netbeans 6.7. Here is a first look, as always from my entirely biased
perspective.
- 2009-06-26
-
Upgrading to Eclipse Galileo
I just installed Eclipse 3.5 (Galileo)it seemed a more attractive
thing to do than actually getting my work done. Fortunately, I only need three
Eclipse plugins right now. Here is how they fared with Galileo.
- 2009-06-16
-
JSF 2.0 Refcard available
DZone just published the
JSF 2.0 version
of my JSF refcard. It provides updated summaries of the tags and attributes
needed for JSF programming, along with a summary of the JSF expression language
and a list of code snippets for common operations.
- 2009-06-15
-
My Department is Slashdotted
I teach computer science at San Jose State University. My department just
ended up on
Slashdot.
One of my colleagues, Dr. Beesonwho, to his great credit, makes
beginning students write lots of little homework programs
until they get
them rightgot into a tussle with
Kyle
Brady, an eager student who insisted on
publishing
his answers on the internet. I don't want to get into the personalities
here. Beeson can be irascible and a bit overbearing, and the student's claim
that he is doing this to increase his chances for employment rings a bit
hollow. When is the last time you hired someone because of their
TicTacToe
program? Even if I did, I'd be wary about candidates who write
if
(foundEmpty == false)
instead of
if (!foundEmpty)
...
- 2009-06-05
-
Java One 2009 Day 4
One of my favorite parts of Java One is the Friday morning toy
show where James Gosling presents a random mixture of cool and
inspirational projects. Of course, all these involve Java in some way.
- 2009-06-04
-
Java One 2009 Day 3
Like every year, I offer a quick script for packrats who want to download
the slides for all the talks. Of course, you can just wait for them to become
available online after the conference, but then you'd not be a true packrat.
Here goes:
- 2009-06-03
-
Java One 2009 Day 2
I do this to myself every year. I go to the opening keynote on Tuesday. I suffer through the love-in-with-Sun-partners part, just so I can get to the good part with the important announcements. Then I go to the Wednesday keynote, which offers no such benefit, and vow never to go to any other keynote except for James Gosling's toy show.
- 2009-06-02
-
Java One 2009 Day 1
I am no fan of keynotes, but I figured I should earn my press pass (thanks
Jacki!) and show up.
- 2009-06-01
-
Java One Day 0
Today is day 0 of Java One, AKA “Community One,” with a focus on
open source and community projects. With the economy being what it is, and Java
One stretching the definition of “early bird” specials past the
breaking point—the discount was good until today—I was fearing for
the worst, but there definitely were crowds today.
- 2009-05-28
-
The Fit and Finish of JSF
When I come
across an article such as
this one, I am
overcome with melancholy. I really want to love JSF. Its heart is in the right
place. It wants to let me drag and drop components onto a form, wire them up
with JavaBeans, and give me AJAX with essentially no work on my part. And it
comes so close.
- 2009-04-21
-
My Oracle Pronouncements for Java
As everyone knows from yesterday
morning's news, Oracle has made an offer to buy Sun Microsystems, Sun has
accepted, and the acquisition is expected to go through by the summer.
- 2009-04-06
-
Much A-do About Nothing
In general, a for
loop may be used if the number of
repetitions is known, as for example, when you need to print a message a
hundred times. A while
loop may be used if the number of
repetitions is not known, as in the case of reading the numbers until the
input is 0. A do-while
loop can be used to replace a
while
loop if the loop body has to be executed before the
continuation condition is tested.
- 2009-02-15
-
A Simple Servlet for Running JUnit in Glassfish
When teaching unit testing in the context of a simple EJB3.1 application, I
was looking for an easy way of testing managed beans and session beans inside
Glassfish. Of course, one can test out-of-container or use an embedded
container (but I didn't quite figure out how to do that with Glassfish
v3I'd appreciate hints), or a
mock container (but that seemed to
require a bit of setup).
- 2009-02-09
-
Long in coming...
A Thinkpad sale seduced me into
upgrading my laptop. My feeble rationale was that I could stop dual-booting,
use Linux on the new laptop and Vista on the old one. So, I got a shiny new
Thinkpad T500 for under $1,000, blew away Vista Homeless Edition, and installed
Ubuntu Jaunty Alpha 4. I expected the usual fussing with wireless networks,
display adapters, and futile fights to activate exotic peripherals. I was
totally disappointed. Everything, and I mean everything, down
to the webcam, worked after a 30 minute install with one reboot and no fussing.
With an alpha release.
- 2009-02-02
-
Towards Java EE Nirvana
Java EE 6 makes it pretty straightforward to crunch out a basic web +
database application. This semester, my software engineering class is building
web apps, and I decided it is simpler to have them use JSF + JPA in Glassfish
v3 rather than some technology that seems easy at first and then lets them
down.
- 2009-01-22
-
A Call to Fix the JCP Oberver Status
In this blog, I report on my disappointing experience with the JCP observer
status, and suggest that another dose of glasnost is needed to fix the
process.
- 2009-01-21
-
A simple JSF2+AJAX example
In this blog, I go over a very simple JSF2+AJAX example and show how one can
spy on the inner workings with the TCP monitor and debugger.
- 2008-12-18
-
Baby Steps with JSF2
There are
several blogs that tell you how to do fancy things with the upcoming JSF 2
(such as these by
Ryan Lubke and
Jim Driscoll). In this blog,
I look at the other side of the coinhow the simplest things are working
out. After all, if
Ruby on Rails has
taught us anything, it is that a technology that makes the simple things simple
has a great shot at getting developer mindshare.
- 2008-12-03
-
What Worked for Our Blackberry Project
After
many weeks of labor, my software engineering class is ready to deliver our
BlackBerry project to Cinequest, the organizers of the San Jose Film Festival.
Moviegoers will be able to check the schedule on their Blackberry devices, see
when their favorite films are playing, and find out about the latest special
events.
- 2008-12-01
-
Where is the source?
This semester, my software engineering class is working on a project to
bring the San Jose Cinequest film festival catalog to the Blackberry. RIM has
generously donated us some devices.
- 2008-11-17
-
Grief with Gantt charts
Occasionally, I have to put together a project schedule with a Gantt chart.
In my software engineering class, I figured I should use something
cross-platform and open-source, and not Microsoft Project, which I vaguely
remember as a muddleheaded mess.
- 2008-10-17
-
Restless about REST
In my software engineering class, we are designing an application that shows films and events for the Cinequest film festival on Blackberry devices. We need to get film schedules and descriptions from a server onto the mobile phones. A typical query would be: “Show all movies playing today”.
- 2008-10-06
-
Core Java Refcard
My second "refcard" has been published by DZone. This time, the DZone team managed to cram an unbelievable amount of Core Java language and library facts onto a small PDF file. Check it out
here.
- 2008-10-05
-
Know When to Fold
I am teaching an undergraduate
course in programming
languages. We build interpreters and compilers for toy languages, in the
hope that students gain a basic understanding of syntax, semantics, and
language translation.
- 2008-09-17
-
Teaching Software Engineering with BlackBerry
One of the best aspects of my job as computer science professor is that I
keep learning new stuff. This semester, I am teaching a software engineering
class.
Cinequest, the organization that puts
on the annual San Jose film festival, approached the CS department, asking for
help with their mobile initiative. We jumped at the chance, and now my students
are hard at work designing and prototyping a BlackBerry application for
festival attendees.
- 2008-09-15
-
Applet Dragging in Linux
Being a Linux user, I watched those applet dragging demos with envy when they only worked on Windows. When the release candidate of JDK 6 update 10 (now there is a product name only a mother could love...) came out, I was eager to try it out on Linux. Initially, I was held back by a factor entirely beyond my control, i.e. my cluelessness and unwillingness to read the docs. Thanks to Aaron Houston and Ken Russell for helping me out. Here are the steps:
- 2008-09-15
-
JSF Refcard available
When I traveled to the U.S. as a nerdy teenager, I was fascinated by those laminated reference cards. It seemed yet another example of boundless American optimism that one can cram an entire semester's worth of information into two pages.
- 2008-09-10
-
Teaching Programming Languages with Scala
This semester, I am teaching the undergraduate programming languages course
at SJSU, a required course for CS majors. The course has two objectives:
- 2008-09-05
-
Lessons from My Summer Vacation
In this blog I reflect on what I learned during my summer vacation, about
standards, folding travel beds, and snatching defeat from the jaws of
victory.
- 2008-07-30
-
Summer School in Switzerland
In this blog, I report on how I am spending my summer vacation (or at least
a part thereof) as a guest lecturer in a summer program in beautiful Canton de
Vaud, Switzerland.
- 2008-05-23
-
What do CS students learn?
On May 23, I gave a presentation at Sun about computer science students,
and how a company can engage with them (
audio |
slides). Here
are some of the questions that I was asked, and the answers that I gave (or
wish I had given), and a question that I wish I had been asked.
- 2008-05-09
-
j1-2008-day4
The hardware, the OS, and the JVM are ready for large numbers of
cores.
The languages, the tools and the programming community at large
are not ready for large concurrent programs.
So... good luck, guys!
- 2008-05-08
-
j1-2008-day3
During a meeting in the Community Corner (java.net booth) with James
Gosling, a participant asked an interesting question: "Which Programming
Language would you use *now* on top of JVM, except Java?". The answer was
surprisingly fast and very clear: - Scala.
- 2008-05-07
-
j1-2008-day2
Here is my report from day 2 of Java One. I continue to feel diffident
about RIA and Java FX Script, the theme of this year's Java One, so I decided
to make my own themes: Ease of development, and transparency.
- 2008-05-06
-
j1-2008-day1
Here is my braindump from Information Overload Central, AKA Java One 2008.
- 2008-05-05
-
j1-2008-day0
Last year, Java One Day 0 was Netbeans Day, in a cozy hotel. This year,
the Java One week started much more grandly, with Community One, at the
Moscone Center. There were tracks for a number of open source communities,
including NetBeans, GlassFish, MySQL, OpenSolaris. Frankly, I preferred the
cozy hotel, but I can see that it is savvy marketing by Sun to have a
large-scale free community event.
- 2008-05-04
-
On Blue-Collar Languages
I ran across
this
tech tip on using wildcards in Java generics. Pretty basic stuff, I
thought. But I was amazed by the comments:
- 2008-04-05
-
Is Computer Science the New Latin?
This
Washington
Post article reports on the elimination of underenrolled Advanced
Placement (AP) courses in American high schools. The subjects affected are:
Italian, Latin Literature, French Literature and, hold on to your hats,
Computer Science AB. (The
College
Board designs high school courses that aim to be equivalent to college
courses. High school students who take the course and pass an exam are often
given college credit.)
- 2008-03-01
-
feel-of-java
Last time, it took me at least 10 hours to do one of the problem, but i
got through #1 in less than 1/2 an hour. most of it was copy and paste. I
didn't even need more than 1 class. am i missing something? It's almost as
if you can lift the solution out of the labs. All I had to do was write 2
really really really simple closures.
- 2008-01-21
-
Swing for the Web--Are We Getting Closer?
When I first heard
about JavaServer Faces, way back at the 2002 Java One conference, it was sold
as Swing for the Web. That caught my attention. I was sick of
assembly programming for the Web with HTML, JavaScript, HTTP,
cookies, servlets, and that special form of tortureJSP custom actions.
Ever since, I have pinned my hopes on JSF because it has one thing going for
it: a component model. When I need, say, a progress bar, I want to
leave it to someone more skilled than me to make such a thing out of images,
JavaScript, or whatever. I just want to hook it up to some property that has
a progress value and move on to the next task. After all, when I use a
JProgressBar
in Swing, I don't worry about the pixels and
animations either.
- 2008-01-08
-
Dinosaurs Can Take the Pain
There has been much discussion on whether Java
programmers are becoming dinosaurs, on an
evolutionary
dead end and overtaken by more nimble mammals. Bruce Tate has long
abandoned Java for greener (or redder) pastures. Bruce Eckel has embraced
Flex , Bill Venners favors Scala. Python is making inroads in college
curricula. What is a Java programmer to do? In this blog, I argue that we
need to focus on less on syntax and more on the pain points of Java
programming.
- 2007-12-29
-
The OLPC and Java
With Java, I can replace my computer with a $500 Internet
appliance.
- 2007-12-20
-
Properties Get No Respect
There has been another flurry of discussions about
closures
in Java and
minor
language enhancements, together with the usual flurry of
leave
the language alone lamentations.
- 2007-12-12
-
DSLs--Standalone or Embedded?
I am a reviewer for Java One. I have about 350 project proposals to plow through and not enough time to give each of them justice.
- 2007-08-17
-
Flying Saucer Comes Through with Flying Colors, or the Triumph of
Infrastructure
I had to render a set of presentation slides in HTML
Slidy format into images. This blog entry shows how to carry out this task
with the excellent Flying Saucer XHTML renderer and concludes with some
ramblings about infrastructure.
- 2007-08-01
-
A Bundle of Joy - NOT.
Today, I rant about Sun's blunder in their bundling of JavaDB in JDK 6.
Executive summary: 1. Don't rely on JavaDB being present in the JDK. 2. A
bungled bundle is worse than no bundle at all.
- 2007-07-14
-
The grass isn't greener on the other side
Today, I am in beautiful San Diego, at a NSF workshop on active learning and UCSD's
Ubiquitous Presenter software. Ubiquitous Presenter lets instructors and students add pen-based markup to slides and share them with each other. It is a nifty tool to engage students in the classroom instead of just lecturing. The student part of the software uses Java, and students can use the mouse or a tablet pen (which just acts as a mouse) to add their notes. The instructor part of the software uses .NET because instructors need to be able to write nicely, and Java doesn't have any support for pens (pressure, erasing, etc.).
- 2007-07-07
-
Number melancholy
Changes in 1.6.0_02
The full internal version number for this update release is
1.6.0_02-b05 (where "b" means "build"). The external version number is
6u05.
- 2007-07-02
-
JSF Support in Eclipse Europa and NetBeans 6.0m10~
When Eclipse Europa was released on June 29 (together with the iPhone
and the GPL 3 license), I wanted to know if it did anything about one of
my many pet peeves: tool support for writing JSF apps. In this blog, I
will compare Eclipse 3.3 and NetBeans 6.0 milestone 10 to see how they do
on the world's most mundane JavaServer Faces application: the login
example from
Core JSF.
- 2007-06-11
-
The Single Thread Rule in Swing
Once a Swing component has been realized, all code that might affect
or depend on the state of that component should be executed in the
event-dispatching thread.
- 2007-05-11
-
Java One Day 4
This is my last day as the intrepid reporter at Java One. The press
room, which had become my home away from home, was closed. Instead of
snarfing up the baked goods and looking for the secret stash of booze, I
chatted with lots of interesting folks in the halls of Moscone, attended a
couple of sessions, and pondered what it all meant.
- 2007-05-10
-
Java One Day 3
This is my third day of reporting from the floor of Java One. I ran
into a number of very interesting folks, got the chance to ask more
hard-hitting questions, and had a mixed bag of sessions.
- 2007-05-09
-
Java One Day 2
This year, I got a genuine press
pass from a kindly soul at Sun. While my quest for priority seating was
still futile, I made progress on my quest to locate the stash of free
booze, and I got the chance to ask more hard-hitting questions. Here is
your intrepid reporter's take on day 2.
- 2007-05-08
-
Java One Day 1
This year, I got a genuine press
pass from a kindly soul at Sun. I was excited about priority seating and
unlimited free booze in the press lounge, neither of which I was able to
locate. But I did get to ask hard-hitting questions in the press
conference. Here is your intrepid reporter's impression of day 1.
- 2007-05-07
-
Java One Day 0
This year, I got a genuine press
pass from a kindly soul at Sun, which entitles me to priority seating at
the keynote, the opportunity to ask hard-hitting questions in the press
conferences and unlimited free booze in the press lounge (I hope).
- 2007-04-17
-
What's so Taxing about Return?
Some responses to my blog on Neil Gafter's closures talk showed concern
with the handling of the return statement in BGGA closures. Since I am
done with my tax return, I am blogging about the intricacies of the return
statement inside closures.
- 2007-04-12
-
Dr. Gafter comes to SJSU
I teach a graduate programming languages class at San Jose State
University. In order to inject some topics of current interest, I had a
lab about closures and the competing closure proposals for Java 7. I got
an email from Neal Gafter: Hey, it's really cool to see your
reference to BGGA in a SJSU lab assignment! I asked if he could
give a talk at the department seminar, to which he graciously agreed. We
had a packed room today. I am very excited that my students had a chance
to witness a bit of history in the making. Here are my impressions of the
talk.
- 2007-01-28
-
Microsoft Patents BlueJ Workbench
BlueJ is a tool for teaching OO programming in Java that is very well
regarded in the CS education community. Microsoft engineers who were
familiar with the BlueJ "workbench" added a similar feature to Visual
Studio, didn't give credit to the BlueJ inventors, and filed a patent
application. Not the way to win the hearts and minds of the education
community.
- 2007-01-12
-
Properties are Design Features
The discussion about properties had reached a fever pitch in the last
weeks, and there is a great deal of dissent about the nature of
properties. Are they meant for tools, are they the tool of the devil to
seduce us away from the goodness of OO, or are they just an irrelevant
preoccupation of programmers who have no tolerance for boilerplate? In
this blog, I would like to argue that properties are legitimate design
features, and that it is the job of a programming language to allow
faithful mapping of design intent to code.
- 2007-01-10
-
Pie in the Sky Properties
Jacob Hookom
has
been vocal about doing properties right rather than simply generating
getFoo/
setFoo methods. Of course, you still want the
JavaBeans introspector to work correctly. I thought it would be
interesting to run with this idea and see where it gets.
- 2007-01-07
-
Arrows in the Back
There has been a flurry of recent blogs on native
property syntax, much of it rather emotional. This blog tries to get past
the emotions, hoping to garner interest in the real issues that need to be
solved for native properties.
- 2007-01-03
-
A JDK6 JavaScript Console Conundrum
I just discovered the JavaScript console (jrunscript)
inside JDK6. Pretty nifty for running quick-and-dirty tests. Or so I
thought until I ran into a bizarre problem with that most exotic of
classes, java.lang.String.
- 2006-10-22
-
The World's Simplest Unit Testing Framework
I describe the world's simplest Unit testing
framework for teaching Java to beginners.
- 2006-09-08
-
The Power and Pain of POJOs
I wrote a quick-and-dirty quiz application to check
whether my software engineering students do their reading assignments (or
at least google quickly). Can an Elvis-level programmer do this in a
couple of days with EJB3 and JSF? Here is my experience report.
- 2006-08-23
-
How Not to Report an Internal Error
NetBeans pops up a dialog with an exception message
when it finds an internal error. And again. And again. And again. And
again. This blog reviews just how user-hostile this behavior is, and
suggests alternatives.
- 2006-07-17
-
Track+ On GlassFish
Directions for setting up the Track+ bug tracking
system on GlassFish. This is all boring, and I just put it up for
reference. If you are looking for something fun, follow one of the links
in the second paragraph instead.
- 2006-07-17
-
Installing GlassFish and PostgreSQL on Ubuntu Server Edition
I don't do LAMP, I do JELP (Java, EE5, Linux,
PostgreSQL). Here are instructions for installing Java, GlassFish and
PostgreSQL on Ubuntu 6.06 "Dapper Drake" Server Edition. No gotchas, just
a bunch of steps that I hadn't found together in one place.
- 2006-07-12
-
Certified Insecurity
I used Java Web Start as a "poor man's installer" for a
Java client app that allows students to check their homework assignments.
The app needs "all permissions", so I simply signed it with a worthless
self-signed certificate. The Web Start security dialog is complete
gibberish to 99% of end users, which works in my favor. Something is wrong
here. Should the JNLP API be less convoluted, so that it is easier to live
in the sandbox. Should it be less of a hassle for an individual to get a
real certificate?
- 2006-07-05
-
Railroad Diagrams
Does anyone still use railroad diagrams (AKA syntax
diagrams)? If so, how do you produce them?
- 2006-07-03
-
Don't Lie to the Entity Manager
JPA is the new object-relational mapping standard that
you can use in EJB3 or in standalone applications. For the most part, it
is phenomenally easy to use. But there is a trap that has bitten more than
one developer. If you ever lie because your fibbing won't affect the
database, your lies can still come back to haunt you. This blog gives two
examples.
- 2006-06-25
-
An EJB 3 Glossary for Elvis
I am working on a glossary of EJB 3 terms that gives
both the official definitions and explanations that Elvis can understand.
(Elvis is the programmer persona who is neither Einstein nor the
point-and-click/drag-and-drop "just give me a wizard" Mort.) What other
definitions would you like? Do you spot errors or inaccuracies? Please let
me know.
- 2006-06-21
-
Why Java Developers Should Switch to Linux
It's summer again, people have more time on their hand,
and they think about switching operating systems. I'd like you to consider
switching to Linux. It's not cool, but you get to enjoy freedom from
crapware and forced upgrades, keyboard shortcuts, and great Java support.
There is just one drawback. Unlike the Mac crowd with their
distinctive-looking hardware, you'll need a garish Linux sticker so that
the world can see you aren't running Windows.
- 2006-06-13
-
Honey, I built the JDK! (on Ubuntu)
These are my notes for building Mustang on Ubuntu 6.06.
Amazingly enough, this works with just a small number of easily fixed
issues. This is good news if you want to tinker with the JDK on Ubuntu.
Even if you don't, it is comforting to know that the Mustang build process
is robust enough to allow the tinkerers to use it on their favorite
platform, so that you can benefit from their labors.
- 2006-06-09
-
The innermost secrets of -javaagent:toplink-essentials-agent.jar
revealed
I had been mystified by what exactly the magic
incantation -javaagent:toplink-essentials-agent.jar does for JPA clients,
and my experiments had been inconclusive. I finally figured it out. Here
is the answer in terms that Elvis can understand.
- 2006-06-08
-
Say No to Properties Boilerplate!
Nobody likes to write properties boilerplate--the
getter, the setter, the Javadoc for the getter, the Javadoc for the
setter, you know the drill. Ok, you say, Eclipse writes it for you. But
you still have to read it. Pages and pages of it in many real life
classes. My graduate student Alexandre Alves implemented a Mustang
compiler extension to remove the drudgery. We want to get this feature
into Dolphin and need your help. Try it out and let us know what you like
and what needs work!
- 2006-06-07
-
Programmer Productivity, JSF, and NetBeans
My first impression using NetBeans 5.5 for JSF 1.2
development: Not easy on the eyes, but the debugger, HTTP monitor, and
GlassFish integration dramatically increased my productivity.