Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

These are not clever tricks, they are the mathematical foundation of our profession. Why do you assume the types fail to model the domain intuitively? Have you ever heard of denotational semantics?


> These are not clever tricks, they are the mathematical foundation of our profession.

Perhaps, but many of the best real world programming tools have a theoretically sound base but sufficient abstraction that the programmer does not need to concern himself with it.

> Why do you assume the types fail to model the domain intuitively?

Well, using six classes/interfaces and an enumeration just to describe a 3x3 array is one clue.

The horrific complexity of the proposed BoardLike interface is another.

And I would argue that the very existence of the Position enumeration is a third, betraying an underlying complexity that isn't shown in the interface here but is almost certainly present throughout the underlying implementation.

> Have you ever heard of denotational semantics?

I have! I have! Can I be clever too now, please?


I was not just trying to be clever. I feel the subject is very applicable here. But more importantly, the horrific complexity is not due to the solution (it really isn't that complex), but is a rather good demonstration of why Java is a rather difficult language to write correct software in.


They could be considered clever tricks because the Java type system does not seem very well suited to expressing such higher-level invariants. These excercises are interesting, but smarter solutions are not magically guaranteed to perform better in the real world.

As for denotational semantics, you should either explain your point fully or this is nothing more than a trivial condescendig remark.

[edited for grammar]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: