7 ms·
> When it comes to maintaining and evolving these systems, the lack of explicit static typing becomes a bottleneck. Assertion without evidence. Lack of static
by kazinator 11y ago
> When it comes to maintaining and evolving these systems, the lack of explicit static typing becomes a bottleneck.
Assertion without evidence.
Lack of static typing is awesome in evolving a system: you can convert a part of it to some new types as "proof of concept" and still load and run the code to get usefully far. You just avoid stepping on the parts which aren't converted/refactored yet.
Having something Working Now (tm) is a great motivator for some developers to keep going; it reduces the "activation potential barriers" against creativity.
The trick to using dynamic languages is to have a ton of static experience. The typing is in your head, where it doesn't get in the way. What we are seeing a lot of lately is a crop of developers who have never worked in anything but some dynamic language.
When I'm working in a dynamic language, my concept of type is consciously coming from all the static experience. That keeps me from doing totally scatter-brained things which are possible. I write code such that most of it could statically check, but with the freedom that some of it doesn't have to. Moreover, I am aware (hopefully!) of which code that is.
- vox_mollis 11y agoLack of static typing is awesome in evolving a system I really don't follow your logic, here. Few things change more frequently while evolving/hacking together software than the data structures and types. Changing a type in one place while forgetting to in N other places is an extremely common defect introduction method that is easily caught with static type systems. If anything, it's the evolving/hacking process that's MOST prone to accumulating runtime type errors than any other process.
- kazinator 11y ago> Few things change more frequently while evolving/hacking together software than the data structures and types. I tend to agree; it is often correct. (Though sometimes we have solid data structures and types and are able to evolve things without changing them.) Anyway, therefore it follows that if we calcify and ossify data structures and types, we kill the progress, not to mention fun. > Changing a type in one place while forgetting to in N other places is an extremely common defect introduction method that is easily caught with static type systems. This is blown out of reasonable proportion by static type advocates. In a dynamic system, type is de facto a few bits of value in an object. So the above situation is just another value that is wrong. Static programs also have run-time values that can be wrong. A static program that is supposed to calculate 42 might calculate 43, which has the correct type. To discover the cause, someone will have to sit down and think about the code. Code which has never been exercised by a test case (coverage) should still be regarded as garbage, in spite of passing type checking. It is not known to be correct. Type checked is not the same thing as correct. The graph of "type-value" in typical code is rather trivial. Take any moderately complex algorithm, and ignore what its operations are doing; just consider their input and output types. The resulting graph/tree is a lot simpler than what is going on with the values. Type problems are trivial. That is why it's even possible to move them to compile time and have static languages. Think about it: something that runs for hours or days in order to produce a result (and is not even known to terminate) can be entirely type-checked in a millisecond. We do not know a whole lot about code just because it has type checked. It may feel like you do, but that's just a feeling. The name of the function might be `sort`, but it could actually fail to sort items, in spite of type checking. Or it could sort them in descending order when the expected order is ascending: some test was reversed and the reverse test type checks because the operator is commutative. You still have to either prove your code if possible and feasible, else test it exhaustively if possible, or else test it imperfectly.
- Peaker 11y ago> We do not know a whole lot about code just because it has type checked. It may feel like you do, but that's just a feeling. You can know a whole lot because it type-checked. What exactly you know depends on how you leveraged the type system. For example, if you define a red black tree as is defined here: https://github.com/yairchu/red-black-tree/blob/master/RedBlackTree.hs#L26-L37 https://github.com/yairchu/red-black-tree/blob/master/RedBla... You know code will never generate trees that break the red/black invariants. The tree is guaranteed to be balanced by the type checking process. > The name of the function might be `sort`, but it could actually fail to sort items, in spite of type checking Unless you use a dependently-typed language. Consider this `sort` definition: sort : (in:List n a) -> (out:SortedList n a, IsPermutation in out) "List n a" is a list of length "n" of values of type "a". "SortedList n a" is a sorted list of length "n" of values of type "a". "IsPermutation a b" is a proof that a is a permutation of b (returned from sort). Here's how you can define a type like SortedList: type SortedList n a = exists min. SortedList' min n a data SortedList' min n a where Empty : SortedList' min 0 a Cons : LessOrEq x y -> (x:a) -> SortedList' y n a -> SortedList' x (1+n) a SortedList thus embeds a proof alongside each element that it is less than or equal to the lower-bound of the remaining list (i.e: the next element). Type-checking this guarantees that `sort` does the right thing, modulo resource-use/performance (or termination, depending on your type checker). Resource use (bounding) can also be type-checked, but requires leveraging the type system even more. These guarantees aren't free -- you have to write the types for them, and you have to prove them by instantiating values of these types. But you can opt in or out of each of these guarantees -- leverage the type system as much as you want. With dynamic typing, you just don't have this tool at your disposal at all. No flexibility to guarantee anything. You're forced to opt out completely.
- AnimalMuppet 11y agoPlease clarify something for me: Does that "proof" run a run time, or at compile time? If at compile time, how does it do so without running into something like the halting problem?
- mokus 11y ago
- dukerutledge 11y agoA modern static type system allows this style of programming.
- kazinator 11y agoNot those aspects of that style of programming in which the developer consciously tries partially refactored, inconsistently typed (and thus ill-formed) programs.
- moonchrome 11y ago>When I'm working in a dynamic language, my concept of type is consciously coming from all the static experience Because it's fun to have to constantly lookup API docs for whatever API you're using right now to get the exact spelling or naming convention for the class that you're using. And naturally we're all writing unit tests with 100% code coverage so none of those typos ever get in to production. Dynamic typing works great with simple APIs. Once you have to deal with complex data graphs with heterogeneous types it becomes tedious at best (eg. a simple and well designed GUI library) or a major pain in the ass (eg. Blender Python API) Oh and let's not even get in to pants on head retarded stuff like monkey patching as a part of regular API (eg. see WAF build system)
- icebraining 11y agoBecause it's fun to have to constantly lookup API docs for whatever API you're using right now to get the exact spelling or naming convention for the class that you're using. Nope, I just let my editor show me the available methods for the class. It sounds like you haven't tried programming in a dynamic language with a modern editor?
- moonchrome 11y agoI have - it heavily depends on the library you're using - it sounds to me like you haven't developed something like a GTK3 app with dynamically loaded bindings, blender extension or WAF build system plugin
- icebraining 11y agoNo, I didn't, but your statements were general in nature ("whatever API you're using right now"). Certainly there are exceptions, but they are not relevant for most of the work being done in dynamic languages.
- moonchrome 11y agoFrom my expirience those aren't the exceptions - it's pretty much half the time tools work and half the time they don't (anything involving native interop basically is a nogo, monkey patching or meta programming equally bad). It's nowhere near the level of support you get from even rudimentary type systems such as Java which can always resolve names and can provide strong refactoring. Why do you think even Python added optional type information and type definitions ala typescript and guys like jetbrains are rushing to support it ?
- seliopou 11y ago> The typing is in your head, where it doesn't get in the way. If the typing's in your head, then why not write it down for the benefit of others? and for the personal benefit of automation provided by the compiler? The answer is that for even the most basic systems, a model of its operation cannot be retained in a single person's working memory for even a moment, nevermind the duration of a incremental refactoring. People have trouble remembering phone numbers long enough to dial them. How are you supposed to remember the complex interactions of functions, libraries, and any state that they might be managing? This is by far the greatest fallacy and self-delusion that is propagated by scripters. Talk about an assertion with a ton of evidence against it.
- deleted 11y ago[deleted]
- alextgordon 11y agoThe same argument would say that it's impossible to write mathematics papers without proof assistants (Coq, etc). Obviously that is bogus, mathematicians are not 'deluded' about their ability to check their work themselves. It's just a skill.
- cwzwarich 11y agoIn the analogy between programming and theorem-proving, programs correspond to proofs. When mathematicians informally check a proof, they are usually judging whether a complete proof could be produced, not whether the presented proof is a complete correct proof. Programmers are not given the same affordance.
- asQuirreL 11y agoI feel like the analogy would be "writing mathematical proofs without writing down any of the propositions" (And indeed, the Curry-Howard correspondence lends credence to this). Writing down types for programs is not just useful because the computer can check them, but also because it commits what is in one's mind. What's more, type-checkers offer a lot more help in checking types than Coq does at proving mathematical propositions (There is a reason, after all, that one is an assistant, whereas the other is a checker), so, relatively speaking, writing a proof without Coq is not as hard as typing a program without a type-checker.
- AnimalMuppet 11y ago> > When it comes to maintaining and evolving these systems, the lack of explicit static typing becomes a bottleneck. > Assertion without evidence. ... > The typing is in your head, where it doesn't get in the way. That's fine, if it's you working on your code (and it hasn't been too long since you last worked on it). But if I wrote the code, now the types are in my head. Sure, it doesn't get in your way there, but it also gives you no protection against you doing something that completely violates the type assumptions of my code. That's where the lack of static typing becomes a bottleneck to maintaining and evolving these systems - when the code was written multiple years ago by multiple parties other than yourself.
- Lazare 11y agoI heard the same argument from a certain breed of NoSQL fans (usually pushing MongoDB, in my experience...). "The datastore is schemaless! It's flexible! You can iterate quickly!" I don't think those claims hold up in practice. In the real world, your data is never schemaless; it's just a question of how explicit you want to make the schema. With the added benefit that we have excellent tooling to help with, eg, migrating explicit schemas.
- douche 11y agoOld-style Java "double" type declarations suck. Stuff like this: BigNastyGenericThing<string,FooMonstrosityFactory<Tuple<int,string,double>>> _nastyFoobarObject = new BigNastyGenericThing<string,FooMonstrosityFactory<Tuple<int,string,double>>>(); That can die in a fire, for all kinds of reasons. I'm a huge fan of C#'s var keyword inference sugar, because it cuts the amount of type annotations in half. It also makes it a lot easier to mess around and iterate - there's less irrelevant syntax trash that's broken if you deliberately change the return type of a function or expression. At least with a statically typed language, I can find all the things that I have to find if I break an interface - I have good tooling that uses the type system and can do semantic analysis and even track down when I'm hitting methods and properties through reflection. On dynamically-typed code, I have to grep the whole source-base, and filter out all the false positives. I blame Javascript. If I could run C# in the browser and have real interfaces that understood the same assumptions instead of the hodge-podge of stringified data-binding and parsing...