background preloader

The Principles of Good Programming

The Principles of Good Programming
Heron-Centric: Ruminations of a Language DesignerThe Principles of Good Programmingby Christopher DigginsJuly 24, 2011 Today's post is a lightly edited repost from my blog at The Area, a web-site dedicated to users of Autodesk media and entertainment products. I came up with this list of principles to help with a recent C# training I gave, and I thought that members of the community could appreciate these principles and have some interesting insights to share. The principles of good programming are closely related to principles of good design and engineering. DRY - Don’t repeat yourself - This is probably the single most fundamental tenet in programming is to avoid repetition. KISS (Keep it simple, stupid!) Avoid Creating a YAGNI (You aren’t going to need it) - You should try not to add functionality until you need it. Avoid Premature Optimization - Don’t even think about optimization unless your code is working, but slower than you want.

Contrasting Performance : Languages, styles and VMs – Java, Scala, Python, Erlang, Clojure, Ruby, Groovy, Javascript There’s a better place to specifically look at performance comparisons across languages than this post – The computer languages benchmarks game. But this post attempts look at performance comparisons a little differently. Based on coding idioms as well. And for a much narrower range of problems (namely one). There are languages which are tightly opinionated on a particular way of doing things. And there are languages which allow you to implement a given logic in multiple ways. This is also a sequel to a post I wrote 3 years ago Performance Comparison – C++ / Java / Python / Ruby/ Jython / JRuby / Groovy. Problem Quoting from The Josephus Problem, Flavius Josephus was a roman historian of Jewish origin. In the general version of the problem, there are n soldiers numbered from 1 to n and each k-th soldier will be eliminated. Idioms I have considered three idioms : Object Oriented : This code has classes reflecting a person (or a soldier) and the chain. Contributions Hardware / Software Updates

Sphere Online Judge (SPOJ) Harold’s Corollary to Knuth’s Law Lately I’ve found myself arguing about the proper design of unit tests. On my side I’m claiming: Unit tests should only touch the public API. The goal is to make sure that the tests are as close to actual usage as possible. By contrast some programmers advocate that tests should be method-limited. This approach may sometimes let the tests be written faster; but not always. Would you believe performance? For instance consider this proposal from Michael Feathers: A test is not a unit test if:It talks to the databaseIt communicates across the networkIt touches the file systemIt can’t run at the same time as any of your other unit testsYou have to do special things to your environment (such as editing config files) to run it.Tests that do these things aren’t bad. More than 30 years ago Donald Knuth first published what would come to be called Knuth’s law: “premature optimization is the root of all evil in programming.”

Video Lectures | Introduction to Computer Science and Programming MemoryImage database · application architecture tags: When people start an enterprise application, one of the earliest questions is "how do we talk to the database". These days they may ask a slightly different question "what kind of database should we use - relational or one of these NOSQL databases?". But there's another question to consider: "should we use a database at all?" One of the defining characteristics of enterprise applications is the need to store long term data, which naturally leads people to reach for a database. The key element to a memory image is using event sourcing, which essentially means that every change to the application's state is captured in an event which is logged into a persistent store. A familiar example of a system that uses event sourcing is a version control system. Event sourcing has many consequences, including the ability to rebuild past states. Against that you do have to ensure you can reliably store the events and process them. The most recent is LMAX.

