Hacker News new | ask | show | jobs
by 1_player 4316 days ago
I was having a similar discussion with a friend of mine.

When I was a teenager, I wrote small C projects, then I discovered the world of OS development and set myself to write a minimal operating system from scratch. It was an amazing experience, with a lot of head-scratching, hours spent debugging weird hardware issues, reading other people's code and just churning out badly engineered (but working) code.

Now, 10 years after, after playing with Haskell, OCaml, Scheme, learning about best practices, variants, typeclasses, static vs dynamic typing and data structures, every time I set myself to write something more than 100 lines I just get stuck: which language is best for the job? How should I refactor this to be more clear and concise?

My programming life definitely got worse (as a C/Python programmer) after I discovered variants and the Option/Either monads.

As I said to him, ignorance is bliss.

1 comments

It does get better - write a lot of code with the new language features and you'll get a sense when they're not useful, or how you can apply them to more mundane languages. You can define a decorator in Python to do Maybe monads, for example:

  def maybe(decorated):
    def worker(*args):
      if any(arg is None for arg in args):
        return None
      return decorated(*args)
    # Standard decorator machinery
    return worker
(This doesn't mean you should; this usage is pretty non-idiomatic and will do strange things in edge-cases. That's my point though...the only way to figure out when it's worth it is to try it out in a few situations and determine when it makes the code simpler.)