Chunky 2016 Spring Update 2016-04-02

In January I published a small snapshot release that added more posing options for player entities. My plan was to improve the posing support and also improve player rendering before I made the 1.3.8 release, however I became very busy with my PhD studies/work and Chunky development has been mostly on hiatus since then. I wanted to write this post to give an update to the Chunky development to everyone who uses Chunky and is interested in the progress of development.

Release 1.3.8

Since the improvements I wanted to add before the 1.3.8 release got delayed, I think it will be a good idea to make the 1.3.8 release anyway because I have made some bugfixes that need to be released. Today I published a new snapshot release, 1.3.8-rc1, which is a release candidate for 1.3.8. If I don’t discover any new issues with this snapshot release I will publish that version as 1.3.8.

User Interface plans

Of all the components in Chunky, the User Interface (UI) is the one I have spent most time on. I actually very much dislike UI programming. It’s tedious, error prone, and time consuming. I am still not pleased with the UI, and there are many things I’d like to improve in it. The most annoying issue right now is that the UI looks and behaves differently on different platforms.

Chunky uses the Java Swing library for its UI components. There are many benefits of using Swing: it is supported on most Java versions and it works on Windows, Mac, and Linux. However, the disadvantages of Swing are also many, and chief among the disadvantages is that the UI components are ugly and behave in some cases unexpectedly. Swing UIs usually end up looking old and janky. The default Swing look and feel is very outdated, but people have tried to remedy this by making their own look and feel libraries for Swing. This is a huge time sink and not at all worth it for small projects like Chunky.

Swing does provide platform-dependent look and feel settings which allow your Java app to look more like a native app, and these settings can make Swing look much better, however it also means that the UI looks different on each platform, and behaves slightly differently. For example, here is a side by side comparison of the control panel from the main window as seen on Windows and Linux:

Swing on Windows vs Linux

I am very displeased with the current state of the Chunky UI, and I’d like to remove these large differences between platforms. I would much prefer if the UI looked the same on all supported platforms. There is a solution to this problem, and that is the Java FX framework. Using Java FX would require users to use Java 8, which I dislike because I really would prefer to support Java 6 as long as possible, however Java FX applications can look really pretty, and they behave well and are consistent between platforms! My plan right now is to try to migrate to Java FX after the 1.3.8 release. Swing components can be used in Java FX and that will allow me to gradually move over to Java FX.

The downside of making a big change in the UI is that it takes a lot of time, and it’s development time that doesn’t help improve the application in a substantial way. In some cases a better working UI can be a big gain, but it won’t add new features or fix existing rendering bugs. So it is difficult to commit to a big UI rework when I know that it detracts from other fixes/improvements that I would like to work on.

Single Document Interface

I had an idea previously to design a single document interface for Chunky. I started working on that, using Swing, but decided to ice the project when I realized that it would take a lot of time to iron out all of the small new issues that were introduced. I still think I’d like to try making a single-document interface in Java FX. Here is a screen shot of one of the partially working single document interface builds:

Single document interface in Chunky

Development hiatus

As mentioned, Chunky development has been mostly frozen for a while. This is due to my PhD studies and all the work I need to do because of it. There will be another hiatus in Chunky development soon, during the summer, because I am returning to Google for a second internship. After that, in August, I am looking forward to taking some vacation time and focusing on Chunky development.

No Comments on Chunky 2016 Spring Update
Categories: Uncategorized

Printf debugging is useful 2016-03-04

Debugging is an essential skill for programmers. Our code breaks often, and in many cases we have to debug our code to figure out why it broke. Some people hate debugging while others love it. I am firmly in the “love debugging” camp, I get a huge kick out of solving a bug in my code by figuring out what’s going wrong and why.

When I think about debugging, printf debugging is usually the first thing that comes to mind, though many may not see it as real debugging. In this post I will try to describe what printf debugging is and why I think it is useful.

