Live data from Hacker News

Have Static Languages Won?

pointersgonewild.com

81–90 of 120 posts

Re: Have Static Languages Won?

#81

Earlier quoted context omitted.

There is one other undeniable advantage to dynamic languages: you can express things in a dynamic language that you can't in a static one. Static languages try to be as sound as possible, at the cost of some completeness. Dynamic languages are less concerned with soundness and can be more complete. As an example, duck typing is usually not possible to achieve in a static language - it's really hard to allow duck typi…

Question is, how many real-world cases there are where duck typing is super beneficial. Usually if you need a bunch of differently-typed objects to fulfill the same contract, you can just make them implement an interface (said interface can also be documented, etc., it makes the intent very explicit). I do believe there are cases where dynamic typing is genuinely useful, but those make up a very small portion of real…

It's not an either/or situation--or at least it shouldn't be. Static and dynamic type systems are not opposites. They're not sworn enemies. They don't necessarily have to be alternatives; it's reasonable to want both.

A couple of years ago I worked for DARPA project that was building a system designed for greatly enhanced security and reliability. It had a novel programming language designed to be able to express a rich set of reliability and security constraints in the type system. It had a rich static type system, but it also had a dynamic type system. Why? Because some important constraints simply can't be analyzed statically.

For example, a program could say that it was impossible for a given piece of information to be delivered to an unauthorized receiver. That constraint cannot be analyzed statically because the authorization status of a given agent can change at any time. The type system had to be able to check authorization, so it had to have a dynamic checker (in fact, the system was designed to be able to do dynamic checks in hardware).

Maybe this sounds like an esoteric use-case, but is that because nobody wants to be able to express such constraints, or is it because we just don't expect to be able to do so because we haven't had the tools?

The project in question is in part meant to make the case that such use-cases should not be esoteric--that one of the reasons that our reliability and security situations are so embarrassing is that we haven't so far taken those considerations seriously enough to develop the tools to deal with them. If we want to get better, maybe we should be thinking about how to integrate both static and dynamic type systems, rather than exalting one and denigrating the other.

Re: Have Static Languages Won?

#82

Earlier quoted context omitted.

There is one other undeniable advantage to dynamic languages: you can express things in a dynamic language that you can't in a static one. Static languages try to be as sound as possible, at the cost of some completeness. Dynamic languages are less concerned with soundness and can be more complete. As an example, duck typing is usually not possible to achieve in a static language - it's really hard to allow duck typi…

Question is, how many real-world cases there are where duck typing is super beneficial. Usually if you need a bunch of differently-typed objects to fulfill the same contract, you can just make them implement an interface (said interface can also be documented, etc., it makes the intent very explicit). I do believe there are cases where dynamic typing is genuinely useful, but those make up a very small portion of real…

I agree that duck typing is rarely critical, you can always work around it when you find you'd like to have it.

On the other hand, I disagree with the scenario you describe: if you have multiple types that come from an external, closed-source library, you won't be able to have them extend a new interface. If you're lucky and they've not been marked final, you'll need to wrap them in another type that extends the right interface, then unwrap them... not at all impossible, but a lot of boilerplate.

The best solution I know of is type classes, in languages that support them.

Re: Have Static Languages Won?

#83
post #33
post #17

JavaScript, PHP, Python, and Ruby are all in the top 5 spots on GitHub. Java is the only STL that made the cut. There are certainly types of work that seem to favor dynamic languages, because they have the ability to do some interesting things. ORMs, for example, far more powerful in dynamic languages as far as I've encountered

Even PHP has trajectory toward static types. Some examples are Hack[1] and PHP7[2]. Check out the talk Rasmus gave at Etsy[3] for more about PHP7 changes but it looks like at least limited support for static or "strict" types (whatever subtle distinction that might be) has enough merit for PHP to implement after all this time. 1. http://hacklang.org/ 2. http://www.php.net/manual/en/migration70.new-features.php 3. htt…

PHP is still a dynamic language. PHP 7 gets us scalar typehinting support, which lets us check types at run-time. There are similar annotation based solutions for Ruby as well, which ultimately rely on a lot of Ruby's metaprogramming features. The idea behind these solutions is to have proper type support where you need it.

You will have to pry duck-typing from my cold dead hands if you try to remove it from PHP/Ruby completely.

Re: Have Static Languages Won?

#84
post #74

Earlier quoted context omitted.

Doesn't Go have the same thing?

I know next to nothing about Go, but I think you're referring to the fact that it has some sort of implicit inheritance resolution - if there is a Reader interface with a read method, and a type A that has a read method with the same signature, then A will be considered to be a subtype of Reader, whether you marked it as such (or whether you want it or not). I see what you mean, this feels like a static version of du…

