Developing cross-platform web/GUI applications

Hi!

I'd like to write cross-platform applications that either run in the browser
or run as standalone GUI applications in a functional programming language.

I understand that Ruby is a functional programming language and I was
wondering:

1. How widely is Ruby used on Linux, Mac OS X and Windows?

2. Are there compilers/interpreters targetting the JVM/.NET that make it
easy to develop GUI applications?

3. Has anyone done any significant work in this area using Ruby?

4. Are scientists and engineers using Ruby?

Many thanks,

···

--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet

Jon Harrop wrote:

Hi!

I'd like to write cross-platform applications that either run in the browser
or run as standalone GUI applications in a functional programming language.

I understand that Ruby is a functional programming language and I was
wondering:
  

Well, I wouldn't call Ruby a "functional" programming language in the same sense as Lisp/Scheme, Haskell and Erlang define themselves as functional programming languages. Ruby is more an "object-oriented programming language" in the same sense as Smalltalk and Java define themselves as object-oriented programming languages.

1. How widely is Ruby used on Linux, Mac OS X and Windows?
  

It depends on what you mean by "widely used." It's installed by default on Macs, but you have to download and install it on from an external repository on Windows, and while it's freely distributed in all the major Linux distro repositories, it isn't usually installed by default.

2. Are there compilers/interpreters targetting the JVM/.NET that make it
easy to develop GUI applications?
  

Yes indeed! The JVM is supported by Sun's jRuby, Microsoft just announced a "Dynamic Language Run-time" that supports Ruby on .NET, and there are miscellaneous other implementations. I don't have any experience with the .NET versions, but I highly recommend jRuby.

3. Has anyone done any significant work in this area using Ruby?
  

If by "this area" you mean web applications, you pretty much have to have been living under a rock if you haven't heard about Ruby on Rails. ;). But general GUI applications are a bit more obscure in Ruby. Most of the major GUI toolkits have Ruby bindings, but there's no clear "first choice" among them.

4. Are scientists and engineers using Ruby?
  

Yes, but it isn't as popular among them as Python is. I'm a scientist/engineer, and I use Ruby, along with Perl and R. But I've never taken the time to learn Python.

···

Many thanks,

http://sciruby.codeforpeople.com

we use it heavily here

http://www.ngdc.noaa.gov/dmsp/index.html

these were made with ruby

http://www.ngdc.noaa.gov/dmsp/interest/katrina.html

as were these

http://www.ngdc.noaa.gov/dmsp/interest/india.html

regards.

-a

···

On May 26, 2007, at 2:55 PM, Jon Harrop wrote:

Hi!

I'd like to write cross-platform applications that either run in the browser
or run as standalone GUI applications in a functional programming language.

I understand that Ruby is a functional programming language and I was
wondering:

1. How widely is Ruby used on Linux, Mac OS X and Windows?

2. Are there compilers/interpreters targetting the JVM/.NET that make it
easy to develop GUI applications?

3. Has anyone done any significant work in this area using Ruby?

4. Are scientists and engineers using Ruby?

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

M. Edward (Ed) Borasky wrote:

Well, I wouldn't call Ruby a "functional" programming language in the
same sense as Lisp/Scheme, Haskell and Erlang define themselves as
functional programming languages.

Ok. I'm from an OCaml/F# background. May I just ask if anyone can translate
the following OCaml one-liner into Ruby:

  let rec nest ?(n=2) f x = if n=0 then x else nest ~n:(n-1) f (f x)

it nests "n" applications of "f" to "x" with "n" defaulting to 2 if it isn't
specified, e.g. "nest ~n:3 f x" gives f(f(f(x))).

This trivial example encapsulates much of what I love about OCaml and it
doesn't translate well into any other language that I know.

Ruby is more an "object-oriented
programming language" in the same sense as Smalltalk and Java define
themselves as object-oriented programming languages.

Hmm. I'm not an OO fan but I was under the impression that Ruby has much
better support for functions than Python.

1. How widely is Ruby used on Linux, Mac OS X and Windows?
  

