Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

38% Positive

Analyzed from 615 words in the discussion.

Trending Topics

#typing#dynamic#type#static#types#problem#errors#weak#object#runtime

Discussion (25 Comments)Read Original on HackerNews

Panzerschrekabout 12 hours ago
In my programming language I have some sort of "borrowing" too (although it's named differently). But my language has no dynamic typing, only static typing is used and thus all checks are compile-time and have no runtime cost. Why bothering with dynamic typing and paying runtime costs for it?
jamiiabout 12 hours ago
> The goal is that most of your code can have the assurances of static typing, but you can still opt in to dynamically-typed glue code to handle repls, live code reloading, runtime code generation, malleable software etc.
Pay08about 11 hours ago
Dynamic typing is neat, I actually prefer it to static typing. Most people who think they have a problem with dynamic typing actually have a problem with weak typing.
DonaldPShimodaabout 5 hours ago
There is no consistent definition of the term "weak typing". Do you mean implicit coercion?

> 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.

gwerbinabout 4 hours ago
Nim type inference was a joy to use although I haven't touched the language in several years due to the language community seeming to collapse a bit.
QuadmasterXLIIabout 4 hours ago
I deeply deeply want to love OCaml but its inherent lack of dynamic dispatch for int / float / complex is brutal
pie_flavorabout 7 hours ago
The standard complaint of pointless type errors that static type analysis would catch has nothing to do with weak typing, nor does the other one about unreliable listing of available ops in your editor by pressing `.` and looking at the autocomplete list. If you think the only thing people think is wrong about dynamic typing is JS `==` then you are swinging at a strawman from a decade ago.
teaearlgraycoldabout 11 hours ago
Yes to dynamic typing. Yes to static analysis.
Pay08about 10 hours ago
What?
antonvsabout 11 hours ago
Technically, in a type theory context, there’s no such thing as “dynamic typing”. Types are a static, syntactic property of programs.

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.

_fluxabout 10 hours ago
The term unityped is used as well, and at typing level this also makes sense: you have one type called object, you put that object alongside the value object ("tag"), and then at runtime all operations on that object check if its type object provides the operation the code is trying to apply on it (or maybe each value object directly knows the operations it supports). I think I prefer this term.

"syntactic type" is a weird term to me, though. Is that in common use?

choegerabout 11 hours ago
Dynamic typing is no typing.

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.

cardanomeabout 6 hours ago
> The point of types is to prove the absence of 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.

Pay08about 10 hours ago
Errors that you can recover from. I simply appreciate the added flexibility. Have you ever tried making a container of arbitrary types in C++?
drabbiticusabout 8 hours ago
Can someone help confirm whether I understand correctly the semantics difference between the final-line eval of

    x^
vs.

    x*
?

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?