caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OCaml compared as a scripting language
@ 2004-06-14  9:52 Richard Jones
  2004-06-14 15:55 ` Brian Hurt
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Jones @ 2004-06-14  9:52 UTC (permalink / raw)
  To: caml-list

It may interest people to know that OCaml was compared to other
computer languages for scripting:

http://merd.sourceforge.net/pixel/language-study/scripting-language/

It comes out somewhere in the middle.  A file utils library and extlib
could help.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
http://www.YouUnlimited.co.uk/ - management courses

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-14  9:52 [Caml-list] OCaml compared as a scripting language Richard Jones
@ 2004-06-14 15:55 ` Brian Hurt
  2004-06-14 16:29   ` Richard Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Brian Hurt @ 2004-06-14 15:55 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

On Mon, 14 Jun 2004, Richard Jones wrote:

> It may interest people to know that OCaml was compared to other
> computer languages for scripting:
> 
> http://merd.sourceforge.net/pixel/language-study/scripting-language/
> 
> It comes out somewhere in the middle.  A file utils library and extlib
> could help.

This is because Ocaml isn't a scripting language.  The only reason it does 
as well as it does is because it's a clearly superior language to it's 
competitors- C++, Java, C#, etc.  :-)

I disbeleive that any language can be the one perfect language for all 
tasks.  While I'd like to see a fileutils package and, of course, I'm a 
submitter to extlib, I don't want to see Ocaml start being contorted in 
order to improve it as a scripting language, and thereby making it a less 
usefull applications language.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-14 15:55 ` Brian Hurt
@ 2004-06-14 16:29   ` Richard Jones
  2004-06-15  6:40     ` Florian Hars
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Jones @ 2004-06-14 16:29 UTC (permalink / raw)
  Cc: caml-list

Sure.  I think it's pretty cool that an application language does
relatively well as a scripting language, when it plainly wasn't
designed to do that.

I think it'd be possible to assemble a very capable scripting language
without affecting the core language at all.  "OCamlScript" would be:

* normal OCaml
+ Regexp/OCaml (a Camlp4 extension, modified to use pcre)
+ File utilities module
+ ExtLib
+ a bunch of helper functions which I've been writing (eg. slurp
  all lines of a file into memory in various ways) - some of this
  is in ExtLib.

It might also make sense to add some operators using Camlp4 for
handling files.  eg. I've always thought it's a crying shame that you
can't write to a file in Perl using 'command >filename'.  You could
actually _do_ something like that in OCaml + Camlp4, which could be a
real timesaver.

This would be an interesting project for someone ...

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
'There is a joke about American engineers and French engineers. The
American team brings a prototype to the French team. The French team's
response is: "Well, it works fine in practice; but how will it hold up
in theory?"'

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-14 16:29   ` Richard Jones
@ 2004-06-15  6:40     ` Florian Hars
  2004-06-15 16:13       ` Bruno.Verlyck
  0 siblings, 1 reply; 17+ messages in thread
From: Florian Hars @ 2004-06-15  6:40 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

Richard Jones wrote:
> I think it'd be possible to assemble a very capable scripting language
> without affecting the core language at all. 

Isn't this what cash is about (minus the regexp stuff and the camlp4 sugar)?
http://pauillac.inria.fr/cash/

Yours, Florian

-- 
Dr. Florian Hars                   |
BIK ASCHPURWIS + BEHRENS GmbH      |  Büro, papierloses (n):
Feldbrunnenstr. 7, 20148 Hamburg   |    Büro, in dem große Haufen Papier
(040) 41 47 87 -21, Fax: -15       |    lose herumliegen       (FdI#321)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15  6:40     ` Florian Hars
@ 2004-06-15 16:13       ` Bruno.Verlyck
  2004-06-15 17:15         ` Richard Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Bruno.Verlyck @ 2004-06-15 16:13 UTC (permalink / raw)
  To: hars; +Cc: rich, caml-list

   Date: Tue, 15 Jun 2004 08:40:46 +0200
   From: Florian Hars <hars@bik-gmbh.de>

   Richard Jones wrote:
   > I think it'd be possible to assemble a very capable scripting
   > language without affecting the core language at all.
   Isn't this what cash is about (minus the regexp stuff and the camlp4 sugar)?
Yes, that was my intent.
   http://pauillac.inria.fr/cash/
Thanks for the hype!

Now that I'm at it...

On Mon, 14 Jun 2004, Richard Jones wrote:
> It may interest people to know that OCaml was compared to other computer
> languages for scripting:
>  http://merd.sourceforge.net/pixel/language-study/scripting-language/
> It comes out somewhere in the middle.
Of course Cash would score somewhat higher than OCaml, if only because
it can get the script on the command line :-).

Anyway, all those language comparisons are always biased; is `program
length' a good measure of scripting capacity ?  It turns the
comparison into a shortest script challenge, doesn't it ?

Bruno.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 16:13       ` Bruno.Verlyck
@ 2004-06-15 17:15         ` Richard Jones
  2004-06-15 17:35           ` John Goerzen
                             ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Richard Jones @ 2004-06-15 17:15 UTC (permalink / raw)
  Cc: caml-list

On Tue, Jun 15, 2004 at 06:13:23PM +0200, Bruno.Verlyck@inria.fr wrote:
> Anyway, all those language comparisons are always biased; is `program
> length' a good measure of scripting capacity ?  It turns the
> comparison into a shortest script challenge, doesn't it ?

Actually it's not a bad measure.  One of the reasons I prefer Perl
over Java, and OCaml over Perl, is verbosity.  On a scale of length of
programs:

OCaml < Perl <<<<<<< Java

In fact I don't think I've ever seen anything as horribly verbose (and
useless) as Java.  COBOL perhaps?

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
http://www.YouUnlimited.co.uk/ - management courses

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 17:15         ` Richard Jones
@ 2004-06-15 17:35           ` John Goerzen
  2004-06-15 18:16             ` Karl Zilles
  2004-06-16  2:12             ` skaller
  2004-06-15 17:41           ` Jon Harrop
  2004-06-15 17:42           ` William D. Neumann
  2 siblings, 2 replies; 17+ messages in thread
From: John Goerzen @ 2004-06-15 17:35 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

On Tue, Jun 15, 2004 at 06:15:35PM +0100, Richard Jones wrote:
> On Tue, Jun 15, 2004 at 06:13:23PM +0200, Bruno.Verlyck@inria.fr wrote:
> > Anyway, all those language comparisons are always biased; is `program
> > length' a good measure of scripting capacity ?  It turns the
> > comparison into a shortest script challenge, doesn't it ?
> 
> Actually it's not a bad measure.  One of the reasons I prefer Perl
> over Java, and OCaml over Perl, is verbosity.  On a scale of length of
> programs:
> 
> OCaml < Perl <<<<<<< Java
> 
> In fact I don't think I've ever seen anything as horribly verbose (and
> useless) as Java.  COBOL perhaps?

My experience has been that OCaml is a lot more verbose than Perl.  For
instance, to output an integer to a file, I'd have to do:

fprintf fd "%d\n" theint;

or

output_string fd ((string_of_int theint) ^ "\n");

Python:
print theint

Perl:
print FD "$theint\n";

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 17:15         ` Richard Jones
  2004-06-15 17:35           ` John Goerzen
@ 2004-06-15 17:41           ` Jon Harrop
  2004-06-15 17:42           ` William D. Neumann
  2 siblings, 0 replies; 17+ messages in thread
From: Jon Harrop @ 2004-06-15 17:41 UTC (permalink / raw)
  To: caml-list

On Tuesday 15 June 2004 18:15, Richard Jones wrote:
> On Tue, Jun 15, 2004 at 06:13:23PM +0200, Bruno.Verlyck@inria.fr wrote:
> > Anyway, all those language comparisons are always biased; is `program
> > length' a good measure of scripting capacity ?  It turns the
> > comparison into a shortest script challenge, doesn't it ?
>
> Actually it's not a bad measure.  One of the reasons I prefer Perl
> over Java, and OCaml over Perl, is verbosity...

This may be a crazy idea, but is there any formal work on automatically 
factoring higher-order functions out of OCaml programs?

I'm thinking along the lines of a tool which could point out when your code is 
unnecessarily redundant and recommend a common function which could be 
factored out. This seems to be much more interesting in the presence of 
HOFs...

The nearest thing I can think of is in-compiler optimisations like CSE.

Cheers,
Jon.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 17:15         ` Richard Jones
  2004-06-15 17:35           ` John Goerzen
  2004-06-15 17:41           ` Jon Harrop
