Hacker News new | ask | show | jobs
by zmmmmm 2622 days ago
Fascinating to see the circle turn further back towards strong / static typing.

One of the major things that has kept me using Groovy over the last 10 years was the reluctance to leave optional / gradual typing behind. Now, nearly every major dynamic language has given in and introduced types, so it seems like this idea of hybrid dynamic/typed languages is now fully mainstream. The problem of course, is they are all built on a legacy of untyped code, not to mention giant communities of people with no culture or habit of tying their code. So it's not clear to me that any amount of added language features can actually compensate for that.

4 comments

I get what you mean, but dynamic typing is a feature, just like static typing is.

Some languages are better from a static POV, and offer some auto features. Some languages are better from a dynamic POV and offer some hinting feature.

You don't want to type your code to do data exploration and analysis, but you may want to extend the original project later to something bigger and move on to types.

There is no such thing as the perfect language for everything anyway. Plus, it's very good that some languages integrates unnatural features to them, for the case where you want to go beyond their initial best case scenario. It won't be perfect, but I don't need perfect, I need programmatic.

The world of programming is vast, the pool of programmers very heterogeneous, and the constraints are super diverse.

> There is no such thing as the perfect language for everything anyway.

People tend to forget this all to easily. For example most of the static type discussions for the past 10 years have taken place on a website built in a dynamic programming language, I'm talking about http://lambda-the-ultimate.org/ which afaik is built in Drupal (i.e. PHP).

To elaborate, I think people don't care what medium they have their discussions in as long as it works.

Are you not going to use StackOverflow because it is written in C# using Microsoft servers instead of Go on Linux?

Did you not use Twitter originally because it was built on Rails?

10 years ago... what CMS was popular in a static typed language? Hell today... what statically typed CMS is popular?

But if that still matters to someone, PHP now supports types!

I think it's interesting to see mostly-static languages implement dynamic features too. For example, C# is mostly statically-typed. But a while back, they introduced the `dynamic` variable type, which makes that variable actually dynamically typed. Once a variable is dynamically typed, you can assign anything to it, call any function on it with any arguments and put its return into any statically-typed variable. It all gets type checked at runtime and blows up then if what you called doesn't actually match any functions on that object.

You could theoretically do all of that before anyways with clever use of reflection, but this makes the compiler create all of that extra code for you from what looks like normal code.

When Apache Groovy had dynamic types only, it was marketed as a complement to Java, but when Groovy 2 came along with static typing added, its backers started pitching it as a replacement for Java, even targeting Android. This endeavor was ultimately unsuccessful, though, and the programmer who wrote the static typing enhancements recently pulled out of Groovy's project management group at Apache. Groovy doesn't run on Android anywhere I know of, and converting large swaths of dynamic code to static using @CompileStatic doesn't work -- you need to repeatedly compile the code and add manual type conversions all over the place until it all runs OK.

Best use Groovy for dynamically typed scripty stuff only, and a JVM language built with static typing from the ground up for building the actual systems, such as Java, Scala, or Kotlin.

I expect a split between very strictly coded and strongly typed everywhere libraries and shared components, and looser high level scripts mix and matching when convenient.

That could be the best of both worlds.