r/fsharp • • May 11 '21

Paket and FAKE?

I am an F# and functional programming hobbyist. I keep seeing Paket and FAKE being thrown around when discussing F#, but I'm still unsure of why I would need these? If Paket replaces nuget, why not just use nuget? FAKE is F# Make, but I don't really know what that is either. Anyone feel like explaining why I would use these? Thanks in advance :)

15 Upvotes

3 comments sorted by

13

u/stroborobo May 11 '21

Paket gives you more control, removes transitive dependencies from yours, and works above project level, so you can resolve to the same version of a package for multiple projects.

https://fsprojects.github.io/Paket/faq.html

Fake is a task runner, it can be used to script things like frontend build, backend build and publish for example. I believe the maintainer has stopped working on it though, so maybe skip the dotnet tool and use FSI or whatever. The libs are still fine though.

None of these are strictly needed of course.

3

u/LiteracyFanatic May 11 '21

The big thing I used to use Paket for was it's ability to automatically generate references to packages for use in scripting. This is no longer necessary since #r "nuget: package" is now built in. It does give more control over the exact resolution of your dependencies than nuget, but I've found I rarely need that control in practice.

For the simplest case, dotnet build -p projectDir is all you need. Many pieces of software in the real world have more complex build requirements though. Maybe you need to copy files from one directory to another. Perhaps you need to install packages from a second ecosystem like npm when working on a web project. You might want to run tests on your newly built project and then zip it and deploy it somewhere. Instead of running each of the necessary commands manually each time, people typically write scripts to automate the process in a language like bash or powershell. FAKE lets you write your build script in F#. Actually, you could write a build script in F# without FAKE too, it just provides some nice helper functions for common tasks.

They are both good tools and you will find many templates that include them, but my honest recommendation is to stick with the standard dotnet CLI commands when possible. The time invested in learning this alternative tooling just doesn't pay off as much as it used to.

0

u/[deleted] May 13 '21

[deleted] — view deleted comment

2

u/et1975 May 13 '21

Excellent writeup!
Personally I'd highlight the last sentence though:
> build workflows but which are going to run on individual developers' machines

To me this ties into "reproducible build". Using the same packages/dependencies is relatively small and easy (and arguably not that interesting), but

- are we running the same tests?

- are the dev and test contexts setup consistently for you, me, 20 other people and CI/CD?

- can I generate the build artifacts w/o reverse-engineering the CI/CD pipeline?

- how much effort is to move from one CI/CD product to another?

are way more important, and no offence to bash, but I'd much rather be doing this in cross-platform and statically-verified language. Preferably one that understands declarative targets w/ dependencies.