
Hello, This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python? To explain where this question is comming from: I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons: 1) Python has a nice IDE-ish thing. It's called "idle". It includes both a shell and an editor. The interface is simple and clear. 2) I can't get Helium to compile (since I can't get ghc to run) on Solaris. 3) Python has some nice introductory documentation. The Haskell documentation is more advanced. 4) She's interested in writing an OOo plugin some day. Python can do that. But I do hesitate. I would like to teach her Haskell because I think it's a better language. But I just don't seem to have the tools to teach it to a complete beginner (idle, documentation). So I'm thinking that perhaps I can use Python, but try to teach her functional principles, like not changing the value of a variable and not letting her functions have side-effects. Given my circunstances, do you think that's a reasonable approach for teaching her how to program? Cheers, Daniel.

Daniel Carrera writes:
I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons:
1) Python has a nice IDE-ish thing. It's called "idle". It includes both a shell and an editor. The interface is simple and clear.
There are others. PyCrust under wxPython etc. Even more under Windows.
4) She's interested in writing an OOo plugin some day. Python can do that.
Plugin FOR WHAT?
So I'm thinking that perhaps I can use Python, but try to teach her functional principles, like not changing the value of a variable and not letting her functions have side-effects.
Given my circunstances, do you think that's a reasonable approach for teaching her how to program?
To teach how to program in a structured way? Yes. To teach how to program functionally? Hm. In a primitive sense, why not, but seriously - no. There are plenty of methods which update in place some objects, say x.append(y), etc. This influences the style, although at the very beginner level you can impose a bit of functionalism. BTW. if your potential pupil is interested in some OO, and you feel some sympathy towards FP, why not try Ocaml? Jerzy Karczmarczuk

karczma@info.unicaen.fr wrote:
Plugin FOR WHAT?
Sorry. OpenOffice.org :-)
To teach how to program in a structured way? Yes. To teach how to program functionally? Hm. In a primitive sense, why not, but seriously - no. There are plenty of methods which update in place some objects, say x.append(y), etc. This influences the style, although at the very beginner level you can impose a bit of functionalism.
Okay. We're talking about an amateur level, nothing big. Cheers, Daniel.

Daniel Carrera wrote:
Hello,
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
Its good for small scripting tasks. Its good for string processing. I find the dynamic typing a pain.
I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons:
Its a great first language for people who aren't interested in making a career of programming.
But I do hesitate. I would like to teach her Haskell because I think it's a better language.
Its a better language for people who either have a computer science background or intend to study computer science. I would not inflict a language like Haskell on someone who just wants to get the job done with as little fuss as possible.
So I'm thinking that perhaps I can use Python, but try to teach her functional principles, like not changing the value of a variable and not letting her functions have side-effects.
For the majority of tasks she is likely to undertake, the above simply doesn't matter.
Given my circunstances, do you think that's a reasonable approach for teaching her how to program?
Teach her Python. If you try and teach her Haskell she will end up programming in visual basic :-). Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "It has been discovered that C++ provides a remarkable facility for concealing the trival details of a program -- such as where its bugs are." -- David Keppel

Erik de Castro Lopo wrote:
Its good for small scripting tasks. Its good for string processing. I find the dynamic typing a pain.
What's dynamic typing?
I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons:
Its a great first language for people who aren't interested in making a career of programming.
But I do hesitate. I would like to teach her Haskell because I think it's a better language.
Its a better language for people who either have a computer science background or intend to study computer science. I would not inflict a language like Haskell on someone who just wants to get the job done with as little fuss as possible.
Thank you for the info, I really appreciate it. I feel better about Python now.
Given my circunstances, do you think that's a reasonable approach for teaching her how to program?
Teach her Python. If you try and teach her Haskell she will end up programming in visual basic :-).
Heh. Cheers, Daniel.

