Live data from Hacker News

Learning Haskell/Python makes you a worse C# programmer

lukeplant.me.uk

11–20 of 64 posts

Re: Learning Haskell/Python makes you a worse C# programmer

#11
post #7

I think the author is simply inexperienced in C#. Here's the right way to express his code: string.Join("\n", from elem in myList where elem.Description != "" select elem.Description); Note how mind-numbingly close this is to the Python: "\n".join(foo.description() for foo in mylist if foo.description() != "") I also think it's considerably easier to read than the foreach loop.

[deleted]

Re: Learning Haskell/Python makes you a worse C# programmer

#12
post #10
post #3

Or in perl: join "\n", map { $_->{description} } grep { $_->{description} ne "" } @mylist; sorry, every time i see something like this, i just can't resist to post code in Perl. =)

I'll see your Perl5 and raise you some Perl6: @list.map(*.description).grep(?*).join("\n")

That is starting to look more like J or K than Perl. Is the Perl 6 team still considering syntax changes? If so, any thought on making map/grep/join operators?

Re: Learning Haskell/Python makes you a worse C# programmer

#13
post #7

I think the author is simply inexperienced in C#. Here's the right way to express his code: string.Join("\n", from elem in myList where elem.Description != "" select elem.Description); Note how mind-numbingly close this is to the Python: "\n".join(foo.description() for foo in mylist if foo.description() != "") I also think it's considerably easier to read than the foreach loop.

Note that this article is from 2006. Hence his using of C# 2.0 instead of a later version which includes Linq.

Re: Learning Haskell/Python makes you a worse C# programmer

#14

It is unfortunate, that the type of positions that employ .NET developers, enforce C# (or sometimes VB.NET) as their language that targets the CLI. While I understand the need for consistency, it would be nice if IronPython or F# were accepted. But dont just feel defeated, make a case to your architect or manager, they might be open to it. However its worth noting that in my experience, C# is a fine language - especi…

[deleted]

Re: Learning Haskell/Python makes you a worse C# programmer

#15
post #7

I think the author is simply inexperienced in C#. Here's the right way to express his code: string.Join("\n", from elem in myList where elem.Description != "" select elem.Description); Note how mind-numbingly close this is to the Python: "\n".join(foo.description() for foo in mylist if foo.description() != "") I also think it's considerably easier to read than the foreach loop.

I've read this article in 2006. Even in this year it was obviously provocative.

Now everybody knows that type inference, list comprehensions and lambda functions can reduce code. Even javers.

Re: Learning Haskell/Python makes you a worse C# programmer

#16
post #13
post #7

I think the author is simply inexperienced in C#. Here's the right way to express his code: string.Join("\n", from elem in myList where elem.Description != "" select elem.Description); Note how mind-numbingly close this is to the Python: "\n".join(foo.description() for foo in mylist if foo.description() != "") I also think it's considerably easier to read than the foreach loop.

Note that this article is from 2006 . Hence his using of C# 2.0 instead of a later version which includes Linq.

Linq, which was inspired by ... Haskell!

Would it be irresponsible to speculate that this article is directly responsible for the inclusion of Linq in C#? It would be irresponsible not to speculate!

Re: Learning Haskell/Python makes you a worse C# programmer

#17
I'm a Python guy with a Java day job so I'm guessing my situation isn't that different from what he dealt with in 2006. Heck, most of us Java guys are dealing with it in 2012!

Python didn't drag my day job down. Instead, it gives me the understanding of what Java's shortcomings are and why IDEs and frameworks exist to cope with them.

It also changed the way I looked at design patterns. Before I knew Python, they were pretty intimidating. Now, I look at a strategy pattern implementation and find it more a cute attempt to compensate for something than anything else.

Re: Learning Haskell/Python makes you a worse C# programmer

#18
post #10
post #3

Or in perl: join "\n", map { $_->{description} } grep { $_->{description} ne "" } @mylist; sorry, every time i see something like this, i just can't resist to post code in Perl. =)

I'll see your Perl5 and raise you some Perl6: @list.map(*.description).grep(?*).join("\n")

That can't be Perl, I actually understood it.

Re: Learning Haskell/Python makes you a worse C# programmer

#19
post #8

It is unfortunate, that the type of positions that employ .NET developers, enforce C# (or sometimes VB.NET) as their language that targets the CLI. While I understand the need for consistency, it would be nice if IronPython or F# were accepted. But dont just feel defeated, make a case to your architect or manager, they might be open to it. However its worth noting that in my experience, C# is a fine language - especi…

I think part of the problem is that, while the CLR is vastly better than the JVM at supporting languages other than its flagship, I also think that the cost of using languages other than C# or VB.NET is higher than a lot of developers are willing to admit. We just allowed some F# code into Kiln. On the one hand, it was vastly simpler than the C# code it replaced. On the other hand, we had to rearchitect our solution…

Also consider that it is hard to hire people to work on your project if you use F#, whereas c# has enough similarities to other languages that it is easy for people to get up to speed. It's too bad, F# is a really great language.

Re: Learning Haskell/Python makes you a worse C# programmer

#20
People should not be so eager to jump to the new functional constructs in C# to proof it can be cool too. There is no shame in imperative programming, it has its own advantages and can be pretty too.

In this case, just using C# a bit more idiomatically can go a long way:

  var descriptions = new ArrayList(mylist.Length);
  foreach (var foo in myList)
  {
    if (foo.Description == "") { continue; }
    descriptions.Add(foo.Description);
  }
  return String.Join("\n", descriptions); 
The names the author gives to his variables are the first indicator that he just isn't really in a C# mindset.
Post reply on HN