Hacker News new | ask | show | jobs
by sklogic 3649 days ago
> Please, do present the solid theory that is not simply derived from speculation and opinion.

What theory shows is enough to claim superiority:

1) Dynamic typing is a subset of a static typing. This thing alone is enough.

2) Static typing provides more semantic options in both compile and run time, meaning that you can do more diverse things. Also quite a strong claim for superiority.

2 comments

My friend, I am one of the biggest proponents of static typing that you will find, and let me say you are talking absolute nonsense. Your argument is very poor indeed and your attitude is setting back the social cause of promoting statically typed languages.
> 1) Dynamic typing is a subset of a static typing. This thing alone is enough.

This is like saying that more syntax is better. No, cutting away from something can make it better. This argument is not at all enough to claim superiority.

(C can be considered a subset of C++. Which is better?)

> 2) Static typing provides more semantic options in both compile and run time, meaning that you can do more diverse things. Also quite a strong claim for superiority.

"More diverse things" is ill defined. Which are they and why are they a net win? This is not at all a strong claim for anything, except "There is more".

> No, cutting away from something can make it better

What?!?

You can build a dynamic type system on top of a static one. The opposite is impossible. What else is there to even talk about?

> "More diverse things" is ill defined.

It is very well defined. Static (i.e., compile time) metadata allows to infer constraints in compile time. Dynamic metadata is useless for deriving constraints. A very obvious consequence of this observation is that there will always be far more boilerplate with dynamic typing than with static.

> You can build a dynamic type system on top of a static one. The opposite is impossible. What else is there to even talk about?

We are talking about the value of different kinds of type systems and using them. Being able to build a dynamic one on top of a static one says very little about whether or not dynamic or static typing is better for actual usage. On top of this lots of languages have added gradual typing, so this idea that you cannot take a language that is not statically typed and add a type system seems misguided.

> A very obvious consequence of this observation is that there will always be far more boilerplate with dynamic typing than with static.

I hope you realize that this is not at all what reality looks like.

> We are talking about the value of different kinds of type systems and using them.

Exactly. And you're apparently suggesting that there may not be a single case where you may want static constraints. Kinda very strong position, needs very strong proofs indeed.

> gradual typing

Gradual typing IS a static typing, period.

> you cannot take a language that is not statically typed and add a type system seems misguided.

What?!?

You cannot build a gradual typing system on top of a dynamic one.

> this is not at all what reality looks like.

I can only conclude that you do not know much about the reality if you think so.

> Exactly. And you're apparently suggesting that there may not be a single case where you may want static constraints.

No, I have consistently asked for objective proof that static typing is a net win over dynamic typing, something you have yet to even address. I don't know if you're intentionally misrepresenting my argument or if you're simply misunderstanding it, but I think you should re-read this whole thread.

As I've said previously, I prefer static strong typing, but I'm also in touch with reality and to present my opinion and speculation as some kind of fact isn't something I'm interested in.

> I can only conclude that you do not know much about the reality if you think so.

If we're jumping to conclusions I'd like to conclude that you think all PL theory is type theory and that you're ignorant of every other bit of it (and also that you're the type of person to think your every opinion is fact. I think both of these have been on display in this thread, so I actually think that's a stronger conclusion than the one you've drawn).

Sorry, cannot reply down the thread, so I'll put my answer here:

> This is not necessarily true: Static typing quite often requires you to satisfy the type system

We're talking about static typing in general, not some particular implementation of it.

Any static type system with an "anything" type (think of the System.Object in .NET, for example) allows a transparent fallback to dynamic at any time.

So, claiming that "there is a cost" is an outright lie.

> I haven't stated that dynamic typing is better, but I have stated that people claiming one or the other need to have proof.

You know, there is a little funny thingy called "logic". And one of the most common tricks in logic is a proof by contradiction. When you're asking for a proof that static typing is superior, the simplest way is to start with "let's assume dynamic typing is superior". This is exactly what I did. Unfortunately, you could not follow.

> If your programs are as airtight as the "proof" you've given here, I'm not sure I ever want to use them.

It's understandable that a person who do not know much about type systems in particular and PL theory in general also apparently does not know much about proofs and logic in general. After all, type theory and proof theory are indistinguishable.

I provided you with a proof. Cannot you follow such a trivial logic?

Let me repeat it again, slowly:

1) Dynamic typing is a subset of static typing. With static typing you can do everything that is possible with a dynamic typing, at no additional cost, while the opposite is not true.

2) Static typing is far more than a mere "validity checking", as you apparently seem to believe. These advanced semantic properties cannot be added on top of a dynamic type system, so, even suggesting that a dynamic type system may be somehow superior is automatically declaring that under no circumstances you will ever need any of these properties.

Is it so hard to follow?!?