Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Christopher Diggins

Dr. Dobb's Bloggers

Modules, Dependency Injection, and Newspeak

December 21, 2009

I'm about to put the finishing touches on the Heron design for its big 1.0 release, by putting in the module system. I left this for last thinking that it would be trivial. Boy was I wrong!

I was going to slap a module system on Heron that looked like Python and be done with it (see this StackOverflow question I asked ). However, through sheer luck I read this blog post by Gilad Bracha and he convinced me I was about to make a big mistake. The problem was, and in part still is, I didn't exactly understand what alternatives I had! 

Gilad Bracha's new language is called Newspeak and is heavily inspired by Smalltalk. It is hard for me to follow everything that he proposes because I don't really speak Smalltalk, but he does make an effort to dumb things down a bit in the Newspeak language specification

The blog post at first sounded like hand-waving to me, but Gilad Bracha is someone worth listening to when it comes to language design. To add to this his ideas receive support from someone else I respect, Phil Wadler.

Philip makes the connection between the Newspeak module system and dependency injection. In addition some people on the Lambda-the-Ultimate.org blog have helped me understand this point further here.  

The lesson I have learned so far is that a poorly implemented module system has many downsides, and that it is possible to have a module system which makes it easier to refactor, mock, and enforce security, via explicit dependency injection.

Some useful links I have been using for digging into the subject further:

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.