Live data from Hacker News

Why static languages suffer from complexity

hirrolot.github.io

301–306 of 306 posts

Re: Why static languages suffer from complexity

#301

Almost all software running the world is written in statically typed languages. This is not by accident or because developers don’t know better. Every few months on HN somebody will make some new claim about why dynamically typed languages are somehow better. But the truth is that statically typed languages have won in the market place for real world software. And I don’t see anything changing that.

The article is about attempting to escape this static vs dynamic dichotomy, not about declaring dynamic languages superior to static ones.

Yes you are right. And I do agree with the author regarding Dependently Typed languages.

Re: Why static languages suffer from complexity

#302
post #12

> I cannot imagine a single language without the if operator, but only a few PLs accommodate full-fledged trait bounds, not to mention pattern matching. This is inconsistency . . . How? > Sometimes, software engineers find their languages too primitive to express their ideas even in dynamic code. But they do not give up . . . Is this a failure of the language, or a failure of the engineer? > If we make our languages…

> > I cannot imagine a single language without the if operator… Production languages (like prolog or make) don’t need an if statement or operator as selection is implicit when a production matches.

I'm not sure I buy your premise -- `make` is a DSL for a very narrow set of problems, and I've never encountered Prolog in production use?

Re: Why static languages suffer from complexity

#303

Earlier quoted context omitted.

Oh, I'll never program in a dynamically typed language again. I'm sold on that. What I'm speaking to is the notion that types are the best model for solving most/all problems in software engineering.

Do people commonly think types are a solution to most or all problems? Other than correctness I am not sure what software engineering problems a type system actually solves, and the rest of the debate is about the expressiveness of the type system (or lack thereof, which forces suboptimal engineering practices in some languages).

> Do people commonly think types are a solution to most or all problems?

There's certainly a subclass of programmers who believe this, yes.

Re: Why static languages suffer from complexity

#304

Earlier quoted context omitted.

>the core reasons why in the vast majority of cases either no specification/documentation exists I feel that is much too pessimistic. >will only cover a small case of the actual specification. If the same applies to proofs: so be it. Don't let perfect be the enemy of good! >For example I would bet money that not a single function in the C, C++, Java and Python standard libraries is fully specified, in the sense of na…

> Take the spec for all sorting algorithms (giving observational equivalence): It's not that simple. You also have to specify the effect set of the algorithm, meaning, assuming we do in place sort: every memory cell other that the input array are unchanged after termination. (If you return a fresh array, you have to specify something related). You also have to specify what happens for general sorting predicates, for…

>It's not that simple. You also have to specify the effect set of the algorithm, meaning, assuming we do in place sort

I implicitly assumed that state would be encapsulated, since after all dependent types are fundamentally incompatible with observable state, but you're right that this is part of the spec. However I have severe doubts about the usability of any specification language that takes more than a one-liner to specify this.

>You also have to specify what happens for general sorting predicates

If you want to admit more general sorting predicates, sure, but normally you'd just allow pure functions.

>The sorting example shows that this largely doesn't work in practise. In my experience for non-trivial programs you tend to have to carry around invariants whose complexity matches the size of the program you are verifying.

If you include lemmas derived from the spec then I'd agree, but then the spec you have to check would still be a lot smaller. If not, then the only specs where I've experienced anything close to this are ones that are just the operational semantics of existing programs i.e. cases where you want to analyze a specific program. Otherwise I'm frankly uncertain as to what even the point of giving a spec would be.

>Haskell and Scala have (local) type-inference. That makes those complex types (somewhat) digestible.

Might make it more tractable to use, but I find my issue is that it's less direct and often obfuscates the meaning.

Re: Why static languages suffer from complexity

#305

Earlier quoted context omitted.

> Take the spec for all sorting algorithms (giving observational equivalence): It's not that simple. You also have to specify the effect set of the algorithm, meaning, assuming we do in place sort: every memory cell other that the input array are unchanged after termination. (If you return a fresh array, you have to specify something related). You also have to specify what happens for general sorting predicates, for…

>It's not that simple. You also have to specify the effect set of the algorithm, meaning, assuming we do in place sort I implicitly assumed that state would be encapsulated, since after all dependent types are fundamentally incompatible with observable state, but you're right that this is part of the spec. However I have severe doubts about the usability of any specification language that takes more than a one-liner…

> doubts about the usability of any specification language that ...

You can extrude hidden state in ML-like languages, which gives rise to all manner of subtle behaviour in combination with higher-order functions. As Pitts, Odersky, Stark and others have shown in the early 1990s, even just the ability to generate fresh names (in ML-like languages, this corresponds to the type Ref(Unit)), in conjunction with higher-order functions gives you essentially all the specification and reasoning problems of state.

> normally you'd just allow pure functions.

This is way too restrictive for non-trivial programs. This restriction work for sorting. And in reality even there you'd run into problem, for example if you take into account that a predicate might throw an exception (which, in practise you cannot avoid, think overflow or taking the head of an empty list).

> the only specs where I've experienced anything close to ...

I think that's because you have not attempted to prove substantial theorems about substantial code. The SeL4 verification is interesting in this context: it's specification (a purely functional specification of the OS behaviour) had, IIRC about 1/3 of the size of the OS's C code. Which is not much of a compression.

Re: Why static languages suffer from complexity

#306

Earlier quoted context omitted.

> But in practice developers misuse features, so adding a feature actually leads to worse code. Is that really a problem on the language's side, though? Devs are capable of mis-using any feature, even extremely basic ones that almost every language has (variable names, for instance (although I'm laughing in FORTH)). Code standards and code reviews are necessary tools in the first place because it doesn't matter what…

> Is that really a problem on the language's side, though? Yes, for a language to be good in practice you need to look at what developers actually do and not how a perfectly rational developer would use the language.

My argument was already predicated on the assumption that developers are imperfect. Please read it again and respond to the actual points I made?
Post reply on HN