Rails in the Large: How Agility Allows Us to Build One Of the World's Biggest Rails Apps
Neal Ford shows what ThoughtWorks learned from scaling Rails development: infrastructure, testing, messaging, optimization, performance.
Tracking change and innovation in the enterprise software development community
Posted by Sadek Drobi on Apr 11, 2008
Echoing at a discussion on dynamic vs. static languages, Debasish Ghosh raises the issue of using dynamic type-checking while programming with static languages. He recalls the common generalization of Greenspun's 10th Law: "any sufficiently complicated program in a statically-typechecked language contains an ad-hoc, informally-specified bug-ridden slow implementation of a dynamically-checked language."
Ghosh believes that this is not necessarily so today. He argues that Java generics, e.g. Guice and EasyMock, allow avoiding workarounds necessary to enforce runtime type checking:
Using Java generics, these frameworks allow compile time type checking for cases which would earlier have to be implemented using a slow and bug ridden simulation of runtime type checking. Guice and EasyMock stand out as two frameworks I have been using that have used the power of generics to implement extraordinary typesafety. […]
Have a look at this piece of code, which binds an implementation
SpecialServiceImplto the interfaceServiceusing GuiceBinder.public class MyModule implements Module {
public void configure(Binder binder) {
binder.bind(Service.class)
.to(SpecialServiceImpl.class)
.in(Scopes.SINGLETON);
}
}”
Even though “it may seem that the "implements" relationship between Service and SpecialServiceImpl is done during runtime”, all type checking is actually done during compile time:
A peek at the source code of Guice reveals that
BinderImpl.bind()returnsBindingBuilderImpl..public
BindingBuilderImpl bind(Class clazz) {
return bind(Key.get(clazz));
}and
BindingBuilderImpltakes as input.to() Class- the bound on the wild card enforces the above "implements" relationship as part of compile time type checking of the arguments ..public ScopedBindingBuilder to(Classextends T> implementation) {
return to(TypeLiteral.get(implementation));
}
Debasish Ghosh advocates for using this kind of solutions rather than trying to achieve dynamic type checking. Not only does it allow avoiding the Greenspun's10th Law but it optimizes the advantages of static typing because it guarantees strong type-safety:
When you are programming in a statically typed language, use appropriate language features to make most of your type checking at compile time. This way, before you hit the run button, you can be assured that your code is well-formed within the bounds of the type system. And you have the power of easier refactoring and cleaner evolution of your codebase.
Technical Debt and Design Death
Learning to be a Good Product Owner: Foundation Skills
The 5 Mandates of Software Development Teams - Presto Manifesto
Unix, Linux Uptime & Reliability Increase While Patch Management Woes Plague Windows (Yankee Group)
Neal Ford shows what ThoughtWorks learned from scaling Rails development: infrastructure, testing, messaging, optimization, performance.
Stuart Halloway discusses Clojure and functional programing on the JVM in depth, and touches on the uses of a number of other modern JVM languages including JRuby, Groovy, Scala and Haskell.
Orion Henry and Blake Mizerany talk about the technology behind Heroku and the benefits of the new add-on system.
Chris Riley presents security issues threatening service based systems, examining security threats, presenting measures to reduce the risks, and mentioning available security frameworks.
This talk investigates technical issues encountered when moving to an Agile process.
Don Box and Amanda Laucher present “M”, a declarative language for building data models, domain models or external DSLs. Don Box's demos show some of M’s features and latest changes of the language.
It is four months since the SOA manifesto was announced; InfoQ interviewed the original author’s to get insight into the motivations and the process behind the initiative.
This article explains the impact memory barriers, or fences, have on the determinism of multi-threaded programs.
No comments
Watch Thread Reply