tag:blogger.com,1999:blog-331038542024-03-07T20:07:37.203+01:00Karsten Wagner's BlogKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-33103854.post-89297136005185243052008-08-02T03:52:00.004+02:002008-08-02T04:13:15.110+02:00The most misunderstood book in CSAfter reading yet another blog post which got it totally wrong, I decided to write a bit about design patterns. In my opinion, the 'GOF' book 'Design Patterns' is probably the most misunderstood book in computer science.The main misunderstandings are:The authors of the book thought they invented the patternsThe book says that you have to use the patterns from the book to write good software.The Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com16tag:blogger.com,1999:blog-33103854.post-71255765233775250692008-05-07T16:33:00.002+02:002008-05-07T17:22:24.145+02:00What makes programming so difficult - and can we make it easier?I often thought about the reasons why programming seems to be so difficult and also so different to many other professions. And to what degree it's possible to simplify and quicken the process. Inspired by this blog post, I want to share my view of the topic here.What's the 'process' behind programming? How do we do it? I think that we can break down the process of programming info three steps:Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com7tag:blogger.com,1999:blog-33103854.post-22428622248832316932008-03-12T20:25:00.002+01:002008-03-12T20:48:17.510+01:00Is 'power' really what we want most from a programming language?Power seems to be a nice thing to have. But what does it really mean? Think of the president of the USA: He's considered quite powerful because (in principle) he is the one who can 'press the button'. But with all his power to destroy, he still can't create peace in the middle-east. That's because power isn't the same as productivity. Power enables one to exert force - but often this simply isn'tKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com2tag:blogger.com,1999:blog-33103854.post-38679255282432058032008-03-10T14:31:00.002+01:002008-03-10T16:05:56.940+01:00Static vs 'dynamic typing', part 2: The personality-factor.After talking about some of the basic nomenclature I will look now into the pros & cons of static typing. But instead of going into pure technical details I want to look at it from a less common angle. What if it's not really a technical but more of a psychological matter?Let's start by looking at my personal experience: I've used languages without static typing often enough to know that theyKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com17tag:blogger.com,1999:blog-33103854.post-31498373178698495712008-02-26T02:26:00.004+01:002008-02-26T04:13:37.563+01:00Static vs "dynamic typing" (part 1)Yes, I admit, it's an old, often reiterated discussion - but nonetheless it's still a quite frequent topic. So I decided to write a bit about it - in fact it's not only a bit so I've split it into multiple parts. In this first part, I want to talk about some of the basics, in the next one or two I will discuss the various pros and cons.Lets start by talking a bit about nomenclature.First: The Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com1tag:blogger.com,1999:blog-33103854.post-86633524465515547862007-08-17T20:27:00.000+02:002007-08-18T10:36:53.558+02:00Better exception handlingException handling seems to be a solved problem. Just use some kind of try/case/finally constructs and we're done. Are we? Exception handling creates several flaws and severe holes in the static checking of a program. While lots of people are researching type systems, exceptions open an ugly hole in the back of most of those systems. But if you try to do it right and type-check exceptions (like Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com11tag:blogger.com,1999:blog-33103854.post-23703563846003157712007-03-07T03:23:00.000+01:002007-03-07T04:14:24.258+01:00Discussion: Why do most people seem to use inferior programming-languages?My last article created a relativly high number of comments, which I will try to discuss in this post.The article was intended as my 'answer' to the topic which is very common in all places where discussions about programming languages takes place: Why do certain ones succeed and others not. I think this is an important question because most people who create new languages want to have some kind Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com14tag:blogger.com,1999:blog-33103854.post-3774735146935308592007-03-05T22:12:00.000+01:002007-03-07T07:02:31.843+01:00Why do most people seem to use inferior programming-languages?If you read discussions about programming languages, one topic is quite common: "Why do people use an inferior language like Java/C++/what-the-hell and not a superior language like Lisp/Haskell/Python/you-name-it"?The reason is: The language is only a small piece a the big scheme. Todays languages aren't that different at all, productivity wise. While some things have a certain impact (having a Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com26tag:blogger.com,1999:blog-33103854.post-8253128493226349082007-02-16T18:20:00.000+01:002007-02-16T23:22:39.197+01:00Understanding Monads. For real.Again an article about the "what are monads?" topic? Aren't there enough on the net already? Maybe. But since I've read a lot of them and still had problems to really 'grok' the concept, I suspect that other may have those problems too.I'm not a mathematician. I've studied physics and while I learned a lot mathematics in the process it's a totally different way of learning mathematics than Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com10tag:blogger.com,1999:blog-33103854.post-87006630487969232872007-02-02T01:27:00.000+01:002007-02-02T02:19:10.281+01:00Why monads are 'evil'This is an heavily updated version of a previous article with a somehow similar name. From the comments to this article I learned where the original article was misleading and partly even wrong. So I try to correct that with this updated version.What is functional programming? Many people tend to think that having closures in a language makes that language a functional one. But by this definitionKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com28tag:blogger.com,1999:blog-33103854.post-68548721412907854312007-01-30T14:25:00.000+01:002007-02-02T02:16:14.430+01:00Real functional programming or "Why the IO-monad is evil"Edit: This article contains some errors and wasn't able to transport my intention correctly. So I've created a new version of this article which hopefully contains less errors and is better to read.What is functional programming? Many people tend to think that having closures in a language makes that language a functional one. But by this definition almost every modern language would qualify as 'Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com12tag:blogger.com,1999:blog-33103854.post-21795838444700363612007-01-06T19:34:00.000+01:002007-01-06T19:40:15.391+01:00What makes a programming language 'more productive'First: What does 'productive' mean? I would loosely define it in the context of programming as "Given two equally skilled programmers or teams of programmers, the less time they need to create and maintain a program for a given problem, the more productive is the implementation language".This definition may have some holes in it, but I first want to make clear, that productivity for me is not an Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com11tag:blogger.com,1999:blog-33103854.post-66673953227435307312006-12-30T16:09:00.000+01:002006-12-30T16:39:37.110+01:00The problem of dealing with data-structuresIt seems to be a 'solved problem': How to represent and use different kinds of data in programming languages. But in fact there's lot of unnecessary complexity and lots of artificial difficulties if you really think about it.Lets just look at an example (It would look similar if I use the Hindley-Milner type system but it's just about the basic principles not about a certain implementation. I Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com11tag:blogger.com,1999:blog-33103854.post-80816515871538159602006-12-27T13:02:00.000+01:002006-12-27T15:42:04.078+01:00My Haskell experiencesI've known Haskell for some time now. The first time I've used it, it was with a system named Gofer after I read a book about the implementation of a compiler for the Miranda language (there were no Miranda system available at this time because it was a commercial system). Gofer was quite complex for the time and also quite useless for practical application (especial considering the performance Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com16tag:blogger.com,1999:blog-33103854.post-86644534992834372042006-11-28T17:07:00.000+01:002006-11-28T20:11:51.277+01:00References violate the principle of encapsulationEvery language with allow the use of direct references to objects also makes encapsulation and thus code-reuse much more unlikely. And because every OOP-language has those references thats the reason why encapsulation in OOP doesn't work the way it's advertised by its promoters.Let's elaborate on this: Any reference is a direct connection to a certain object. That's quite convenient: If we have aKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com2tag:blogger.com,1999:blog-33103854.post-67463394139737515712006-11-26T18:03:00.000+01:002006-11-27T00:38:33.468+01:00Why pointers and references are a bad thingReferences and pointers are quite common in the world of programming languages. References are something like the address of some data on the heap. Pointers are quite like references, but with additional operations of changing the address (by incrementing or decrementing it or even by arbitrarily creating it from some integer value). So a reference is a limited kind of pointer: One with a fixed Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com5tag:blogger.com,1999:blog-33103854.post-1164026124651752362006-11-20T13:28:00.000+01:002006-11-20T17:45:29.531+01:00Rich languages vs. minimal languagesA common pattern in the design of programming languages seems to be to designing languages as 'slim' as possible. The idea is to create as few abstractions as possible directly in the language and then to implement all the useful things the programmer needs in the libraries. While there are obviously some differences in how strict this design pattern is applied, I think that it has to be Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com6tag:blogger.com,1999:blog-33103854.post-1158161051982920142006-09-13T17:18:00.000+02:002006-09-13T17:33:22.273+02:00Disadvantages of user-extensible languagesA lot of languages are going the way of giving as much user extensibility as possible. Lisp is the obvious forerunner: With it's flexible macro facility, it's possible to create nearly every imaginable extension to the language. Look for example at the loop facility in CommonLisp: It's a 'language inside a language' (sometimes called 'DSL' - domain specific language). In Lisp the 'price' for thisKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com3tag:blogger.com,1999:blog-33103854.post-1156518257434483592006-08-25T16:50:00.000+02:002006-08-25T17:04:18.310+02:00OOP is dead (part 3)Before I take an in depth look at another severe problem with object-oriented-programming I want to talk about why I believe that OOP its really dead. Hey, Java is alive and kicking, C# (.NET/mono) also and still there's lot's of C++ programming. So how could OOP be dead then? Sure, I used exaggeration to make my point more obvious. But there is more: Have you looked at the actual development in Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com3tag:blogger.com,1999:blog-33103854.post-1156342644388763202006-08-23T16:11:00.000+02:002006-08-27T13:48:56.703+02:00Java enhancements I would like to seeAfter some critique of the new closure proposal (because of it's redundancy) I want to talk about some Java extensions I would like to see. Those extensions complement Java in useful ways to make some often used idioms a bit more easy to use without promoting a totally different programming style.Counter for the for-each-loop:I often write something like this:int i = 0;for(Something s: data) { Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com1tag:blogger.com,1999:blog-33103854.post-1156293517305688972006-08-23T02:34:00.000+02:002006-09-04T00:48:51.426+02:00OOP is dead (part 2)A second and even more severe reason why OOP has reached it's peak and more and more people are looking for alternatives is mutable state (I'll write only 'state' from now on). Most programmers don't even think much about state, they simply take it as common part of programming, but in fact it's the source of most bugs and difficulties in programming. So what's 'state'? It's the current value of Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com23tag:blogger.com,1999:blog-33103854.post-1156252138881390322006-08-22T15:07:00.000+02:002006-08-22T15:10:02.086+02:00Some more remarks on closures in Java (part 2)One feature they proposed are non-local returns. This feature is well known from Smalltalk and allows a closure to change the control-flow of the enclosing method. In Smalltalk there was a good reason for this feature: Smalltalk had no control-constructs like if-then, for, while etc. For example let's look at 'if-then' in Smalltalk. It's implemented as a method of the true and false classes. I'veKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com0tag:blogger.com,1999:blog-33103854.post-1156248615572886752006-08-22T14:07:00.000+02:002006-08-22T14:15:28.303+02:00Some more remarks on closures in JavaFirst: They already exists. Inner classes ARE closures. Really. I can't say that often enough, but everybody who don't recognize anonymous-inner-classes as closures simply hasn't understood the concept of either anonymous-inner-classes or closures.But inner classes have an additional feature: Multiple entry-points.Lets have a little, somewhat silly example (I use the proposed closure-syntax):voidKarsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com4tag:blogger.com,1999:blog-33103854.post-1156168625434441932006-08-21T15:57:00.000+02:002006-08-21T16:58:56.153+02:00Closures for JavaRecently there was a proposal to add closures to Java. While this sounds like a good idea to many people who are used to have closures in their favorite language, it's in fact really useless, because Java already has closures for some time now.In Java closures are called anonymous inner classes. Those are in fact full featured closures, because they really capture the environment of the method Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com1tag:blogger.com,1999:blog-33103854.post-1156181427729361982006-08-19T17:26:00.000+02:002006-09-04T00:49:58.136+02:00OOP is deadSure, that sounds dramatic, but I really think that OOP reached it's peak and is on the decline. In the last time we saw increasing interest in functional programming languages and concepts from functional programming (like closures, continuations etc). Many people want to see those concepts available in well known OOP-languages like Java, C#, C++ etc. And the language designers reacts and are Karsten Wagnerhttp://www.blogger.com/profile/09652404623625038743noreply@blogger.com16