First, let’s review some common debugging techniques:

  • Looking at the output. Some kinds of errors can be found without even looking at the source code. This is common whenever you are working with graphical applications, e.g. in a Graphical User Interface it is often easy to identify a bug and how to fix it when something doesn’t work as intended. Just looking at the program output in non-graphical applications can be useful too. For example, if your program should print a list of items and it prints them in an unexpected order, then the bug is probably that the list is not sorted before being printed.
  • Stare at it until you figure out what when went wrong. This is a surprisingly common debugging technique. You can often figure out what is wrong by just reviewing your code again and thinking about how the control flow could lead to the unintended behavior.
  • Explain your code to someone else (or a rubber duck). This deubgging method is useful but often overlooked. It is easy to make incorrect assumptions about your code, it’s a mistake every programmer does many many times. When you try to explain your code to someone else something interesting happens: you end up re-evaluating your assumptions and realizing that some of them were wrong, and that can lead to discovering the cause of a bug.
  • Printf debugging: inserting print statements in your code to test your assumptions or visualize control flow. We’ll talk more about this soon.
  • Using a debugger. This is probably what people associate most with “real” debugging, although it may not be the most common method because it requires additional tools and mental context switching. Debuggers can be hugely powerful though, and there are lots of different ways to use a debugger ranging from simple to advanced: stepping through instructions, setting breakpoints, setting watchpoints, setting conditional breakpoints / watchpoints, attaching to a running program. Knowing how and when to use a debugger is awesome, but debuggers are not the main topic of this post.

Let’s examine printf debugging a bit more. As I said, printf debugging is the practice of inserting print statements in your code. You might not even think of this as a debugging technique because it doesn’t rely on a debugger, but as seen in the list above many debugging techniques don’t require a debugger. The lack of a debugger is in fact a part of why printf debugging is useful. Although many development environments come with a built-in debugger, they usually require a separate workflow to start the debugger. It might not be that difficult, it’s usually quite easy, but it is often just quicker or simpler to insert a few print statements to test your code. I usually find that inserting print statements is less mentally straining than switching to a debugging mode – it means I have to switch the way I think about my code and figure out useful places to add breakpoints.

Here are a few other reasons why I think printf debugging is useful:

  • You don’t need extra tools to insert print statements. Just edit the code then build and run the program as usual.
  • Print statements can be used to follow the control flow of the code, without stepping through it in a debugger. Using print statements you can easily generate a timeline of of interesting points in the execution. Selected variable values can also be printed in the same high-level timeline if needed.
  • Low impact on timing sensitive bugs. Using a debugger interrupts the control flow and can cause timing-sensitive issues to become untraceable. Print statements are less intrusive when debugging concurrent code that depends on a specific thread interleaving to be triggered.
  • The printf method usually gives more high-level information than using a lower-level technique tool such as a debugger where you often step through statement-to-statement and see very detailed but often uninteresting information about the control flow and program state.
  • A debugger may not be available, then printf debugging might be the best bet to figure out what is actually happening in the code.

Printf debugging does have lots of legitimate uses, however in some cases it’s not the best thing to do. Here are some reasons why printf debugging can be bad in some situations:

  • The debug print statements need to be removed after you fixed the issue. This is tedious and error prone. It’s easy to forget to remove a debug print statement.
  • It’s boring to insert print statements. When there are many variables you want to know the value of it is probably time to switch to using a debugger.
  • Output logging is not always available. If you make apps for a smartphone it might not be easy to get a console to print debug messages on. Many kinds of plugins in different kinds of software don’t have a debug console either.
  • Too much output. Printf debugging is sometimes too verbose, particularly when the place you insert the print statements is called very many times before the bug occurs.

I think there is much more that could be discussed about the pros and cons of printf debugging, but the main point is that it’s a simple technique to use and there is no shame in using a less sophisticated tool if it gets the job done. In the end it only matters if you can find the bug in a reasonable time, not which tools you used to find it.

One final thing I want to show is a technique I use when I debug Java code. Sometimes I add the following line to my code in a place where I know that incorrect behaviour is happening:

new Throwable().printStackTrace();

