DE version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
40% Positive
Analyzed from 864 words in the discussion.
Trending Topics
#typing#dynamic#type#static#problem#types#actually#weak#errors#language

Discussion (32 Comments)Read Original on HackerNews
No, the real actual problem is with invisibility aka: the absence of readability:
In a "dynamic typing" program the interpreter knows what `a` is but YOU not.
In very strong sense. You can imagine that `a` is a `int` because, well, you write the program, right? But in fact, is only probabilistic assumption.
Some day, `a` will be a program that delete the files of your computer.
> Most people who think they have a problem with dynamic typing actually have a problem with weak typing.
Ironically, I would counter that, in my experience, most people who have a problem with static typing actually have a problem with verbose type systems, like Java's or C++'s — or Rust's. (Rust is at least gaining something for its verbosity.)
Type inference is a neat way to bridge the gap. OCaml, Haskell, and Swift (to name a few) all feature distinct type inferencing that give you the benefits of static types without as much syntactic overhead.
It is no accident that all mainstream dynamic languages now have optional typing support, either in the language directly or via linters.
It's not just Python too, I've hit the same issue in Common Lisp.
Yes one can run contracts and unit tests and static analysis, but what's a type checker anyway other than a very strict static analysis tool?
The correct term for languages that don’t have syntactic types is “untyped”.
> Most people who think they have a problem with dynamic typing actually have a problem with weak typing.
All people who say things like this have never studied computer science.
"syntactic type" is a weird term to me, though. Is that in common use?
The point of types is to prove the absence of errors. Dynamic typing just has these errors well-structured and early, but they're still errors.
Maybe for you. Originally static typing was to make the job of the compiler easier. Dynamic typing was seen as a feature that allows for faster prototyping.
And no, dynamic typing does not mean untyped. It just means type errors are checked at runtime instead of compile time.
You can have strongly typed dynamic languages. Common Lisp is a very good example.
Weak typing is a design mistake. Dynamic typing has its place as it allows you to have types that are impossible to express in most static type systems while avoiding the bureaucratic overhead of having to prematurely declare your types.
The best languages allow for gradual typing. Prototype first then add types once the general shape of your program becomes clear.
It seems like either one evaluates the contents of the `box`, and would only make a difference if you tried to use `x` afterwards? Essentially if you final-line eval `x^` and then decide you want to continue that snippet, you can't use `x` anymore because it's been moved. Awkwardly, it also hasn't been assigned so I'm not sure the box is accessible anymore?
More or less. x^ moves the whole box whereas x* copies the contents of the box.
> Awkwardly, it also hasn't been assigned so I'm not sure the box is accessible anymore?
Yes, if you move something and don't assign it then it gets dropped, same as rust.