Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’d be curious to hear more about how you’re using F#? I’ve previously used Python for scripting, but just started developing for a company pretty deeply entrenched in .NET. Currently they’re migrating a lot from VB to C#, but I’ve missed having a handy scripting language like Python for small tools or test applications. Do you think F# could fill that roll?


Powershell is probably best fit for that role. You have to learn a new scripting language but since it runs on .Net you can actually bring in .Net Classes if you need a little more power.

https://learn.microsoft.com/en-us/powershell/module/microsof...


It should be able to! F# has "gradual typing" and full type inference which means you often do not need to specify the types at all, and it also happens to be whitespace-sensitive language much like Python is. Both of these aspects should make it feel quite familiar while also giving you full advantages of static typing.

One thing to note is I find `dotnet fsi {some script name}.fsx` taking more time to start than ideal - up to 800ms is just too much, normal .NET applications usually start in a fraction of this.

I recently posted a submission here for "FSharpPacker" written by my friend that lets you compile F# scripts to standalone applications (either runtime-dependent, self-contained or fully native binaries, much like Go), it also has some comments on getting the best mileage out of it: https://news.ycombinator.com/item?id=42304835

Probably the best feature that also comes with scripting (both C# and F#) is "inline" nuget references e.g. #r "nuget: FSharp.Control.TaskSeq" which will automatically pull the dependency from nuget without ever dealing with manually installing it or tinkering with build system in any other way.

Some additional links:

https://learn.microsoft.com/en-us/dotnet/fsharp/tools/fsharp...

https://github.com/dotnet-script/dotnet-script (C# is also a quite productive language for scripting and small programs because of top-level statements, record types, pattern matching and many other functional features though perhaps not as strongly represented as in F#, it's just very unfortunately abused in enterprise world, with teams often going out of their way to make the code far more bloated than necessary, against the language design intentions)

https://github.com/waf/CSharpRepl


F# is a leap if it's your first functional / ML style language (but worthwhile). Modern C# is good for small tools and scripting, there is the dotnet-script tool for running single .csx files




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: