2014-02-09

juan_gandhi: (VP)
2014-02-09 09:09 am

almost sympathizing...

...with Comp Sci PhDs that do not understand category theory but are trying hard to come up with some "science", because they have to. It all mostly looks pretty ridiculous.
juan_gandhi: (VP)
2014-02-09 07:38 pm

just got it

In 2009 James Iry wrote about Nothing type in Scala: http://james-iry.blogspot.com/2009/08/getting-to-bottom-of-nothing-at-all.html

I got the idea eventually

If you have an empty class, it is the initial object (aka bottom); and in OOP there's probably no way to even express the idea.

Kind of obvious, right? Null has a value, hence it is not an initial object (Daniel Spiewak probably meant something else); anything that has a value is no good.

Void is not a good candidate either, but it could be, if it were not owned by Java.

scala> def nothingness: Nothing = {println("This is nothingness");throw new RuntimeException("byte me")}
nothingness: Nothing

scala> def vacuum:Void = {println("you are in space, char!"); throw new RuntimeException("I am void but not null")}
vacuum: Void

scala> def eatSpace(space:Void) = { println("I eat space"); println("and I got " + space)}
eatSpace: (space: Void)Unit

scala> eatSpace(vacuum)
you are in space, char!
java.lang.RuntimeException: I am void but not null
	at .vacuum(:7)
	at .(:10)
	at .()
	at .(:7)
	at .()
	at $print() 
// etc

scala> eatSpace(nothingness)
This is nothingness
java.lang.RuntimeException: byte me
	at .nothingness(:7)
	at .(:10)
	at .()
	at .(:7)
	at .()
	at $print()
//etc