News for hackers. Stuff that matters.
Re:Bottom Type in F# by tegeek on Wednesday September 23, 2020 @04:45AM (#24564584)
One of the remarkable property of ML languages is algebraic data types and then type systems. Look here

type Bottom = private Bottom of Bottom

Modeling any kind of data is intuitive and simple. This is why ML languages (F#, oCamel etc.) shines in industries where you've complex data like Finance. Reading any F# code is like reading a novel. It starts with modeling of data and small functions. Then these small functions and data evolves into bigger features. File by file you keep moving upwards. For example if you are writing a Json parser in F#, you start with Modeling Json data first. And here it is

type JsonValue = | String of string | Number of decimal | Float of float | Record of properties:(string * JsonValue)[] | Array of elements:JsonValue[] | Boolean of bool | Null

Then everything starts from here.

Re:Bottom Type in F# by sevensor on Wednesday September 23, 2020 @11:34AM (#24568254)
While I love that Python bolted on a type system, I wish it could do this. I need recursive types about twice a month, and Python just isn't doing it for me. (And while I'm complaining, the replace function for dataclasses is totally kneecapped by not being able to type check its field assignments.)
Re:Bottom Type in F# by bsaul on Wednesday September 23, 2020 @06:06AM (#24565138)
I would say algebraic data type is the number 1 reason Swift is becoming so popular.

The syntax may not be as elegant as ML languages, but it's still by far the best amongst the "mainstream" languages.

Re:Bottom Type in F# by GiorgioG on Wednesday September 23, 2020 @06:41AM (#24565346)
> I would say algebraic data type is the number 1 reason Swift is becoming so popular.

Let's not kid ourselves - iOS is the #1 reason Swift has any popularity at all. Outside of the Apple ecosystem Swift is practically non-existent.

Re:Bottom Type in F# by bsaul on Wednesday September 23, 2020 @12:40PM (#24568926)
fair enough. By "popular" i should have said "beloved".

Objective-c was hated by pretty much everyone, and was mainly used because of iOS.

i've yet to find an iOS developer that actually doesn't wish he could code in swift on the server side. It's a really pleasant language.

Re:Bottom Type in F# by nwsm on Wednesday September 23, 2020 @09:12AM (#24566605)
However, I would be interested in server-side Swift if anyone has good use cases or resources.