←back to thread

Why F#?

(batsov.com)
445 points bozhidar | 2 comments | | HN request time: 0.597s | source
Show context
oguz-ismail ◴[] No.43546198[source]

>whitespace is significant, like in Python

hard pass

replies(5): >>43546246 #>>43548986 #>>43549106 #>>43550293 #>>43551353 #
fire_lake ◴[] No.43548986[source]

Static typing removes the downside of whitespace.

Oh, and every language with line comments (so most of them) has significant whitespace.

replies(1): >>43549517 #
AnimalMuppet ◴[] No.43549517[source]

> Static typing removes the downside of whitespace.

How so?

> Oh, and every language with line comments (so most of them) has significant whitespace.

Technically true, but that's not what people mean by "significant whitespace" in this context. So you're being pedantic rather than saying anything meaningful.

But you made me think. The ultimate nightmare would be significant trailing whitespace - the spaces and/or tabs after all the visible characters change the meaning of the line.

replies(2): >>43550473 #>>43557424 #
Akronymus ◴[] No.43557424[source]

In f#'s case, there is the trifecta of everything being an expression, static typing and default immutability. This means you often write code like this:

let foo = if bar then baz else someDefault

Due to it being an expression you assign what the if evaluates to to foo. Due to static typing, the compiler checks that both branches return the same type. Due to the default immutability you don't declare and assign in separate steps. What this results in, is that accidentally using the wrong indentation for something usually results in an error at compile time, at the latest.

Compared to how python does significant whitespace is that it's dynamic typing + statement based, which means you can easily end up assigning different types to the same variable in different branches of an if, for example.

I hope I explained it in understandable terms

replies(1): >>43559415 #
1. fire_lake ◴[] No.43559415[source]

Pythons approach to variable declarations makes this doubly bad.

replies(1): >>43559470 #
2. Akronymus ◴[] No.43559470[source]

Tbh, I've been successful enough in avoiding using python that I don't know the specifics of that.