This will result in a stack trace showing the call stack for the problematic point in the program. This starts to get into territory where it’s better to use a debugger, but if you just want to know the location of one statement in the call stack and are not bothered to inspect local variables etc, then the above line might be a useful hack.

No Comments on Printf debugging is useful
Categories: Uncategorized

Loving The Witness 2016-02-01

I have been playing The Witness recently. It’s a gorgeous puzzle game. I am a fan of puzzle games and I think The Witness is one of the best I have played so far. The puzzles are what really make The Witness great, but the aesthetics are a big plus too. The atmosphere of the game is somewhat like Riven, in that you explore a desolate island world listening to gentle gusts of wind, rustling leaves and lapping waves, getting mildly infuriated by puzzles you don’t quite get. While not being vexed by an inscrutable puzzle, it can be quite meditative to walk around in the serene game world of The Witness.

The Witness

It is difficult to talk about the puzzles in The Witness without spoiling the game, and I really encourage you to try it if you are at all interested in puzzle games. I will try to describe why I love the game without spoilers.

A puzzle game needs a progression of difficulty – the puzzles can’t be straight up super hard, that would make it feel unfair and make players give up prematurely. It also can’t be too easy all the time, because making the puzzles too easy takes away the rewarding feeling of solving the puzzles, and then the game becomes boring – a tedious task rather than a rewarding challenge. I have played many games that were too easy and became boring because of that, for example The Bridge is a decent game but a bit too easy for me so I didn’t enjoy it as much.

In my opinion, the puzzles in The Witness are well balanced. They constantly offer new challenges by repeating old mechanics in slightly different ways. The Witness may be too difficult to some players. It does get quite complicated the further into the game you get, but it is on the other hand really rewarding to finally solve those difficult puzzles. Sometimes you just need to take a break from the game, or go look at another set of puzzles while you think about the puzzle you were stuck on in the back of your mind.

The Witness

Another great aspect of puzzle games is when you can solve the puzzle without being told how to. The best puzzle games manage to hint at the solution without blatantly telling you the solution. Solving puzzles like that feels really great – it makes you feel smart, and that is a big part of playing puzzle games. The Witness manages to give useful hints without being too obvious, and there are very few situations where the solution is directly given to you. I also feel like the hints are not too obtuse either, but there were definitely some puzzle mechanics that I had to just take a break and come back to to figure out the hint.

The Witness

The puzzles in The Witness involve many different mechanics, and it is up to the player to discover those mechanics. It’s all about figuring out what rules the puzzles obey, and which order to do certain things. The solution to the puzzle is really just moving a cursor from point A to B without violating those rules. It’s a simple system with a big variety of mechanics that challenges you with new and interesting head gymnastics. The game is also open-ended in this sense, because there are many puzzles at any time that you can try to solve, but some of the puzzles teach you how to solve others of the available puzzles.

A puzzle in The Witness

Though I really liked The Witness, there are some things that could be improved:

  • The game seems to be unplayable for colorblind people due to using colors heavily in the puzzles.
  • Some puzzles are more difficult or impossible for hearing impaired people.
  • The story is abstract and unsatisfying. I’d like to know more about what happened to the island and why I am there. It seems sort of like a virtual reality spa, but I guess it is up to interpretation.
  • The save system could be done a bit better. If you want to use multiple saves you have to trust the game to not overwrite all of your old auto saves.

The Witness may be a bit pricey right now, but it was worth the money for me. The highlights of the game are:

  • Rewarding puzzles that make you feel smart.
  • Pretty graphics.
  • Awesome atmosphere and sounds.
  • Lots of puzzles (more than 500!).
  • Lots of secrets.
No Comments on Loving The Witness
Categories: Uncategorized

My TEDx Talk 2016-01-19

I gave a talk at a TEDx event, TEDxLund here in Sweden, this past autumn (October 10, 2015). The event was organized by a group of University students. I was very surprised to be invited to speak at the event, and immediately I became nervous about the prospect of giving a TEDx talk. I have seen many amazing TED talks in the past and I feared being compared to other much better speakers and end up looking like an amateur. I am also not entirely comfortable with being filmed, and the idea of a video of me ending up on the Internet made me uncomfortable. I decided to give the talk despite this because I hoped that I might inspire a few people to learn programming.