Erik de Castro Lopo wrote:
Its good for small scripting tasks. Its good for string processing. I find the dynamic typing a pain.
What's dynamic typing?
I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons:
Its a great first language for people who aren't interested in making a career of programming.
But I do hesitate. I would like to teach her Haskell because I think it's a better language.
Its a better language for people who either have a computer science background or intend to study computer science. I would not inflict a language like Haskell on someone who just wants to get the job done with as little fuss as possible.
Thank you for the info, I really appreciate it. Very interesting. Cheers, Daniel.

Daniel Carrera wrote:
Erik de Castro Lopo wrote:
Its good for small scripting tasks. Its good for string processing. I find the dynamic typing a pain.
What's dynamic typing?
I can't say it any better than this: http://c2.com/cgi/wiki?DynamicTyping Basically, types are determined at runtime instead of compile time. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp." -- Greenspuns Tenth Rule Of Programming

On 5/10/05, Daniel Carrera
Hello,
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
Python has first class functions and lexical scoping, and encourages higher-order functions, though to a much lesser degree than a real functional language. It has list comprehensions which it stole directly from haskell, and a tab oriented syntax that is somewhat similar to haskell's offside rule but simpler. It is very natural to write in a somewhat functional style, especially in regards to sequence processing: higher order functions and listcomps provide the processing and its built in generators and iterator protocol provide some of the benefits of laziness. Its elementary pattern matching encourages you to return as many values from a function as you need and use zip() (another haskell steal) to iterate over parallel sequences (all pattern matches are irrefutable, though). However, python is definately an imperative language. How much mutable state your objects have depends entirely on programmer discipline. Some built in types are mutable, and it's up to you whether you copy or mutate. Python's "lists" are actually arrays, and recursive car/cdr type stuff is not a natural fit. Python loves a for loop. All that said, it "feels" haskellish to me for some reason. I think teaching python is a reasonable approach. If you are used to using the REPL, writing small functions, and using listcomps and HOFs and not engaging in gratuitous mutation then I don't think haskell will be such a huge jump. Dynamic typing -> static typing and "why do you have to use do {}" is likely to be a bigger issue. I went from haskell to python so my perspective is all backwards though :)

Quinn Dunkan wrote:
Python has first class functions and lexical scoping, and encourages higher-order functions, though to a much lesser degree than a real functional language.
I was surprised to hear about first class functions and higher order functions. So I googled for a bit, and I found something neat: ---<snip>--- # Python implementation of Common Lisp's remove_if def remove_if(predicate, lst): return [elem for elem in lst if not predicate(elem)] print remove_if(lambda x:x % 2, [1,2,3,4,5,6,7,8]) ---<snip>--- This is so cool. So there we have a higher order function, passing a funtion as an argument, and even lambda notation. Neat.
It is very natural to write in a somewhat functional style, especially in regards to sequence processing: higher order functions and listcomps provide the processing and its built in generators and iterator protocol provide some of the benefits of laziness.
Hhhmmm.. I guess the above is also an example of that. [snip: lots of very interesting info I didn't know about] Thank you for all the information. I learned a lot today. I had no idea that Python had these features. Cheers, Daniel.

Daniel Carrera
I had no idea that Python had these features.
Future versions of Python won't have all those features, see: http://lambda-the-ultimate.org/node/view/587 This is specifically about the fabled Python 3000 which will be a backwards compatibility breaking version. Py3k won't happen soon, but it will happen. -- It seems I've been living two lives. One life is a self-employed web developer In the other life, I'm shapr, functional programmer. | www.ScannedInAvian.com One of these lives has futures (and subcontinuations!)| --Shae Matijs Erisson

Daniel Carrera a écrit :
Quinn Dunkan wrote:
Python has first class functions and lexical scoping, and encourages higher-order functions, though to a much lesser degree than a real functional language.
I was surprised to hear about first class functions and higher order functions. So I googled for a bit, and I found something neat:
---<snip>--- # Python implementation of Common Lisp's remove_if def remove_if(predicate, lst): return [elem for elem in lst if not predicate(elem)]
print remove_if(lambda x:x % 2, [1,2,3,4,5,6,7,8]) ---<snip>---
This is so cool. So there we have a higher order function, passing a funtion as an argument, and even lambda notation. Neat.
Well, I would not recommand using lambda functions ! The main reason is they are limited in that they only accept expressions (ie. not statements) and you can end up with very ugly things (mainly because of the lack of if-expressions). Better use local functions for the same goal ! So your example becomes:
def is_even(x): ... return x%2 print remove_if(is_even, [1,2,3,4,5,6,7,8])
Or even better:
def is_even(x): ... return x%2 print remove_if(is_even, xrange(1,9))
And as local functions have lexical closure this is very interesting (much more than lambda).
It is very natural to write in a somewhat functional style, especially in regards to sequence processing: higher order functions and listcomps provide the processing and its built in generators and iterator protocol provide some of the benefits of laziness.
Hhhmmm.. I guess the above is also an example of that.
[snip: lots of very interesting info I didn't know about]
Thank you for all the information. I learned a lot today. I had no idea that Python had these features.
Cheers, Daniel. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68

Pierre Barbier de Reuille wrote about Python and lambdas:
Well, I would not recommand using lambda functions ! The main reason is they are limited in that they only accept expressions (ie. not statements) and you can end up with very ugly things (mainly because of the lack of if-expressions).
Oh! You would *like to have imperative statements within LAMBDA*? Friend, you are in state of mortal sin! I suppose that if somebody decides to use lambdas, he wants to do some functional programming, no? True, there are no conditional expressions. But there are because of the laziness of boolean combinators. This works: (x > y) or 'allez en enfer' Jerzy Karczmarczuk

Hello Jerzy, Wednesday, May 11, 2005, 3:40:51 PM, you wrote: JK> I suppose that if somebody decides to use lambdas, he wants to do some JK> functional programming, no? well, i am use this all the way :) simplified example of one usage: (allocate, shrink) <- memoryAllocator buf size (buf,size) <- allocate 65536 ... shrink buf realsize another example: compress read_f write_f = do buf <- malloc 65536 let go = len <- read_f buf 65536 when (len>0) $ do ... write_f outbuf outlen go go and i find this feature very convenient -- Best regards, Bulat mailto:bulatz@HotPOP.com

Jerzy Karczmarczuk a écrit :
Pierre Barbier de Reuille wrote about Python and lambdas:
Well, I would not recommand using lambda functions ! The main reason is they are limited in that they only accept expressions (ie. not statements) and you can end up with very ugly things (mainly because of the lack of if-expressions).
Oh! You would *like to have imperative statements within LAMBDA*?
Friend, you are in state of mortal sin!
I suppose that if somebody decides to use lambdas, he wants to do some functional programming, no?
True, there are no conditional expressions. But there are because of the laziness of boolean combinators. This works:
(x > y) or 'allez en enfer'
That's not my point ! I'm only saying there is no if-expression ... so you _need_ statements. And if you really want to use lazy boolean operators, you'll end up having very ugly code replacing tests ... Pierre
Jerzy Karczmarczuk
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68

On Wed, 11 May 2005, Jerzy Karczmarczuk wrote:
Pierre Barbier de Reuille wrote about Python and lambdas:
Well, I would not recommand using lambda functions ! The main reason is they are limited in that they only accept expressions (ie. not statements) and you can end up with very ugly things (mainly because of the lack of if-expressions).
Oh! You would *like to have imperative statements within LAMBDA*?
Friend, you are in state of mortal sin!
I suppose that if somebody decides to use lambdas, he wants to do some functional programming, no?
Debatable.
True, there are no conditional expressions. But there are because of the laziness of boolean combinators. This works:
(x > y) or 'allez en enfer'
Yes, and hallelujah, there are other options too -- suppose we define a helper function (because "exec" is also a statement) to execute a compiled code object: def ex(st, env): exec(compile(st, '<string>', 'single'), env) Now we can use this function to compile and execute anything we like from inside the lambda! five = lambda x: ex('if x == 5:\n\tprint "five"\nelse:\n\tprint "not five"', locals()) Donn

On 2005-05-11, Daniel Carrera
---<snip>--- # Python implementation of Common Lisp's remove_if def remove_if(predicate, lst): return [elem for elem in lst if not predicate(elem)]
print remove_if(lambda x:x % 2, [1,2,3,4,5,6,7,8]) ---<snip>---
This is so cool. So there we have a higher order function, passing a funtion as an argument, and even lambda notation. Neat.
Yes, but actually much of that is slated for removal from the Python language in future versions. See http://www.python.org/peps/pep-3000.html

On 27/05/05, John Goerzen
Yes, but actually much of that is slated for removal from the Python language in future versions. See
I still can't believe that Guido will get away with this...

Quinn Dunkan
Python has first class functions and lexical scoping, and encourages higher-order functions, though to a much lesser degree than a real functional language.
It's lexical scoping is limited: - The syntax can be heavy, as you can't embed a function containing statements inside an expression. - Because of implicit variable definitions (and lack of other syntax which could change that) you can't modify variables introduced by outer functions. - Class definitions don't use lexical scoping (definitions introduced in a class body are not visible as unqualified names by their bodies). -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/

Date: Tue, 10 May 2005 19:02:33 -0400 From: Daniel Carrera
Hello,
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
To explain where this question is comming from:
I have a lady friend who wants to learn how to program. I just decided to teach her Python for practical reasons:
1) Python has a nice IDE-ish thing. It's called "idle". It includes both a shell and an editor. The interface is simple and clear.
2) I can't get Helium to compile (since I can't get ghc to run) on Solaris.
3) Python has some nice introductory documentation. The Haskell documentation is more advanced.
4) She's interested in writing an OOo plugin some day. Python can do that.
But I do hesitate. I would like to teach her Haskell because I think it's a better language. But I just don't seem to have the tools to teach it to a complete beginner (idle, documentation).
Trying to teach Haskell to non-programmers is, IMNSHO as someone who teaches programming to very smart kids as my job, a *very* bad idea. It's simply too rich and difficult a language for beginning programmers. The conceptual barriers are formidable even for most experienced programmers, and there are much easier ways to accomplish the goal of learning functional programming (including Haskell), if that's what you want. The sequence I recommend for that is Scheme -> Ocaml -> Haskell, which involves picking up a few new concepts at each stage. You could also go Scheme -> Haskell for very bright and ambitious students. However, Scheme is not currently a very practical language compared to (say) python, and python does contain some functional aspects as well. So python is a decent first language both for practical programming and for would-be functional programmers. I've noticed that most of the hard-core FP types I know also use python occasionally as their imperative language of choice -- it's simply less distasteful than most of the alternatives. Here at Caltech we teach Scheme first (for programming concepts), then students can go in several different directions. Learning java or C is a common next step. Python generally comes after java and C, though it doesn't have to, and most students have no trouble picking it up. Ocaml and Haskell come later, and only a few really hard-core types learn those. Eventually I hope that functional languages will become more mainstream and "practical", because they're just better. But for someone who wants to get a practical language under her belt, starting with Haskell is not the way to go. I have enough problems convincing people to learn Scheme. I've even had people beg me to teach them Matlab as a first programming language, because that is the only language that they needed to get their work done. Telling them that Matlab's programming language is a creeping horror doesn't sway them at all. Mike

