News for hackers. Stuff that matters.
Re:Ravi – Lua 5.3 with optional static typing by hellofunk on Saturday October 17, 2015 @01:20PM (#10405182)
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.
Re:Ravi – Lua 5.3 with optional static typing by ersoft on Saturday October 17, 2015 @03:24PM (#10405684)
Please 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/

[1] https://github.com/teodor-pripoae/protokol

[2] https://gist.github.com/teodor-pripoae/da785e3985a69555040e

Re:Ravi – Lua 5.3 with optional static typing by hellofunk on Saturday October 17, 2015 @05:13PM (#10406128)
There is another paper linked in another HN thread at the moment: 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.

Re:Ravi – Lua 5.3 with optional static typing by naasking on Saturday October 17, 2015 @02:53PM (#10405570)
> 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.

Re:Ravi – Lua 5.3 with optional static typing by PicassoCT on Sunday October 18, 2015 @08:38AM (#10408056)
type-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

Re:Ravi – Lua 5.3 with optional static typing by hellofunk on Saturday October 17, 2015 @05:15PM (#10406143)
Well there is also a fair amount of supportive opinion on the contrary, that "better" is a system without types altogether, hence dynamic languages.
Re:Ravi – Lua 5.3 with optional static typing by duaneb on Sunday October 18, 2015 @02:00AM (#10407354)
Dynamic languages have types, too. Even perl has its distinctions between lists and strings.
Re:Ravi – Lua 5.3 with optional static typing by aikah on Saturday October 17, 2015 @10:27PM (#10406997)
But most dynamic languages have types. PHP ,Ruby,Python and even JavaScript have types.
Re:Ravi – Lua 5.3 with optional static typing by CyberDildonics on Saturday October 17, 2015 @04:34PM (#10405950)
Typing 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.

Re:Ravi – Lua 5.3 with optional static typing by speedkills on Saturday October 17, 2015 @08:24PM (#10406746)
Some 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.
Re:Ravi – Lua 5.3 with optional static typing by Zergy on Saturday October 17, 2015 @02:00PM (#10405363)
> 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.

Re:Ravi – Lua 5.3 with optional static typing by jdonaldson on Saturday October 17, 2015 @04:15PM (#10405871)
What are you referring to by "inject tools for heterogenous collections?
Re:Ravi – Lua 5.3 with optional static typing by meric on Saturday October 17, 2015 @04:43PM (#10405984)
I take it to mean like a map that can take any type as key or value.