3 ms·
I have not written my first Go (or Scala) program yet, but I have written some F# code and loved the language (and the fact that everything is an expression too
by PySlice 14y ago
I have not written my first Go (or Scala) program yet, but I have written some F# code and loved the language (and the fact that everything is an expression too). It does have som complex features, and special syntax appears very often, but after reading just a bit of documentation, I can easily understand the core concepts and syntax.
On the other hand, Scala gives me a completely different feeling: when reading the docs and samples, I often ask myself:
How can I mentally parse this?
It's nice that I can abbreviate some common constructs (when writing), but when reading code, how can I tell which concepts are being used? How do I look up these operators when they could come from anywhere (global, first operand, second operand, implicit conversion, etc.)
How do I know when parentheses, dots, curly braces, are mandatory or optional? Could the compiler misunderstand me in complex situations? Where does this construct really end if so many things are optional? At least F# uses indentation, so I know the compiler will warn me if I wrote something that is not quite right according to the precedence rules.
There are too many implicit things going on, how do I know which meaning of _ (underscore) is meant here?
- happy_dino 14y agoI'd say this is largely a non-problem. If you already know F#, then Scala is a much simpler, more consistent language. In a way, Scala seems to be a refined, better designed version of F#. For instance, F# has support for functional and object-oriented programming, but most people I spoke to recommend just ignoring the object parts. That's certainly my impression, too. Compared to Scala, F# didn't manage to combine FP and OOP into a single, coherent approach. You have more or less ML's type system with the object stuff bolted on. Another example would be that F# has tons of features where a single one could suffice. Consider the Unit of Measurement stuff, the various forms of (computation) expressions and type providers. Scala can do all of that and a lot more with "just" macros. > It's nice that I can abbreviate some common constructs Not sure what you mean with that. > How do I look up these operators when they could come from anywhere (global, first operand, second operand, implicit conversion, etc.) Not really. There are no operators, everything is a method invocation. The method is either defined on the type of the left, or added by an conversion from that type. That's it. > How do I know when parentheses, dots, curly braces, are mandatory or optional? Method calls with one argument can leave out dot and parentheses. If a method has a side effect, you define and call it with parentheses, otherwise you leave them out. > There are too many implicit things going on, how do I know which meaning of _ (underscore) is meant here? People love to make up scary examples, but I have never seen any actual misuse of implicits in real code. The meaning of the underscore doesn't change, it is always the same: "There exists something, but I don't care to give it a name." I hope that helps a bit!
- PySlice 14y ago> If you already know F#, then Scala is a much simpler Well, F# does seem to have a lot of "bolted-on" features, but Scala always gives the impression that things "come out of nowhere", e.g. a simple underscore turns the whole expression into a lambda! It looks neat, but I will need some practice to get used to things like this. But, as I said, this is just a superficial analysis, some thing we can only learn after some practicing. > Not sure what you mean with that. Braces, parenthesis, dots, semicolons, and IIRC you can use the arrow => without anything on its left side. > The method is either defined on the type of the left, or added by an conversion from that type. That's it. Unless it ends with a colon, right? > Method calls with one argument can leave out dot and parentheses That's somewhat simpler than I expected. I thought it was something Perl-like or Ruby-like (where obj.method + 1 is different from obj.method +1). There should be some way to get a reference to a method without calling it, that I still haven't learnt. > If a method has a side effect, you define and call it with parentheses, otherwise you leave them out Not sure I understand this. Is this the preferred coding style or something enforced by the compiler? > I hope that helps a bit! Yes, it helped! Thanks!