A Repeat: New Language After Ruby?

I have always felt that OO solves problems that some languages never
really had. Also, I believe that every problem is best expressed in
terms of objects. I find a lot of OO solutions very obtuse and
difficult compared to the simpler algol-like algorithms in non OO
languages. It depends on what you are doing.

Crap, crap, crap!

Of course, I meant to say I do NOT think every problem is best
expressed in terms of objects.

However, and there always is one, there is one thing that drags me back
to Java which I despise. A cross platform GUI as standard. I think that
this is what turned alot of people onto Java, I know it got me. Now if
Ruby had one that was part of the standard install for all platforms
(Windows, Linux, Macintosh as a minimum) then I could forget all about
Java and clear some space on my bookshelf.

No Tk doesn’t count!

This is one of the best most succint posts of the year! I couldn’t
have said it any better; ditto brother.

I have been hoping that FOX would become Ruby’s `standard’ (for all
platforms and part of the standard distro) GUI lib; as swing is to
Java.

I too can get by writing everything I need as long as the basic
building blocks are there. Nowadays, if an app doesn’t have a gui,
being more than a shell script, it’s destined for the thrash bin.

//ed

Fri, 23 Aug 2002 05:57:05 +0900, William Djaja Tjokroaminata billtj@y.glue.umd.edu pisze:

That’s why I really hesitate to start learning Haskell. It seems
Haskell can only be interfaced with C through some intermediary
called “Greed Card” and not directly as between C and Ruby.

You don’t have to use GreenCard (which is kind of obsolete). You can
write glue code by hand; most of glue is on the Haskell side. The
language offers the ability to call C functions directly from Haskell,
provided that you have arguments ready in Haskell types corresponding
to C types:

foreign import “fnmatch” unsafe
fnmatchC :: Ptr CChar → Ptr CChar → CInt → IO CInt

and offers a library for converting basic types and managing C memory.
Here is how fnmatch might be wrapped in Haskell: pattern and string
are Haskell strings converted to Ptr CChar values pointing to temporary
buffers, and flags is a list of values instead of a bitmask:

fnmatch :: String → String → [MatchFlag] → Bool
fnmatch pat str flags = (
unsafePerformIO $
withCString pat $ \patPtr →
withCString str $ \strPtr →
fnmatchC patPtr strPtr flagsInt) /= 0
where
flagsInt = (flag FnmFileName (#const FNM_FILE_NAME)) .|.
(flag FnmPeriod (#const FNM_PERIOD)) .|.
(flag FnmNoEscape (#const FNM_NOESCAPE)) .|.
(flag FnmLeadingDir (#const FNM_LEADING_DIR)) .|.
(flag FnmCaseFold (#const FNM_CASEFOLD))
flag cons bit = if cons elem flags then bit else 0

The #const construct is not real Haskell and this file must be run
through hsc2hs preprocessor which replaces them with integer literals
corresponding to these C constants.

You can convert Haskell functions to C function pointers (requires
nonportable magic from the Haskell compiler to build code on the
heap) and directly access C variables (i.e. obtain the pointer to
the variable from Haskell and use Haskell functions to read and write
through it).

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/

Hi,

Thanks for the info. I have scanned the Haskell web page, but the answer
is not obvious. Can we really call C from Haskell and call Haskell from
C, at least as good as the interaction between Ruby and C? (Sometimes the
information like this cannot be obtained until we are really deep in the
language.)

Because Ruby is also procedural, basically there is some kind of
one-to-one mapping between Ruby and C. Because Haskell is functional, I
don’t know whether it is possible. For example, there is already Ruby
interface for vi (or vi interface for Ruby?), but there is no such thing
for GNU Emacs, as Emacs is written in Lisp; some people say that
Ruby-Emacs interaction is impossible.

Regards,

Bill

···

============================================================================
Nat Pryce nat.pryce@b13media.com wrote:

On Thu, 2002-08-22 at 14:55, William Djaja Tjokroaminata wrote:

I have some doubt with functional programming languages. Can Haskell or
any of them be interfaced with C/C++/Java (at the linking level)?

Yes. Haskell code can make calls to C. That’s how I/O, user
interfaces and other services are implemented.

But… why are you asking this on the mailing list instead of
downloading a Haskell system and learning it for yourself? :slight_smile:

now that’s interesting.

would you consider porting back if we could give you a good GUI
solution?

···

On Thu, 2002-08-22 at 12:16, Jim Menard wrote:

That is the only reason I translated DataVision from Ruby to Java. The code
feels bloated now, but at least the GUI runs everywhere without end users
having to install a GUI library.


~transami

oh sure… now take it back :wink:

but seriously if you consider for a moment that even our thoughts are
utterly steeped in the concept of object, i don’t think that the OO
aspect of Ruby or any other object oriented language is the real cause
of these problem expressions to which you refer. i think it is more to
do with the fact that our programmable object models aren’t more
malleable and flexible.

~transami

···

On Thu, 2002-08-22 at 14:57, Charles Shannon Hendrix wrote:

Crap, crap, crap!

Of course, I meant to say I do NOT think every problem is best
expressed in terms of objects.

Right. The main use I’ve had for functional programming languages these
days is for prototyping. Once I got comfortable with programming in
OCaml it was ridiculously easy to create baroque data structures and
elegant algorithms to manipulate them, in a fraction of the time it
would have taken to do the same thing in a more low-level language like
C, mainly because I didn’t get the headaches that come from pointer
tracing and other pitfalls. From there, the ideas obtained from the
prototype clarified the process of writing the final C code, which was
far more elegant, maintainable, and understandable, I suspect, than had
I not tried to make the prototype and jumped straight to C.

···

On Fri, Aug 23, 2002 at 12:54:53AM +0900, Gavin Sinclair wrote:

(My concern is, if I
really write a Haskell code for a project, then I am stuck with Haskell, I
cannot switch parts of it to C.)

You’re not stuck with Haskell; you can port it to Ruby. Or C.


Rafael R. Sevilla +63(2)8123151
Software Developer, Imperium Technology Inc. +63(917)4458925

In article ak3icc$stl$1@grapevine.wam.umd.edu,

Very well said, Charles. I completely agree with you.

That’s why I really hesitate to start learning Haskell. It seems Haskell
can only be interfaced with C through some intermediary called “Greed
Card” and not directly as between C and Ruby. Also one of my colleages
here is learning Scheme. I still cannot persuade myself to learn Haskell
in particular (why not Scheme, or even Emacs Lisp, which will make my
editor do all the wonderful things?) or a functional language in general.

Regards,

Bill

(deleted)

I used to be where you are, but now I generally have to feel like a
language will help me get work done before I can spend time on it.

    • Well, two years ago I would have been right with you. Why spend
      time on learning something new, I’ll pick it up fast enough if
      I need to. I was very bored and disatisfied at work. Something
      was definitely wrong. I started looking back at how I got
      sucked into this whole computer thing and I realized that it
      was because I liked learning new things. In the job world it’s
      easy to get in a rut, after all once you’ve climbed the
      learning curve a few times you rarely get that much out of
      repeating the process.
    • However, I thought about it a lot and I resolved that I would
      spend at least one afternoon a week on “playing”,
      i.e. exploring new tools and languages regardless
      of whether they would be useful or not. I eventually poked
      around with Ruby and from there got lead to the book
      “The Pragmatic Programmer”. That book definitely put me
      in touch with why I drifted into computers to begin with.
      The first few chapters are actually kind of depressing,
      it’s a sad commentary on the computer industry that people
      actually have to be told to do some of the very basics,
      but I found the rest of the book to be very inspirational.
      It reminded me of how I should be doing things,
      “Quality is Important”. I also reread “Zen and the Art of
      Motorcycle Maintainance” at about the same time. It really
      drove home the point to me that I would never be satisfied
      with computers until I could feel that I was doing quality
      work and not just “yet another awful hack”.
    • IMHO, if you program for a living and your job doesn’t allow
      you the time and space to try things “just for the heck of it”.
      It’s time to get a new job. Working with computers can
      easily turn into depressing grunt work even with a 6 figure
      salary.
    • I think learning a functional language is a useful thing to
      do, at least read some of the original papers. I actually get
      a lot more out of reading the design papers than twiddling the
      bits, but you have to do enough bit twiddling to really get
      the papers. I came to the realization that Ruby is many ways
      a functional language.
    • Lastly, read “The Pragmatic Programmer” if you haven’t and
      try and stick with it to the later chapters.
    • Booker C. Bense
···

William Djaja Tjokroaminata billtj@y.glue.umd.edu wrote:

Charles Shannon Hendrix csh_hatespam@widomaker.com wrote:

one word: GUtopIa

···

On Sun, 2002-08-25 at 19:25, Edward Wilson wrote:

However, and there always is one, there is one thing that drags me back
to Java which I despise. A cross platform GUI as standard. I think that
this is what turned alot of people onto Java, I know it got me. Now if
Ruby had one that was part of the standard install for all platforms
(Windows, Linux, Macintosh as a minimum) then I could forget all about
Java and clear some space on my bookshelf.

No Tk doesn’t count!

This is one of the best most succint posts of the year! I couldn’t
have said it any better; ditto brother.

I have been hoping that FOX would become Ruby’s `standard’ (for all
platforms and part of the standard distro) GUI lib; as swing is to
Java.

I too can get by writing everything I need as long as the basic
building blocks are there. Nowadays, if an app doesn’t have a gui,
being more than a shell script, it’s destined for the thrash bin.

//ed


~transami

William Djaja Tjokroaminata wrote:

Very well said, Charles. I completely agree with you.

That’s why I really hesitate to start learning Haskell. It seems Haskell
can only be interfaced with C through some intermediary called “Greed
Card” and not directly as between C and Ruby. Also one of my colleages
here is learning Scheme. I still cannot persuade myself to learn Haskell
in particular (why not Scheme, or even Emacs Lisp, which will make my
editor do all the wonderful things?) or a functional language in general.

Regards,

OCaml can be extended easily extended by C-functions. (It’s a bit more
complicated than extending Ruby, but still not too hard.)

I have chosen OCaml because it’s great performance and practical libraries
and because it seems to be very stable.

OCaml has the ambititon to become a really usefull language for everyday use,
not just an experimental one for theoretical purposes. For me Haskell seems
to be quite a “toy for students”, while OCaml is a really serious and practical
project. (I don’t want to offend anybody, these are just my impressions, and
not backed by too much experience on Haskell.)

Any language that includes C as a proper subset will have problems with
garbage collection, will not be able to rely on the types of variables, will
have to deal with casts, …

