web developer & system programmer

coder . cl

ramblings and thoughts on programming...


implementing DSLs in haskell

published: 28-08-2012 / updated: 28-08-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

Haskell is a purely functional language with a strong-static typing system. That does not means that you cannot build a compiler using Haskell, and you have a wide variety of compiler constructions libraries and tools. The one that I use in many cases is Parsec. Parsec is a monadic combinator based parser generator that can be modified in runtime, and you do not compile its specification, because it is written directly in Haskell using its set of combinators, providing a very dynamic behavior and allowing a wide variety of possible implementations. Recently on the blog www.programando.org, was launched a challenge to construct a DSL parser for L-System specifications.

programming and learning curves

published: 09-08-2012 / updated: 09-08-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

If you have pretty clear programming concepts, learning new programming languages is not so hard as it seems. But those concepts are hard to understand. I will use my most recent learnt programming language, where probably you already know about what is it. Haskell is a programming language fulfilled with concepts, mostly based on mathematical abstractions inherited from Lambda Calculus, Combinatory Logic and Category Theory, among other topics that are covering its well known constructs, like Monads — which is inherited from Category Theory. You can understand how to work with Monads, like the IO Monad, StateMonad, and similar ones, but you need to understand the Monad basis from the perspective of the Category Theory to build your own Monads as abstractions. I am pretty sure that you can find theoretical basis on most programming abstractions, once you understand those theoretical basis, you are able to build well structured abstractions by yourself. Even if your knowledge on each topic is not so deep an abstraction variant, you can understand those concepts behind each construct and implement not so formal variants of each abstraction.

flow control data types

published: 04-07-2012 / updated: 04-07-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

Static typing and dynamic typing usually are offering null references as solution for the not an object problem. With strong-static typing systems, there are not null references, because there is nothing that can be treated as wild-card type, as Object() in Java and void * in C and C++ — everything have a type. So, there are some flow control structures allowing the programmer to handle the not an object problem using composite data types. Classical examples are the Maybe Monad and the Either Monad in Haskell. Both of them, allow you to control the behaviour of the program using a composite type to bind null reference requirements.

parallel haskell

published: 16-06-2012 / updated: 16-06-2012
posted in: development, haskell, programming, sysadmin
by Daniel Molina Wegener

Haskell as functional programming language has a different approach to parallelism, mainly speaking on terms of SMP parallelism — and probably extended to other types of parallelism as it is seen in some hackages like Cloud Haskell. Rather than focusing on processing, like standard libraries are doing like POSIX threads, Haskell is focused on evaluation, allowing the programmer to send expressions to be evaluated in different threads and joining them as it is done using pthread_cond_wait and pthread_join. This approach is very nice, because it is a very good abstraction for parallel computations, reducing the amount of code and leaving a clear idea at the first look which computations are being parallelized.

typing is not a problem

published: 10-06-2012 / updated: 12-06-2012
posted in: development, haskell, java, programming, python, rants, tips
by Daniel Molina Wegener

Typing is not a problem. We have many programming languages which are using dynamic typing. Dynamic typing is not so good as you can think. It allows you to do much stuff, where you can evaluate some expressions like (int)"1" + 1 = 2, without type errors. The problem with that kind of flexibility is the fact that there is no standard on boolean evaluations, leading to logic errors, and obviously to program failures. Even in some type-safe programming languages, they allow some stuff like that, there is C++98 and further versions allowing a wide variety of type casts, where any mistake on the casted values can generate logic errors and failures.

programando.org: challenge 2012-05

published: 27-05-2012 / updated: 28-05-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

The challenge of this month at programando.org, a programming blog written by Eduardo Díaz, is presenting a challenge related to statistics, mainly the calculation of the standard deviation and the variance. I usually place some programming challenge responses here in my blog. From now I will place the site in the post title and the challenge title, so you can track the results from and other competitors. Well, as usual, I am practising with Haskell, because I really want to reach very professional skills with it.

my software design principles

published: 05-05-2012 / updated: 06-05-2012
posted in: development, haskell, java, programming, projects, tips
by Daniel Molina Wegener

Most modern applications are providing APIs. That allows you to integrate those applications providing APIs with third party applications and create a real cloud computing environment. From an architectural perspective, we should have at least to have in mind the architectural pattern to be used, design patterns to be implemented, the protocol to use and the data format to expose the API. The architectural pattern should be simple, the design pattern efficient, the protocol lightweight and the data format flexible for your requirements. With a good API design, it should be stable enough to support changes along the time dynamically.