Michael Vanier wrote:
I have enough problems convincing people to learn Scheme. I've even had people beg me to teach them Matlab as a first programming language, because that is the only language that they needed to get their work done. Telling them that Matlab's programming language is a creeping horror doesn't sway them at all.
Now, why so? I won't defend the Matlab language too strongly, but I used it for teaching scientific computations, I exploited the vectorized expressions, I used objects, and even a lot of functional constructs. I don't see any reason to call it a creeping horror. It is quite homogeneous and simple, and is decently interfaced. Jerzy Karczmarczuk

Date: Wed, 11 May 2005 07:49:38 +0200 From: Jerzy Karczmarczuk
Michael Vanier wrote:
I have enough problems convincing people to learn Scheme. I've even had people beg me to teach them Matlab as a first programming language, because that is the only language that they needed to get their work done. Telling them that Matlab's programming language is a creeping horror doesn't sway them at all.
Now, why so? I won't defend the Matlab language too strongly, but I used it for teaching scientific computations, I exploited the vectorized expressions, I used objects, and even a lot of functional constructs. I don't see any reason to call it a creeping horror. It is quite homogeneous and simple, and is decently interfaced.
Jerzy Karczmarczuk
It's incredibly inconsistent. To cite just one example, the syntax is geared towards the notion that "everything is a two-dimensional matrices of double-precision floating point numbers". If you want to have a three-dimensional array, you can do that, but the syntax is not going to be nearly as elegant, because matlab's array syntax doesn't scale at all. I haven't used matlab seriously for a few years (thankfully), but I vaguely recall several other instances of the same problem. Basically, matlab makes programming very easy within a very restricted domain, but if you want to go outside that domain, you will have to endure a lot of pain. That is not good language design. In contrast, Mathematica has a pretty consistent and elegant language. Mike

