Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first thing I noticed about that C# example was that it was written in passive voice.


Let's look at a more complex example. Assume "page" is a list of strings. We want to get every word on the page (exact whitespace treatment and tokenizing behavior isn't important; just the gist)

Python:

  (word for line in page for word in line.split())
C#:

  from line in page, word in line.Split() select word
I think that translates to:

  page.SelectMany(line => line.Split())
The Python is a bit confusing; the first C# example is much easier to read. Verbosity is traded for understanding. It is a careful balancing act, but I prefer the balance in C# in this instance. (Don't get me wrong, C# and Python are by far my two favorite languages, I love them both)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: