Saturday, 3 April 2021

The Little Book of Java Programming

As I write this, the sun is shining, the birds are tweeting and I can see primroses in the grass outside my window. Here in Britain, spring has finally arrived! And when spring arrives, I always feel it really is time to start work on something new. I have a few new projects lined up, some of which I’ll tell you about later in the year. But I’ve also just finished a book. My latest release is called The Little Book Of Java and it should be the perfect thing (I hope!) for anyone who wants to learn to program in Java quickly and easily.

As always, I’ve tried to get right to the heart of the topic without bombarding the reader with lots of information (class libraries, method listings and so on) that you can easily find online.

The Little Book Of Java explains Object Orientation, classes, methods, generic lists and dictionaries, file operations, serialization and exception-handling, creating commandline and 'visual' form-based applications. You can download the source code ready to run at the commandline or load into an IDE (the free NetBeans IDE is recommended).

Topics covered include...

  • Fundamentals of Java
  • Object Orientation
  • Classes and Class Hierarchies
  • Variables, Types, Constants
  • Operators & Tests
  • Methods & Arguments
  • Constructors
  • Access Modifiers
  • Arrays & Strings
  • Loops & Conditions
  • Files & Directories
  • structs & enums
  • Overloaded and overridden methods
  • Exception-handling
  • Lists & Generics
  • Streams & Serialization
  • ...and much more

You can buy The Little Book Of Java in paperback or for Kindle from:

 Amazon (US):

Amazon (UK):

And also from other Amazon stores worldwide.

Tuesday, 16 February 2021

FREE Collapsible Outliner with Delphi Source Code

I've just uploaded the code of a fully-featured collapsible outliner which I originally developed for my own use but I’ve now decided to make publicly available. This lets you create lists or ‘trees’ of all kinds of structure information: contacts lists, TODO lists, project plans, plot outlines (for writers), a CD or MP3 database – whatever takes your fancy.

The project contains many thousands of lines of Object Pascal code for Delphi. To download the zip file, sign up to my mailing list and I’ll send you a link. In the meantime, here’s a short video overview:

If you need a quick way to learn Delphi, you can get a copy of my book, The Little Book Of Delphi, on Amazon:

Amazon US:

Amazon UK:

Monday, 7 December 2020

Learn to Program Java Adventure Games

I’m pleased to announce my latest book which explains how to write a retro-style text adventure in Java using object oriented techniques. I already have a book on programming adventure games in C#. The new Java book explains all the techniques described in that book so that you can parse user commands (e.g. “put the sword into the sack”), take and drop objects, move around a map, save and load games and so on. But it also goes much further, to explore more advanced techniques.

For example, it can use adjectives to distinguish between similar objects. Maybe there are three swords here. The user says “take sword”. The game may now reply “Do you mean the gold sword, the silver sword or the Elvish sword”? Or the player may write commands such as “Put the small gold ring into the big brown wooden box.” 

I also explain how to use recursion to ‘unwind’ networks of objects into linear lists. For example, if you have a sack containing three boxes and each box contains three treasures, you would need to navigate a network of objects to locate each treasure. You can either do that recursively each time the player wants to interact with the treasure or you can create a linear list of treasures so that your code can iterate through that list (for 1 to 10, say) instead of recursing down the network of objects.

And I’ve added a ‘mass’ property to objects. The mass is defined as a value that indicates how difficult that object would be to carry. It’s not really ‘mass’ as a physicist would understand it! So a huge but very light kite might have the same mass as a small but very heavy gold brick. Every time the player picks up an object, the ‘mass’ being carried increases until no more objects can be carried. And it’s no good cheating by putting massive objects into low-mass containers (say, a sack) and then carrying that container. Thanks to recursion, my code calculates the entire mass of containers and everything they contain!

The Little Java Book of Adventure Game Programming is available in paperback or Kindle format, from Amazon stores worldwide:

Buy from Amazon US:

Buy from Amazon UK:

You can sign up to the Bitwise Books mailing list and download all the source code free. I hope you have fun writing some games!

Monday, 5 October 2020

Learn C# Programming - FREE!

If you've subscribed to my YouTube channel you'll know that I have lots of lessons on programming C, Java, Delphi, Ruby and more. Over the past few months I've been posting a series of videos to help people get up to speed with C# programming. These lessons can be followed in order if you are new to C# or you can just jump in to watch whichever lesson is of interest. This is the latest video...

The complete course is called The Little Course Of C# and you can view all the lessons (more to be added later on) HERE.

To be notified whenever I add new lessons, be sure to subscribe to my YouTube channel.

Tuesday, 22 September 2020

Learn Recursion in Java

Recursive programming is surprisingly hard to learn for something that, in essence, is really quite simple. A recursive function is one that calls itself. So, you might have a function called x() which somewhere inside its code calls itself x() rather than some other function such as y()

Recursion is a very valuable technique when you want a function to do an operation a certain number of times until it’s run out of things to do. For example, if you want to count all the files in a set of subdirectories you can use recursion to keep looking for more subdirectories until there are no more subdirectories (or subdirectories of subdirectories) to recurse. Then you can count the files in each subdirectory. This sounds like it should be easy to do – and in essence it is. But unless you really understand how recursion works, it can be tricky. 

I teach a whole course on recursion and I also have a book. Either one will teach you all you need to know to understand recursion – what the stack is; how frames are added to and removed from the stack whenever a function is called; how to save values from recursive functions; how to return values; how to avoid infinite recursion and more…