@ 2004-06-15 17:42           ` William D. Neumann
  2 siblings, 0 replies; 17+ messages in thread
From: William D. Neumann @ 2004-06-15 17:42 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

On Tue, 15 Jun 2004, Richard Jones wrote:

> OCaml < Perl <<<<<<< Java
>
> In fact I don't think I've ever seen anything as horribly verbose (and
> useless) as Java.  COBOL perhaps?

Mmmmm... now you're bringing back the memories.  Yeah, I think COBOL
pretty much has to rank as one of the least dense programming languages
out there (not counting fringe stuff like unlambda) -- especially if you
go all "hardcore" and type things like MULTIPLY A BY B GIVING C. instead
of C = A * B.

Heh.  COBOL was fun.

William D. Neumann

---

"Well I could be a genius, if I just put my mind to it.
And I...I could do anything, if only I could get 'round to it.
Oh we were brought up on the space-race, now they expect you to clean toilets.
When you've seen how big the world is, how can you make do with this?
If you want me, I'll be sleeping in - sleeping in throughout these glory days."

	-- Jarvis Cocker

Think of XML as Lisp for COBOL programmers.

	-- Tony-A (some guy on /.)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 17:35           ` John Goerzen
@ 2004-06-15 18:16             ` Karl Zilles
  2004-06-15 19:23               ` John Goerzen
  2004-06-16  2:12             ` skaller
  1 sibling, 1 reply; 17+ messages in thread
From: Karl Zilles @ 2004-06-15 18:16 UTC (permalink / raw)
  To: John Goerzen; +Cc: Richard Jones, caml-list

John Goerzen wrote:
> My experience has been that OCaml is a lot more verbose than Perl.  For
> instance, to output an integer to a file, I'd have to do:
> 
> fprintf fd "%d\n" theint;

vs.

> print FD "$theint\n";

Wow!  That's 4 extra characters!

I've ported several thousand-line perl scripts to OCaml.  My experience 
is that the resulting scripts are about the same size as the original 
scripts.  They're just infinitely easier to maintain.

There is a lot of syntactic sugar in perl (especially for i/o) that 
makes simple programs very small.  As the program grows more complex, 
the benefits are fewer.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 18:16             ` Karl Zilles
@ 2004-06-15 19:23               ` John Goerzen
  2004-06-15 21:17                 ` Alex Baretta
  0 siblings, 1 reply; 17+ messages in thread
From: John Goerzen @ 2004-06-15 19:23 UTC (permalink / raw)
  To: Karl Zilles; +Cc: Richard Jones, caml-list

On Tue, Jun 15, 2004 at 11:16:44AM -0700, Karl Zilles wrote:
> Wow!  That's 4 extra characters!

It was one example.  Look at the grep example at
http://merd.sourceforge.net/pixel/language-study/scripting-language/#grep
for a much more significant difference.

> There is a lot of syntactic sugar in perl (especially for i/o) that 
> makes simple programs very small.  As the program grows more complex, 
> the benefits are fewer.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 19:23               ` John Goerzen
@ 2004-06-15 21:17                 ` Alex Baretta
  0 siblings, 0 replies; 17+ messages in thread
From: Alex Baretta @ 2004-06-15 21:17 UTC (permalink / raw)
  To: Ocaml

John Goerzen wrote:
> On Tue, Jun 15, 2004 at 11:16:44AM -0700, Karl Zilles wrote:
> 
>>Wow!  That's 4 extra characters!
> 
> 
> It was one example.  Look at the grep example at
> http://merd.sourceforge.net/pixel/language-study/scripting-language/#grep
> for a much more significant difference.

I'm not going to recode grep in Ocaml for any amount of money, but I can 
assure you that the implementation you mention is suboptimal length-wise.

Besides, most other implementations are simply unreadable. A couple more 
lines of code are worth the extra readability in this case.

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 17:35           ` John Goerzen
  2004-06-15 18:16             ` Karl Zilles
@ 2004-06-16  2:12             ` skaller
  1 sibling, 0 replies; 17+ messages in thread
From: skaller @ 2004-06-16  2:12 UTC (permalink / raw)
  To: John Goerzen; +Cc: Richard Jones, caml-list

On Wed, 2004-06-16 at 03:35, John Goerzen wrote:

> fprintf fd "%d\n" theint;
> 
> or
> 
> output_string fd ((string_of_int theint) ^ "\n");
> 
> Python:
> print theint
> 
> Perl:
> print FD "$theint\n";

This is not a fair comparison though: if you need to do lots of
output, which I do in the Felix code generator, you define
abbreviations.

pl (si theint);

which is shorter than the Perl.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 20:07 ` Brian Hurt
  2004-06-16  2:26   ` skaller
@ 2004-06-16 11:00   ` sejourne kevin
  1 sibling, 0 replies; 17+ messages in thread
From: sejourne kevin @ 2004-06-16 11:00 UTC (permalink / raw)
  To: Brian Hurt, OCaml

--- Brian Hurt <bhurt@spnz.org> a écrit : > On Tue, 15
Jun 2004, Hellflame wrote:
> An example of this is implicit sideeffects
> side-effects- something Perl 
> does a lot of.  This is actually an efficiency in
> the small, and it lets 
> you write quick hacks like (if I recall my Perl
> correctly):
> 	while (<>) {
> 		$count += $_;
> 	}
> 
> The equivelent Ocaml code might look something like:
> 
> let sumfile =
> 	let rec loop cnt =
> 		let line, eof =
> 			try
> 				(input_line stdin), false
> 			with
> 				| End_of_file -> "", true
> 		in
> 		if eof then
> 			cnt
> 		else
> 			loop (cnt + (int_of_string line))
> 	in
> 	loop 0
> ;;
> 
> I just quintupled the lines of code there- 3 lines
> to 15 lines.  
> 
> But the problem is that Perl get's in brevity (in
> part) by sideeffects- it 
> sets the (effectively) global and widely used $_
> variable.  If the code 
> got modified to:
> 	while (<>) {
> 		do_something(1, 2, 3);
> 		$count += $_;
> 	}
files can be see as a kind of data for an iterator.
In my personnals libs I have function like :
let fold_lefti f x a =
  let r = ref x in
  for i = 0 to Array.length a - 1 do
    r := f  i !r  a.(i)
  done;
  !r
;;

let file_fold_left fonction result file =
  let r = ref result in
   try while true do r:= fonction !r file done; !r
   with | End_of_file -> !r
;;

...

For the sum I use the second:

 let sumfile name = 
  let cin = open_in name in
  let result =
    file_fold_left (fun r
f->r+int_of_string(input_line f)) 0 cin
  in close_in cin;
    result
;;

and for stdin :

let sumstdin =
  file_fold_left (fun r _->r+(int_of_string
(read_line()) ) ) 0 ()
;;


So if I use my libs ( :-) ) then for the sum in write
only 3 lines too.

kevin


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 20:07 ` Brian Hurt
@ 2004-06-16  2:26   ` skaller
  2004-06-16 11:00   ` sejourne kevin
  1 sibling, 0 replies; 17+ messages in thread
From: skaller @ 2004-06-16  2:26 UTC (permalink / raw)
  To: Brian Hurt; +Cc: Hellflame, Ocaml Mailing List

On Wed, 2004-06-16 at 06:07, Brian Hurt wrote:
> On Tue, 15 Jun 2004, Hellflame wrote:

> 
> Now, the whole situation has reversed.  Ocaml's feature of 
> immutability/functional programming becomes an advantage in the large, 
> while Perl's feature of side effects becomes a disadvantage.

Hmm .. but (a) Perl like most languages can be used
in a functional way to some extent and (b) Ocaml is worse
than Perl, C or C++ or Felix when it comes to side-effects
since there is no syntactic or type system support.

I think the number of constructions needed for a good
programming language are quite small. I also think we
have little idea what they are: clearly we need
a unified account of both functional and stateful
programming perhaps derived by dualising the better
understood functional paradigm. 

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
  2004-06-15 18:27 Hellflame
@ 2004-06-15 20:07 ` Brian Hurt
  2004-06-16  2:26   ` skaller
  2004-06-16 11:00   ` sejourne kevin
  0 siblings, 2 replies; 17+ messages in thread
From: Brian Hurt @ 2004-06-15 20:07 UTC (permalink / raw)
  To: Hellflame; +Cc: Ocaml Mailing List

On Tue, 15 Jun 2004, Hellflame wrote:

I said:
> > I disbeleive that any language can be the one perfect language for all 
> > tasks. 
> 
> I think the Lisp camp would take exception to your comment.  Most of the
> Lisp hackers I know think it is the perfect language for all things and
> is the best language out there.  I tend to regard them as nuts and go
> about my work though.

:-)  Actually, that was a pointed barb at the C++ camp, large numbers of 
whom beleive that C++ is the way, the truth, and the light. although perl, 
python, and ruby fanatics are just as bad.  Both smalltalk fanatics I've 
met had it, as had a large number of Java fanatics.  In days past, I knew 
people who said that about C, Pascal, assembly language, PL/1, and 
FORTRAN.

