* RE: [Caml-list] Interactive technical computing
@ 2007-03-09 13:33 Robert Fischer
2007-03-09 13:49 ` Jon Harrop
2007-03-09 13:54 ` skaller
0 siblings, 2 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-09 13:33 UTC (permalink / raw)
To: caml-list
>> After all, Java and C# aren't intended to be used like that, yet they
>> certainly have wide-spread adoption.
>
> They don't make binary shared libraries
> because the architecture is a virtual machine driven by
> bytecode .. they DO make dynamically linkable bytecode
> libraries.
>
As long as you play within the bounds of their VM. This is no different than Ocaml.
~~ Robert.
-----Original Message-----
From: skaller [mailto:skaller@users.sourceforge.net]
Sent: Thursday, March 08, 2007 6:04 PM
To: Robert Fischer
Cc: caml-list@inria.fr
Subject: RE: [Caml-list] Interactive technical computing
On Thu, 2007-03-08 at 15:26 -0600, Robert Fischer wrote:
> > Putting aside the obvious cultural resistance to using a sensible
> > language for this project, there is one technical hurdle: It needs to
> > compile into a DLL which can be linked to other programs (in C and
> > other languages). I can't generate such code using ocamlopt, at least
> > not without using unsupported out-of-tree extensions.
> >
> I don't think this is a real hurdle to general adoption of a language.
It is in fact an utter and complete show stopper.
I've spent 6 years developing Felix precisely to solve this
problem: a high level language that can generate shared libraries
which can use and be used by other shared libraries.
Ocaml is great for stand-alone programs but a significant
fraction of software development is library building,
and Linux distros such as those based on Debian provide
a library component model which demands dynamic linkage
so the components can be upgraded without end user recompilation.
I expect this will eventually be solved too.
> After all, Java and C# aren't intended to be used like that, yet they
> certainly have wide-spread adoption.
They don't make binary shared libraries
because the architecture is a virtual machine driven by
bytecode .. they DO make dynamically linkable bytecode
libraries.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-09 13:33 [Caml-list] Interactive technical computing Robert Fischer
@ 2007-03-09 13:49 ` Jon Harrop
2007-03-09 13:54 ` skaller
1 sibling, 0 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-09 13:49 UTC (permalink / raw)
To: caml-list
On Friday 09 March 2007 13:33, Robert Fischer wrote:
> > They don't make binary shared libraries
> > because the architecture is a virtual machine driven by
> > bytecode .. they DO make dynamically linkable bytecode
> > libraries.
>
> As long as you play within the bounds of their VM. This is no different
> than Ocaml.
On the contrary, it is very different:
Can you dynamically load code and get native performance? Not with OCaml.
Can you compile to a cross-platform format and keep native performance? Not
with OCaml.
Can you write an interactive environment (top level) and keep native
performance? Not with OCaml.
Can you link to libraries (e.g. OpenGL) and be cross-platform? Not with OCaml
(I think, because you need a custom run-time).
I've got a killer high-performance 2D and 3D visualization library written in
OCaml and I'd like to sell it, but I don't want to sell the source code
because I value it too much. What can I do? Well, I can port it to F# and
sell it there. In the mean time, OCaml users are stuck with GNUPlot.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
2007-03-09 13:33 [Caml-list] Interactive technical computing Robert Fischer
2007-03-09 13:49 ` Jon Harrop
@ 2007-03-09 13:54 ` skaller
1 sibling, 0 replies; 40+ messages in thread
From: skaller @ 2007-03-09 13:54 UTC (permalink / raw)
To: Robert Fischer; +Cc: caml-list
On Fri, 2007-03-09 at 07:33 -0600, Robert Fischer wrote:
> >> After all, Java and C# aren't intended to be used like that, yet they
> >> certainly have wide-spread adoption.
> >
> > They don't make binary shared libraries
> > because the architecture is a virtual machine driven by
> > bytecode .. they DO make dynamically linkable bytecode
> > libraries.
> >
> As long as you play within the bounds of their VM. This is no different than Ocaml.
Performance is different :) That's why I use Ocaml native code
exclusively, which doesn't support dynamic loading (yet :)
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
@ 2007-03-09 17:41 Robert Fischer
0 siblings, 0 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-09 17:41 UTC (permalink / raw)
To: caml-list
Weird -- I thought F# was having all kinds of performance problems. Got metrics?
~~ Robert.
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of Jon Harrop
Sent: Friday, March 09, 2007 11:26 AM
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Interactive technical computing
On Friday 09 March 2007 14:13, Robert Fischer wrote:
> Performance of Ocaml's bytecode is slower than F#? Really?
Performance of OCaml compiled to native code with ocamlopt is sometimes slower
than F#, so yes.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
@ 2007-03-09 15:35 Robert Fischer
0 siblings, 0 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-09 15:35 UTC (permalink / raw)
To: caml-list
Performance of using F# linking into native applications is better than using OCaml bytecode and linking into native applications? Is F# faster than OCaml bytecode these days? Is the OCaml bytecode's link into dynamic libraries somehow slowing things down?
I'm still having trouble seeing what you're getting at -- sorry if I'm being dense.
~~ Robert.
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of skaller
Sent: Friday, March 09, 2007 9:22 AM
To: Robert Fischer
Cc: caml-list@inria.fr
Subject: RE: [Caml-list] Interactive technical computing
On Fri, 2007-03-09 at 08:13 -0600, Robert Fischer wrote:
> Performance of Ocaml's bytecode is slower than F#? Really?
I wrote:
> > As long as you play within the bounds of their VM. This is no different than Ocaml.
>
> Performance is different :) That's why I use Ocaml native code
> exclusively, which doesn't support dynamic loading (yet :)
I have no idea about performance of F#: I'm talking about
using a Debian based Linux operating system which uses
dynamic loading of high performance machine binaries.
I once implement a Python interpreter in Ocaml, call Vyper.
One of the reasons I gave up was that to extend it with
the equivalent of Python's C modules, I had to write the
equivalent code in Ocaml and *statically* link it into
the program.
The main reason for doing this wasn't performance, but
to provide bindings to C libraries.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
@ 2007-03-09 14:21 Robert Fischer
0 siblings, 0 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-09 14:21 UTC (permalink / raw)
To: Jon Harrop, caml-list
> Can you dynamically load code and get native performance? Not with OCaml.
>
> I've got a killer high-performance 2D and 3D visualization library written in
> OCaml and I'd like to sell it, but I don't want to sell the source code
> because I value it too much. What can I do? Well, I can port it to F# and
> sell it there. In the mean time, OCaml users are stuck with GNUPlot.
>
Do you have metrics showing that performance is better with F# than OCaml in these two cases?
>From what I understand, F# has a major performance issue resulting from the way the .Net VM handles allocation. Is that old info?
> Can you compile to a cross-platform format and keep native performance? Not
> with OCaml.
>
F# goes to byte code, OCaml goes to byte code. If you want to be "cross-platform", you're pretty much headed to a VM one way or another.
> Can you write an interactive environment (top level) and keep native
> performance? Not with OCaml.
>
The top-level is something I've been hacking on a bit, and I am a bit cranky with it right now, too. I'll post something on it later.
> Can you link to libraries (e.g. OpenGL) and be cross-platform? Not with OCaml
> (I think, because you need a custom run-time).
>
What are you doing with F# where you see it as more "cross-platform" than OCaml? I guess I don't understand the charge.
>From what I understand, your basic argument is "F# is cross-compatible with the .Net framework, and therefore better". This is definitely something I agree with. If I trusted the .Net framework to ever become and remain genuinely cross-platform (I expect Mono to be killed by vicious attack lawyers as soon as MS cares), I'd be a lot more inclined to use it.
~~ Robert.
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of Jon Harrop
Sent: Friday, March 09, 2007 7:49 AM
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Interactive technical computing
On Friday 09 March 2007 13:33, Robert Fischer wrote:
> > They don't make binary shared libraries
> > because the architecture is a virtual machine driven by
> > bytecode .. they DO make dynamically linkable bytecode
> > libraries.
>
> As long as you play within the bounds of their VM. This is no different
> than Ocaml.
On the contrary, it is very different:
Can you dynamically load code and get native performance? Not with OCaml.
Can you compile to a cross-platform format and keep native performance? Not
with OCaml.
Can you write an interactive environment (top level) and keep native
performance? Not with OCaml.
Can you link to libraries (e.g. OpenGL) and be cross-platform? Not with OCaml
(I think, because you need a custom run-time).
I've got a killer high-performance 2D and 3D visualization library written in
OCaml and I'd like to sell it, but I don't want to sell the source code
because I value it too much. What can I do? Well, I can port it to F# and
sell it there. In the mean time, OCaml users are stuck with GNUPlot.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
@ 2007-03-09 14:13 Robert Fischer
2007-03-09 15:21 ` skaller
` (2 more replies)
0 siblings, 3 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-09 14:13 UTC (permalink / raw)
To: caml-list
Performance of Ocaml's bytecode is slower than F#? Really?
~~ Robert.
-----Original Message-----
From: skaller [mailto:skaller@users.sourceforge.net]
Sent: Friday, March 09, 2007 7:54 AM
To: Robert Fischer
Cc: caml-list@inria.fr
Subject: RE: [Caml-list] Interactive technical computing
On Fri, 2007-03-09 at 07:33 -0600, Robert Fischer wrote:
> >> After all, Java and C# aren't intended to be used like that, yet they
> >> certainly have wide-spread adoption.
> >
> > They don't make binary shared libraries
> > because the architecture is a virtual machine driven by
> > bytecode .. they DO make dynamically linkable bytecode
> > libraries.
> >
> As long as you play within the bounds of their VM. This is no different than Ocaml.
Performance is different :) That's why I use Ocaml native code
exclusively, which doesn't support dynamic loading (yet :)
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
2007-03-09 14:13 Robert Fischer
@ 2007-03-09 15:21 ` skaller
2007-03-09 17:26 ` Jon Harrop
2007-03-09 18:50 ` Jon Harrop
2 siblings, 0 replies; 40+ messages in thread
From: skaller @ 2007-03-09 15:21 UTC (permalink / raw)
To: Robert Fischer; +Cc: caml-list
On Fri, 2007-03-09 at 08:13 -0600, Robert Fischer wrote:
> Performance of Ocaml's bytecode is slower than F#? Really?
I wrote:
> > As long as you play within the bounds of their VM. This is no different than Ocaml.
>
> Performance is different :) That's why I use Ocaml native code
> exclusively, which doesn't support dynamic loading (yet :)
I have no idea about performance of F#: I'm talking about
using a Debian based Linux operating system which uses
dynamic loading of high performance machine binaries.
I once implement a Python interpreter in Ocaml, call Vyper.
One of the reasons I gave up was that to extend it with
the equivalent of Python's C modules, I had to write the
equivalent code in Ocaml and *statically* link it into
the program.
The main reason for doing this wasn't performance, but
to provide bindings to C libraries.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-09 14:13 Robert Fischer
2007-03-09 15:21 ` skaller
@ 2007-03-09 17:26 ` Jon Harrop
2007-03-09 18:50 ` Jon Harrop
2 siblings, 0 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-09 17:26 UTC (permalink / raw)
To: caml-list
On Friday 09 March 2007 14:13, Robert Fischer wrote:
> Performance of Ocaml's bytecode is slower than F#? Really?
Performance of OCaml compiled to native code with ocamlopt is sometimes slower
than F#, so yes.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-09 14:13 Robert Fischer
2007-03-09 15:21 ` skaller
2007-03-09 17:26 ` Jon Harrop
@ 2007-03-09 18:50 ` Jon Harrop
2 siblings, 0 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-09 18:50 UTC (permalink / raw)
To: caml-list
On Friday 09 March 2007 14:13, Robert Fischer wrote:
> Performance of Ocaml's bytecode is slower than F#? Really?
Sum 1/x for x in [1 .. 10^6]. In OCaml:
time (Array.fold_left (+.) 0.)
(Array.init 1000000 (fun i -> 1. /. float(i+1)));;
In F#:
time (Array.fold_left (+) 0.)
(Array.map ((/) 1.) [|1. .. 1000000.|]);;
OCaml takes 0.256s, F# takes only 0.047s => F# more than 5x faster than OCaml
bytecode.
On numerical code, F# can be faster than native-code compiled OCaml. For
example, a naive 2^n FFT:
let fft a =
let n = Array.length a in
let j = ref 0 in
for i = 0 to n-2 do
if i < !j then
(let t = a.(!j) in
a.(!j) <- a.(i);
a.(i) <- t);
let m = ref (n/2) in
while !m <= !j do
j := !j - !m;
m := !m/2
done;
j := !j + !m
done;
let j = ref 1 in
let b = ref (neg c1) in
while !j<n do
let w = ref c1 in
for m = 0 to !j-1 do
let i = ref m in
while !i < n do
let t = !w *@ a.(!i + !j) in
a.(!i + !j) <- a.(!i) -@ t;
a.(!i) <- a.(!i) +@ t;
w := !w *@ !b;
i := !i + !j + !j
done
done;
j := !j + !j;
b := sqrt !b
done;
a;;
n=1<<15
ocamlopt: 0.164s
F#: 0.134s
F# is 22% faster, probably thanks to complex numbers in the language.
Discrete wavelet transform (4-tap Daubechies, n=2^20), OCaml is 25% faster:
ocamlopt: 2.03s
F#: 2.53s
Note that this is apples and oranges because my Windows environment is still
only 32 bit. If .NET shows the same performance improvement moving from
> From what I understand, F# has a major performance issue resulting from the
> way the .Net VM handles allocation. Is that old info?
Allocation is slower in F# for two main reasons:
1. The run-time is optimised for C# code that has quite different expected
value lifetimes (far fewer very short-lived objects compared to F#).
2. F# supports concurrency, which incurs a big performance cost in allocation
and GC.
but the consequence of this is that very allocation-heavy code (e.g. symbolic
rewriting) is up to 4x slower in F#. Lists are also more heavyweight in F#.
However, F# regains a lot of performance by having a much faster stdlib.
For example, creating a 2^16-element set is an allocation-intensive task. In
OCaml:
# module Int = struct
type t = int
let compare = compare
end;;
# module IntSet = Set.Make(Int);;
...
# time (Array.fold_right IntSet.add (Array.init 65536 (fun i -> i)))
IntSet.empty;;
0.744047s
Compiled with ocamlopt I get 0.065s.
For F# I get 0.240s. That's 3.7x slower than native-code OCaml.
However, it is worth noting that the F# equivalent is much more concise, just:
time (Array.fold_right Set.add [|0 .. 65535|])
Set.empty;;
primarily because no functors are involved when making a set. The comparison
function is taken from the element type.
> > I've got a killer high-performance 2D and 3D visualization library
> > written in OCaml and I'd like to sell it, but I don't want to sell the
> > source code because I value it too much. What can I do? Well, I can port
> > it to F# and sell it there. In the mean time, OCaml users are stuck with
> > GNUPlot.
>
> Do you have metrics showing that performance is better with F# than OCaml
> in these two cases?
In theory, performance should be very close because so much work is done by
the graphics card and not the CPU. In practice, I only just figured out how
to render static geometry optimally from DirectX, so my F# version still
sucks.
Once I've integrated that into my purely-functional scene graph I'll let you
know what the performance is like. I expect F# to win because I'm exploiting
concurrency and the application is more numerical than allocation intensive.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
@ 2007-03-08 21:26 Robert Fischer
2007-03-09 0:04 ` skaller
` (2 more replies)
0 siblings, 3 replies; 40+ messages in thread
From: Robert Fischer @ 2007-03-08 21:26 UTC (permalink / raw)
To: caml-list
> Putting aside the obvious cultural resistance to using a sensible
> language for this project, there is one technical hurdle: It needs to
> compile into a DLL which can be linked to other programs (in C and
> other languages). I can't generate such code using ocamlopt, at least
> not without using unsupported out-of-tree extensions.
>
I don't think this is a real hurdle to general adoption of a language.
After all, Java and C# aren't intended to be used like that, yet they
certainly have wide-spread adoption.
I suppose there is gcj for Java, but that's not in 99+% of Java
development, and I'm not sure that will give you a lib at the end of the
day. I don't know of an equivalent for that in C# -- in all the C#
development I've done, we've never even considered it.
~~ Robert.
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of Richard Jones
Sent: Thursday, March 08, 2007 3:17 PM
To: Jim Miller
Cc: caml-list@inria.fr; skaller
Subject: Re: [Caml-list] Interactive technical computing
On Wed, Mar 07, 2007 at 10:36:18PM -0500, Jim Miller wrote:
> What's I think is the interesting point about this discussion is "What
are
> the hurdles toward acceptance of any new language, scripting or not,
into a
> given community?" Obviously OCAML and the ML languages have deeply
> penetrated some markets but haven't even dented others. There have
been
> lots of papers, studies, and discussion written on this (
> lambda-the-ultimate.org has many of them archived) so that's probably
> something for a different thread to be read wearing flame-retardant
> underthings.
I'm currently contributing to a 45KLOC C library which I'm sure would
be about 10 times smaller if written in a reasonable language.
Putting aside the obvious cultural resistance to using a sensible
language for this project, there is one technical hurdle: It needs to
compile into a DLL which can be linked to other programs (in C and
other languages). I can't generate such code using ocamlopt, at least
not without using unsupported out-of-tree extensions.
Rich.
--
Richard Jones
Red Hat
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: [Caml-list] Interactive technical computing
2007-03-08 21:26 Robert Fischer
@ 2007-03-09 0:04 ` skaller
2007-03-09 10:06 ` Jon Harrop
2007-03-09 10:25 ` Jon Harrop
2007-03-10 14:55 ` Richard Jones
2 siblings, 1 reply; 40+ messages in thread
From: skaller @ 2007-03-09 0:04 UTC (permalink / raw)
To: Robert Fischer; +Cc: caml-list
On Thu, 2007-03-08 at 15:26 -0600, Robert Fischer wrote:
> > Putting aside the obvious cultural resistance to using a sensible
> > language for this project, there is one technical hurdle: It needs to
> > compile into a DLL which can be linked to other programs (in C and
> > other languages). I can't generate such code using ocamlopt, at least
> > not without using unsupported out-of-tree extensions.
> >
> I don't think this is a real hurdle to general adoption of a language.
It is in fact an utter and complete show stopper.
I've spent 6 years developing Felix precisely to solve this
problem: a high level language that can generate shared libraries
which can use and be used by other shared libraries.
Ocaml is great for stand-alone programs but a significant
fraction of software development is library building,
and Linux distros such as those based on Debian provide
a library component model which demands dynamic linkage
so the components can be upgraded without end user recompilation.
I expect this will eventually be solved too.
> After all, Java and C# aren't intended to be used like that, yet they
> certainly have wide-spread adoption.
They don't make binary shared libraries
because the architecture is a virtual machine driven by
bytecode .. they DO make dynamically linkable bytecode
libraries.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-09 0:04 ` skaller
@ 2007-03-09 10:06 ` Jon Harrop
0 siblings, 0 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-09 10:06 UTC (permalink / raw)
To: caml-list
On Friday 09 March 2007 00:04, skaller wrote:
> On Thu, 2007-03-08 at 15:26 -0600, Robert Fischer wrote:
> > > Putting aside the obvious cultural resistance to using a sensible
> > > language for this project, there is one technical hurdle: It needs to
> > > compile into a DLL which can be linked to other programs (in C and
> > > other languages). I can't generate such code using ocamlopt, at least
> > > not without using unsupported out-of-tree extensions.
> >
> > I don't think this is a real hurdle to general adoption of a language.
>
> It is in fact an utter and complete show stopper.
Agreed. This is blocking the development of third party libraries written in
OCaml.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 21:26 Robert Fischer
2007-03-09 0:04 ` skaller
@ 2007-03-09 10:25 ` Jon Harrop
2007-03-10 14:55 ` Richard Jones
2 siblings, 0 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-09 10:25 UTC (permalink / raw)
To: caml-list
On Thursday 08 March 2007 21:26, Robert Fischer wrote:
> > Putting aside the obvious cultural resistance to using a sensible
> > language for this project, there is one technical hurdle: It needs to
> > compile into a DLL which can be linked to other programs (in C and
> > other languages). I can't generate such code using ocamlopt, at least
> > not without using unsupported out-of-tree extensions.
>
> I don't think this is a real hurdle to general adoption of a language.
> After all, Java and C# aren't intended to be used like that, yet they
> certainly have wide-spread adoption.
On the contrary, that is exactly how C# is intended to be used. Most libraries
used from F# are written in C# (and the same for most other .NET languages).
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 21:26 Robert Fischer
2007-03-09 0:04 ` skaller
2007-03-09 10:25 ` Jon Harrop
@ 2007-03-10 14:55 ` Richard Jones
2007-03-10 22:07 ` Michael Vanier
2 siblings, 1 reply; 40+ messages in thread
From: Richard Jones @ 2007-03-10 14:55 UTC (permalink / raw)
To: caml-list
On Thu, Mar 08, 2007 at 03:26:03PM -0600, Robert Fischer wrote:
> > Putting aside the obvious cultural resistance to using a sensible
> > language for this project, there is one technical hurdle: It needs to
> > compile into a DLL which can be linked to other programs (in C and
> > other languages). I can't generate such code using ocamlopt, at least
> > not without using unsupported out-of-tree extensions.
> >
> I don't think this is a real hurdle to general adoption of a language.
> After all, Java and C# aren't intended to be used like that, yet they
> certainly have wide-spread adoption.
It is a hurdle because not all programming is writing end-user
application code.
In fact what is somewhat sad is that OCaml (unlike Java and C#) can
compile to native code which really has very minimal "environmental
needs" - just a smallish library of functions and a GC which is
written on top of C's malloc. So really it could be an ideal
replacement for libraries written in C, where the heavy lifting is
done in OCaml and there are some thin bindings to provide a C API.
Rich.
--
Richard Jones
Red Hat
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-10 14:55 ` Richard Jones
@ 2007-03-10 22:07 ` Michael Vanier
2007-03-29 0:33 ` Jon Harrop
0 siblings, 1 reply; 40+ messages in thread
From: Michael Vanier @ 2007-03-10 22:07 UTC (permalink / raw)
To: Richard Jones; +Cc: caml-list
I agree 100%. This is the biggest limitation to using ocaml for large projects.
If it were fixed, ocaml would become an unstoppable juggernaut ;-)
Here's a paper describing an approach to this problem for an extended version of
Standard ML:
http://www.ps.uni-sb.de/Papers/abstracts/missing-link.html
This actually goes further than dynamic linking to provide a full component
model. What I wouldn't give to see this in ocaml.
Mike
Richard Jones wrote:
> On Thu, Mar 08, 2007 at 03:26:03PM -0600, Robert Fischer wrote:
>>> Putting aside the obvious cultural resistance to using a sensible
>>> language for this project, there is one technical hurdle: It needs to
>>> compile into a DLL which can be linked to other programs (in C and
>>> other languages). I can't generate such code using ocamlopt, at least
>>> not without using unsupported out-of-tree extensions.
>>>
>> I don't think this is a real hurdle to general adoption of a language.
>> After all, Java and C# aren't intended to be used like that, yet they
>> certainly have wide-spread adoption.
>
> It is a hurdle because not all programming is writing end-user
> application code.
>
> In fact what is somewhat sad is that OCaml (unlike Java and C#) can
> compile to native code which really has very minimal "environmental
> needs" - just a smallish library of functions and a GC which is
> written on top of C's malloc. So really it could be an ideal
> replacement for libraries written in C, where the heavy lifting is
> done in OCaml and there are some thin bindings to provide a C API.
>
> Rich.
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-10 22:07 ` Michael Vanier
@ 2007-03-29 0:33 ` Jon Harrop
2007-03-29 8:41 ` Joel Reymont
0 siblings, 1 reply; 40+ messages in thread
From: Jon Harrop @ 2007-03-29 0:33 UTC (permalink / raw)
To: caml-list
On Saturday 10 March 2007 22:07, Michael Vanier wrote:
> I agree 100%. This is the biggest limitation to using ocaml for large
> projects. If it were fixed, ocaml would become an unstoppable juggernaut
> ;-)
Concurrency has to be on that list as well though. F# inherits concurrency
from .NET and it is vastly easier to use than the last time I tried
concurrency (on a supercomputer, in Fortran).
However, a recent thread discussed the fledgling development of concurrency
for OCaml and it sounded fascinating (although I still haven't found time to
read it in detail!).
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Interactive technical computing
@ 2007-03-08 1:13 Jon Harrop
2007-03-08 1:49 ` [Caml-list] " Jim Miller
` (3 more replies)
0 siblings, 4 replies; 40+ messages in thread
From: Jon Harrop @ 2007-03-08 1:13 UTC (permalink / raw)
To: caml-list
Being a user of both OCaml and Mathematica, playing with the new F# language
from Microsoft and watching tutorial videos about VPython:
http://showmedo.com/videos/series?name=pythonThompsonVPythonSeries
has given me a lot of inspiration about interactive technical computing
environments. This class of applications is hugely useful for working
scientists and engineers because it lets you slice and dice your data in
interesting ways whilst also giving you visual throwback and even letting you
do some fancy visualisations.
For example, I'm in the process of updating my ray tracer language comparison:
http://www.ffconsultancy.com/languages/ray_tracer/index.html
and I'm using a mix of OCaml (to fire off compilation and execution commands)
and Mathematica (to dissect the results, compute verbosity using regexps and
plot graphs):
http://www.ffconsultancy.com/tmp/mathematica.png
Mathematica's equivalent of the OCaml top-level is called a notebook. It
provides expression input and result output, just like OCaml, but integrates
graphics, adds typesetting and lots of mathematical functions. However, it is
widely used for more general purpose programming despite being very slow.
Using F# from Visual Studio 2005 provides some of this functionality. The
following screenshots illustrate 2D and 3D graphics spawned from an F#
interactive session using a little of my own code and DirectX/ComponentsXtra:
http://www.ffconsultancy.com/tmp/fs_xygraph.png
http://www.ffconsultancy.com/tmp/fs_3dplot.png
For all non-trivials examples in F# it is necessary to spawn a separate thread
to handle the GUI of the visualization, or the GUI will hang when the
top-level is doing an intensive computation.
I think F# has a great future because of its ability to spawn visualizations
from a running interactive session. Expensive commercial offerings like
Matlab and Mathematica are ok when you're doing something they have built-in
(e.g. a Fourier transform) but when you're problem is not trivially
decomposed into their built-in operators (e.g. a wavelet transform), F# and
OCaml are typically 2-5x faster, and when you must resort to more general
purpose programming F# and OCaml are often 100x faster.
However, there is a lot of work to be done in getting competitive charting and
visualization tools into F# and I'm thinking that OCaml could benefit from a
joint venture here. Low-level routines would target DirectX in F# and OpenGL
in OCaml but high-level routines could be language and platform agnostic,
handling a scene graph that is essentially a typed version of Mathematica's
to provide much faster graphics and even interactive visualisation
(Mathematica is software rendered and not interactive!).
This raises several questions:
. What OCaml programs currently allow OpenGL-based visualizations to be
spawned from the top-level?
. Has anyone tried to write an IDE that mixes OCaml code with graphics?
. Would anyone here be interested in a low-cost cross-platform technical
computing environment based upon the OCaml and F# languages?
Obviously I'm interested in this from a commercial perspective. That looks
easy for F# but not so easy for OCaml. Compiled OCaml+OpenGL code is not as
portable (between machines) as F#+DirectX. Also, I can sell F# DLLs and even
make the library available to other .NET languages (albeit with a
significantly less productive API).
Finally, I'd like to note that operator overloading is probably the single
biggest difference between my F# and OCaml code. The ability to apply + and -
to many types, particularly vectors and matrices, makes this kind of work so
much easier. Even if you have to add the odd type annotation. So I'd love to
see a compatible implementation of overloading introduced into OCaml.
I'd like to hear everyone's opinions on this as, it seems to me, we're sitting
on the foundations of a great technical computing system.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 1:13 Jon Harrop
@ 2007-03-08 1:49 ` Jim Miller
2007-03-08 2:52 ` skaller
2007-03-08 2:12 ` Erik de Castro Lopo
` (2 subsequent siblings)
3 siblings, 1 reply; 40+ messages in thread
From: Jim Miller @ 2007-03-08 1:49 UTC (permalink / raw)
To: Jon Harrop; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 6002 bytes --]
I think that this would be a potentially fantastic application! As a
physicist I am frequently faced with the option of using an interactive tool
that supports graphics (PV-WAVE, IDL, R, and Matlab/Octave are very popular)
but is VERY slow or doing things in a fast but tedious language (C/C++ are
currently the rage with a few individuals that still do Fortran 9X).
Having an OCaml based language that combines a top level command line loop
that allows me to interactive explore data and develop scripts but that
allows me to compile those into something fast could be a very, very useful
tool. My particular domains are atmospheric photochemistry as well as
satellite mission planning and imagery exploitation. We tend to do a LOT
less with 3D visualizations and much more with traditional line, contour,
and scatter plots. We also do a lot of false color imagery.
The closest that I have come to this is a quick module that allows me to
spawn a gnuplot program and pass command strings, via a pipe. A few
functions to ensure that data is formatted properly and I have something
that's manageable.
I'd be interested in conspiring/planning on something in this space. It
would also be useful to see if there's a useful way to bridge this with R,
which is my current favorite language for doing statistical data analysis
and plot generation but it still suffers from the problems of speed.
On 3/7/07, Jon Harrop <jon@ffconsultancy.com> wrote:
>
>
> Being a user of both OCaml and Mathematica, playing with the new F#
> language
> from Microsoft and watching tutorial videos about VPython:
>
> http://showmedo.com/videos/series?name=pythonThompsonVPythonSeries
>
> has given me a lot of inspiration about interactive technical computing
> environments. This class of applications is hugely useful for working
> scientists and engineers because it lets you slice and dice your data in
> interesting ways whilst also giving you visual throwback and even letting
> you
> do some fancy visualisations.
>
> For example, I'm in the process of updating my ray tracer language
> comparison:
>
> http://www.ffconsultancy.com/languages/ray_tracer/index.html
>
> and I'm using a mix of OCaml (to fire off compilation and execution
> commands)
> and Mathematica (to dissect the results, compute verbosity using regexps
> and
> plot graphs):
>
> http://www.ffconsultancy.com/tmp/mathematica.png
>
> Mathematica's equivalent of the OCaml top-level is called a notebook. It
> provides expression input and result output, just like OCaml, but
> integrates
> graphics, adds typesetting and lots of mathematical functions. However, it
> is
> widely used for more general purpose programming despite being very slow.
>
> Using F# from Visual Studio 2005 provides some of this functionality. The
> following screenshots illustrate 2D and 3D graphics spawned from an F#
> interactive session using a little of my own code and
> DirectX/ComponentsXtra:
>
> http://www.ffconsultancy.com/tmp/fs_xygraph.png
> http://www.ffconsultancy.com/tmp/fs_3dplot.png
>
> For all non-trivials examples in F# it is necessary to spawn a separate
> thread
> to handle the GUI of the visualization, or the GUI will hang when the
> top-level is doing an intensive computation.
>
> I think F# has a great future because of its ability to spawn
> visualizations
> from a running interactive session. Expensive commercial offerings like
> Matlab and Mathematica are ok when you're doing something they have
> built-in
> (e.g. a Fourier transform) but when you're problem is not trivially
> decomposed into their built-in operators (e.g. a wavelet transform), F#
> and
> OCaml are typically 2-5x faster, and when you must resort to more general
> purpose programming F# and OCaml are often 100x faster.
>
> However, there is a lot of work to be done in getting competitive charting
> and
> visualization tools into F# and I'm thinking that OCaml could benefit from
> a
> joint venture here. Low-level routines would target DirectX in F# and
> OpenGL
> in OCaml but high-level routines could be language and platform agnostic,
> handling a scene graph that is essentially a typed version of
> Mathematica's
> to provide much faster graphics and even interactive visualisation
> (Mathematica is software rendered and not interactive!).
>
> This raises several questions:
>
> . What OCaml programs currently allow OpenGL-based visualizations to be
> spawned from the top-level?
>
> . Has anyone tried to write an IDE that mixes OCaml code with graphics?
>
> . Would anyone here be interested in a low-cost cross-platform technical
> computing environment based upon the OCaml and F# languages?
>
> Obviously I'm interested in this from a commercial perspective. That looks
> easy for F# but not so easy for OCaml. Compiled OCaml+OpenGL code is not
> as
> portable (between machines) as F#+DirectX. Also, I can sell F# DLLs and
> even
> make the library available to other .NET languages (albeit with a
> significantly less productive API).
>
> Finally, I'd like to note that operator overloading is probably the single
> biggest difference between my F# and OCaml code. The ability to apply +
> and -
> to many types, particularly vectors and matrices, makes this kind of work
> so
> much easier. Even if you have to add the odd type annotation. So I'd love
> to
> see a compatible implementation of overloading introduced into OCaml.
>
> I'd like to hear everyone's opinions on this as, it seems to me, we're
> sitting
> on the foundations of a great technical computing system.
>
> --
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> OCaml for Scientists
> http://www.ffconsultancy.com/products/ocaml_for_scientists
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 7166 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 1:49 ` [Caml-list] " Jim Miller
@ 2007-03-08 2:52 ` skaller
2007-03-08 3:00 ` Jim Miller
0 siblings, 1 reply; 40+ messages in thread
From: skaller @ 2007-03-08 2:52 UTC (permalink / raw)
To: Jim Miller; +Cc: Jon Harrop, caml-list
On Wed, 2007-03-07 at 20:49 -0500, Jim Miller wrote:
> I think that this would be a potentially fantastic application!
The question is whether you would get a sufficient grant to
actually pay for it.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 2:52 ` skaller
@ 2007-03-08 3:00 ` Jim Miller
2007-03-08 3:10 ` skaller
0 siblings, 1 reply; 40+ messages in thread
From: Jim Miller @ 2007-03-08 3:00 UTC (permalink / raw)
To: skaller; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]
I have no doubt that nobody would give you a grant do to this. The
immediate question my sources would ask is "WHY?" when there are so many
other languages out there. The number of research scientists that I know of
that are asking for anything like this is exceedingly low.
On a side note, this is the most frustrating thing about the physics
community I work with. I'm involved at GMU in the COMPUTATIONAL physics
department. We are supposed to be applying cutting edge technology to
problems and yet the application of new languages gets VERY little traction
there. Every argument I've ever made to the faculty there about the ability
for an O'Caml type language to improve our productivity and confidence in
the answers it produces tends to fall on deaf ears.
Of course, I am just a student there, but I'm also an experienced (15 years)
professional programmer that might know a thing or two about programming ...
sigh.
Most research physicists that I work with (NRL in particular) are worse.
On 3/7/07, skaller <skaller@users.sourceforge.net> wrote:
>
> On Wed, 2007-03-07 at 20:49 -0500, Jim Miller wrote:
> > I think that this would be a potentially fantastic application!
>
> The question is whether you would get a sufficient grant to
> actually pay for it.
>
> --
> John Skaller <skaller at users dot sf dot net>
> Felix, successor to C++: http://felix.sf.net
>
[-- Attachment #2: Type: text/html, Size: 1791 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 3:00 ` Jim Miller
@ 2007-03-08 3:10 ` skaller
[not found] ` <beed19130703071919g1f537f59o93ce06871fba8f3a@mail.gmail.com>
0 siblings, 1 reply; 40+ messages in thread
From: skaller @ 2007-03-08 3:10 UTC (permalink / raw)
To: Jim Miller; +Cc: caml-list
On Wed, 2007-03-07 at 22:00 -0500, Jim Miller wrote:
> I have no doubt that nobody would give you a grant do to this.
That isn't the question. If Harrop developed it and sold it
for $US 5000.00 would your grant cover it?
Harrop can estimate the market by surveying researchers
and finding what their financial situations could support.
One grant isn't expected to cover the whole development!
BTW: I did some computational atmospheric photochemistry
in the 1970s, looking at ozone and effects of SSTs,
but mainly studying the socio-political role of
funding of those studies .. (most of the money came
from people with vested interests :)
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 1:13 Jon Harrop
2007-03-08 1:49 ` [Caml-list] " Jim Miller
@ 2007-03-08 2:12 ` Erik de Castro Lopo
2007-03-08 11:12 ` Andrej Bauer
2007-03-08 11:59 ` Vu Ngoc San
3 siblings, 0 replies; 40+ messages in thread
From: Erik de Castro Lopo @ 2007-03-08 2:12 UTC (permalink / raw)
To: caml-list
Jon Harrop wrote:
> Finally, I'd like to note that operator overloading is probably the single
> biggest difference between my F# and OCaml code. The ability to apply + and -
> to many types, particularly vectors and matrices, makes this kind of work so
> much easier. Even if you have to add the odd type annotation. So I'd love to
> see a compatible implementation of overloading introduced into OCaml.
I'm mainly a Linux guy so the chances of me getting up close and personal
with F# are exactly zero :-). However, I am interested in hearing about
the differences between F# and Ocaml wrt operator overloading. Care to
clue me (and everyone else) in?
Cheers,
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo
+-----------------------------------------------------------+
"Reality is just a crutch for people that can't handle CyberSpace!!"
- Hank Duderstadt
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 1:13 Jon Harrop
2007-03-08 1:49 ` [Caml-list] " Jim Miller
2007-03-08 2:12 ` Erik de Castro Lopo
@ 2007-03-08 11:12 ` Andrej Bauer
2007-03-08 11:59 ` Vu Ngoc San
3 siblings, 0 replies; 40+ messages in thread
From: Andrej Bauer @ 2007-03-08 11:12 UTC (permalink / raw)
To: caml-list; +Cc: Jon Harrop
Jon Harrop wrote:
> I'd like to hear everyone's opinions on this as, it seems to me, we're sitting
> on the foundations of a great technical computing system.
I would be very much interested in participating in an effort to develop
an interactive environment for ocaml that surpases the currect toplevel.
I have in mind a toplevel that can be used *easily* as part of an
application, has support for line-editing, fancy typesetting and
graphics display. Intelligent pretty-printing would probably be a
natural consequence of such desires (so that we graphics is just a fancy
pretty printer).
As far as symbolic computation and manipulation of mathematical
expressions is concerned: I am not sure that overloading operators and
doing other kinds of violence to ocaml is the right way to go. It might
be better to have instead a specific language for symbolic computation
_on top_ of ocaml. The symbolic computation language would swallow the
horrible and nasty notation that is used in mathematics, digest it, and
pass it on to ocaml.
Best regards,
Andrej
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 1:13 Jon Harrop
` (2 preceding siblings ...)
2007-03-08 11:12 ` Andrej Bauer
@ 2007-03-08 11:59 ` Vu Ngoc San
2007-03-08 12:43 ` Jon Harrop
3 siblings, 1 reply; 40+ messages in thread
From: Vu Ngoc San @ 2007-03-08 11:59 UTC (permalink / raw)
Cc: caml-list
You probably know it already, but it is very easy to spawn opengl
graphics directly from the toplevel using sdl. Then if you use the
toplevel inside emacs, you get something very similar to the screenshots
you had.
And since you are into screenshots, here is one :-)
http://www-fourier.ujf-grenoble.fr/~svungoc/prog/oplot/toplevel_plot.png
San
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 11:59 ` Vu Ngoc San
@ 2007-03-08 12:43 ` Jon Harrop
2007-03-08 21:28 ` Vu Ngoc San
0 siblings, 1 reply; 40+ messages in thread
From: Jon Harrop @ 2007-03-08 12:43 UTC (permalink / raw)
To: caml-list
On Thursday 08 March 2007 11:59, Vu Ngoc San wrote:
> You probably know it already, but it is very easy to spawn opengl
> graphics directly from the toplevel using sdl. Then if you use the
> toplevel inside emacs, you get something very similar to the screenshots
> you had.
>
> And since you are into screenshots, here is one :-)
>
> http://www-fourier.ujf-grenoble.fr/~svungoc/prog/oplot/toplevel_plot.png
This is just the kind of thing that I'd like to hear about!
How exactly do you do that? Can you post a complete working example?
Looks great... :-)
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 12:43 ` Jon Harrop
@ 2007-03-08 21:28 ` Vu Ngoc San
2007-03-09 0:14 ` skaller
0 siblings, 1 reply; 40+ messages in thread
From: Vu Ngoc San @ 2007-03-08 21:28 UTC (permalink / raw)
To: Jon Harrop; +Cc: caml-list
Jon Harrop a écrit :
> How exactly do you do that? Can you post a complete working example?
>
> Looks great... :-)
>
Thanks :-)
The idea is that sdl (contrary to glut or lablgtk2), does not have a
"main loop": so you can write your own. This allows you to open an
opengl window from the toplevel, and when you quit your mainloop, you
get back nicely to the toplevel. You can even let the window open when
you are back to toplevel, but then the graphics are not updated anymore.
Nice enough: you can later update the sdl window (no need to close it
and open another one !).
If you really need interaction in the window and in the toplevel at the
same time, you can launch the sdl mainloop in a separate thread. It
really works. But I wouldn't try to open two sdl windows at the same
time (??).
I don't have the courage -- and time -- to give you a "working example"
(see below) but the initialisation is like this:
Sdl.init [ `VIDEO ];
Sdlvideo.set_video_mode !window_width !window_height [ `DOUBLEBUF ;
`OPENGL ; `RESIZABLE]);
Sdlwm.set_caption "Oplot - SDL Window" "";
Then you can issue any openGL command you wish. Even from the toplevel !
You can also use Sdlttf to handle any ttf font.
.....
Now, since you sort of asked for it, here it is:
I have written a small graphics library that does all of this. But this
is my first ocaml program, first use of openGL etc.. so I'm not
particularly proud of it. It is quite messy, and in a state of perpetual
development. You can find a (not so recent) version at
http://www-fourier.ujf-grenoble.fr/~svungoc/prog/oplot/index.html
This lib is actually useful (to me) because you can insert LaTeX
formulas and export directly to xfig (or postscript). It produces
postscript of better quality than maple :-)
There is a (very recent) GUI for this at
http://www-fourier.ujf-grenoble.fr/~svungoc/prog/goplot/index.html
which uses lablgtk2 and launches sdl in a separate thread... (yep. my
first use of GTK and of threads.. don't be too harsh if you read my
code... -:) ). However, and even though I'm not a programmer (I do this
for learning ocaml during my spare time), I'd be happy to have some
feedback. There is a package with precompiled binaries that works on at
least three linux machines :-)
San
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Caml-list] Interactive technical computing
2007-03-08 21:28 ` Vu Ngoc San
@ 2007-03-09 0:14 ` skaller
0 siblings, 0 replies; 40+ messages in thread
From: skaller @ 2007-03-09 0:14 UTC (permalink / raw)
To: Vu Ngoc San; +Cc: Jon Harrop, caml-list
On Thu, 2007-03-08 at 22:28 +0100, Vu Ngoc San wrote:
> If you really need interaction in the window and in the toplevel at the
> same time, you can launch the sdl mainloop in a separate thread. It
> really works.
No it doesn't. It works on Linux, but not on Windows.
Messages on Windows go to the thread that creates the
window, and fetches are done by default on the current
thread's message queue. X maintains a queue per
process, so it works on Linux (but be careful because
even re-entrant X isn't really re-entrant).
SDL has a serious design bug: it can't be used as a library,
it insists on providing the mainline (you can hack around
this though). On Linux, you don't have to do this because
the SDL mainline does nothing.
OpenGL has an even more serious design bug: contexts
are implicit. This is extremely bad design: it was
designed to work with serial code and optimise use
of a single video card.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2007-03-30 11:36 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-09 13:33 [Caml-list] Interactive technical computing Robert Fischer
2007-03-09 13:49 ` Jon Harrop
2007-03-09 13:54 ` skaller
-- strict thread matches above, loose matches on Subject: below --
2007-03-09 17:41 Robert Fischer
2007-03-09 15:35 Robert Fischer
2007-03-09 14:21 Robert Fischer
2007-03-09 14:13 Robert Fischer
2007-03-09 15:21 ` skaller
2007-03-09 17:26 ` Jon Harrop
2007-03-09 18:50 ` Jon Harrop
2007-03-08 21:26 Robert Fischer
2007-03-09 0:04 ` skaller
2007-03-09 10:06 ` Jon Harrop
2007-03-09 10:25 ` Jon Harrop
2007-03-10 14:55 ` Richard Jones
2007-03-10 22:07 ` Michael Vanier
2007-03-29 0:33 ` Jon Harrop
2007-03-29 8:41 ` Joel Reymont
2007-03-30 11:31 ` Jon Harrop
2007-03-08 1:13 Jon Harrop
2007-03-08 1:49 ` [Caml-list] " Jim Miller
2007-03-08 2:52 ` skaller
2007-03-08 3:00 ` Jim Miller
2007-03-08 3:10 ` skaller
[not found] ` <beed19130703071919g1f537f59o93ce06871fba8f3a@mail.gmail.com>
2007-03-08 3:27 ` skaller
2007-03-08 3:36 ` Jim Miller
2007-03-08 21:16 ` Richard Jones
[not found] ` <45F10E90.5000707@laposte.net>
2007-03-09 7:43 ` Matthieu Dubuget
2007-03-10 14:58 ` Richard Jones
2007-03-08 12:22 ` Gerd Stolpmann
2007-03-08 14:24 ` Christophe TROESTLER
2007-03-08 19:34 ` Jon Harrop
2007-03-08 20:34 ` Christophe TROESTLER
2007-03-09 10:22 ` Jon Harrop
2007-03-09 10:45 ` Christophe TROESTLER
2007-03-08 2:12 ` Erik de Castro Lopo
2007-03-08 11:12 ` Andrej Bauer
2007-03-08 11:59 ` Vu Ngoc San
2007-03-08 12:43 ` Jon Harrop
2007-03-08 21:28 ` Vu Ngoc San
2007-03-09 0:14 ` skaller
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).