7 ms·
I often wonder if the whole idea of "typing" is the wrong decision in language design, if we shouldn't come up with something better. Dynamic languages are ofte
by hellofunk 11y ago
I often wonder if the whole idea of "typing" is the wrong decision in language design, if we shouldn't come up with something better. Dynamic languages are often trying to insert some form of typing. Static languages are often trying to inject tools for heterogenous collections. It's clear there are advantages to both approaches, yet a languages is usually definitely one or the other, which seems limiting. Not that I have a solution, but perhaps breaking programs into primitive types or lack thereof isn't the right approach to the abstraction.
- Zergy 11y ago> yet a languages is usually definitely one or the other Not necessarily true. C# has the dynamic keyword that bypasses the static typing and Java has the concept of Dynamic Proxies.
- naasking 11y ago> I often wonder if the whole idea of "typing" is the wrong decision in language design, if we shouldn't come up with something better. Not sure what you mean by "better". A "type" is a proposition about the program. You can't get more general than that. Any static checking system will have an interpretation in terms of types, so it's hard to see what could possibly be better than a type system. There are just different type systems with different properties.
- hellofunk 11y agoWell there is also a fair amount of supportive opinion on the contrary, that "better" is a system without types altogether, hence dynamic languages.
- PicassoCT 11y agotype-safety allows for the generating of far more efficient machine code. And you type your language everywhere, the difference is the time it happens and the consistency of the rules below handling type-conversions. lua sets the type depending on the value assigned at run-time. There are a lot of non-dynamic lanugages who pretend to have dynamic types (var)but actually just let the compiler deduce at compile time the assigned valuetype
- ersoft 11y agoPlease check crystal [0]. It has syntax inspired from ruby, types are automatically infered, and it supports method overloading and metaprogramming using compile time macros. Simple Crystal programs are valid Ruby scripts. I recently implemented a protobuf library in Crystal[1], and while the code for benchmark[2] is 100% valid code (no explicit typing), it runs 10 times faster due to Crystal beeing compiled instead of interpreted. [0] http://crystal-lang.org/ http://crystal-lang.org/ [1] https://github.com/teodor-pripoae/protokol https://github.com/teodor-pripoae/protokol [2] https://gist.github.com/teodor-pripoae/da785e3985a69555040e https://gist.github.com/teodor-pripoae/da785e3985a69555040e
- jdonaldson 11y agoWhat are you referring to by "inject tools for heterogenous collections?
- meric 11y agoI take it to mean like a map that can take any type as key or value.
- CyberDildonics 11y agoTyping becomes a tool for solving multiple problems and its uses become more vague under these terms. In the most basic sense, types can offer the size in bytes of the data. They can also be used to verify that certain data can be used in certain ways. If you look at C++ you can use polymorphism if you want a uniform interface and generality elsewhere. You can use templates if you want uniform data size and interface.
- hellofunk 11y agoThere is another paper linked in another HN thread at the moment: https://news.ycombinator.com/item?id=10405143 https://news.ycombinator.com/item?id=10405143 It's worth a read for anyone interested in this topic. I'm not sure why all the downvotes, but it seems like typing in general is not a concept that has stabilized among languages, is the point I'm trying to make. That languages are often adding or loosening typing notions is an interesting indication to me that it is a bit fickle. But as the article I linked here points out, a lot depends also on what your particular definition of "type" is.
- speedkills 11y agoSome static languages do have techniques for dealing with heterogenous lists. It is getting hard to find someone talking about a scala library these days without hearing them mention their use of hlist.