On Tooling and Static Typing
Eugen Kiss
473

I agree with the overall sentiment, but it’s not actually about static typing — it’s about having a language that has first class types, whether dynamic or static, having a codebase that really utilises them, and then supplementing it with robust type OR behavioural annotations supported by tooling. Static typing is simply one way to enforce some of this behaviour.

However, static typing alone does not always solve tooling navigability. Your example can be applied in a statically typed language and provide zero useful guidance to the user:

function createS3Client(config:Map<String,String>) : Object {
// Docs can't tell us that config contains a certain key...
// Callers have no idea what type of Object is returned
}

To gain usefulness, you have to use some sort of rich type system in your code. All of the following hypothetical examples could give all the tooling support you mention:

fn createS3Client(config:SpecificToS3Config) : S3Client {...}
fn createS3Client(config:IProvidesS3Config) : S3Client {...}
fn createS3Client(config:Map<String,String>{accountKey:String}) : S3Client {
// Hypothetical language allows specifying
// keys that should be present
}
/** @param config {accountKey:String} **/
fn createS3Client(config:Map<String,String>) : S3Client {
// doc block can be inspected by tooling for extra detail
}

As a corollary, here’s an example in a dynamic language (PHP, in this case), that has both tooling support right now, and ticks the boxes (inline docs, navigability, refactorability):

/**
* @var $config IProvidesS3Config
*/
function createS3Client($config) {
// Zend, PHPStorm, PDT will all autocomplete on $config->
// and allow 'find declaration' for the ISuppliesS3Config
// interface using the doc block comment,
// and this method will be found with find usages
}

So, static typing isn’t the key thing here. Using types, or interfaces, in your codebase that can provide specific point-in-time usefulness to developers is the first step, and having either an annotation system (as per doc blocks), or static typing within the language syntax itself, is.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.