4 ms·
Yes :) That moment when it simply clicks, it's not something that goes away. It has certainly made my day-to-day programming work a lot sweeter, hence I can't s
by tejasv 6y ago
Yes :) That moment when it simply clicks, it's not something that goes away. It has certainly made my day-to-day programming work a lot sweeter, hence I can't shut up talking about it. And it's not like I write some esoteric ML or data science code, a lot of these are boring line-of-business applications, yet it is so satisfying designing those in F#.
- natchy 6y agoDoes interop with c# get easier? Trying to figure out how to map to an overloaded C# callback (maybe hidden in an *.extension doc!) has wasted hours of my time. F# (the ml family in general) is my favorite language right now but, man, the .net APIs are rough. Lacking the same UX I’m used to in Node, Ruby, and Elixir.
- tejasv 6y agoInterop is janky. It works, but there are some gotchas that need to be worked around. It works in 95% of the cases without much mucking around, but it's not pretty, so you're better off tucking that away in some dark corner.
- jpcooper 6y agoCan you explain the interop a bit more? I’ve been looking into an F# job. Having a functional background, the language looks nice, but I’m wondering about the ecosystem. Can you not use .Net libraries as easily as you can from C#?
- natchy 6y agoYes. Typically interop is very straightforward. You look in the api docs and copy paste. Example here is the String doc[1]. Way down you see all the methods. Some of the methods have overloads (multiple variants). Pretty straightforward here. (E.g. `"mystring".Contains("ring")`) Where it gets more verbose and finicky is when the API takes a C# callback. Even more complex is if it’s asynchronous so it takes a C# callback as a Task. An example being the `.Use` method for defining server middleware.[2] To see how it’s done, here’s a gist I found.[3] Notice how the function for requestHandler is verbosely annotated with Func<> and RequestDelegate, etc. Luckily this isn’t the norm, most APIs are less complicated. Even so, you write a wrapper (abstraction) around that complexity and only look at your wrapper. Which is why someone in this thread said to leave them in a dark corner. [1]: https://docs.microsoft.com/en-us/dotnet/api/system.string?view=net-5.0 https://docs.microsoft.com/en-us/dotnet/api/system.string?vi... [2]: https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.useextensions.use?view=aspnetcore-5.0#Microsoft_AspNetCore_Builder_UseExtensions_Use_Microsoft_AspNetCore_Builder_IApplicationBuilder_System_Func_Microsoft_AspNetCore_Http_HttpContext_System_Func_System_Threading_Tasks_Task__System_Threading_Tasks_Task__ https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnet... [3]: https://gist.github.com/kspeakman/7870a75283f6942dd96ff34a03a612f8#file-program-fs-L27 https://gist.github.com/kspeakman/7870a75283f6942dd96ff34a03...
- Serow225 6y agoI think it will get better in F# 5.1, which adds native C# Task support... https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1087-resumable-code-and-task-builder.md https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-...
- seankearon 6y agoIn the meantime, you can use the fantastic TaskBuilder.fs for C# Task support and interop. https://www.nuget.org/packages/TaskBuilder.fs/ https://www.nuget.org/packages/TaskBuilder.fs/ https://github.com/rspeele/TaskBuilder.fs https://github.com/rspeele/TaskBuilder.fs
- jpcooper 6y agoThanks. I appreciate the explanation.