armin's blog

Programming tech

Type parameterization is a useful concept, and it even found its way to Java and C#. I’ve found a nice technical comparison, a must read for C++ template aggrieved veterans who waited a long time to move over. And geeks surely will enjoy the implementation paper for C# :)

Idea: bring statically and dynamically typed languages together - and solve code duplication forever.

  • create a language that is syntactically based on JavaScript and intrinsically supports full type inference.
  • create a parser and analyzer for that language that supports the extraction of type signatures requirements or each function, function group or class. For example for a function c = a * b: a type signature requirement could be “a must be able to be multiplied with b”, or for a function c = a.customer: “a must support a member named ‘customer’”.
  • build a server that supports
    • uploading of such functions
    • the extraction of context documentation
    • the extraction of type signature requirements
    • efficient matching of type signature requirements
  • create an IDE oder IDE plugin that is able to extract type signature in locally created code and supports intellisense like operation by matching with type signature requirements of the server.
  • create a compiler for that language that creates – based on the matched type signatures – static code for a effective GC supporting language like C# or Java.

yours
armin

A program's first impression: A serious advice to installer developers

  • Don’t display every name of a the file that is copied or any other process description, nobody can grasp them and effectively nobody cares.
  • Don’t present percentage information or a bar reflecting the progress the installer makes, try to reflect the time it will take to finish the process. If you can’t, admit it, and present a simple progress indicator with no relation (anything that animates will do it) and show a message like “usually the installation takes around [put a number here] minutes to complete”, so that users can plan their time! A very rough estimation based on the installed processor / harddrive should be fine. Provide installation progress information only on request. A tooltip over the progress animation should satisfy the impatient.
  • Never interrupt the progress for non-fatal user interaction, present all the dialogs you need in advance, test if the folders can be created, and so on. If you can’t, redesign.
  • Don’t present “generating installer script” or other useless information as an excuse. Geeks know that if this is taking longer then a fraction of a second on modern computers without any drive access, you used an unscalable O(n ^ put your exponent here) algorithm somewhere.
  • Use one single progress indicator and time estimation. Don’t present one for each module or installation pass. A progress bar going full and back to zero makes your users nuts.

And finally: Accept that installation and uninstallation should be one single transaction and so they should be presented. Optimize for speed and simplicity, that is the first impression you should give to your users. Don’t be proud of all the code, graphics, presentations, animations and computations you’ve created to make it look good. Instead, be aware that an installer effectively steals the most valuable thing in the world, and that’s time.

yours
armin

Hoaxes and lies

Not believing in religion? Here is proof that everything is a hoax. For more details, the Zeitgeist movie will consume more of your life’s time. And though men are happiest with smart wives, they mostly lie when it matters to you most. And if you think that this was hard to accept, consider school and the career model are hoaxes, for sure.

If not beliefs, hope stays, now we know why we are nerds, so better learn more about the earth or statistics if you want to survive the atheists’ war. Or try to create something cool like the google’s scalability architecture.

For non sophisticated spare time wasting, have some fun with images or print all your code to survive the next EMP bomb, ignited by some religion x fanatic that hates another religion y fanatic, where x != y.

Have fun, don’t build your morality on beliefs, and try to unlearn all habits your parents thought were good for you.

yours
armin

The resurrection of "goto"

Accepting that the paper Go To Statement Considered Harmful may be outdated for modern programming languages and reading an Email conversation on Kernel Trap, you may consider putting goto back into your development toolbox.

If not done so already ;)

yours
armin

Got bored? Get some links!

Got bored? Here are some impressive software development links I’ve found on the net over the last few days:

Always a fan of Simon Peyton-Jones and his works, I found it very interesting what is going on right now at the edge of programming language design. In this video on channel9, Simon talks with Erik Meijer – the father of Linq – about merging concepts from Haskell and C#.

Not inspired, well then try to learn Haskell in 10 minutes.

Again, not pushed? You may try to exhibit some of your genius code here and forward it to someone.

More abstract, you should definitely read this article before debating type systems. And if you are new to design patterns, consider they might be crap and then be sure to classify yourself.

Though JavaFX is conceptually impressive, it is pretty slow, but this surely will not change the discoverability of the features in you future RIA.

yours
armin

Cells

Most of my spare time (yes, I have a job, too:), I spend working on framework components. A few weeks ago I started to create a nice – new kind of – application framework for Silverlight.

I have some clients who like the idea of remote editing and configuration, so I decided to bring some .NET to the browser. The framework is based on the Meta Mediator and Properties First pattern and already contains some UI components, automatic layout management, animation support at property granularity … the usual stuff you need to create for visual editing components.

Its core is based on a change notification mechanism that works by a per object subscription method to wire event handling.

