10 ms·
Code is Engineering; Types are Science
- taneq 7y agoIf code is engineering, then types aren't science; they're electronic design rules. Coding without types is like trying to design a printed circuit board without a 'check widths and clearances' button.
- nine_k 7y agoMore like without "check for disconnected circuits" button.
- taneq 7y agoThat too. Usually your 'DRC' button will check for unconnected signals, shorted signals, clearances, and a bunch of other stuff that I've never used. Having the ability to enter a bit of metadata and then have the computer automatically and almost infallibly check your work is one of the best bits of CAD.
- mannykannot 7y agoI like the way you think, but maybe it can be flipped around: types are engineering, and code is... assembly? fabrication? Putting together a product is still part of engineering, but it is not called engineering if it is done on a 'try it and see' basis.
- jonfw 7y agoCode is more like hot rodding- you throw stuff together, making design decisions by the seat of your pants except for a high level plan (which stays very malleable) It's very different than the 'conventional' engineering that goes into building a competitive race car
- bgorman 7y agoInteresting article. Types definitely make it easier to figure how things work in new codebases. I wonder how often do experienced Haskell developers find bugs in production.
- tsimionescu 7y ago> I wonder how often do experienced Haskell developers find bugs in production If by this you mean that you are wondering how often bugs in Haskell programs make it to production, the answer seems to be "at about the same rate as bugs in C or Java, as far as we can tell". Which, given that Haskell's (default) type system is not much more powerful at expressing constraints than C or Java's, shouldn't be a big surprise. Haskell's type system is much more flexible, allowing you to express specific types for many cases where in Java or C you would have to resort to Object or void*; but otherwise, Haskell types can not encode much more powerful constraints than C or Java types - you can only express the available operations and the "shape". The bulk of the power comes from enforcing purity, but that is essentially a property of the standard library, not of the type system. For example, you can't express that a type is a Monad in Haskell - you can specify that it supports the Monad operations, but you have to rely on manual checking to see if it respects all of the monad laws. Note that Idris or Coq are another matter entirely (as are dependent type systems implemented in Haskell extensions).
- sweeneyrod 7y ago> If by this you mean that you are wondering how often bugs in Haskell programs make it to production, the answer seems to be "at about the same rate as bugs in C or Java, as far as we can tell". That seems surprising. What are the bugs that Haskell has but C and Java don't that replace all the null pointer exceptions?
- danielscrubs 7y agoI had a horrible problem with space leaks when running weeks in production, didn't help that I used a pure Haskell db at the time. :) Here are some more info http://blog.ezyang.com/2011/05/space-leak-zoo/ http://blog.ezyang.com/2011/05/space-leak-zoo/ It's been almost a decade since though. Maybe the compiler catches more nowadays.
- devin 7y agoIt’s not an either/or.
- enriquto 7y agoThen, fortran or numpy programmers who can only conceive a single type of data (the multi-dimensional array of floats), are not doing science? I disagree.
- 91edec 7y agoI prefer to call them guild navigators.
- enriquto 7y agoMaybe they are not doing programming, and they are certainly not doing engineering, but they are definitely doing science!
- shepherdjerred 7y agoWhat's the spice in this analogy
- thesuperbigfrog 7y agoCaffeine. It is by will alone I set my mind in motion. It is by the brew of arabica that thoughts acquire speed, the teeth acquire stains, stains become a warning. It is by will alone I set my mind in motion.
- Arrrlex 7y agoThis isn't a reply to your substantive point (of course I agree that fortran/numpy programmers do science), but certainly when I'm coding with numpy I have a mental model of the shapes of the arrays, very akin to the mental model I have of the types of objects in e.g. Haskell or Python. Sure, the shapes are runtime properties and they're not enforced anywhere, but that doesn't matter to my mental model of what's going on.
- MaxBarraclough 7y agoWhether or not you're doing science doesn't depend on which software tools you use, it depends on whether you're advancing the frontier of human knowledge. If you're producing publishable scientific research, you're doing science. If you aren't, you're probably not doing science. I don't think the article is saying otherwise, it's just highlighting a similarity between what type systems do, and the sort of reasoning we associate with science.
- Pmop 7y agoEngineering can happen way before you do any coding. It just turns out that's almost industry standard to do both at the same time these days.
- 29athrowaway 7y agoScience -> Engineering -> Technology Technology is applied engineering, and engineering is applied science. The study of types may fall into some field of science. Applying it is engineering.
- tsimionescu 7y agoThe study of types is generally done as part of mathematics, not sciences. There are some attempts to study type system impact in real world programs, and ergonomics, which would fall under science, but these are a very small part of PLT. However, the point of the article was different - the article was claiming that when you are writing the actual code for your program, you are normally using engineering-style reasoning (abduction), whereas when you are defining the hierarchy of types for your system, you are mainly applying scientific-style reasoning (induction). Personally, I think that the article is a gross over-simplification of every single term - of deduction, abduction, and induction; of maths, science, and engineering; and of what programmers actually do. It is in fact so over-simplified that I don't see any valuable insight into the article at all. It almlst reads like a description of programming from a TV show that is trying to sound brainy.
- jonnypotty 7y agoI can write types = I'm doing science. I can write code = I'm doing engineering. I'm sure that feels good for lots of people. "trying to sound brainy" - totally agree. this is ultimately the aim of so many attempts to show insight by defining or redefining terms - even if the the people involved don't know it. It's because acidemics and intellectuals have to have ways to evelate themselves above ordinary folk, and usually they do this with language. We can see how important this has become in computing when you look at how important the words you use are. God forbid you use the wrong term, say container when you should be saying entity and oooo, bad programmer - why? Because we don't actually know what makes a good programmer so we have to rely on these cultural language indicators. What was a nontrival programming problem that was solved by applying these ideas? I'd be interested in that. Somehow I suspect this doesn't exist.
- Rochus 7y agoISO/IEC/IEEE 24765 3.3810 software engineering 1. systematic application of scientific and technological knowledge, methods, and experience to the design, implementation, testing, and documentation of software ... It's all there just waiting for someone to read it.
- eternalban 7y agoAt CHF 198.00, IEEE is "just" waiting to collect fees before permitting unwashed practitioners from reading it. But we do get a preview and there is a link to www.computer.org/sevocab so we can get a sense of their taxonomical approach. (Try searching for "Data type").
- Rochus 7y agoNo, it's free. Just download it from https://standards.iso.org/ittf/PubliclyAvailableStandards/c071952_ISO_IEC_IEEE_24765_2017.zip https://standards.iso.org/ittf/PubliclyAvailableStandards/c0....
- eternalban 7y agoThanks!
- pjc50 7y agoBut what use is that document to the current discussion? You're not one of those people who thinks that pointing to an entry in a dictionary settles an argument?
- Rochus 7y agoIt shows the acknowledged state of the art and thus offers an alternative for people who do not always want to start from scratch. I am well aware that there is a generation that questions everything (because they like to do so or because they simply do not know the state of the art, e.g. because it was not covered in their bachelor studies).
- slifin 7y agoIf I was given the choice, I can have either static analysis or types I would pick static analysis every time
- nicoburns 7y agoTypes are just one kind of static analysis. So it makes sense that you'd want the superset rather than the subset.
- naasking 7y agoIt's not so clear cut. Types are compositional, by definition. Static analysis needn't be compositional, and so a small change could cause dramatic and unpredictable long-range effects elsewhere in your code. Figuring out what changed or what went wrong can be a nightmare.
- diegoperini 7y agoI had the chance to experiment this idea a few years ago. I had a text editor which could only lint Javascript. My project was a haskell+js hybrid. There was no analysis for hs aside from running the compiler and seeing the output. Writing the hs part was a nightmare at first. Once the project grew and I needed refactoring, js became the main nightmare. Hs simply did its thing which at that point, I already had got used to it. Js couldn't tell me if anything wrong outside of function boundaries. A smarter js linter may prove me wrong but I believe types serve a long term goal by sacrificing productivity in the beginning.
- OJFord 7y agoI don't understand this dichotomy - type checking vs. all other static analysis? Or unchecked types vs. static analysis without types? Or something else?
- ukj 7y agoSimilar ideas come out of the NuPRL project ( http://nuprl.org/Intro/intro.html http://nuprl.org/Intro/intro.html ) > Starting with the slogan "proofs-as-programs," we now talk about "theories-as-systems." But if you rewind history, you could also see the parallels to Peter Naur's "Programming as Theory building" Or more recently: Luciano Floridi's "The Logic of Information: A Theory of Philosophy as Conceptual Design" Different descriptions of the same thing. You could probably relate most of these ideas all the way back to the Greek classics. Democritus. Aristotle. Socrates. Plato. Our tools are finally catching up...
- somewhereoutth 7y agoFollowing Godel:- my intuition suggests to me that for a sufficiently powerful programming language (Turing complete?), any type system will preclude otherwise valid statements in the language. Such illegal but valid statements will be much more numerous than legal statements. These statements may not just be valid, they may be useful, and perhaps even elegant!
- naasking 7y agoSure, and our structural engineering tools and processes no doubt similarly rule out many highly artistic and potentially safe architectural designs. Notice how this argument only seems compelling to programmers when applied to programming. If you want to go beyond the safe norms, you would have to pay the cost of validating the safety of your design. The analog in programming might be theorem proving that your elegant design was still safe.
- somewhereoutth 7y agoIndeed, a type system is a great tool for producing correct code, and I cannot advocate doing away with type safety. However, my counter-argument would be that important failures often occur due to unforeseen interactions in complex systems, perhaps more so than due to actual defects. If a type system precludes simple solutions ("obviously no bugs"), then that may cause problems in itself. My feeling is that type systems should be separate from the language, and should statically validate in a progressive manner (eg Typescript on Javascript). As the type system is evolved to become more expressive, the amount of unsafe code can be reduced - but never quite eliminated (if my conjecture is correct).
- marcosdumay 7y ago> Sure, and our structural engineering tools and processes no doubt similarly rule out many highly artistic and potentially safe architectural designs. Once in a while, civil engineering has a revolution exactly because somebody proves that a class of new designs is safe. The argument is compelling on every field.
- deleted 7y ago
- seemslegit 7y agoFalsely dichotomic analogies are falsely dichotomic
- thekhatribharat 7y agoI put a related question on Computer Science Stack Exchange a week ago. Linking it here in the hopes that HN users roll-calling here will shed some light. Ref: https://cs.stackexchange.com/questions/122066/does-the-underlying-computational-calculus-in-type-theories-affect-decidability https://cs.stackexchange.com/questions/122066/does-the-under...
- indymike 7y agoAn elephant's toenail is part of the elephant, but is not "the elephant." Types are implementation details to a computer scientist, just as unit conversions are implementation details to a chemist. Likewise, code is an artifact of engineering, not the engineering itself.
- kazinator 7y agoCounterpoint: code is scripture; types are religion.
- AnimalMuppet 7y agoThat doesn't seem quite right to me. Maybe code is sermons, types are scripture? Or even code is a religious person's lived-out life, and types are scripture?
- kazinator 7y agoTypes are Science. Static types are theoretical science. Dynamic types are empirical science.
- dadair_ca 7y agoSoftware development doesn’t need to be put into a singular box; it’s all of engineering, art, science. It’s also none of them.
- platz 7y agoThe point of the article, for those who read it, is to characterize different activities of development in a static language as deductive, abductive, or inductive and to discuss examples and relationships between these activities. it's not to contrast static languages with dynamic languages.
- crimsonalucard 7y agoHe conflates science and logic. Science and logic are two very different things. for example, given: f(x) = x*0; verify the hypothesis that: for all n in Real Numbers, f(n) = 0 To verify the above using science you would take a statistical sample of x and verify that it equals zero for that sample. 1*0 == 0 2*0 == 0 3*0 == 0 4*0 == 0 That's four test samples out of an infinite domain. To fully verify the function f via science you technically need infinite test cases to verify the fact. Usually you can never achieve this in reality so science usually takes what you call a "sample" and you say that if the sample is true very likely the hypothesis is true. The only assumption science makes is that probability theory applies to events in reality. Note the isomorphism between science and unit testing; Same bs with none of the statistical rigor. To do the same in logic you have to make assumptions from axioms and logically derive a proof from axioms. The previous thing which was called a hypothesis is now called a theorem: for all n in Real Numbers, f(n) = 0 The proof of the theorem from the axioms of arithmetic can be found here: https://math.stackexchange.com/questions/400605/a-proof-of-n0-0 https://math.stackexchange.com/questions/400605/a-proof-of-n... That being said how does Type theory and code apply to science and logic and engineering? Type theory is part of logic it is not part of science. Don't conflate the two. What is engineering? Engineering is creating solutions for problems using either or both Science/Logic. In the realm of software engineering there is very little of both, It's all an art. Logic is rarely employed for verification and when it's done it's usually just type checking; and testing isn't done to a rigorous level that other scientific and engineering disciplines require. For say the creation of the 787 airliner. The entire plane is built theoretically in software to such a degree that when they actually materialize the theoretical model as a physical prototype it can actually fly. Then after it is built they test it rigorously to a very high degree. For most of software, none of the above is is ever done. We mostly work like artists, just making shit up (design patterns) and adhoc automated testing. So in all practicality your coding job has no relation to either science, engineering or logic. You are an artist. I know technically you apply bits an pieces of science and logic in your programming job but ultimately you use adhoc logic and science for even crossing the street, I'm not going to count programming as a "science" due to this.
- eli_gottlieb 7y ago>That's four samples out of an infinite domain. To fully verify the function f via science you technically need infinite test cases to verify the fact. Usually you can never achieve this in reality so science usually takes what you call a "sample" and you say that if the sample is true very likely the hypothesis is true. The only assumption science makes is that probability theory applies to events in reality. Usually equating null-hypothesis significance testing with the scientific method is a sign of cargo cult.