Haskell, C, Project Euler and Words
This is a quick test to try to understand how long it takes to write 800 words.
I’m trying to understand that because Steve Yegge posited 800 words as his preferred normal word count, and I’d like to know whether that is a reasonable count for me to try to get to also. Mostly I’m trying to figure out what it would take for me to post more regularly on a blog. I know that there is a difference between quality and quantity, and I’m a little afraid that if I’m optimizing for speed, I may well not have much worth saying.
However, I think it’s possible that the regularity of posting would mean that there is a greater likelihood of me being disciplined enough that whenever I have good stuff it would get posted rather than the current circumstance where it is easy for stuff to never actually make it onto the site.
The things I would like to focus on are programming and Christian life.
I don’t know that those actually go together, but those are the things that interest me most, so that’s what I imagine I will tend to talk about.
I am also getting a little bit back into Math as I’ve been working on the problems from Project Euler. It’s nice to be doing them in Haskell since it’s support form mathematical notation (especially for sequences) makes it a lot easier for me to conceptualize when I’m working through problems. It makes me want to re-read my Abstract Algebra book and go through the Discrete Mathematics book that I’ve been meaning to read.
It might be nice someday to end up in a position where those kinds of problems are ones that I work on regularly. I daydream of going back to college sometimes and these kinds of problems have made me consider whether it would make sense to explore a degree in something like Decision Science or some kind of statistical modeling field. I think Haskell would be suited to that kind of work also, as long as it could be modeled discretely and not as a continuous curve.
This is very different from my other current projects of trying to develop mobile web apps. That’s a completely different kind of programming. Arguably more practical, more results oriented.
I’m not sure which I prefer. I like the mental challenge of the kinds of problems Project Euler represents, but I don’t know of any practical applications of that kind of programming, except perhaps for cryptography, but to get into those kinds of real problems, would take a lot more research than I am willing to commit to right now.
So far I’ve been able to do the various Project Euler problems I’ve tried in both Haskell and C. In all cases so far, I have solved the problem first in Haskell and then created a solution in C based on the understanding I gained from doing it in Haskell. Typically my solutions in C are not direct translations from Haskell since the languages are so different that what works in one is almost physically opposed to what works in the other language.
However, there is a transference of concepts of a sort.
If you look at iteration as traversing a sequence of numbers, then a C solution can be constructed that mimics some of the ideas embodied in the Haskell sequence oriented solutions.
The trick is that where in Haskell I’ve mapped an operation across each member of the number sequence, in C, I traverse the sequence (well sequentially) and apply the operations as I get to each number.
Essentially a for loop is a map across the indexes of the for loop. The stuff inside the for/while loop is the function that is being mapped across the sequence.
It’s not quite that Haskell and C are opposites (although some senses they are) but in this case more like they are different axis. They feel perhaps orthogonal to each other. Each of them can map to a problem, but they do it in completely different (but somehow related ways). It’s like each of them is a shadow of the problem on a different wall. Each contains a representation of the problem, but they are different shapes.
I am glad to be learning both at the same time, and I am glad to be using each to go through Project Euler at the same time, as it causes me to think about things that I would otherwise be too lazy to pursue on my own.
I think at some point it would be interesting once I am more familiar with C and Haskell to go back through some of these problems with C++.
I might appreciate C++ more since it has better support for sequences than C and thus some solutions from Haskell might translate more directly into C++ than into C. I also had the realization this morning that the way that I collect information in Haskell to solve proble may map fairly well onto object