News for hackers. Stuff that matters.
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by SideburnsOfDoom on Tuesday October 15, 2019 @05:07AM (#21256758)
> Allow functions outside of classes

Why? You can put them in a static class, and if C# ever had this feature, it would just be syntactic sugar for a hidden static class.

But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design.

> Adopt (files and dirs) instead of forcing namespace declarations

Likewise.

> Structural typing

Like "dynamic" in C# 4 ? Been there, done that and it didn't take off really. It's useful for some interop cases and that's about it. Strong types, with type inference is more suited to the language design.

https://stackoverflow.com/questions/2690623/what-is-the-dyna...

https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by goto11 on Tuesday October 15, 2019 @05:42AM (#21256917)
Structural typing is different from dynamic typing. C# supports structural typing in the form of tuples and anonymous types. But you can't return an anonymous type from a method. This is a significant limitation.

As for "free" functions: C# already recognizes the usefulness of this in the "using static" directive. This is useful for a lot more than "hello world".

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by moron4hire on Tuesday October 15, 2019 @08:43AM (#21257769)
You can't return an anonymous type, but the syntactic difference between an anon type and a tuple is two characters: parens instead of curly braces.
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by Faark on Tuesday October 15, 2019 @04:05PM (#21263072)
And the little "new" in front of it. I actually preferred the curly braces version and would have loved for them improve it instead of creating a replacement.

And well, I'd expect them to get it right eventually. It is at least their third evolution of that feature... there was a System.Tuple as well. Wonder if they ever come out and officially deprecate their earlier attempts.

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by SideburnsOfDoom on Wednesday October 16, 2019 @09:00AM (#21269852)
> Wonder if they ever come out and officially deprecate their earlier attempts.

That (mostly) doesn't happen.

I would say that .NET Core was the sole attempt to deprecate a lot of the framework. And most of it came back anyway; see the title of the parent article.

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by goto11 on Wednesday October 16, 2019 @07:40AM (#21269273)
I don't think C# have ever deprecated language features. You can still use the old "delegate{}" syntax even though we have the more concise arrow syntax.
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by manigandham on Tuesday October 15, 2019 @06:33PM (#21264723)
Why are "free" functions useful? What actual real difference does it make compared to putting an extra word in front to call the method?
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by goto11 on Wednesday October 16, 2019 @06:51AM (#21268986)
You don't need to put the extra word in front since "using static" was introduced. But you still need to define a useless static class.
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by jeswin on Tuesday October 15, 2019 @05:38AM (#21256898)
> But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design.

Fairly complex programs can be written with just plain functions, all of them elegantly starting off column 0 instead of being tabbed for namespaces and classes. It works especially well with directory structure based namespaces. eg: Microsoft's own TypeScript.

> Like "dynamic" in C# 4 ?

No not dynamic, I wouldn't use that very much either. https://en.wikipedia.org/wiki/Structural_type_system

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by nbevans on Tuesday October 15, 2019 @09:34AM (#21258162)
It sounds like you are using the wrong language. F# is what you want to be using.
Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by SideburnsOfDoom on Tuesday October 15, 2019 @10:24AM (#21258687)
> No not dynamic

Ok, I see that structural typing is a third type system option.

But honestly, I don't want C# and .NET to contain every feature and paradigm ever created. It would be bloated and hard to use. Already there is significant legacy and different ways of doing the same thing, and it's likely to get even worse.

If the language that you ideally want is built around structurally typed free-floating functions, then it probably isn't C#. It probably exists, it's likely possible on the .NET platform, but it doesn't work and think like C#.

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by pjc50 on Tuesday October 15, 2019 @05:30AM (#21256861)
> But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design.

That's what the Powershell integration is for.

Re:.NET Core 3.0 Concludes the .NET Framework API Porting Pr... by SideburnsOfDoom on Tuesday October 15, 2019 @05:40AM (#21256905)
> That's what the Powershell integration is for.

And projects such as scriptcs and cake

http://scriptcs.net/

https://cakebuild.net/