Live data from Hacker News

Learning Haskell/Python makes you a worse C# programmer

lukeplant.me.uk

21–30 of 64 posts

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

#21
C# has gotten much better since that article was written, but I've still got a 'bag of tricks' that I feel guilty about such as properties that return delegates and such.

I like using functional methods in Java to implement DSLs but the guava docs are right when they say you shouldn't be ashamed to use a for loop from time to time in Java.

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

#22

TLDR: C# 2.0 had ugly syntax. article from 2006 in c#3.0 we write string.Join("\n", mylist.Select(x=>x.Description()).Where(x=>x != "").ToArray()); and now string.Join("\n", mylist.Select(x=>x.Description()).Where(x=>x != ""));

A method named 'where' seems really odd.

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

#23
post #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.Descrip…

The spirit of your code is correct but I think you'll get a runtime error since the inferred type of your iteration variable, foo, will be System.Object.

Here's a slightly more idiomatic C# 2.0 (i.e. sans var goodness)

  ArrayList descriptions = new ArrayList(mylist.Length);
  
   foreach (Foo foo in myList)
    if (foo.Description != "")
        descriptions.Add(foo.Description);
  
  return String.Join("\n", descriptions);

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

#24
post #12
post #10

Earlier quoted context omitted.

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?

map, grep and join are subs as well as methods. Perl6 is a multi-paradigm language and of course there's more than one way to do it - even when using the same operations.

Instead of chaining methods, one could also use

    # p5 style
    join "\n", grep ?*, map *.description, @list;

    # dataflow style
    @list ==> map *.description ==> grep ?* ==> join "\n";
    join "\n" 

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

#25

TLDR: C# 2.0 had ugly syntax. article from 2006 in c#3.0 we write string.Join("\n", mylist.Select(x=>x.Description()).Where(x=>x != "").ToArray()); and now string.Join("\n", mylist.Select(x=>x.Description()).Where(x=>x != ""));

A method named 'where' seems really odd.

Why? It's a fluent interface.

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

#27
post #16
post #13

Earlier quoted context omitted.

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!

LINQ was introduced by Erik Meijer, an Haskell researcher working on .NET team.

http://research.microsoft.com/en-us/um/people/emeijer/papers...

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

#28

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…

On my case I would cry of happiness if F# would ever be allowed, sadly my employers only care to hire cheap developers that can write a few statements in any language.

Java developers are sold to customers as expert .NET consultants, because on management eyes C# is just like Java! :(

Post reply on HN