Linked by Thom Holwerda on Thu 6th Sep 2012 18:07 UTC, submitted by MOS6510
General Development "Imagine an approach to programming where you write down some description of what your code should do, then before running your code you run some automatic tool to see if the code matches the description. That's Test-driven development, you say! Actually, this is what you are doing when you use static types in most languages too. Types are a description of the code's inputs and outputs, and the check ensures that inputs and outputs match up and are used consistently. Modern type systems - such as in Haskell or above - are very flexible, and allow these descriptions to be quite detailed; plus they are not too obtrusive in use and often very helpful."
Order by: Score:
It's interesting...
by satsujinka on Fri 7th Sep 2012 20:27 UTC
satsujinka
Member since:
2010-03-11

that the other programming related "news" have lots of comments, but this one has none.

I mean Haskell's a great language so I'm surprised there's no dialog here. Is it a demographic thing? Or is the post just too long to form coherent posts?

Reply Score: 2

RE: It's interesting...
by Alfman on Sat 8th Sep 2012 01:20 UTC in reply to "It's interesting..."
Alfman Member since:
2011-01-28

satsujunka,

Having tried haskell (along with prolog), I have to say it is way ahead of it's time. It is truly in a league of it's own.

algebra : calculus :: C++/Pascal/Java/... : Haskell


In a conventional language, I'd have the write the specific algorithm to solve a problem. In Haskell, I can write the relationships and constraints of the answer I want, but then it's up to the language to find a way to reach the answer. Many functions can be evaluated forwards and backwards.

It requires a radical shift in thinking, which is probably why it's not been popular. Several generations down the line though I hope we'll see more languages adopting the Haskell approach programming, emphasising the "what" instead of the "how".

Reply Score: 3

RE[2]: It's interesting...
by satsujinka on Sat 8th Sep 2012 02:57 UTC in reply to "RE: It's interesting..."
satsujinka Member since:
2010-03-11

Except Haskell really doesn't require too much of a change in thought patterns (especially if you've encountered other functional languages.) You don't have to use type annotations. You don't have to understand monads and arrows. You have to deal with immutability, but the concept isn't foreign (pretty much all languages have a notion of constants.) There's even 'do' notation that's basically an imperative language.

I think the thing that gets a lot of people is that functional languages are largely math based. For some reason that scares people, when it really should be viewed as a good thing. And in many ways it is, after all if you came out with a new language today and said it didn't have first class functions... you'd probably be laughed at.

Reply Score: 2

RE[3]: It's interesting...
by Alfman on Sat 8th Sep 2012 04:43 UTC in reply to "RE[2]: It's interesting..."
Alfman Member since:
2011-01-28

My memory must be failing me because I thought haskell supported lazy evaluation and solving problems using automatic variable enumeration with constraints. Quite the contrary haskell requires all variables to hold exact values from their instantiation. Therefore it seems you are right that haskell is another functional language. Prolog is the language that requires a completely different way of thinking about algorithms, but I forget what other language it was similar to... oh well that's what happens when there are too many languages to keep track of - they all blur together.

Reply Score: 2

RE[4]: It's interesting...
by satsujinka on Sat 8th Sep 2012 05:32 UTC in reply to "RE[3]: It's interesting..."
satsujinka Member since:
2010-03-11

Haskell is lazily evaluated.

Reply Score: 2

RE[5]: It's interesting...
by Alfman on Sat 8th Sep 2012 06:25 UTC in reply to "RE[4]: It's interesting..."
Alfman Member since:
2011-01-28

I was really referring to the lazy evaluation as it applies more specifically to prolog. In typical languages (and haskell) a variable can only hold one value (the value may be a list, but it's never the less discrete). In prolog a variable can hold all possible values at the same time and you need to add criteria to get to the values that you want. If you evaluate prolog variables at some intermediate points, it might produce an infinite number of possible values. However due to lazy evaluation, the language is able to do algebraic manipulation against sequence generators INSTEAD of attempting to test each possible discrete value. In other languages where a variable cannot represent more than one value, this doesn't really come up (whether the value is computed from a lazily evaluated function or not).

It's really been a long time since I've worked with prolog, I'd have to go research it some more. It really is a fundamental change in the way we think of algorithms.

Reply Score: 2

RE[2]: It's interesting...
by zima on Sun 9th Sep 2012 06:45 UTC in reply to "RE: It's interesting..."
zima Member since:
2005-07-06

I can write the relationships and constraints of the answer I want, but then it's up to the language to find a way to reach the answer. [...]
It requires a radical shift in thinking, which is probably why it's not been popular. Several generations down the line though I hope we'll see more languages adopting the Haskell approach programming, emphasising the "what" instead of the "how".

Asking as a mostly layman: could that be the closest thing we have to the mythical / fantasy / cargo cult scifi standard of "Computer! Do [one thing] and [some different thing]!" commands? ;p

Reply Score: 3

RE[3]: It's interesting...
by Alfman on Sun 9th Sep 2012 18:12 UTC in reply to "RE[2]: It's interesting..."
Alfman Member since:
2011-01-28

Haha, well part of the problem is that while computers are good at running commands, those commands have to be preprogrammed and are very literal.

I'd argue an unprogrammed human is equally incapable of executing commands, but the human has the capacity to learn dynamically from the environment. As we execute commands, the steps become ingrained. It's like a new job in something new, even if you are smart you are going to look like a baboon until the programming sets in.

The show "Undercover Boss" is hilarious because you see how incompetent company CEOs are starting out from the bottom of their company.

http://www.youtube.com/watch?v=8BAqimE2Dxg


If we want to give commands more naturally to computers, we'll probably have to expect alot of failures in the field and allow the computers to learn from their own mistakes just like a human would.

Reply Score: 2

not just Haskell
by feydun on Sat 8th Sep 2012 04:36 UTC
feydun
Member since:
2012-02-27

But it's not an article about Haskell. If, like me, you know Haskell only vaguely and can't follow some of the examples it's still a very interesting read.
It's primarily about the power of types, how you can use them to provide some of the functionality of test-driven development and make programs more declarative and thus leave less room for bugs.

Like many people from a scientific computing background, I tend to care a lot about performance and don't mind if that means not writing in a very high level language. The irony is that in practice I spend much longer developing and debugging programs than executing them, and that's not even taking into account that while a calculation is running I can use my time on something else.
As the article shows, one aspect of high-level languages is that the higher degree of abstraction means you can express more about what you expect from the program, the point being that you'll spend less time tearing your hair out while explaining to an obtusely infuriating machine what you really meant to say.

Reply Score: 3