My course normally costs $45 but if you click this link you can enroll for just $19 (plus any local taxes applicable):

(Valid until end of October)

Alternatively, you can buy my book, The Little Book Of Recursion, from Amazon:

Amazon (US)

Amazon (UK)

Or search for its ISBN: 978-1913132057

The code examples in the course and book are mainly given in C and Ruby. However, recursion works in a similar way in all mainstream languages. To prove this, I’ve translated most of the C code into Java. You can get all the free source code (C, Ruby and Java) just by signing up to my mailing list and I’ll send you the download link:

Meanwhile, here’s a short lesson explaining how to write just about the simplest possible recursive function in Java…

Tuesday, 8 September 2020

Can’t Upgrade Delphi RADStudio from Embarcadero

Why I used to love Delphi – but not so much now…

So I loaded up Delphi (Community Edition) this morning and I saw an unhelpful dialog box telling me that the software had expired and prompting me to enter a valid serial. I found my serial number, entered it, but it wasn’t accepted. What was I to do? The damned dialog box didn’t give me any other options.

Time to Google. Lots of other people had the same problem. Advice was to go to the Embarcadero site and download a new copy of the software: 

I did that. Or tried to. Every effort I made to log in failed with a warning that my session had expired. Maybe my browser (Chrome) was the problem? OK, so I tried in Firefox. Same error. In desperation, I tried the Microsoft Edge web browser. Amazingly, this time I managed to log in.

I now had to download the latest version of the software, uninstall my old version, install the new one, wait for a new serial number, enter that… anyway, eventually the installation went again successfully.

Look, I like Delphi. I’ve used its Object Pascal language ever since Delphi was first launched and before that I used its predecessor, Turbo Pascal, since the early 1980s. But, come on, chaps, this download-and-install palaver is nuts. You provide a free edition of Delphi (good) but you make it bomb out after a year and then you go to some lengths to make the reinstallation as painful as possible. It’s a positive incitement to use the open source Object Pascal alternative, Lazarus instead:

The history of the free edition of Delphi is an odd one. From the launch of Delphi 1, way back in 1995, I was the Delphi columnist for PC Plus Magazine in the UK. I wrote Delphi programming columns every month for over ten years and readers could follow along using the free copy of Delphi that its developers, Borland, supplied on the PC Plus cover disk. Whenever a new version of Delphi was released, we had a new free copy on the cover disk.

Then the Borland programming team split away to form a company called CodeGear and they were quickly bought up by another company called Embarcadero. Sadly, Embarcadero didn’t seem to understand the importance of providing a free edition. I asked for one so that I could teach a course on Delphi. And for the first time ever, my request was refused. So I based that course on Lazarus.

In the meantime, Microsoft had decided that it would be a jolly good idea to provide free copies of its IDE, Visual Studio, to anyone who wanted one. Visual Studio doesn’t support Pascal as standard but it does support C# – a very good language that was created by Anders Hejlsberg, the man who had previously been responsible for Delphi before Borland made the unfortunate error or losing him and other members of his team to Microsoft. 

Now let me be ruthlessly honest. Delphi/RADStudio is a fine programming environment. But it’s not as good as Visual Studio. Visual Studio is simply the best. Embarcadero must have noticed that the Delphi market was dwindling while C# was very much in the ascendant. Rather (too) late in the day they decided to release a free Community Edition of Delphi. OK, so better late than never.

But then they go and implement this incredibly infuriating expiry, download and update mechanism. This doesn’t stop you carrying on programming with Delphi after one year is up. All it does, is make you very annoyed with the software and the company for making the update process as inscrutable and infuriating as possible. I have no idea why they do that. It’s bad PR, it’s bad marketing, it’s just really bloody annoying.

OK, so I finally have Delphi reinstalled. But I now feel so ill disposed towards it that I think I’ll spend the rest of the day programming in Visual Studio!

Tuesday, 1 September 2020

Program Adventure Games with the BIFF Framework

As a passionate adventure game player and programmer, from the 1980s onwards, I’ve decided that the time has come to help other programmers embark on the noble quest of developing retro-style adventure games. I’ve already taught a course and written a book (available on Amazon US, Amazon UK and worldwide) on writing adventure games in C#. But if you’ve never written a game before you might still find it hard to implement all the features needed. Wouldn’t it be great if someone had already written a library of classes that encapsulated all the essential behaviour needed for a game – a parser to interpret text commands, Rooms to create a map, Treasures to create objects, actions to let the player look at objects, take, and drop them or put one object inside another one?

Welcome to BIFF!

BIFF is short for The Bitwise Interactive Fiction Framework. I’ve spent much of the last year writing this framework in Java and now I’m starting work on translating it into C#. The Java version of BIFF is currently more complete – it can handle reasonably complicated commands such as “Put the small golden egg into the big carved wooden box” or “Unlock the treasure chest with the magic brass key”. I will make BIFF for Java freely available later in the year.

Since many people have already read my C’# book or followed my course, I decided that, rather than wait until the C# release of BIFF has all the features in the Java version, I would release BIFF for C# in incremental stages so that existing readers and students can carry on developing their games using the new features. This necessarily means that the early releases will always be substantially incomplete. However, if you want to deepen your understanding of game programming, this is a great opportunity for you to try to modify the latest release by adding on additional features. You are free to modify BIFF as required as long as you leave my copyright notice in the comments of the source code.

To download the code of my C# adventure game book (whether or not you’ve actually bought it!) as well as the current release of BIFF for C#, juts sign up to my mailing list at Meanwhile, here is a short introduction to BIFF…