Michael Vanier comments my defense of Matlab:
I used objects, and even a lot of functional constructs. I don't see any reason to call it a creeping horror. It is quite homogeneous and simple, and is decently interfaced.
It's incredibly inconsistent. To cite just one example, the syntax is geared towards the notion that "everything is a two-dimensional matrices of double-precision floating point numbers". If you want to have a three-dimensional array, you can do that, but the syntax is not going to be nearly as elegant, because matlab's array syntax doesn't scale at all.
Come on... Matlab has cells and the full object-oriented layer nowadays. There are short ints, strings, complex numbers, etc. The extensibility is good. The overall consistency is reasonable. Syntax for 3D arrays? Give me one single language where this is natural and immediate. We are 2D readers/writers, our way of presenting information is 2D within a text editor, and similar problems hit everywhere. I used 3D matrices for the image synthesis, for colour image processing, for simulations of physical systems. It wasn't worse, and even better than in many other languages.
I haven't used matlab seriously for a few years (thankfully), but I vaguely recall several other instances of the same problem. Basically, matlab makes programming very easy within a very restricted domain, but if you want to go outside that domain, you will have to endure a lot of pain.
Since you vaguely remember something you are thankfully away from, I believe I can continue to "endure my pain" and I can assure all the other readers of this text from the perspective of somebody who uses Matlab *NOW*, that this "pain" is supportable. Optional smiley. The vectorized "comprehension" expressions are really neat.
In contrast, Mathematica has a pretty consistent and elegant language.
Since I respect others' religions I won't argue. But I hope you don't try to convince us that Mathematica is good at number crunching... Jerzy Karczmarczuk

Jerzy Karczmarczuk
Syntax for 3D arrays? Give me one single language where this is natural and immediate.
I can think of 3: Mathematica, Maple and APL.
But I hope you don't try to convince us that Mathematica is good at number crunching...
For linear algebra, Maple, Mathematica and Matlab all use ATLAS and hardware BLAS (when available). For IVP ODEs, the author of the underlying numerical solver for Matlab and Maple are lead by the same person (Larry Shampine); he has publicly stated that he thinks the one for Maple representes the state-of-the-art [mostly because of access to symbolic differentiation], with the one in Matlab being just a bit behind. Furthermore, for 'structured' matrices (including sparse), there are simple examples where both Mathematica and Maple are arbitrarily faster than Matlab on LU and QR decompositions, as well as Eigenvalue computations. While Mathematica and Maple used to be pathetic at numeric computations, that has changed a lot in the last 5 years. Jacques

