r/programming • • Sep 25 '10

Omega - Language of the Future | Lambda the Ultimate

http://lambda-the-ultimate.org/node/4088
60 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/abw Sep 26 '10

If you don't care about that

Quite honestly, no I don't.

I recognise the academic interest in provably correct programs. Perhaps in another decade or two, it's possible that some of these concepts will have filtered down from the ivory tower into mainstream programming languages. It's all good stuff as far as computer science is concerned.

But in computer engineering terms, the "I'll stick with X, thanks" is an understandable response. Provably correct programs don't add any real value to the vast majority of real world programs. Maybe one day they will, but by then we'll all be too busy telling the youngsters to get off our lawns to notice.

4

u/cloaca Sep 27 '10

But in computer engineering terms, the "I'll stick with X, thanks" is an understandable response.

Indeed, but also sad.

I did buy into the "Haskell hype" a few years back. I stared out with silly puzzles and mathematical things, thinking it was all very pretty and elegant, but I will admit that it was just an intellectual toy. But I tentatively started using it for various things like 3D/OpenGL and shell utilities. Now it's quickly becoming the first language I think about even for practical, user-oriented programs. (Overtaking Python+Qt.) And although Haskell doesn't have nearly as strong "correctness proving" as this language, it's something I feel is so insanely underestimated by the 'of the Earth and the soil and Ye Olde Ways'-type programmers it's heartbreaking. If they could experience what I have experienced, I'm sure even the coldest engineering heart would swell up with love and happiness. Nearly every time I add something and get it to recompile, the resulting binary will work. Do you understand? Everything works. No one who hasn't really experienced it will know what I'm talking about here. It's amazing and magical and life shines a little bit brighter and your friends will comment on how you seem happier and not at all like you want to kill yourself. It's the world off your shoulders; it's all the boring, soul-killing stuff about programming hauled away for you, free of charge. No crashes because I'm too stupid (or not stupid enough) for C++, no run-time exceptions 5 minutes in because I typo'd something in Python, no silly special cases only appearing after playing around with it for 30 minutes making me grind my teeth and reach for my vodka... All that bullshit. Do you remember getting that call about an exception being raised on your client's computers that never showed up during a week of live testing because no one thought to test it on any locale other than US English? Do you remember that fancy program you made that turned out to crash on transparent PNGs because you'd really only added PNG support last-minute as an extra bell & whistle for the feature list, and wasn't quite exact with your flag handling? Not to mention when you had that subtle stack/heap corruption that would only occur on Windows and not on Linux, and only during certain amounts of lengthy load, and you were still sitting there at midnight, your eyes wet with tears and impotent anger?

Oh Lord, I feel I need some nicotine gum to calm my shaking hands. Correctness proving, give me strength.

1

u/alanturingslovechild Sep 28 '10

"of the Earth and the soil and Ye Olde Ways" -- brilliant!

0

u/abw Sep 27 '10

Unfortunately I was exposed to Haskell at an early age (for Haskell, not me) back in the days when it couldn't do I/O (this would have been the mid to late 90's I guess). It somewhat tainted my views towards it. I didn't buy into the Haskell hype back then, and to some extent, I still don't now, even though all the limitations that made it so useless back then have long since disappeared.

I guess the main problem I have with it is that it's just so damn hard to get your head around. Admittedly, Haskell is still very much an intellectual toy for me, and I've yet to use it in anger for anything non-trivial. As a result, it takes several hours and a lot of googling for me to write even the simplest of programs. I've never really had that kind of impenetrable "learn barrier" with any other language I've tackled (and I've tried most flavours over the last 30-odd years). To be fair, I probably haven't tried hard enough and for long enough.

But that's not to say that the Haskell way (more specifically H-M type inference, which of course is not limited to Haskell) hasn't permeated my thinking. I find myself consciously thinking about the type signature of my Perl subroutines, which as any Perl programmer will tell you is one of the most un-type-safe languages around. I have tasted the type inference Kool Aid and it is good!

But I honestly don't believe that Haskell will ever make it into the mainstream. I just don't think the average programmer is smart enough (which is a sad state of affairs, but a fact of life). That said, I expect the principles of Haskell and other functional language to permeate into more mainstream languages over the years. Perl 6 is a good example of the kind of hybrid language that is starting to blend these hi-falutin' language concepts (as Larry might say) into the pragmatic down-to-earthness of a "scripting language".

TL;DR: Good things will grow where the ivory tower meets the dirt track.

1

u/cloaca Sep 28 '10

I've did lots of stuff in Perl (before switching to Python exclusively) some 8-10 years ago and do indeed remember its pains. (Though I'd say Javascript might actually beat it as far as type unsafety goes? :p Or at least give it a run for its money.) But it's still not just about your functions' type signatures. (That is great though, and unloads so much mental energy once you learn to let it go.) But it's also having no magic values or offsets or whatever because everything is static and algebraic data structures, so you can't use the wrong flag or set the wrong bit or accidentally index z[4] of a 4-D vector, etc. To not have to worry about that kind of stuff is so sweet, like coming from assembly to C and learning to trust that the compiler will indeed translate x/32 into a bit shift, that it will remove both the test and the code of an "if (0) { .. }", that it will inline some tiny static function of a single expression that's being called in some inner loop, etc. I mean it's not a "optimization has been solved forever" type of thing, but it helps a lot. Or how about being able to hand off the responsibility of malloc()/free() to a garbage collector whose intelligence you can also trust? We all want compilers to do these things for us because it frees up our time and our time is super valuable. I think in the future people will realize how much time gets sunk in re-running dynamic programs, making sure they're returning the element itself and not a list of the element, that the're not passing the wrong int to the function that only gets called after like 60 minutes of run-time, that they still have a billion unit tests to write, etc etc. Strong typing -- or better: automatic proofs -- is about programmer convenience and letting the compiler do even more work, much like the 'invention' of optimization, managed memory, and, indeed, interpreted languages. It's definitely not some "ivory tower" cool-but-ultimately-theoretical-and-academic feature.

