Re: [Haskell-cafe] Very silly

Juan Carlos Arevalo Baeza wrote:
Andrew Coppin wrote:
Some guy told me that templates are "the best feature in the language", and proceeded to show me a huge chunk of highly complex-looking code which is approximately equivilent to
join :: Array x -> Array x -> Array x
I was unimpressed.
Now I'm curious to know what chunk of code he showed you. FWIW, that declaration you put there is done in C++ like so:
template < typename X > Array<X> join(Array<X> const&, Array<X> const&);
Nothing more. I like both languages for very different reasons. C++ for its insane amount of flexibility, and Haskell for its expressiveness. And I've encountered equally harsh roadblocks in both whenever I try to get "too crazy" while using them.
Well no, he included the implementation as well as just the signature.
Actually, that's a lie. I was impressed that such a low-level language could manage even that much abstraction. But I still prefer the Haskell way...
The dynamic range of the C++ language is probably unparalleled. In particular, templates enable implementing high level abstractions in a way such that we're still discovering how far it can go. But of course, it's not just templates: it's templates when united to all other language features like overloading.
C++ has some interesting ideas. I haven't learned how to use templates yet, but what I do find interesting is that there is no automatic memory management, and yet you can still do fairly dynamic programming. I've never seen any other language that allows this. (I had assumed it's impossible...) This makes me wonder just now necessary GC really is, and whether there is some way to avoid it...

Hallo, Andrew Coppin wrote:
C++ has some interesting ideas. I haven't learned how to use templates yet, but what I do find interesting is that there is no automatic memory management, and yet you can still do fairly dynamic programming. I've never seen any other language that allows this. (I had assumed it's impossible...) This makes me wonder just now necessary GC really is, and whether there is some way to avoid it...
Garbage collection was invented by Lisp implementors because of a common pattern in functional languages: The sharing of parts of structures, like lists. In an imperative world this is straightforward, one allocates a linked list, uses it, and then releases the memory. In a world full of closures that may have captured parts of your list, manual memory management is near impossible. -alex http://www.ventonegro.org/

asandroq:
Hallo,
Andrew Coppin wrote:
C++ has some interesting ideas. I haven't learned how to use templates yet, but what I do find interesting is that there is no automatic memory management, and yet you can still do fairly dynamic programming. I've never seen any other language that allows this. (I had assumed it's impossible...) This makes me wonder just now necessary GC really is, and whether there is some way to avoid it...
Garbage collection was invented by Lisp implementors because of a common pattern in functional languages: The sharing of parts of structures, like lists. In an imperative world this is straightforward, one allocates a linked list, uses it, and then releases the memory. In a
This is why memory management is a notoriously trivial problem in C++ ;) -- Don (who thinks that complicated access patterns aren't unique to FP)

Not that I want or need to defend C++ on this list, but reference-counted smart pointers (e.g. boost::shared_ptr<>), embedded inside copy-on-write proxy classes, largely simulates eager garbage collection. Targeted overriding of the new operator can make this lazier for efficiency. In other words, there are well established idioms in most successful languages to solve obvious problems. Haskell's strengths are more in making these idioms simple and robust enough for the average user, not just the guru, and to make difficult or impossible the misuse of unsafe idioms. Dan Don Stewart wrote:
asandroq:
Hallo,
Andrew Coppin wrote:
C++ has some interesting ideas. I haven't learned how to use templates yet, but what I do find interesting is that there is no automatic memory management, and yet you can still do fairly dynamic programming. I've never seen any other language that allows this. (I had assumed it's impossible...) This makes me wonder just now necessary GC really is, and whether there is some way to avoid it...
Garbage collection was invented by Lisp implementors because of a common pattern in functional languages: The sharing of parts of structures, like lists. In an imperative world this is straightforward, one allocates a linked list, uses it, and then releases the memory. In a
This is why memory management is a notoriously trivial problem in C++ ;)
-- Don (who thinks that complicated access patterns aren't unique to FP) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Alex Sandro Queiroz e Silva
-
Andrew Coppin
-
Dan Weston
-
Don Stewart