Jacques Carette writes:
Jerzy Karczmarczuk wrote:
Syntax for 3D arrays? Give me one single language where this is natural and immediate.
I can think of 3: Mathematica, Maple and APL.
Well, you are the village specialist on Maple here,so I won't argue too long, but kill me, I can't see how Maple makes things more *natural and immediate* than Matlab *in this context*. Maple is rich, there are arrays, Arrays, Matrices (which are *not* multi- dimensional, only two), etc., based on rtables. In which sense rtables are more natural and immediate than multidim matrices in Matlab? Indexing is similar (Maple has a full plethora of adjustable indexing functions, but Matlab can achieve the same with the OO layer). Initialization, hmmm, in Maple there are nested lists, in Matlab it is a bit awkward, but with 'cat' along any dimension this is not so bad. What else? Maple is more rich and more complicated, so it has more potential 'power', but that wasn't my point. Mathematica,... well it has nested lists called Array, or Table, or Matrix (which doesn't seem to be more than 2-dim either). Why this is better than in Matlab? -- ... from a "normal" user perspective if possible. For such a user APL doesn't seem to be a popular option, so let's forget it, although it is a respectable part of history of programming languages. ==========
Furthermore, for 'structured' matrices (including sparse), there are simple examples where both Mathematica and Maple are arbitrarily faster than Matlab on LU and QR decompositions, as well as Eigenvalue computations.
While Mathematica and Maple used to be pathetic at numeric computations, that has changed a lot in the last 5 years.
I would like to see some comparisons. Not that I don't believe you, but Matlab made some progress as well (although all this "progress" is sometimes dubious, with the slowing-down of the interface, regression bugs, etc.; no system is ideal, Maple neither). Jerzy Karczmarczuk

karczma@info.unicaen.fr wrote:
Jacques Carette writes:
Jerzy Karczmarczuk wrote:
Syntax for 3D arrays? Give me one single language where this is natural and immediate.
I can think of 3: Mathematica, Maple and APL.
I can't see how Maple makes things more *natural and immediate* than Matlab *in this context*.
I claim that Maple (and Mathematica) are as natural and immediate as Matlab in the context of 2D arrays and matrices, and that (at least) Maple is more natural for n-dimensional arrays.
Maple is rich, there are arrays, Arrays, Matrices (which are *not* multi- dimensional, only two), etc., based on rtables. In which sense rtables are more natural and immediate than multidim matrices in Matlab? Indexing is similar (Maple has a full plethora of adjustable indexing functions, but Matlab can achieve the same with the OO layer).
You have put your finger on the reason: Maple's indexing into all objects that are an occurence of the family of "rectangular tables" (ie where the implementation data-structure is an rtable even though the abstract type might be Vector or Matrix or ...) is completely uniform, regardless of dimension. In Matlab, you have no such abstract uniform interface - you have to build it yourself. I have not looked too closely, but it appears that Mathematica offers something equivalent to Maple in this regard. Matlab's weakness here is that the implementation (array) and the Abstract Data Type of a matrix are confounded into one. In Maple, these are separate, with proper interfaces. Of course, since it is Maple, users still have 100% access to the underlying implementation, for good or ill. [Talk about initialization options]
Why this is better than in Matlab?
I should have been clearer: I only claim at least as good as Matlab, with definite sub-cases where it is better.
Furthermore, for 'structured' matrices (including sparse), there are simple examples where both Mathematica and Maple are arbitrarily faster than Matlab on LU and QR decompositions, as well as Eigenvalue computations. I would like to see some comparisons. Not that I don't believe you, but Matlab made some progress as well
I don't have the time to get into detailed comparisons - and much to my horror, the internal white papers where lots of the leg work of doing these comparisons were never made public! Here is a benchmark to try: [Creates a random 30000 by 30000 matrix mb but with a banded 30-30 structure, a random 100000 vector v and solves mb*x = b. Timing done on my slow Celeron laptop]
with(LinearAlgebra): N:=30000: (bl,bu):=30,30: mb := RandomMatrix(N,outputoptions=[datatype=float,shape=band[bl,bu]]): v := RandomVector(N,outputoptions=[datatype=float]): infolevel[LinearAlgebra]:=2: st:=time(): LinearSolve(mb,v): time()-st; LinearSolve: "using method" LU LinearSolve: "calling external function" LinearSolve: "CLAPACK" hw_dgbtrf_ LinearSolve: "CLAPACK" hw_dgbtrs_
1.062 [that is 1.062 seconds!] Unless you have 6.8 Gigabytes of main memory on your computer, I would not attempt this in Matlab.
(although all this "progress" is sometimes dubious, with the slowing-down of the interface, regression bugs, etc.; no system is ideal, Maple neither).
All the mathematical systems suffer greatly (Maple included) from such extremely dubious "progress". I find the new Maple interface close to unusable [luckily for me, work on that started after I had left the company ;-) ]. The point I am trying to make is that being able to use extremely complex 'types' (like a Matrix has a band structure) is what allows Maple to beat Matlab. And the proper use of concepts like ADTs and interfaces makes it easy to write uniform code even if the underlying 'type' varies greatly [There are 13 different internal rtable representations in Maple, not counting indexing functions, orientation, type-representation, etc -- but this is invisible to the user]. The big pain with Maple is that it is dynamically typed (this is Haskell-cafe after all!). On the other hand, things like 'this is a banded(30,30) 30000x30000 matrix' still seem to be out of reach of Haskell [because the tricks I have seen to encode numbers into types all make encoding the number 30000 completely unpalatable]. Jacques