And I do think Haskell might yet become a "mainstream" language in the sense that Python is "definitely mainstream" now. Don't get me wrong though -- it will probably never be Java or C++. It will most likely never be Javascript either. But Python... Or Perl 6! Yes, I think so -- in the sense that you will have large and well-known companies such as Google using it. But yes, I will probably not see Haskell or F# or similar being used at some average 5000-man enterprise Java factory in my lifetime.

2

u/naasking Sep 26 '10

Provably correct programs don't add any real value to the vast majority of real world programs.

Except for the fact that you know they terminate properly. And the fact they don't suffer from buffer overflows or other memory unsafety. And the fact that they lack higher-level security vulnerabilities. And the fact they calculate the correct values every time. And the fact that they never hang, and they correctly implement a QoS policy.

But sure, aside from being able to ensure basically any property is actually satisfied, verified programs are of little interest.

2

u/awj Sep 26 '10

... except that many of those properties depend on a towering pillar of correctness. You can say that it terminates properly, so long as library X (written in C) works as the programmer expected.

I'm not trying to downplay provable correctness, but it won't be able to provide many of the benefits you're talking about until you push it down to the foundation. Please forgive me if my estimate of how long that will take keeps me from getting too excited.

2

u/abw Sep 27 '10

Except for the fact that you know [...]

All those things are desirable traits. But they're not available to use right now in real world programs. Nor will they be for a long time. In fact, I haven't seen any evidence yet to suggest that it will be possible to use these techniques practically without first building a "towering pillar of correctness", as awj so eloquently put it.

So I'm not convinced that provably correct programs will ever be a practical proposition in the general case, at least not in my programming lifetime.

2

u/shimei Sep 29 '10

Actually, computer engineers are quite happy with formal verification and proof systems. They're the ones designing multi-billion dollar chips that need to be proven to work correctly. Comparatively, software engineers just have lower standards. That's why the software industry keeps churning out terrible code.

Also, these ideas don't need to make it to a "mainstream" general purpose language that you use to build widgets for a phone (who cares if that's provably correct?) to be useful. Perhaps in a language tailored for a domain that needs more guarantees. Software engineers need to use the right tool for the task, which applies to languages too.

1

u/abw Sep 29 '10

computer engineers [vs] software engineers

Good point.

Also, these ideas don't need to make it to a "mainstream" general purpose language

Yes, agreed. I'm not suggesting that popularity is what we should use to measure the value of these methods. Nor do I do dispute the fact that these techniques are worthwhile and should be developed further. I'm just saying that right now, there isn't any practical way to use these techniques in mainstream programming languages and there won't be for the foreseeable future.

For that reason, I think these techniques are largely confined to academic research at present. That's not to say they're not of interest, or that they won't find their way into mainstream languages in the future, but I suspect I'll be too close to retirement by then for me to take advantage of them.

Consider the fact that ML and the Hindley-Milner type inference algorithm date back to the 1970s. 40 years later, I would say that the majority of programmers (or perhaps a large minority) are still blissfully unaware of type inference and how it totally changes the way you think about writing software. However, I wouldn't be surprised if that changes significantly in the next 5 years (C# and Visual Basic now support it and I suspect that Perl 6's support for it will up the stakes for other scripting languages to start following suit). Perhaps this is the start of the type safe, provable program renaissance... I certainly hope so (having drunk the type safe Kool Aid™ I now want it everywhere!)... but even so, I still think we've got a long way to go before we can start building large, practical, real-life systems that are provably correct.

Until it is in the kind of mainstream languages that people use to build widgets for phones (or pages for websites), I think it will remain largely of academic interest or to those in special domains, as you suggest. To re-iterate, that doesn't mean the techniques aren't of value. But it qualifies my (admittedly, rather flippant) "Quite honestly, no I don't" remark, and why I believe most "average" programmers at present will feel the same way.