Consder this code:
private ModelThing SaveThing(ModelThing modelThing)
{
Thing modelChangesAsEntity = modelThing.ToEntity(...
For further actions, you may consider blocking this person and/or reporting abuse
Its not demeaning just not first-class in same way as Typescript/JavaScript.
I think if it's truly first class it should be able to do this:
It has a name and namespace, it doesn't need a Class wrapper.
It's well defined as the only input and output parms are string.
Many consider the fact that Java and C# cannot have executing code outside of classes a feature. On that same note, they consider JavaScript allowing anything and everything at the top level to be an anti-feature. So, you can rain on C#'s parade all you want, but the decision to mandate structure is not inherently wrong or "second-class".
What's mandating about anonymous classes, or use of Dynamic? Typescript is more modern than C# and gives the developer a choice of strong and weak typing. Most of all it treats functions as first class citizens.
I'm not raining on any parades here, that's your idea of what I'm doing. I'm just proving my point that .NET people don't really like accepting Functional Programming ideas outside of their curtained niche. Shoot the majority don't embrace Extension methods.
I was referring to their decision to mandate namespaces and classes contain the code that actually runs (namely methods and variables).
Weak typing sux. Don't need it.
I love extension methods. I don't know many people who hate 'em.
What's your whole angle with pushing functional programming into .NET projects? If the people you work with don't care for functional programming and are solving problems just fine in OOP or other paradigms, what do you care? If you wanna use functional programming in your own projects, knock yourself out. I see plenty of functional programming done in C#, though.
Weak Typing does suck except for disciplined OOP folks who know when to use it to their advantage.
Ya I love extension methods too, they are the only real functional style (apart from the Func) in C#. No fancy interface or class defs needed there, as they automatically telegraph the interface, and there's no way to get by it.
Functional programming using extension methods is my angle. That's all.
Lambda,
Linq,
Extension Method,
Anonymous Method,
Delegates,
Switch Expression,
Local Method,
Pattern Matching,
Higher Order Function etc.
C# has both functional and OOP capabilities.
You're right...
That's why I say functions are not first class. Even though MSFT claims they are first class.
In Typescript and JavaScript, functions as well as classes sit at same layer. C# forces functions inside of a class.
Hi,
You should have a look at F#. I have learned it using FAKE, it was a great way to learn about functional programming.
Modern analyzers would propose you change those local delegate variables to local methods.
True...
I did this example based on the only real functional constructs we have in C# which are 1) Func and 2)Extension methods. I've worked in shops where they were adverse to Extension Methods, thus the reason the title is as it is. Unfortunately for C# Func, despite what MSFT says are not 1st class citizens as they are in Typescript/JavaScript. Maybe this is the reason I've seen resistance to extension methods.
As noted in the other discussion thread, you have yet to defend this claim. The C# syntax simply isn't what you like, but they have all the same abilities.
A lot of developers use Linq, I believe.
Can functions be declared outside of a class in C#?
static
methods are mechanically equivalent to freestanding methods. This seems like an arbitrary qualification for being "first-class".Yes but I can't do this... in C# like I can in Typescript
Sure, but my point is you are not missing anything in terms of capability.
There. Now you can access it via
J.unk
. Happy? I mean, what is it you really want? You're gonna need to find far worse things to leverage any kind of meaningful criticism against C# here.Or here's one...
The C# Equivalent of first class functions in Typescript/JavaScript are Extension Methods.