On 11/05/05, Jerzy Karczmarczuk
Michael Vanier comments my defense of Matlab:
I used objects, and even a lot of functional constructs. I don't see any reason to call it a creeping horror. It is quite homogeneous and simple, and is decently interfaced.
It's incredibly inconsistent. To cite just one example, the syntax is geared towards the notion that "everything is a two-dimensional matrices of double-precision floating point numbers". If you want to have a three-dimensional array, you can do that, but the syntax is not going to be nearly as elegant, because matlab's array syntax doesn't scale at all.
Come on... Matlab has cells and the full object-oriented layer nowadays. There are short ints, strings, complex numbers, etc. The extensibility is good. The overall consistency is reasonable.
I had to use it a bit for a class and it was *PURE PAIN* beyond the simplest of things.
Syntax for 3D arrays? Give me one single language where this is natural and immediate.
Numerical Python! Yes, the syntax is Python's, but the syntax doesn't really do much of anything unless you use it with Numeric. Anyway, the syntax is quite uniform and general. You can use it for any number of dimensions (including 0!). -- Sam

Samuel Bronson writes about Matlab:
I had to use it a bit for a class and it was *PURE PAIN* beyond the simplest of things.
With my full respect, this is your problem. My students, with some guidance, managed to implement a small automatic differentiation package in it, and they are still alive and happy. Another team worked on physical models of musical instruments, and they finished the project without trying to murder anybody.
Syntax for 3D arrays? Give me one single language where this is natural and immediate.
Numerical Python! Yes, the syntax is Python's, but the syntax doesn't really do much of anything unless you use it with Numeric. Anyway, the syntax is quite uniform and general. You can use it for any number of dimensions (including 0!).
I used NumPy quite recently (with PIL, for image processing; actually this was a pedagogical attempt to reimplement my old Clean package Clastic using a vector language, not a functional one. This worked, moreover NumPy is free.) So I second your good opinion of Numerical Python, although the story of two not-so compatible implementations, the old NumPy (or Numeric) and NumArray is a bit annoying. But why we have used it? BECAUSE it is similar to Matlab, in fact cloned somehow *after it...*, the whole idea of Ufuncs is based on Matlab. So, please, let me keep my previous opinion that it is not easy to find something explicitly better than Matlab or its clones in the discussed context. It is obviously my personal impression, I won't convert anybody, but I will defend my standpoint. Jerzy Karczmarczuk

Date: Wed, 11 May 2005 13:06:51 +0200 From: Jerzy Karczmarczuk
Michael Vanier comments my defense of Matlab:
I used objects, and even a lot of functional constructs. I don't see any reason to call it a creeping horror. It is quite homogeneous and simple, and is decently interfaced.
It's incredibly inconsistent. To cite just one example, the syntax is geared towards the notion that "everything is a two-dimensional matrices of double-precision floating point numbers". If you want to have a three-dimensional array, you can do that, but the syntax is not going to be nearly as elegant, because matlab's array syntax doesn't scale at all.
Come on... Matlab has cells and the full object-oriented layer nowadays. There are short ints, strings, complex numbers, etc. The extensibility is good. The overall consistency is reasonable.
Syntax for 3D arrays? Give me one single language where this is natural and immediate. We are 2D readers/writers, our way of presenting information is 2D within a text editor, and similar problems hit everywhere. I used 3D matrices for the image synthesis, for colour image processing, for simulations of physical systems. It wasn't worse, and even better than in many other languages.
Python: # 2-d array: print a[0][0] # 3-d array: print a[0][0][0] This also applies to most languages, including C. If you like matlab, go right ahead and use it. The same goes for Visual Basic. I could care less what programming languages you use. But if you think matlab is an elegant language, we will have to agree to disagree. And that is the last word I will say on this subject, since this is a Haskell mailing list. Mike

