Forum: Ruby Developing cross-platform web/GUI applications

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
827b1643b9e1ac6af6a9341db5bd3f6a?d=identicon&s=25 Jon Harrop (Guest)
on 2007-05-26 22:55
(Received via mailing list)
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,
3bb23e7770680ea44a2d79e6d10daaed?d=identicon&s=25 M. Edward (Ed) Borasky (Guest)
on 2007-05-27 00:35
(Received via mailing list)
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.
827b1643b9e1ac6af6a9341db5bd3f6a?d=identicon&s=25 Jon Harrop (Guest)
on 2007-05-27 03:16
(Received via mailing list)
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. :-)

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. :-)

> 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!
B19b02a49b433c9e2e6e6c43785d2bfb?d=identicon&s=25 James Tucker (Guest)
on 2007-05-27 09:10
(Received via mailing list)
Jon Harrop wrote:
> 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.
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2007-05-27 16:26
(Received via mailing list)
On Sun, May 27, 2007 at 10:15:06AM +0900, Jon Harrop wrote:
> 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[x], 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"
827b1643b9e1ac6af6a9341db5bd3f6a?d=identicon&s=25 Jon Harrop (Guest)
on 2007-05-28 01:11
(Received via mailing list)
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[x], 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!
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2007-05-29 01:01
(Received via mailing list)
On Mon, May 28, 2007 at 08:10:11AM +0900, Jon Harrop wrote:
>
> >   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" }
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-05-30 00:55
(Received via mailing list)
On May 26, 2007, at 2:55 PM, Jon Harrop wrote:

>
> 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?

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
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-09-25 23:04
(Received via mailing list)
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?

you did!

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

cheers.

-a
A87f7a014c624587fab0d3d78c5b9c18?d=identicon&s=25 Bil Kleb (Guest)
on 2007-09-25 23:08
(Received via mailing list)
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,
A87f7a014c624587fab0d3d78c5b9c18?d=identicon&s=25 Bil Kleb (Guest)
on 2007-09-25 23:10
(Received via mailing list)
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. :-)

I'd recommend you start with Camping,

  http://camping.rubyforge.org

instead then migrate to Rails if need more amenities.

Regards,
This topic is locked and can not be replied to.