Easing into SICP "The Structure and Interpretation of Computer Programs" by Abelson and Sussman ( is often recommended reading on HN and elsewhere. However, you may find it to be much denser than the breezy computer books that are typically published. To help you acclimate to the concepts in SICP, I recommend the following steps: First, read "Concrete Abstractions" by Max Heilparin ( and "Simply Scheme" by Brian Harvey ( Next, listen to or watch Brian Harvey's lectures for "The Structure and Interpretation of Computer Programs" ( Third, watch the lectures by Holly Yanko ( Finally, watch the videos of Abelson and Sussman (

MongoDB for a large queuing system | kill the radio Our queuing system is different from others in that it supports dependencies. For instance, before one job completes, its four children have to complete first. This allows us to create jobs that are actually trees of items all processing in parallel. On a small scale, things went fairly well. We built the entire system out, and tested and built onto it over the period of a few months. Then came time for production testing. Without a doubt, MongoDB was the biggest bottleneck. This was pretty disappointing. So there’s my advice: don’t use MongoDB for evenly-distributed high-write applications. On a more positive note, for everything BUT the queuing system (which we did get working GREAT after throwing enough servers at it, by the way) MongoDB has worked flawlessly. TL,DR; MongoDB is awesome.

ArsDigita University Curriculum About the Curriculum The curriculum was modeled on the undergraduate CS program at MIT. Several of the courses were straightforward adoptions of MIT courses. A few were specifically designed for the program, which was roughly in line with the ACM's 2001 Model Curricula for Computing. Courses Math for Computer Science - Tara Holm Structure and Interpretation of Computer Programs - Holly Yanco Discrete Math - Shai Simonson How Computers Work - Gill Pratt Object-oriented Program Design - David Goddeau Algorithms - Shai Simonson Systems - Luis Rodriguez Web Applications - Philip Greenspun Theory of Computation - Shai Simonson Artificial Intelligence - Patrick Winston Unix Workshop Database Management Systems - Ravi Jasuja Applied Probability - Tina Kapur Course of study The course of study at ArsDigita University was sequential, with most courses lasting one month, and was comprised exclusively of computer science and related mathematics.

Regular Expressions in Programming Environment Regular expressions are a way of describing patterns of text that can be useful for processing text documents or when looking for a pattern and possibly replacing it with another. Regular expressions are a very powerful tool indeed, and the best thing is that they go beyond just one programming language or tool. You’ll find Regex enabled applications everywhere. File renaming tools might use Regex to allow complex renaming operations; most IDEs support it, search tools as well. Once you master regular expressions, you’ll find tons of applications. What we are covering here are some of the basic principles of regular expressions. What are Regular Expressions? Regular Expressions are a way of defining a pattern to be replaces or processed in a body of text. Imagine you have a rather long document with a single repetitive misspelling say a name Mr. have been changed to – What one can do? The Basics Matching Repetitions Group

Relating Category Theory to Programming Language Theory The most immediately obvious relation to category theory is that we have a category consisting of types as objects and functions as arrows. We have identity functions and can compose functions with the usual axioms holding (with various caveats). That's just the starting point. One place where it starts getting deeper is when you consider polymorphic functions. Category theory also meshes nicely with the notion of an 'interface' in programming. There is also a beautiful relationship between pure typed lambda calculus and cartesian closed categories. Another example is the way structurally recursing over recursive datatypes can be nicely described in terms of initial objects in categories of F-algebras. And one last example: dualising (in the categorical sense) definitions turns out to be very useful in the programming languages world.

Livre blanc : Maîtrisez votre dette technique Le 4 Juin 1996, à 9h35 le vol 501 de la fusée Ariane 5 effectue son premier décollage. Quelques secondes plus tard, le système de guidage inertiel reçoit trop d’informations et se met hors service, car reconnu défaillant. L’ordinateur de bord est alors notifié qu’un dysfonctionnement est en cours et compromet les informations concernant la trajectoire de la fusée. Cette modification de la trajectoire entraîne l’arrachage d’un moteur d’appoint, déclenchant l’auto destruction de la fusée. Au-delà du caractère spectaculaire de cet exemple, il est intéressant de noter que l’origine du dysfonctionnement réside dans un module développé pour une version antérieure de la fusée et devenu obsolète. A travers ce document, nous découvrirons en quoi la dette technique ralentit la productivité des équipes et nuit aux projets. Télécharger le Livre blanc « Maîtrisez votre dette technique ».