« Back to home

Reflection in Go and modifying struct values

Recently I found myself wanting to write some code to load values into a Go object. The obvious approach is reflection. However, the Go documentation on reflection is somewhat impenetrable, and the accompanying article on The Laws of Reflection only has a single skimpy example involving structs right at the end. After some trial and error I came up with some robust code to demonstrate examining a struct and altering its fields.…

Read more »

Go: Preliminary verdict

So, how do I feel about Go, now that I know it better? The good On the whole, I like it. Some high points: It’s reasonably terse, and there’s not much syntax to remember. Like Ruby, you can do a lot in not much code, and unlike (say) Java there isn’t really a big need for an IDE. It inherits from Modula-2 a focus on compile-time efficiency. No header files, a compact grammar, and rigid dependency declaration make for rapid compilation times.…

Read more »

Review: "The Go Programming Language"

“The Go Programming Language” by Alan A.A. Donovan & Brian W. Kernighan Addison-Wesley Like many other programmers, I learned to write C by reading “The C Programming Language” by Kernighan and Ritchie, the book known to hackers everywhere as “K&R”. I confess that I was initially drawn to “The Go Programming Language” out of sheer Kernighan brand awareness. Would it be the K&R of the Go world? I certainly hoped so, as I have strong preferences when it comes to programming language textbooks.…

Read more »

My first Rust disappointment

Rust is an up-and-coming new programming language which offers compile time safety, automatic memory management, and C-like performance. It also offers automatic resource management. In Java terms, it takes AutoCloseable, formalizes it more, and makes it ubiquitous throughout the language. When a resource is accessed, it is given a scope of applicability; when the scope ends, the resource is automatically closed. This eliminates problems like unclosed file and database handles.…

Read more »

Chronological pitfalls

Since the US just changed time zone, and the EU will be changing time zone soon, it seems like a good time to refresh an old posting of mine about dates and times, and how hard it can be to do the right things with them in software. I’ve spent a lot of my career in the computer industry working on computer-based calendar systems and organizers of various kinds. Here are a few pitfalls to be aware of.…

Read more »

Java annoyance: final parameters

First, the summary:

Q: What does it mean when a method I’m calling declares that its parameters are final?

A: To you, nothing. It’s a safety feature for the author of the method.

Q: OK, so when should I declare method parameters as final?

A: Absolutely always.

Q: Isn’t that just annoying busywork?

A: Pretty much so, yes. You must be new to Java.

And now, the lengthy discussion.

Read more »

Java: not all that bad these days

It took Sun a long time to get there, but as of Java 5 I began to quite like Java. Proper collection classes with generics were added, with a non-painful syntax for iterating over collections. No more for (Iterator it = container.iterator (); it.hasNext (); ) { … }, you can just do (say) for (String x : container) { … } and get proper type safety into the bargain.…

Read more »

JavaScript: The Good Parts

I remember back in the 1980s paying something like £40 for a copy of Kernighan and Ritchie’s original book on “The C Programming Language”. An outrageous amount for a book which was a little over 200 pages, I thought. However, during the 1990s, something happened to books about computer programming. Like the fast food junkies of our nations, they started to get bigger and bigger, with the essential meat surrounded by more and more extraneous fat.…

Read more »