The video is now live on YouTube: Rendering Minecraft | Jesper Öqvist | TEDxLund

My script went through many big revisions and even complete rewrites. My initial goal for the speech was to motivate young people to learn programming, so the first version of my script was all about that. I didn’t mention Chunky because it seemed unrelated to the topic. However, Chunky is probably the most noteworthy thing I have done in my life, so it seemed like my talk should be about Chunky in some way. Chunky is also a nice and well-contained success story and part of the advice I got about writing a TED talk was that you should use a story to engage the audience. The story of Chunky seemed more engaging than just talking about programming in general.

The final speech is about three things: Chunky, programming, and Minecraft. I had some key points I wanted to talk about and this was the best way I could think of to touch on each point. Those key points were:

  1. Programming is fun.
  2. You can do cool things if you learn to code.
  3. Programming is not as difficult as it may seem.
  4. Minecraft and other video games can be a great inspiration to learn programming.

Talking about Chunky was tricky because although it sort of helped the second point it could easily undermine the third point. I didn’t want to make Chunky seem too impressive. It is probably easy to think “I could never make anything like that”, especially for non coders, but the message I wanted to convey was that anyone can make something like Chunky, at least that was implied. Such a statement is difficult to make convincing without seeming arrogant, it might turn out sounding like I am too good at programming to be able to see the difficulties about learning to code. I tried to not trivialize the amount of work I have spent on Chunky, and I wanted to emphasize the iterative nature of coding – you make something crappy first and keep on improving it until it becomes better. That’s the way I made Chunky, and I am certain that with enough time and motivation anyone could make something similar because the math you need to know to make a ray tracer, like Chunky, is very simple and there are tons of tutorials online for both the math bits and the code bits.

One thing that made writing the talk difficult was that I had to write it for an audience that probably does not know what “ray tracing”, “path tracing”, or maybe even “rendering” means. I tried to use as simple words as possible, and explain any more complex words that I used. Rendering ended up in the title of the talk though, which might have been a bad idea. The title of my talk was a quick decision, “Rendering Minecraft” literally describes what Chunky does, but I started regretting the name afterwards because it might be misleading and imply that I have worked on the actual Minecraft game, which I have not. I hope there is not too much confusion about that.

There are probably many things that could have been improved in my TEDx talk, but I feel like I did the best I could with the limited time I had to prepare for the talk. I was very relieved after the event, because all of the script writing and rehearsing had been making me really stressed.

One of the people who came up and talked to me after my speech was the mother of a boy who plays Minecraft. She said her son was interested in programming, and wondered if I had any tips for where to learn programming. The one site I could think of then was Code Academy, but I have compiled a list of other sites I know of where you can learn more about programming below:

  • has free programming courses, and a few small programming games in the “Hour of Code” section of the site, for example there is a Minecraft-inspired game that teaches the basic principles used in programming. Check out Minecraft Hour of Code here. I played it myself, and later I showed it to my younger sister (13 years) who played through it on her own. It is quite constrained and does not let you do a lot of interesting things, but it might be a good starting point.
  • Scratch is an online programming playground that lets you make interactive graphical things by dragging control blocks around to build a program. There are examples of things people have created on the site, everything from simple animations to playable games.
  • Kojo, a learning environment based on the Scala programming language, lets you experiment with more “real” programming – you write your programs in plain text rather than by connecting boxes.
  • Code Academy, and Khan Academy are sites that offer free courses in programming. I have not tried these, but I have heard good stuff about them.
No Comments on My TEDx Talk
Categories: Uncategorized

Entity posing and UI redesign 2016-01-06

I have been working on adding controls for posing and skinning entities in Chunky. I added a new tab in the Render Controls dialog which has a list of poseable entities and controls for adjusting each entity individually. It also allows adding/removing entities. It is still unfinished but somewhat useful, so I uploaded a new snapshot build with this work in snapshot 1.3.8-alpha1.

