본문 바로가기

problem solving/Project Euler in Haskell

Haskell - The 1st Note

As I worked as a programmer, I've written a lot and been reading many programs written by other authors. Sometimes I found that I enjoys doing this job - understanding, realizing, creating and solving problems. And when I works with other people as a team to solve, figure out, or whatever, I fill like we are talking each other via our code. Code delivers author's idea, considerations, perspectives, and even their personalities and more. That is great experience especially if I worked with a person from whom I could learn a lot. Some people inspires me with their work it shows me how elegantly problems could be solved, how they organize code blocks so that readers could understand their ideas.

But sometimes I found that I struggling to understand what code means. I hate codes that have too many variables involved in the same function effecting each other and some of them reaches their scope globally, that strongly ties whole world into one block. Imperative programming is like state machines. and that kind of program - functions or objects are tied via global variables - is like state machine with transition edges from one state to another state in the very opposite side of the world. The whole picture of it is like a intricate web that makes me fill trapped in a maze that I could not escape from forever. Bigger program tends to have larger number of states accompanying more complicated transitions. That make it too difficult to maintain.

This is why I getting interested in stateless programming. I've been trying to write programs consist as minimum states as possible. but because of tools (languages or programming paradigm), sometimes it's inevitable that I write complicated structure of code. Now I think that it is very hard to write stateless program in imperative programming languages. Stateful is nature of imperative programming. 

So I'd rather like to find another approach from much fundamental level. There are two main streams in programming model, one is imperative programming and another is functional programming. I've always written programs with former one. But from now I will chose later one when it is appropriate. For this I need to be familiar with one of functional programming languages. My choice is Haskell. I'll learn Haskell by solving problems from ProjectEuler to get familiar with it as I did for Python before. And then carry out a project if I have a time.