At 19:02 10/05/05 -0400, Daniel Carrera wrote:
Hello,
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
I think it's benefits are neatly summed up by this comment from Tim Berners-Lee, "Python is a language you can get into on one battery": [[ By the way... Python is cool. I had lamented that it ws a long time since I had a practial hacking environment, and Dan Connolly suggested Python as something you could start quickly but which would scale to a large system. One day, 15 minutes before I had to leave for the airport, I got my laptop back out of my bag, and sucked off the web the python 1.6 system and the python tutorial, and a copy of a small notation3 parser Dan had hacked together. I was happy to find that Python is a language you can get into on one battery! I have been happily hacking ever since. I remember Guido trying to persuade me to use python as I was trying to persuade him to write web software! ]] -- http://dev.w3.org/cvsweb/2000/10/swap/Overview.html?rev=1.20 I was using Python for much of my work before I came to Haskell. It took me a long time to learn to use Haskell anything like effectively (partly, but not entirely, because I'd been corrupted by years of imperative programming). I now choose Haskell for my work because its greater formality appeals to me for my desired applications, but I still use Python and would probably choose it for the kind of use you propose. To be a "starter language", I think there needs to be some delineation between the simple, obvious concepts of functional programming and the more advanced notions that are needed to build programming frameworks. (cf. my recent posting referring to a comment by Alan Kay and Smalltalk -- http://www.haskell.org//pipermail/haskell-cafe/2005-May/010020.html). I do think that there's a strong role for functional programming for "non-professional" programmers, but I'm not sure that "raw" Haskell is it. I think the Vital project (http://www.cs.kent.ac.uk/projects/vital/) is an interesting take (at the level of function rather than specifically the visual aspects) but (last time I looked) lacks IO capability.) #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact

Daniel Carrera wrote:
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
I learnt it some years ago to do some simple text processing. Eventually I used it for three small projects. I learnt to hate dynamic typing, I learnt to hate that a forgotten 'return' is interpreted as 'return None', I didn't like that some types were mutable and others not. The documentation is poor due to missing types. Maybe it is due to the documentation (indexing) or because of the module structure, but it is hard to find the functions you need. I found that regular expressions are not of that big help for parsing texts. I missed some support for processing data 'on the fly'. Haskell's laziness makes a great job in this respect. I'm now porting one of my Python projects to Haskell and it is really more fun.

On 2005-05-10, Daniel Carrera
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
I switched from Python to Haskell recently, almost completely. To me, there are two main advantages of Python over Haskell: breadth of available libraries and quality of documentation for beginners. I believe that the Haskell language is better, and I use it even for small scripting tasks -- for which it seems just as well-suited as Python to me. There are, IMHO, two schools of thought regarding how to teach people programming. Some people hold that the best way is to start with a low-level language such as C, and show them how to use pointers, implement linked lists, etc. Others hold that it's better to start with a higher-level language. Python and Haskell are both inappropriate for the former, but could both work for the latter. -- John
participants (19)
-
Aaron Denney
-
Bulat Ziganshin
-
Daniel Carrera
-
Daniel Carrera
-
Donn Cave
-
Erik de Castro Lopo
-
Graham Klyne
-
Jacques Carette
-
Jerzy Karczmarczuk
-
John Goerzen
-
karczma@info.unicaen.fr
-
Lemming
-
Marcin 'Qrczak' Kowalczyk
-
Michael Vanier
-
Pierre Barbier de Reuille
-
Quinn Dunkan
-
Samuel Bronson
-
Shae Matijs Erisson
-
Thomas Davie