Let me use PL/1 as an example, as it's less likely to stir up emotions.  
PL/1 was the first language that I know that was explicitly designed to be 
all things to all people.  The problem that developed with PL/1 was that, 
to be all things to all people, it had 18 gazillion features.  Which meant 
that you started getting people programming in different subsets of the 
language not being able to even understand each other's code.

The "modernist" (to use Larry Wall's teminology) theory of programming 
languages arose largely as a reaction to the "pre-modernist" languages 
before them- which share a lot of philosophical with the "post-modernist" 
langauges Wall touts (the most striking of which is untrammelled 
complexity).  At which point the whole debate turns into yet another 
instance of programmers reinventing the wheel (but this time we'll make it 
with four sides, instead of just three!).

Actually, I could argue this is third time around this block.  Consider
"Goto's Considered Harmfull" and procedural programming (which gave rise
to PL/1) was a reaction to the goto-heavy sphagetti programming paradigm, 
which still had adherents into the seventies.  Modernism leads to 
post-modernism leads to post-post-modernism which looks an awful lot like 
the original modernism.

The way to get off this rollercoaster is to realize that efficiency in the
small is not the same as efficiency in the large.  In fact, what may be an
advantage at one level may be a disadvantage at another level.  And that 
therefor efficiency in the large cannot be acheived with a large number of 
efficiencies in the small.

An example of this is implicit sideeffects side-effects- something Perl 
does a lot of.  This is actually an efficiency in the small, and it lets 
you write quick hacks like (if I recall my Perl correctly):
	while (<>) {
		$count += $_;
	}

The equivelent Ocaml code might look something like:

let sumfile =
	let rec loop cnt =
		let line, eof =
			try
				(input_line stdin), false
			with
				| End_of_file -> "", true
		in
		if eof then
			cnt
		else
			loop (cnt + (int_of_string line))
	in
	loop 0
;;

I just quintupled the lines of code there- 3 lines to 15 lines.  

But the problem is that Perl get's in brevity (in part) by sideeffects- it 
sets the (effectively) global and widely used $_ variable.  If the code 
got modified to:
	while (<>) {
		do_something(1, 2, 3);
		$count += $_;
	}

Now if $_ is modified by the function do_something, the whole routine is
broken.  This code and the do_something() routine now have a dependency-
intentional or not- between them.  For small programs (for a sufficiently
loose definition of small), this isn't a problem- just don't do that, or 
handle the interaction.  For large programs, these "unintentional" 
dependencies are more likely to crop up unexpectedly, and be harder to 
track down.  The technical term for these unintentional, unexpected 
interactions is "bugs".

Now, the whole situation has reversed.  Ocaml's feature of 
immutability/functional programming becomes an advantage in the large, 
while Perl's feature of side effects becomes a disadvantage.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Caml-list] OCaml compared as a scripting language
@ 2004-06-15 18:27 Hellflame
  2004-06-15 20:07 ` Brian Hurt
  0 siblings, 1 reply; 17+ messages in thread
From: Hellflame @ 2004-06-15 18:27 UTC (permalink / raw)
  To: bhurt; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

  I disbeleive that any language can be the one perfect language for all 
  tasks. 

I think the Lisp camp would take exception to your comment.  Most of the Lisp hackers I know think it is the perfect language for all things and is the best language out there.  I tend to regard them as nuts and go about my work though.


HFX

[-- Attachment #2: Type: text/html, Size: 949 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-06-16 11:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-14  9:52 [Caml-list] OCaml compared as a scripting language Richard Jones
2004-06-14 15:55 ` Brian Hurt
2004-06-14 16:29   ` Richard Jones
2004-06-15  6:40     ` Florian Hars
2004-06-15 16:13       ` Bruno.Verlyck
2004-06-15 17:15         ` Richard Jones
2004-06-15 17:35           ` John Goerzen
2004-06-15 18:16             ` Karl Zilles
2004-06-15 19:23               ` John Goerzen
2004-06-15 21:17                 ` Alex Baretta
2004-06-16  2:12             ` skaller
2004-06-15 17:41           ` Jon Harrop
2004-06-15 17:42           ` William D. Neumann
2004-06-15 18:27 Hellflame
2004-06-15 20:07 ` Brian Hurt
2004-06-16  2:26   ` skaller
2004-06-16 11:00   ` sejourne kevin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).