Obtaining BGGA Closure Parameter Types at Runtime
Recently Alex Miller has explored the use of BGGA closures for building dynamic visitors. Such visitor builders, and also Ricky Clarkson's closure-based pattern matcher, could be greatly simplified if...
View ArticleVerbosity of Non-closured Java Violates the Law of Demeter
It is well known that Java programs (at least of the non-closured kind) tend to be rather verbose. Some people actually even prefer this, since it may make program more readable. In this post, however,...
View ArticleWhy C++ Still Kicks Ass
Take this simple class for three-dimensional vectors with parametrized types:template<typename T>class vec3 {public: T x; T y; T z; vec3(T const& x_, T const& y_, T const&...
View ArticleInferential Duck Typing, or: Type Hierarchies Considered Harmful
Let's begin with some Java code:interface File { void open(); void close(); void delete();}interface Fridge { void open(); void close(); void addSticker(Sticker s);}class Util { //...
View ArticleReuse as a Refactoring Strategy
There has been a strange pattern reoccuring in a lot of my development efforts. Often, when I write a component X acting as a backend ("server"), and a component Y acting as a frontend ("client") to X,...
View ArticleStatic Checking is Defensive Programming
(But not vice versa.)void openFridge(Object object) {____if(!(object instanceof Fridge)) {________throw new IllegalArgumentException("!(object instanceof Fridge)");____} else {________((Fridge)...
View ArticleProbabilistic Modus Tollens
Here's the rule that justifies the classical modus tollens inference:[A => B] <=> [~B => ~A].An example: if all kings have crowns, then not having a crown means one is not a king.However,...
View ArticleArguing on Taste
A saying goes: "you can't argue with taste". This is neither true nor false: the saying is too ambiguous to warrant such classification.This is a classical case of equivocation—the confusion of...
View ArticleC++ Kana #1 — Usable Logging
Let's exercise RAII and streaming. Write function line() that allows you to writeline() <<"hello world "<< 5 <<"!";transforming tostd::cout <<"hello world 5!"<< std::endl;
View ArticleC++ Kana #2 — Dependency Injection
This time we'll exercise templates and the typeid keyword to build a Guice-inspired dependency injection framework. Write class Injector that allows you to writeclass IService {public: virtual...
View Article