News for hackers. Stuff that matters.
Re:Poll: What's Your Favorite Programming Language? by MatthewPhillips on Friday March 23, 2012 @04:17PM (#3747028)
Eh, C# is good for the environment it lives in, but it's not without it's cruft.

C#'s answer for all of its missing features seems to be a generic class. Don't have tuples? We'll give you Tuple<T>. Don't have inline functions? We'll give you Func<T>. It feels very tacked on (especially Func).

Re:Poll: What's Your Favorite Programming Language? by hackinthebochs on Friday March 23, 2012 @04:27PM (#3747093)
Func<T> is just the type signature they use for lambdas. The syntax allows fully inline functions now:

() => { DoSomething(); }

No return value needed (compiles down to an Action<T> I think)

Re:Poll: What's Your Favorite Programming Language? by masklinn on Friday March 23, 2012 @05:25PM (#3747393)
> No return value needed (compiles down to an Action<T> I think)

Which is an other crufty thing in C#: because Void/() is not a type (inherited from Java), it needs to have both `Func<Tn..., T>` and `Action<Tn...>` in order to handle functions-with-a-return-value and functions-without-a-return-value.

Re:Poll: What's Your Favorite Programming Language? by hackinthebochs on Friday March 23, 2012 @05:30PM (#3747413)
This is true, but its mostly transparent unless you're doing something particularly ugly.
Re:Poll: What's Your Favorite Programming Language? by masklinn on Friday March 23, 2012 @06:07PM (#3747595)
Like trying to take one of these as parameter or return it?
Re:Poll: What's Your Favorite Programming Language? by hackinthebochs on Friday March 23, 2012 @07:14PM (#3747809)
This is a statically typed language mind you. If you're passing something around as values, you're gonna need to declare what its type is (of course there's type inference, but that just turns it into a totally different language)
Re:Poll: What's Your Favorite Programming Language? by masklinn on Saturday March 24, 2012 @04:31AM (#3748863)
> If you're passing something around as values, you're gonna need to declare what its type is

I fail to see the relation this has with my issue.

Re:Poll: What's Your Favorite Programming Language? by lolcraft on Saturday March 24, 2012 @06:06AM (#3749003)
You should need to know whether you require the lambda you're accepting to return some value or not, and its type.
Re:Poll: What's Your Favorite Programming Language? by masklinn on Sunday March 25, 2012 @05:01AM (#3752123)
You completely missed the point I was making. Try reading these comments again.
Re:Poll: What's Your Favorite Programming Language? by MatthewPhillips on Friday March 23, 2012 @05:37PM (#3747452)
Can't recursively call a lambda function, no thanks.
Re:Poll: What's Your Favorite Programming Language? by chrisb on Friday March 23, 2012 @06:25PM (#3747675)
There are two ways of recursively calling lambda functions, neither perfect, but both usable.

  Func<int,int> fib = null;
  fib = n => n > 1 ? fib(n - 1) + fib(n - 2) : n;
Or write yourself a Y fixed-point combinator, described in http://blogs.msdn.com/b/wesdyer/archive/2007/02/02/anonymous...

  delegate Func<A,R> Recursive<A,R>(Recursive<A,R> r);
  static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f) {
    Recursive<A, R> rec = r => a => f(r(r))(a);
    return rec(rec);
  }
used like this:

  Func<int,int> fib = Y<int,int>(f => n => n > 1 ? f(n - 1) + f(n - 2) : n);
(I'm not advocating writing a fib function this way, but it's a useful example!)
Re:Poll: What's Your Favorite Programming Language? by icebraining on Friday March 23, 2012 @06:22PM (#3747653)
Re:Poll: What's Your Favorite Programming Language? by anarchotroll on Friday March 23, 2012 @04:23PM (#3747073)
I also feel like "Funcs" are a work around. What I like the most about C# is the fact that it keeps evolving and incorporating new paradigms (closures, lambdas, LINQ, etc)
Re:Poll: What's Your Favorite Programming Language? by fleitz on Friday March 23, 2012 @05:06PM (#3747286)
Try F# then, tuples, records, pattern matching, etc. It's essentially OCaml.net
Re:Poll: What's Your Favorite Programming Language? by MatthewPhillips on Friday March 23, 2012 @05:39PM (#3747461)
Have used F# quite a bit. It's nice, the nicest ML I've used, but it has some cruft as well. It feels like 2 languages, really, the nice functional ML language, and then the C#-with-F#-syntax object oriented side. I wish they wouldn't have bothered with the latter.
Re:Poll: What's Your Favorite Programming Language? by pjmlp on Saturday March 24, 2012 @02:10AM (#3748655)
Actually the OO side is quite similar to OO in OCaml, so I miss your C# remark there.

For a language to be first class in .NET it needs to be able to do OO with the same semantics that the CLR has, otherwise you will have leaky abstractions all over the place.

Re:Poll: What's Your Favorite Programming Language? by sofuture on Friday March 23, 2012 @04:31PM (#3747118)
Yeah, C# tuples are a pretty glaring hack in an otherwise great, evolving language.
Re:Poll: What's Your Favorite Programming Language? by eropple on Friday March 23, 2012 @05:56PM (#3747540)
Like other C# features and behaviors, I expect that, down the line, the language will pick up syntactic sugar to make the creation and usage of those tuples more straightforward (see delegates -> anonymous functions -> lambdas).
Re:Poll: What's Your Favorite Programming Language? by manojlds on Friday March 23, 2012 @09:56PM (#3748208)
Yeah and F# is the breeding ground for C# features
Re:Poll: What's Your Favorite Programming Language? by pjmlp on Friday March 23, 2012 @06:15PM (#3747628)
Func<T> are part of expression trees.

They are intended to manipulate the abstract syntax tree of lambda expressions. A bit like macros.

You should only need to know about them if doing AST manipulations.