When you accept C, you are accepting a huge amount of baggage. It was
necessary when C was being designed, and for some purposes still is. But it
makes safe programs, at the absolute best, very difficult. (Mind you, Ruby’s
no star here either. It frequently can only tell you “a parenthesis wasn’t
closed somewher in this file”. (Possibly that’s a string error rather than a
parenthesis error.) And if you omit a closing end, the error messages are …
strange. But variables know what kind of variable they are, and that pays
for a lot. So does automated garbage collection. (When you interface it
with C, watch out for this one, as it takes care.)

What I would like is a decent way to interface Ruby with, say, Ada (decent
includes you don’t need to step through C on the way between them). Ada is
a pretty good language of the C kind (actually, it’s closer to C++) which is
hampered a lot by the lack of flexibility, and area where Ruby excells. C is
both efficient and flexible, but is nearly as dangerous as assembler
(reasonable, there was a macro assembler created for the 6800 that included
most of the features of C).

···

On Thursday 22 August 2002 08:54, you wrote:

The lsnguage you mention most is C. Why not learn advanced C?

Gavin

Tom Sawyer transami@transami.net writes:

That is the only reason I translated DataVision from Ruby to Java. The code
feels bloated now, but at least the GUI runs everywhere without end users
having to install a GUI library.

now that’s interesting.

would you consider porting back if we could give you a good GUI
solution?

I’m not sure. DataVision has a large user base now and I can’t abandon
them. I will have to continue Java development even if I port it back to
Ruby.

I would also have to think about what would make a “good GUI solution”. I
started by tring Tk, FOX, and Gtk. Each one didn’t do something I wanted.
Don’t ask what; it’s been about a year since I switched.

You can still get the Ruby version; visit
DataVision - Browse Files at SourceForge.net and grab
version 0.0.2.

Jim

···

On Thu, 2002-08-22 at 12:16, Jim Menard wrote:

Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“I am sure that like Java, [C#] will be a ‘no pointer’ language, where the
most common runtime error will be a ‘NULL pointer exception’.”
– Jerry Kott, in comp.lang.smalltalk

I agree with the prototyping thing. In fact, that is what I just did. I
have written my network simulator in Ruby. The core is complete; it is
done. However, the performance is poor for a network simulator. When I
start to “replace” the most critical parts to C, it gets 10 times faster.

Now, here is where Ruby really shines. Because Ruby is procedural,
translating (or porting?) from Ruby to C, other than the data structure,
is relatively straighforward. Furthermore, because the class and module
definitions in Ruby are never closed, I really can mix and match the parts
in Ruby and C.

I doubt that I can do the same thing with Haskell. When I start to
“port” from Haskell to C, I guess the C port cannot be run until it is
completely finished; no mix and match like Ruby and C. Also, although I
don’t have the experience yet, my feeling is that it will not be easy to
translate from Haskell to C. Yes, probably there is some great concept or
code construct that we can write in Haskell; but then when we try to write
it in C, my concern is we will encounter barriers.

Regards,

Bill

···

===========================================================================
Rafael ‘Dido’ Sevilla dido@imperium.ph wrote:

On Fri, Aug 23, 2002 at 12:54:53AM +0900, Gavin Sinclair wrote:

(My concern is, if I
really write a Haskell code for a project, then I am stuck with Haskell, I
cannot switch parts of it to C.)

You’re not stuck with Haskell; you can port it to Ruby. Or C.

Right. The main use I’ve had for functional programming languages these
days is for prototyping. Once I got comfortable with programming in
OCaml it was ridiculously easy to create baroque data structures and
elegant algorithms to manipulate them, in a fraction of the time it
would have taken to do the same thing in a more low-level language like
C, mainly because I didn’t get the headaches that come from pointer
tracing and other pitfalls. From there, the ideas obtained from the
prototype clarified the process of writing the final C code, which was
far more elegant, maintainable, and understandable, I suspect, than had
I not tried to make the prototype and jumped straight to C.


Rafael R. Sevilla +63(2)8123151
Software Developer, Imperium Technology Inc. +63(917)4458925

Hi,

Thanks for sharing your thoughts. Is it really true that Ruby is in many
ways a functional language? I know that Ruby was influenced to a certain
degree by Lisp, but can you elaborate on this further? If Ruby indeed has
some functional language nature, I will nominate Ruby as “the ultimate
functional language” :), just like one C course instructor called C as the
“ultimate assembly language”.

I am almost at the point of deciding to learn a functional language. The
only problem is still the question, why Haskell? Why not Scheme, ML, or
Lisp, which have discussion groups?

Regards,

Bill

···

==========================================================================
bbense+comp.lang.ruby.Aug.23.02@telemark.stanford.edu wrote:

    • I think learning a functional language is a useful thing to
      do, at least read some of the original papers. I actually get
      a lot more out of reading the design papers than twiddling the
      bits, but you have to do enough bit twiddling to really get
      the papers. I came to the realization that Ruby is many ways
      a functional language.
    • Lastly, read “The Pragmatic Programmer” if you haven’t and
      try and stick with it to the later chapters.

That’s the word this thread has been waiting for.

When you’re playing, you’re having fun. And when you’re having fun,
you make good things.

Dave, may I say that playing is a very pragmatic thing to do?

Massimiliano

···

On Sat, Aug 24, 2002 at 12:38:42AM +0900, bbense+comp.lang.ruby.Aug.23.02@telemark.stanford.edu wrote:

    • However, I thought about it a lot and I resolved that I would
      spend at least one afternoon a week on “playing”,

Sat, 24 Aug 2002 00:58:45 +0900, William Djaja Tjokroaminata billtj@z.glue.umd.edu pisze:

Is it really true that Ruby is in many ways a functional language?

In one way it is: it makes great use of anonymous functions with
lexical scope (i.e. blocks and procs), including basic library
functions for iterating over lists. Unpacking multiple results into
named variables is also the way functional languages usually return
several results.

In another way it isn’t: modifying values and binding new values to
variables is common, and even strings are mutable.

It also doesn’t provide common functional features: pattern matching
together with extracting values from components of matched structured
values; lists in the style of Lisp/Scheme/ML/Haskell/etc. - a list
is either empty or consists of the first element (head) and the rest
which is a list (tail), where accessing tail and building a new list
from given head & tail is O(1); or algebraic types in general.

I am almost at the point of deciding to learn a functional language.
The only problem is still the question, why Haskell? Why not Scheme,
ML, or Lisp, which have discussion groups?

I’m subscribed to 13 Haskell-specific mailing lists (including related
to particular compilers).

Haskell is more pure compared to these other languages: side effects
like I/O are in a separate layer in the language semantics, and mutable
variables are rare (not in the standard even). Haskell’s type system
is more advanced than ML’s (and also more complex), it has a very
interesting system of overloading/dispatching.

OTOH OCaml is more practical: very fast implementation. Haskell strings
are lists of characters, so you construct and deconstruct them with
recursive functions, your own or generic list functions, and it’s
convenient but slow; OCaml strings are array-like and mutable, you
must preallocate and fill them (inconvenient and bad style but fast)
or glue from smaller strings (more convenient but slower) or use an
extensible string buffer (not functional style).

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ Blog człowieka poczciwego.

Thanks for sharing your opinion. I completely agree with you. I think
learning a new thing is important, but because of the schedules and
priorities, I think it is better if the new language can also be put
practically for everyday use. Well, for me probably it is left to choose
among Haskell, Scheme/MzScheme/Guile (because of SWIG) and OCaml…

Regards,

Bill

···

===========================================================================
Christian Szegedy szegedy@nospam.or.uni-bonn.de wrote:

OCaml can be extended easily extended by C-functions. (It’s a bit more
complicated than extending Ruby, but still not too hard.)

I have chosen OCaml because it’s great performance and practical libraries
and because it seems to be very stable.

OCaml has the ambititon to become a really usefull language for everyday use,
not just an experimental one for theoretical purposes. For me Haskell seems
to be quite a “toy for students”, while OCaml is a really serious and practical
project. (I don’t want to offend anybody, these are just my impressions, and
not backed by too much experience on Haskell.)

FWIW, the last three projects I’ve started the lack of a decent GUI solution
was one of the main reasons that I didn’t choose Ruby. Reports are important
too, but one runs across the GUI problem first.

···

On Thursday 22 August 2002 12:07, you wrote:

On Thu, 2002-08-22 at 12:16, Jim Menard wrote:

That is the only reason I translated DataVision from Ruby to Java. The
code feels bloated now, but at least the GUI runs everywhere without end
users having to install a GUI library.

now that’s interesting.

would you consider porting back if we could give you a good GUI
solution?

FWIW, the last three projects that I’ve started, the lack of a decent GUI was
a main reason for not considering Ruby. Reports are important too, but one
runs across the GUI problem first.

Mind you, these were small, internal, projects, but that’s probably a much
more common kind of thing to need done.

···

On Thursday 22 August 2002 12:07, you wrote:

On Thu, 2002-08-22 at 12:16, Jim Menard wrote:

That is the only reason I translated DataVision from Ruby to Java. The
code feels bloated now, but at least the GUI runs everywhere without end
users having to install a GUI library.

now that’s interesting.

would you consider porting back if we could give you a good GUI
solution?

Another Urban Legend strikes! :slight_smile:

C is older than the 6800, by rather a lot. (C predates
microprocessors in general, IIRC, unless you consider the original
intel 4004 a microprocessor)

C’s generally considered a PDP-11 assembly, but K&R have denied that.

···

At 2:20 AM +0900 9/3/02, Charles Hixson wrote:

(reasonable, there was a macro assembler created for the 6800 that included
most of the features of C).


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk