F# versus Scala

Both integrate with scalafmt which is the standard formatting tool for scala.

2 Likes

Expanding on Jasper’s comment: Scala is flexible when it comes to style. So instead of there being One True Style that everything must get formatted in, you define your own .scalafmt.conf file, and then use the scalafmt tool (either directly or through the IDE) to format as you prefer.

(You can also define formatting directly in IntelliJ, but it’s generally better to use scalafmt – more standard, more easily integrated into CI, designed to be checked in with the project, not tied to the specific IDE.)

2 Likes

Here are the final results of Fibonacci speed test :


nim : 5s
fsharp: 6s
scala :8s
crystal : 8s
scala_native : 10s
racket-scheme: 11s
sbcl-lisp: 15s
ocaml: 46s
chicken-scheme: 77s

How do you do scala formatting in vscode ?
[ With intellij-idea it’s just ctrl-shift-alt-L ]

Add a .scalafmt.conf file (Metals should ask you to do that when you have a Scala project open). Then it auto-formats when you save file with Ctrl+S.
The file contents can be as simple as:

version = "3.7.15"
runner.dialect = scala3
1 Like