Everything worked out, object observation is truly transparent and so layer separation (for example model / view) is possible without additional effort. But because dependencies introduced by change notification are hidden and “upper” layers refer to lower ones, most connections are effectively bidirectional from the perspective of the garbage collector.

And that introduces, well, memory leaks, and even more problematic, change notification paths that are triggered even when objects are not used anymore.

The problem of bidirectional dependencies in GC environments, especially in user interfaces, exists for a long time and has not been solved effectively (for what I know). There are “weak references”, which solve merely the memory leakage, but change propagation will continue to happen until the GC runs. No solution for an environment where the execution time for changes are crucial.

I scratched my head for a few days, but now, I think I found a solution:

The Meta Mediator - meta patterns in .NET

Using Reflections in .NET is – in particular – simple. You can always access meta data that is available in your execution assembly. And the more I get used to it, the more I use it for everyday problems. Last weekend for example I solved a problem that came up in a new framework I develop.

I wanted to decouple the dynamic creation of viewer instances for user interface model objects.
Imagine you create a button class (in pseudo-code):

class Button : Model
{
  bool event Activated;
  Shape BackgroundShape;
  Shape ActivationShape;
};

Soon you want to decouple the viewer logic from the button, so you create a separate class hierarchy with the abstract base class View:

class ButtonView : View
{
  ButtonView(Button button);
 
  override void onMouseDown();
  override void render();
}

An instance of this class is responsible for interfacing with the UI. It manages shape animation, mouse movement and raises – when the user clicks – the Button.Activated event.

Then, I imagined how I would like to create views without any knowledge about the Model.
Given a base class Model I wanted a method that creates the right View instance.

A naive attempt would be to declare a “createView()” method in the Model base class and override it in the derived ones. But this would imply that the model knows about its view, for which it really don’t cares.

Then an idea came up to use Reflection and tag the ButtonView’s constructor with an attribute. So the final code looked like:

class ButtonView : View
{
  [MediatesTo(typeof(View))]
  ButtonView(Button button);
 
  override void onMouseDown();
  override void render();
}

Using an extension method and a dictionary that maps the constructor’s first argument to the type that the MediatesTo attribute specifies, creating a view for any model finally resulted into:

Model button = new Button();
// 'button' could be any model for which a View exists.
View view = button.mediateTo<View>(button);

This meta pattern is capable to decouple interfacing layers that needed to be created in frameworks. It may be used for View separation or platform bindings.

Anything You Can Do, I Can Do Meta – Charles Simonyi

yours
armin

Properties First

Silverlight, a platform to bring serious development to the browser. That is what I am thinking about it. I jumped into it. A fresh start. Silverlight contains a simple but powerful rendering engine and a set of media components. What are missing are user interface widgets, automatic layout management and everything else that makes it useful for building applications.

When compared with WPF, Silverlight’s dependency property system seems to be very limited, even so that adding properties is not supported. Yes, it is in its early alpha stages, but because the property system does not use generics like it could be, I tried to build my own. I’ve put down all these puristic attempts and started with the obvious: a common base class named Part that stores the properties. For accessing them, I found a very neat syntax pattern, which I call “properties first”:

For example, to set a property:

var myPart = new Part();
Size[myPart] = new Size(100.0, 100.0);

to retrieve a property:

var size = Size[myPart];

Short, simple, and concise. You don’t need to build property wrappers and properties may be dynamically attached or bound to a specific base type. Of course this system supports change propagation and simple invalidation logic. Probably a base for more to come …

visions first!!

yours
armin

Libsmart online again

After going through a lot of trouble updating the database from Drupal 4.5.0 to Drupal 4.6 to Drupal 4.7 and finally to Drupal 5.1 and fixing lots of time consuming problems that have been caused by the update.php script which simply did not apply to my configuration, Libsmart our C++ System development library Martin and I created years ago, is now online again.

The issue tracking system works bit shaky and not everything is configured like it should be, and I need to upload the Doxygen documentation as soon as possible. I am also thinking to release a GPL version to the public, though most functionality has been superseded by the Boost libraries now. Even my Elist container found a probably much more sophisticated replacement by the Boost Intrusive Containers … Well, Boost is like its name, BIIIG, so may be you give Elists a try, too.

For me the time of C++ for application development is gone and so moving forward, I found a very impressive article about the internals of the .NET JIT compiler which effectively even more motivates me to ignore all the performance paranoia that occurs when moving away from the controlled environment we experienced in C++.

And going one step further, read about what Richard Hamming had to say about You and your Research. Though the text is very long, it is an inspiring read for visionaries, but you may check his entry at Wikipedia first.

One last thing, if you are interested in source code management, this Google screen cast The Flow of Change by Laura Wingerd definitely gives you a basic understanding about branching and merging terminology and policies.

yours
armin

Syndicate content