News for hackers. Stuff that matters.
Re:Type Systems Explained with Examples by nvader on Monday September 28, 2020 @07:09PM (#24622211)
I would pay good money for a comparison of type systems, delivered in the vein of Cow Economics.

In Self, you have a cow. You ask the cow to moo. It moos.

In Java, you have a cow. You construct a CowMooFactory to create an MooIpml. The MooImpl moos.

In Python, you have a cow. You ask it to moo. It quacks.

In C, you have a pointer to a cow. You ask it to moo. Segmentation fault (core dumped).

Re:Type Systems Explained with Examples by TheOtherHobbes on Tuesday September 29, 2020 @07:12AM (#24626280)
In Haskell mooing is an impure side effect. It has to be handled with a special design pattern - which recursively generates further side effects, including an infinite number of online tutorials which fail to explain what it does.

This pattern is called a Moonad.

Re:Type Systems Explained with Examples by nicoty on Tuesday September 29, 2020 @03:37PM (#24631989)
Re:Type Systems Explained with Examples by samatman on Monday September 28, 2020 @10:52PM (#24623760)
In ML, your value moos. It is inferred to be a cow.

In Ruby, your value moos. Could be a cow; might be a MooDuck. Do you really care?

Re:Type Systems Explained with Examples by grawprog on Tuesday September 29, 2020 @12:05AM (#24624065)
In Assembly, there is no cow, no mooing, there's a bunch of places where parts of cows and moos may or may not be stored. It's up to you to pick the parts of the cows and moos in the correct order, then send the numbers representing the places where the cow and moo parts are stored to a magic box that interprets your sequence of numbers and puts the cow into the correct order after which you jump over to the cow and tickle its belly until it moos.
Re:Type Systems Explained with Examples by dllthomas on Tuesday September 29, 2020 @10:32PM (#24635174)
In ML, it's inferred if it might, in any potential future, moo.
Re:Type Systems Explained with Examples by leloctai on Tuesday September 29, 2020 @01:59AM (#24624549)
So what's the difference between ruby and python?
Re:Type Systems Explained with Examples by ClikeX on Tuesday September 29, 2020 @02:32AM (#24624713)
During the Ruby's runtime the cow might get monkeypatched into a bat.
Re:Type Systems Explained with Examples by tomp on Tuesday September 29, 2020 @06:11AM (#24625852)
In Ruby, the cow moos automatically.
Re:Type Systems Explained with Examples by shadowgovt on Tuesday September 29, 2020 @10:29PM (#24635163)
About 3 seconds, depending on how many cows you have. ;)
Re:Type Systems Explained with Examples by keybuk on Tuesday September 29, 2020 @01:16AM (#24624362)
In Swift, if cow is a reference type you all share a cow that moos whoever asks, but if cow is a value type then you all have your own copy of a cow that only moos for you.
Re:Type Systems Explained with Examples by tgv on Tuesday September 29, 2020 @03:08AM (#24624907)
That doesn't make any sense.
Re:Type Systems Explained with Examples by kitd on Tuesday September 29, 2020 @07:11AM (#24626275)
Didn't think Python had duck typing...
Re:Type Systems Explained with Examples by dllthomas on Tuesday September 29, 2020 @02:52PM (#24631520)
What do you think "duck typing" is? Historically, it feels like I've mostly heard the term applied to Python.

Edited to add: Please don't take my question as rhetorical attack - it was intended as inquiry. There may be different definitions floating around.

Re:Type Systems Explained with Examples by kitd on Wednesday September 30, 2020 @10:14AM (#24638918)
Well, there we are. I don't know Python so, both jokingly and literally, I didn't know Python had duck typing.
Re:Type Systems Explained with Examples by ealhad on Tuesday September 29, 2020 @04:49AM (#24625397)
In Rust, you have a Cow. It's smart and allows you to clone borrowed things, including things which can moo.
Re:Type Systems Explained with Examples by Joker_vD on Tuesday September 29, 2020 @06:36AM (#24626023)
But only clones on write, which is a useful optimization.