It depends on what you mean by "widely used." It's installed by default
on Macs,

Really? It is bundled by Apple? That's incredible! =8-)

2. Are there compilers/interpreters targetting the JVM/.NET that make it
easy to develop GUI applications?
  

Yes indeed! The JVM is supported by Sun's jRuby, Microsoft just
announced a "Dynamic Language Run-time" that supports Ruby on .NET, and
there are miscellaneous other implementations. I don't have any
experience with the .NET versions, but I highly recommend jRuby.

Awesome!!! This is exactly the kind of thing I'm looking for.

3. Has anyone done any significant work in this area using Ruby?
  

If by "this area" you mean web applications, you pretty much have to
have been living under a rock if you haven't heard about Ruby on Rails.
;).

Oh yeah, I forgot. :slight_smile:

I had a look at Ruby on Rails a while ago and, although I can do scientific
computing with my eyes closed, web programming is like double Dutch to me.
Couldn't make head nor tail of it. I think I'm improving now though. :slight_smile:

But general GUI applications are a bit more obscure in Ruby. Most of
the major GUI toolkits have Ruby bindings, but there's no clear "first
choice" among them.

Ok, thanks.

4. Are scientists and engineers using Ruby?
  

Yes, but it isn't as popular among them as Python is. I'm a
scientist/engineer, and I use Ruby, along with Perl and R. But I've
never taken the time to learn Python.

Are there many tools for scientists and engineers written in Ruby? What sort
of stuff do you write in Ruby?

Thanks very much!

···

--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet

ara.t.howard wrote:

we use it heavily here

http://www.ngdc.noaa.gov/dmsp/index.html

I also saw your stuff in Al Gore's /Inconvenient Truth/ movie, no?

Later,

···

--
Bil Kleb
http://fun3d.larc.nasa.gov

Jon Harrop wrote:

I had a look at Ruby on Rails a while ago and, although I can do scientific
computing with my eyes closed, web programming is like double Dutch to me.
Couldn't make head nor tail of it. I think I'm improving now though. :slight_smile:

I'd recommend you start with Camping,

  http://camping.rubyforge.org

instead then migrate to Rails if need more amenities.

Regards,

···

--
Bil Kleb
http://fun3d.larc.nasa.gov

Jon Harrop wrote:

M. Edward (Ed) Borasky wrote:

Well, I wouldn't call Ruby a "functional" programming language in the
same sense as Lisp/Scheme, Haskell and Erlang define themselves as
functional programming languages.

Ok. I'm from an OCaml/F# background. May I just ask if anyone can translate
the following OCaml one-liner into Ruby:

  let rec nest ?(n=2) f x = if n=0 then x else nest ~n:(n-1) f (f x)

it nests "n" applications of "f" to "x" with "n" defaulting to 2 if it isn't
specified, e.g. "nest ~n:3 f x" gives f(f(f(x))).

This trivial example encapsulates much of what I love about OCaml and it
doesn't translate well into any other language that I know.
  

If I understood your description, and the code correctly, this should work:

n ||=2; if n == 0; x else n.times do x = f x; end end

or should that be:

n ||=2; f ( x = if n == 0; x; else; n.times do x = f x; end; x; end )

of course, you could recurse using a temporary value rather than x, if you wanted to.

initialize an example with:

def f x; 2 * x; end; x = 2

I'm sure there's probably a more 'functional' way also.

If I do have your example correct, I should think a generic recursor function would not be hard to implement in ruby.

In fact:

def recurse func, depth, *initials
  working = initials
  depth.times do
    working = func.call *working
  end
  working
end

Initialize like so:

def f x, y
  [2 * x, 1 * y]
end

x,y=2,10

Use like so:

recurse method(:f), 2, x, y

n.b. this should work for arbitrary argument lengths provided the called function returns an array of arguments for itself.

Does this satisfy?

Oh, I thought I'd add a block version too, just for all those people that love blocks (and because it may be useful in this context):

def recurse_blk depth, *initials, &blk
  working = initials
  depth.times do
    working = yield(*working)
  end
  working
end

example: recurse_blk(2, x, y) do |a,b| f(a,b) end

Enjoy.

M. Edward (Ed) Borasky wrote:
> Well, I wouldn't call Ruby a "functional" programming language in the
> same sense as Lisp/Scheme, Haskell and Erlang define themselves as
> functional programming languages.

Ok. I'm from an OCaml/F# background. May I just ask if anyone can translate
the following OCaml one-liner into Ruby:

  let rec nest ?(n=2) f x = if n=0 then x else nest ~n:(n-1) f (f x)

it nests "n" applications of "f" to "x" with "n" defaulting to 2 if it isn't
specified, e.g. "nest ~n:3 f x" gives f(f(f(x))).

The closest to the OCaml would look like:

  def nest(x, n = 2, &f)
    if n == 0 then x else nest(f, n - 1, &f) end
  end

nest(-3) { |a| a + 1 } #=> -1

However, I'd probably write it like:
  def nest(x, n = 2)
    (1..n).inject(x) { |acc, _| yield(acc) }
  end

nest("a", 3) { |a| a + a } #=> "aaaaaaaa"

···

On Sun, May 27, 2007 at 10:15:06AM +0900, Jon Harrop wrote:

This trivial example encapsulates much of what I love about OCaml and it
doesn't translate well into any other language that I know.

you did!

forgot about that. ruby and al gore - what a combo!

cheers.

-a

···

On May 29, 2007, at 5:05 PM, Bil Kleb wrote:

ara.t.howard wrote:

we use it heavily here
http://www.ngdc.noaa.gov/dmsp/index.html

I also saw your stuff in Al Gore's /Inconvenient Truth/ movie, no?

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

Logan Capaldo wrote:

The closest to the OCaml would look like:

  def nest(x, n = 2, &f)
    if n == 0 then x else nest(f, n - 1, &f) end
  end

Ok, that's easily the best I've seen in any other language.

nest(-3) { |a| a + 1 } #=> -1

So nest(-3) defaults to nest(-3, 2) and returns a closure that accepts the
anonymous function { |a| a + 1 } and applies it to -3 twice, is that right?

Back in OCaml, that is:

  nest ((+) 1) (-3)

However, I'd probably write it like:
  def nest(x, n = 2)
    (1..n).inject(x) { |acc, _| yield(acc) }
  end

I don't understand this one. I think "inject" is a fold and "yield" returns
a value and a continuation. Looks like the continuation is ignored the next
time it is accumulated, but won't the result have a continuation in it?

nest("a", 3) { |a| a + a } #=> "aaaaaaaa"

I think this is:

  nest ~n:3 (fun a -> a^a) "a"

Thanks!

···

--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet

Logan Capaldo wrote:
> The closest to the OCaml would look like:
>
> def nest(x, n = 2, &f)
> if n == 0 then x else nest(f, n - 1, &f) end
> end

Ok, that's easily the best I've seen in any other language.

> nest(-3) { |a| a + 1 } #=> -1

So nest(-3) defaults to nest(-3, 2) and returns a closure that accepts the
anonymous function { |a| a + 1 } and applies it to -3 twice, is that right?

Back in OCaml, that is:

  nest ((+) 1) (-3)

> However, I'd probably write it like:
> def nest(x, n = 2)
> (1..n).inject(x) { |acc, _| yield(acc) }
> end

I don't understand this one. I think "inject" is a fold and "yield" returns
a value and a continuation. Looks like the continuation is ignored the next
time it is accumulated, but won't the result have a continuation in it?

inject is a fold. yield is not a continuation, but rather a way of
accessing the passed in function (block) anonymously.

def f
  yield
end

def f1(&b)
  b.call
end

f { puts "Does the same thing" }
f1 { puts "Does the same thing" }

···

On Mon, May 28, 2007 at 08:10:11AM +0900, Jon Harrop wrote:

> nest("a", 3) { |a| a + a } #=> "aaaaaaaa"

I think this is:

  nest ~n:3 (fun a -> a^a) "a"

Thanks!

--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet