Top
Best
New

Posted by signa11 14 hours ago

A sufficiently detailed spec is code(haskellforall.com)
496 points | 257 commentspage 5
adampunk 11 hours ago|
Just waterfall harder
quotemstr 10 hours ago||
No, a spec is not code. It's possible to describe simple behavior that's nevertheless difficult to implement. Consider, say,

  fn sin(x: f16) -> f16
There are only 64k different f16s. Easy enough to test them all. A given sin() is either correct or it's not.

Yet sin() here can have a large number of different implementations. The spec alone under-determines the actual code.

mungoman2 10 hours ago||
Well, the spec can of course define constraints of how the function is implemented.
9rx 10 hours ago||
It says a sufficiently detailed spec is code. Your spec lacks details that could be added.
quotemstr 9 hours ago||
If you're defining "spec" that way, the word is meaningless. The point of a spec is what it doesn't say.
9rx 3 hours ago||
It's turtles all the way down. If you write your spec in C you can get pretty detailed into how sin is implemented, but not fully. The compiler is going to take your spec and still do things with it that you didn't say, like optimize it in ways you never imagined possible.

If "spec" doesn't imply that, what does it mean to you? Or maybe you are suggesting that C "code" isn't code[1] either?

[1] By the original definition of code that is actually quite true, but I think we can agree the term, as normally used, has evolved over the years?

MartinezOnCha24 4 hours ago||
good read. thanks for sharing
measurablefunc 12 hours ago||
I agree with the overall structure of the argument but I like to think of specifications like polynomial equations defining some set of zeroes. Specifications are not really code but a good specification will cut out a definable subset of expected behaviors that can then be further refined with an executable implementation. For example, if a specification calls for a lock-free queue then there are any number of potential implementations w/ different trade-offs that I would not expect to be in the specification.
catlifeonmars 11 hours ago|
I kind of feel like the specification would call for an idealized lock free queue. Whereas the code would generate a good enough approximation of one that can be run on real hardware.

To invert your polynomial analogy, the specification might call for a sine wave, your code will generate a Taylor series approximation that is computable.

codebje 9 hours ago||
A thorough specification might even include the acceptable precision on the sine wave; a thorough engineer might ask the author what the acceptable precision is if it's omitted.
ModernMech 4 hours ago||
I’d say it differently - that without code the spec is insufficient. Maybe you don’t need a full program as the spec but without some code, you’re left trying to be precise in natural language and that’s not what they are good for.
pkoird 11 hours ago||
Meh, it's the age old distinction between Formal vs Informal language.

Simply put: Formal language = No ambiguities.

Once you remove all ambiguous information from an informal spec, that, whatever remains, automatically becomes a formal description.

manmal 11 hours ago|
Is that true though? If I define a category or range in formal language, I’m still ambiguous on the exact value. Dealing with randomness is even worse (eg input in random order), and can’t be prevented in real world programs.
pjmlp 9 hours ago||
Kind of, that is why non-functional requirements exist, because not everything is code.
firemelt 6 hours ago||
just like what djikstra said
qwertytyyuu 8 hours ago|
Called tests yeah
More comments...