A screenshot showcasing the new Entities tab:

Entities Tab

I want to add some more features to the Entities tab before I release version 1.3.8:

  • Automatic downloading of player skins based on player ID.
  • Ability to save poses for easier posing.
  • Allowing multiple entities to be edited at the same time.

User Interface Redesign

I have been thinking about a redesign of the Chunky UI recently. I would like to get rid of the 3D preview window and integrate it into the main Chunky window. I also want the Render Controls to be inside the main window by default. I’m imagining something similar to how most 3D editors work where there is one or more 3D views of the scene in the middle of the window and toolboxes on the sides of the window. I also want the Render Controls tabs to become individual toolboxes that can be repositioned individually in the UI by the user.

Part of the motivation for this redesign is that the default mode you enter when Chunky starts is a plain 2D map viewing mode, while the most common task in Chunky is creating 3D scenes so the 3D scene mode should be the default mode. The map should just be a tool you use to load chunks from a Minecraft world.

One source of inspiration for me is the Blender UI:

Blender UI

Another idea I had was to migrate the Java 8 and JavaFX, but that is a larger change and nothing I want to deal with anytime soon.

3 Comments on Entity posing and UI redesign
Categories: Uncategorized

How I make temporary accounts 2015-12-22

I don’t like creating new accounts with my real email address, because:

  • I don’t want to be automatically subscribed to newsletters. This is annoying and happens very frequently, often without the offending site asking if I want to receiver their newsletter.
  • The more databases my email is in, the more likely hackers get it and sell it to spammers.

To avoid using my real email address for websites where I want to do low-priority stuff I have a process for generating a temporary public email address using mailinator,, or similar providers. These websites let you go to a static public URL to view an inbox for any email account on the domain, for example if I go to I will see all email recently sent to This is super useful, because now I can register accounts that are in no way tied to me personally.

To pick unique email address, username, password and first/last names I use a few Python scripts. This is the script I use to generate passwords:

import random, string
chars = string.lowercase + string.uppercase + string.digits
print(''.join(random.choice(chars) for i in range(10)))

This can also be used to generate an email address. For example, if I run the script to get a random string:

$ python 

I can use as the email address for my new account. I also generate a separate random string for the password. Some sites have banned accounts from using email addresses, so then I use or another similar site.

To generate username and first/last name I use another script called

import string
from random import choice
prefix = [ 'Dr', 'Captain', 'Mr', 'Ms', 'Big', 'The', 'Not' ]
first = [ 'Happy', 'Crappy', 'Flappy', 'Jiggly', 'Wobbly', 'Neat', 'Freaky', 'Honking',
    'Prickly', 'Picky', 'Pixly', 'Random', 'Sick', 'Slippery', 'Slim', 'Shady', 'Wily' ]
last = [ 'Pants', 'Dog', 'Cat', 'Bird', 'Bag', 'Toe',
    'Waffle', 'Truck', 'Jeep', 'Beep', 'Boop', 'Phony', 'Puff', 'Rocket', 'Panda',
    'Hat', 'Boy', 'Girl', 'Crunch', 'Bee', 'Morty', 'Rick', 'Biggles' ]
for i in range(10):
    print(''.join([ choice([ '', choice(prefix) ]), choice(first), choice(last) ]))

The name generating script uses word lists for parts of a name, and picks randomly one first-part and one last-part. It also picks one prefix for half of the generated names. It prints ten names so that I have some alternatives to pick from and can pick one that I like. The word lists here have been shortened, my real lists are much longer so that I get more variety in the generated names.

Here are some names generated by the above script:

$ python

I use this process to sign up for online news sites, forums, and sometimes just to try out new services or APIs that require registration. This method is obviously not secure, because the email inbox is public and anyone can hijack your temporary account if they figure out your email and do a password recovery, so I use this method mostly for truly temporary accounts. I do use the password script to generate passwords for most of regular my accounts too because I want to avoid reusing passwords.

No Comments on How I make temporary accounts
Categories: Uncategorized