>I'm not sure how I feel about loosing control over what supertypes my type extends, though - well, I lie. I don't like it.

Well, don't you lose that by default (and even more) with dynamic typing?

Re: Have Static Languages Won?

#85
post #84

Earlier quoted context omitted.

I know next to nothing about Go, but I think you're referring to the fact that it has some sort of implicit inheritance resolution - if there is a Reader interface with a read method, and a type A that has a read method with the same signature, then A will be considered to be a subtype of Reader, whether you marked it as such (or whether you want it or not). I see what you mean, this feels like a static version of du…

> I'm not sure how I feel about loosing control over what supertypes my type extends, though - well, I lie. I don't like it. Well, don't you lose that by default (and even more) with dynamic typing?

You do, and I really, really dislike doing any serious work without a solid type system.

Re: Have Static Languages Won?

#86
post #63

Article points to http://wtfjs.com/ to show "glaring flaws" of JS. JavaScript is not perfect, but almost all what is presented on sites similar to wtfjs.com are non-issues to me. It may be stupid or surprising that API behaves in some ways, but as long as it behaves exactly as in documentation it is not much of a problem. I always check available documentation even for basic APIs in every language that I use. i.e. I…

Two things:

a) Maxime works on a compiler for JS, so even if something is documented to death, it usually makes analyses less precise and/or more complex.

b) Many statically-typed languages have a REPL (OCaml, Haskell, Scala); this is not an issue with the typing discipline, but with the tools available to the developers.

Re: Have Static Languages Won?

#87
post #21

Earlier quoted context omitted.

Anecdotally, on my year around 75% of students were there just because CS was supposed to bring money. They've started CS studies while not knowing how to program, knowing nothing about operating systems or caring. For them it was a 9-17 future job, nothing more.

First time I've ever heard a 9-5 job called a "9-17" job. Decided to Google it to see how common it was, and all the results are for the Bible verse Job 9:17 - > He would crush me with a storm and multiply my wounds for no reason. Seems appropriate for some "9-17" jobs.

That quote is amazingly apt. Working in software can definitely be a "9:17 job".

Re: Have Static Languages Won?

#88

Earlier quoted context omitted.

> It takes time for languages which are rapidly gaining mindshare Honestly curious: which new languages are those?

Go, Swift and Rust come to mind. Some alternative JVM languages aren't doing too badly either.

Swift is very much an Apple language, replacing Objective-C. You won't see it replacing JavaScript, PHP, Python, or Ruby.

Same for Rust, which mostly replaces C++ and a bit of C. Maybe some Java, too, for people using Java for the safety despite really wanting something lower level.

IMHO Go isn't much competition to most popular dynamic languages, but some people disagree.

Re: Have Static Languages Won?

#89
post #61

No, they didn't. This article is narrow minded and prejudiced. Of cause if we're talking about programming in general - static typing languages are often a better option. But programming doesn't ends there, there is technical computing, statistical computing, data analysis and so on. How about beating Python + numpy + pandas in data crunching or maybe R in statistics? In this fields underlying data types is almost al…

> How about beating Python + numpy + pandas in data crunching I'd think this sentiment misses a small bit of context. In the above combination, Python is the glue language, which merely makes it easy to dispatch the heavy lifting. Numpy is a damn good convenience wrapper around the under-the-hood number crunching engines - which themselves are written in static languages. I mean, have you ever tried to _build_ numpy…

> So, invoking numpy as a testament to power of dynamic languages misses a pretty important point.

I don't think so. People build Numpy in a different language to the one they expose it in because those languages have different strengths.

If Numpy's source languages (including BLAS and LAPACK) were suitable for front-end usage, Python would have never entered the equation.

I think it's more a testament that despite the base libraries being so freely accessible, only dynamic languages have actually built front-ends that people want to use. Even Julia is dynamic.

Re: Have Static Languages Won?

#90
post #71

"Dynamic languages are at a disadvantage. Most of the mainstream ones out there today were designed by amateurs, people with no formal CS background" Patently false. * from Wikipedia Python: Guido van Rossum * Master's degree in mathematics and computer science from the University of Amsterdam * Recognized as a Distinguished Engineer by the Association for Computing Machinery Ruby: Yukihiro Matsumoto * Graduated with…

> Dynamic languages such as PHP, JS, Python and Ruby

Don't forget the other dynamic language frequently mentioned in the article...

PHP: Rasmus Lerdorf graduated in 1993 from the University of Waterloo with a Bachelor of Applied Science in Systems Design Engineering.

But perhaps the author's definition of "mainstream" includes languages of Groovy's degree of adoption.

Post reply on HN