C++ vs Haskell programming language

ok there is a guy on facebook that said
Adam Bilbrough wrote:
I'll introduce Haskell which is a functional language and quite different to other languages like C++. You can do anything in Haskell that you can do with C++ and with less code, less bloat and usually with zero debugging.

But it depends how your brain works, some people just can't 'get it'.


1. do you guys know this programming language?
2. is it true that Haskell can do everything c++ can do?
3. zero debugging? (i don't know what he mean by that)
1. I've heard of it, but never used it

2. Probably. Most languages can do anything other languages can do. It just takes different code.

3. This statement totally decredits him, in my book. Any nontrivial program written in any language will require debugging. He's probably just more familiar with Haskell than he is with C++, so his C++ code has more flaws and therefore requires more debugging. The exact opposite could be true for someone else.
@Disch
thanks for your answer..

btw have you written a book? so i gave it quick google search, and found this http://en.wikipedia.org/wiki/Thomas_M._Disch is that you(the person on wikipedia)?
Last edited on
Agreed on all points with Disch.

Though Haskell is a functional programming language only. C++, being derived from C, is inherently an imperative
language, though C++ is rich enough in itself to also allow functional programming.

The big thing about functional programming languages is that it is easier to prove correctness of algorithms because
you don't really have writable memory; you simply bind values to symbols.

But the trick is that every programmer on the planet started out by using an imperative language--be it BASIC, pascal,
C, Cobol, Assembler, VisualBasic, or whatever--and probably has more experience with them than functional languages.
As a result, most programmers find it easier to write programs in an imperative style than a functional style. Writing
programs using a functional language is a bit of a paradigm shift.

I myself remember the days in college learning about SML (a functional language) and wondering why on earth anyone
would actually want to use a functional language. It just seemed hard, because I was focused on this variable holding
this value, then getting modified, etc, etc.

Nowadays, I'm always looking for ways to make my code more functional in nature because I find it much easier to
write correct code that way. Why? A couple of reasons. 1. functions end up being much smaller (1-2 liners),
meaning it is easier to "see" that they do the right thing. 2. variables (symbols) get initialized with the value they
need to hold, rather than initializing them with some value and "fixing" the value later in the function.

wow I didn't know that terminologies like functional language and imperative language exist so I'm reading about it now. (excuse me for that, I'm not a CS student, I'm a self learner)

again, thanks for your thoughts.
No, I am not Thomas Disch (According to that wikipedia page, he died in 2008 or maybe I was misreading the page? Bah).

Disch isn't my real name, it's a handle I came up with way back in 7th grade before I even had the internets.
Last edited on
Considering Disch is alive now,
Thomas Michael Disch (February 2, 1940 – c. July 4, 2008) was an American science fiction author and poet.

should give you your answer.
haha.. i didn't focus on the dates so i didn't knowhe's dead..

chirsname wrote:
Considering Disch is alive now,
Thomas Michael Disch (February 2, 1940 – c. July 4, 2008) was an American science fiction author and poet.

should give you your answer.
programmer can be a poet at the same time, and he has Career in Computer Game Design (which makes me think he is cplusplus.com Disch)
closed account (z05DSL3A)
He could be a ghost writer....



Sorry for that, momentary laps of...somthing.
He could be a ghost writer....


I laughed
Why is it that functional programming is so often said to produce on average more correct code than imperative programming? Surely merely changing the notation shouldn't change the amount of logical errors by that much.
Also, how do the debugging facilities compare to those oriented to imperative programming?
I just read the half of all posts, so im sorry. But.

I have really much experience with Haskell, since here it is taught from the start in university. Means it is the first programming language you learn in classes.

Since i am used to math, i really gained a lot from Haskell. (there is a real big mathematical aspect to Haskell)

But one thing to make clear: Haskell is really really really slow. It is used in rapid development to develop algorithm (and so you see in competitions mostly functional programming languages like haskell to be used). But the real runtime is horrible, and Haskell never was designed to be fast. It is designed to provide short and clear source code. It is even coming into the economy, but rather slow.

Pretty much everything you can do in C++, you can do in Haskell and it is all functional. (The I/O is cheated, because it is not possible to do this in a functional manner, because you have state of the outside world).

The time i learned Haskell i already had a lot lot of C (not C++) experience and this was helpfull too. Even if it is a totally different thing to write Haskell programs (e.g. you do NOT have any variables, EVERYTHING is recursive - even if it does not seem so) it gave me a deeper insight of the insides and the value of Haskell. Mathematical experiences are not bad, but not needed either.

I really recommend to learn Haskell or an other functional programming language, since it is broaden one's horizont, creating new perspective in it's own programs. (I mean, you can program in C++ in the same recursion way as in haskell, you just dont have the nice lazy evaluation and list facilities. And even for this, im sure there are some libraries.)


Hope, this helped

Maikel


Edit:

You even have a OOP replacement: Types. You can define your own Types, and categorize them in "Classes". A Class means something like an Interface in Java. If a Type has specific properties, it can be registered in a class.
Last edited on
Why is it that functional programming is so often said to produce on average more correct code than imperative programming? Surely merely changing the notation shouldn't change the amount of logical errors by that much.


In any computer program, the "state" of the program is defined by the current values of all the memory locations
used by the program (ie, the variables). The program is in a coherent state if all memory locations contain
correct values. Imperative languages allow you to write code such that the state is not coherent at all times.
For example:

1
2
3
4
void Player::move( int new_x, int new_y ) {
   x = new_x;
   y = new_y;
}


For a brief moment, between the two lines of code, the state of the program is not coherent, because the player
never was at coordinate (new_x, y). He was at (x, y) and moved instantaneously to (new_x, new_y).

In functional languages, this isn't really possible since neither x nor y can be changed; rather, you can create a
new player at the new location.
My $0.02:

1. Yes.
2. No. (Not without some extension -- meaning: perhaps someday.)
3. Bunkus. Every program needs debugging.

Some problems are more easily solved with one methodology over another. This isn't any form of reduced "bloat". It is merely a good problem-solution alignment.

@maikel
Haskell isn't necessarily slow -- the Haskell system you were using is just slow (particularly if you are using an interpreted version and especially if you are using Hugs). A proper Haskell compiler can make code that is just as fast as something written in C++, minus overhead.

I can't stand monads.

I heartily second the suggestion to learn a functional language. My preference is Scheme. But Haskell is nice too. (I just don't like it, personally.)

Or Awk.

:-]
closed account (S6k9GNh0)
I don't like either of their syntax patterns. They both bug the utter crap out of me.
Yes, I know they can be Awkward. :-]
Topic archived. No new replies allowed.