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.
Learning Haskell/Python makes you a worse C# programmer
11–20 of 64 posts
Re: Learning Haskell/Python makes you a worse C# programmer
#12Or 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")
Re: Learning Haskell/Python makes you a worse C# programmer
#13I 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.
Re: Learning Haskell/Python makes you a worse C# programmer
#14It 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…
Re: Learning Haskell/Python makes you a worse C# programmer
#15I 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.
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
#16I 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.
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
#17Python 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
#18Or 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")
Re: Learning Haskell/Python makes you a worse C# programmer
#19It 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…
Re: Learning Haskell/Python makes you a worse C# programmer
#20In 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.