As a kid, Chuck Norris found the blue sky too boring and got busy with a watercolour paint set and brushes. The rainbow was the result. If you say "Chuck Norris sucks...", he appears in person; then you continue "...the strength of his enemies with a mere glance." if you value life. Everybody celebrates with fireworks. Chuck Norris celebrates by pulling off meteorites from their orbits and creating shooting stars. The East India Company was created because a young Chuck Norris expressed a casual desire for Indian seasoning in his gravy. The rest is history. Cyclones are created whenever Chuck Norris takes a deep breath and creates an intense low-pressure area in the region.Probably these would make good Rajnikanth facts, except probably the East India Company one (Rajnikanth being an Indian)
Hari's Corner
Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and thenPapa Hari's Chuck Norris Facts
Filed under:
Humour and Nonsense by
Hari
Posted on Wed, Dec 14, 2011 at 10:45 IST (last updated: Wed, Dec 14, 2011 @ 10:45 IST)
BiaCV - an open source, cross-platform résumé editor/creator in Python
Filed under:
My software by
Hari
Posted on Tue, Dec 6, 2011 at 15:11 IST (last updated: Tue, Dec 6, 2011 @ 15:13 IST)
Five tips about Functional Programming for a Haskell newbie from a Haskell newbie
Filed under:
Tutorials and HOWTOs by
Hari
Posted on Mon, Nov 7, 2011 at 15:43 IST (last updated: Mon, Nov 7, 2011 @ 16:15 IST)
- Simple calculator that takes two values and performs an action based on user input. Areas of a triangle, area of parallelogram etc.
- Fibonacci series, and other basic recursive patterns.
- A Caesar-cipher encryption function.
- A program that reads a string of characters and identifies it as either an integer, a floating point number or a word.
- A program that reads an integer number and outputs its English equivalent. E.g. 1200 : one thousand two hundred. (this could be where it gets harder though)
- A postfix (or reverse polish) expression evaluator.
My Haskell article was linked at reddit
Filed under:
Internet and Blogging by
Hari
Posted on Wed, Nov 2, 2011 at 18:34 IST (last updated: Thu, Nov 3, 2011 @ 14:57 IST)
#haskell
IRC channel at freenode for submitting my previous article to reddit. There are some interesting comments in there. My thanks to all those who contributed comments, both here and at reddit. Why learning Functional Programming and Haskell in particular can be hard
Filed under:
Tutorials and HOWTOs by
Hari
Posted on Mon, Oct 31, 2011 at 19:52 IST (last updated: Fri, Dec 30, 2011 @ 15:30 IST)
factorial (0) = 1 factorial (n) = n * factorial (n-1)What it means is that you define a factorial of a number N as the number N multipled by the factorial of N-1. So the function calls itself till it calls factorial (0). This is called a "base case" (where recursion is terminated). This is fairly easy to understand. However, it is far from intuitive from the point of view of working out a solution for a problem that one might solve using an iterative approach. A real world problem may illustrate this better: counting pebbles. The instinctive way to counting a number of pebbles that are laid out in a row is simply to point a finger at each pebble, one at a time, and mentally increment a counter for every pebble you point at. This is an iterative approach. Another less obvious (but still easy) method is simply to pick up a pebble and keep it in your palm and repeat the function until you run out of pebbles. The number of pebbles in your palm at the end of the process is the answer. You've just "folded" the problem using an accumulator (your palm) instead of using your finger (counters). Of course, there will always be a debate as to which is more efficient but that is besides the issue but I think it's a good way to mentally "map" recursion and iteration as any. Functional programming favours the second approach and FP languages support recursion by optimization techniques, even implicit recursion through folding - a concept that keeps recurring in the FP paradigm. Recursion is only the tip of the iceberg though. But it is certainly an early barrier that needs crossing. Too much theory can be off-putting One thing I found when searching for tutorials/articles on Functional Programming is theory. You'll run into a lot of theory and they can easily confuse you and lead to a conclusion that "functional programming is for academicians". While it's inevitable that you need some grounding in mathematics for functional programming, it's not strictly a requirement. But even then, the terminology can be heavy, especially with relation to the more advanced concepts like Functors, Monoids, Monads etc. I confess that I still don't know them and trying to even familiarize myself with them is frustrating. I would suggest that letting go of these topics initially and focussing on the basics as more important. Tutorials that make it seem simpler Actually for Haskell, the excellent guide "Learn You A Haskell for Great Good" makes Haskell seem ridiculously easy at first look. But actually the learning difficulty begins when some of the more advanced concepts are introduced. Pitfall one for most people I expect will be "higher order functions." It doesn't become 'slightly harder' after that. It becomes ten times harder unless you are already conditioned to functional programming intuitively. Actually I would recommend reading a few chapters early on and try to really grasp the basics first. Going too fast, like with imperative programming languages, will lead to confusion. Everything "looks" intuitive in functional programming when presented as a solution (ignoring the more advanced concepts and syntactical complexities involved, for a moment). Arriving to that solution is precisely where you find the roadblocks. My recommendation would be probably to swallow the concepts in small bits and write working code on your own for simple programs using those concepts. It might be slow going, but then again, learning is never a piece of cake. Forget the Zealotry or just ignore it This might seem controversial, but a lot of articles I read on the internet sound a lot like zealotry to me, extolling the virtues of Functional Programming and making it appear that imperative programming are for the mentally inferior ape-types. Sure, that is putting it a bit high, but it can be a bit depressing to read such articles. Whether FP paradigm is truly superior or not is besides the issue. Point is, to a newbie, it can seem daunting and downright depressing to see your second nature (read: imperative programming methodology) trashed like that. Frequently you come across "code samples" solving the same problem: one with the imperative approach with exaggerated clumsiness and the other (almost unreadble, but elegant looking) functional solution ("isn't that clever!" kind of solutions) Ignore that (except for the code bit which can be educational once you're more comfortable with FP). Such talk/writing adds nothing of value to a newbie and to my mind it creates too many expectations about what FP can offer. While terms like "expressive", "rich", "elegant" and "graceful" are thrown around frequently in reference to FP, to a newbie it is just marketing talk in my opinion. Maybe it can deliver, maybe it cannot. But as a newbie, such articles are a distraction from learning and can even lead to demotivation (why don't I just *get* it?) And finally... The above are just some of the few pitfalls that a programmer new to FP paradigm (with a focus on Haskell) is likely to fall into. I might add, there are a few other points to add to the above, but they are relatively minor and can be overcome with familiarity and practice.
- Type system: This is specific to Haskell, but nonetheless, the strong, static type system can be an irritation and annoyance to those used to dynamically typed languages. However, with practice, it gets easier to understand and one actually begins to appreciate its strengths.
- Syntax and syntactic sugar: I never heard of the latter term until I came across Haskell and I confess that these elements can be a bit confusing at first. Every new programming language (including imperative languages) has this issue, so it's not unqiue to FP paradigm (though it can be a slightly harder hurdle in FP).
- Associativity: This is another common term used in FP paradigm and learning the associativity of functions can be a little confusing as can concepts like compositing, currying etc. Simply learning to "read how this code works" can be challenging at first and takes time to begin to understand.
- Laziness and lazy evaluation: This is specific to Haskell and while the concept itself sounds very intuitive, it can be a bit confusing to understand "how" it works in practice especially if you're still thinking like an imperative programmer. I would suggest forgetting about understanding it and just take it for granted until you run into a situation where it actually matters whether a function works lazily or not.
Something about Haskell I wanted to share
Filed under:
Software and Technology by
Hari
Posted on Thu, Oct 27, 2011 at 21:46 IST (last updated: Thu, Nov 3, 2011 @ 14:56 IST)
I am a newbie to Haskell myself, so my perspective is purely from a beginner point of view, but within three days I have picked up the most basic concepts and feel fairly comfortable with the functional style. At least, mentally I am now ready for pattern matching, recursion and other fundamental concepts of functional programming as opposed to imperative, iterative approach to programming. Will I be able to write a full-fledged GUI within a week or even a month? I doubt it. But just the process of learning itself is rewarding. My suggestions would be to learn the bare minimum you require to write simple 'hello world' type programs (with slowly increasing complexity) and then go on from there. Trying to digest everything at once can be very frustrating, as can be the task of trying to write a "real" application. Stop reading tutorials. Yes, this goes against the grain, but really tutorials tend to either over-simplify some things or lead to confusion. The "Learn you a Haskell" tutorial is an exception, but even there, don't try to approach all the concepts head on. If I might make a small comparison. Learning another imperative programming language is like getting to understand a different accent/dialect in English if you are already familiar with English. Learning Haskell is like learning German. The script looks mostly the same, but it's a whole different thing altogether. If after learning for a few weeks, you can speak a few words in German and communicate basic ideas, you're already progressing well. Haskell is somewhat similar.Yes, well, learning Haskell can be compared to learning German if you only know the different dialects/variants of English. The alphabet is mostly the same, but it is just not English!