For performance, write it in C - Part 2, comparing C, Ruby a

Chad P. wrote:

I can’t remember the last time I used a case statement. It was probably
in the mid 1970s in FORTRAN. And R programmers don’t tend to use as many
control structures as other language programmers do, favoring instead
the built in vector logical and indexing operators.

But I already know Perl … my original comment was that I needed to
unlearn it to learn Ruby. It’s mostly syntactic – curly braces,
semicolons, scalars beginning with dollar signs, etc. I never liked
the Perl dollar sign/at sign/percent sign syntax convention.

. . . and my point is that you shouldn’t have to “unlearn Perl”, and I
find it shortsighted and narrow to make that kind of statement with any
seriousness.

No … I don’t have to unlearn the parts of Perl that are common to
Ruby. I do have to unlearn putting semicolons at the end of every
statement, using curly braces for blocks, using tabs for indentation
instead of spaces, and starting an ordinary scalar working variable with
a dollar sign. I have to unlearn taking a string like “3.56” to an
integer power and getting a double precision value back. I have to
unlearn “$a{‘Sep’} = 3;” and replace it with “a[‘Sep’] = 3”, etc.

I don’t see that happening. I see Rails getting a lot of attention, and
many people being attracted first to it then, by way of Rails, to Ruby
in general. Ultimately, people seem to be getting enamored with the
language, with Rails as merely the “gateway drug”. The number of people
I’ve run across who do one project in Rails, then go on to use Ruby
without ever touching Rails again, outnumbers the people who come to
Rails and don’t continue to use Ruby for anything else.

Well, I downloaded Rails … I bought the book(s) … I worked through
half of the tutorial … and decided I wasn’t interested in building
that kind of web application. And until David Black’s book came along,
there really was no sense at all I could make from Rails. I could take
someone else’s Rails code and edit it without breaking it too badly,
re-implement something like the demo apps, etc., but I couldn’t actually
sit down, say, “I want my web application to do this, this, this and
this …”, and then sit down and make it happen. I simply didn’t have a
reading knowledge of Ruby.

Now I think I could do that; I’m just waiting for an excuse to build a
web app. Meanwhile, I’m building something else, and I’m building it in
pure Ruby. And I’m doing it in pure Ruby against the advice of folks who
think I should drop into C for the number crunching or use an existing
number crunching library written in C.

That’s true, too. I still don’t like it – and, in many cases, I think
Java was chosen for those applications because of the excellent
marketing Java has received, rather than because Java was the Right Tool
For The Job. Some of those applications might have been better written
using other languages. That doesn’t mean they’re bad apps, though.

Well … some of the Java applications I like are “Compendium”,
“DBDesigner4”, Protege, the PEPA Workbench, the GUI wrapper on PRISM,
and a couple of audio applications I haven’t used in a while. In those
cases, I think Java was chosen for its portability and for its
convenient GUI. It’s really being used as a “scripting language” in the
case of PRISM … the underlying application is in C for speed. The PEPA
Workbench was originally written in ML, but I don’t think the ML version
had a GUI. All the rest are “pure Java”.

They’re all GUI applications, and I suspect the only alternative to Java
would have been Tcl/Tk (or some other language with a Tk GUI) at the
time these applications were conceived. There are more choices now –
everybody has a Tk GUI, nearly everybody has a GTK, QT, Fox, and wx GUI
toolkit, and nearly everybody can do all this on Windows, Linux, Mac and
Solaris. Does Java still run on a Mac?

Yeah, even macro assembler. I’ll leave that work for someone else, for
the time being: it’s not my cup of tea.

The macro assembler programmers I know drink coffee … a lot of coffee.
:slight_smile: Do Ruby programmers drink Ruby Mist?

On Sun, Jul 30, 2006 at 11:47:57AM +0900, M. Edward (Ed) Borasky wrote:

No … I don’t have to unlearn the parts of Perl that are common to
Ruby. I do have to unlearn putting semicolons at the end of every
statement, using curly braces for blocks, using tabs for indentation
instead of spaces, and starting an ordinary scalar working variable with
a dollar sign. I have to unlearn taking a string like “3.56” to an
integer power and getting a double precision value back. I have to
unlearn “$a{‘Sep’} = 3;” and replace it with “a[‘Sep’] = 3”, etc.

Why? Why not just remember that it’s a separate language? I’ve
experienced a little negative transferrence of knowledge between Ruby
and Perl because of their similarities, but once I got past that minor
hurdle my growing knowledge in each language has only helped with my
ability to learn more about the other. If you aren’t doing the same,
you’re doing something wrong.

Chad P. wrote:

I don’t see that happening. I see Rails getting a lot of attention, and
many people being attracted first to it then, by way of Rails, to Ruby
in general. Ultimately, people seem to be getting enamored with the
language, with Rails as merely the “gateway drug”. The number of people
I’ve run across who do one project in Rails, then go on to use Ruby
without ever touching Rails again, outnumbers the people who come to
Rails and don’t continue to use Ruby for anything else.

[ snip ]

Now I think I could do that; I’m just waiting for an excuse to build a
web app. Meanwhile, I’m building something else, and I’m building it in
pure Ruby. And I’m doing it in pure Ruby against the advice of folks who
think I should drop into C for the number crunching or use an existing
number crunching library written in C.

Thanks for making my point for me.

They’re all GUI applications, and I suspect the only alternative to Java
would have been Tcl/Tk (or some other language with a Tk GUI) at the
time these applications were conceived. There are more choices now –
everybody has a Tk GUI, nearly everybody has a GTK, QT, Fox, and wx GUI
toolkit, and nearly everybody can do all this on Windows, Linux, Mac and
Solaris. Does Java still run on a Mac?

Yeah, you can still run Java on a Mac. Of course, for the purposes you
describe, I suspect Smalltalk would have been a better choice for those
applications in most cases. Smalltalk is underrated and marginalized to
the point that almost nobody thinks of it when choosing a language for a
project, though, unfortunately.

Chad P. wrote:

Yeah, even macro assembler. I’ll leave that work for someone else, for
the time being: it’s not my cup of tea.

The macro assembler programmers I know drink coffee … a lot of coffee.
:slight_smile: Do Ruby programmers drink Ruby Mist?

I’ll let you know when I’m a “Ruby programmer”, I guess. I’m just a
Ruby hobbyist for the most part, right now. In fact, I’m really kind of
a Perl and PHP programmer, and a lots-of-other-languages hobbyist. I
also get paid more for my english writing than my Perl, PHP, Ruby, et
cetera, writing – so I guess I’m an English programmer, in a sense.

Hey, whatever pays the bills.

Chad P. wrote:

Why? Why not just remember that it’s a separate language? I’ve
experienced a little negative transferrence of knowledge between Ruby
and Perl because of their similarities, but once I got past that minor
hurdle my growing knowledge in each language has only helped with my
ability to learn more about the other. If you aren’t doing the same,
you’re doing something wrong.

I learn for two reasons … either because I need to or because I want
to. I needed to learn FORTRAN because management thought macro assembly
was unmaintainable. I needed to learn Perl, because my “awk” scripts had
become unmanageable and my boss said, “Perl’s the best language for that
sort of thing now.” Which it was. I wanted to learn Lisp, Forth, R,
and Ruby. I don’t want to become a better Perl programmer. I just want
to be “good enough” at it.

Yeah, you can still run Java on a Mac. Of course, for the purposes you
describe, I suspect Smalltalk would have been a better choice for those
applications in most cases. Smalltalk is underrated and marginalized to
the point that almost nobody thinks of it when choosing a language for a
project, though, unfortunately.

Smalltalk is a member of my list of the half dozen pivotal programming
languages. The other five are macro assembler, Fortran, Lisp, APL and
Forth, Smalltalk was/is truly a marvelous environment. But when these
applications were designed, I don’t think anyone was giving away a run
time/compiler/interperter/environment for Smalltalk.

I did try Squeak at one point. I found the GUI so counterintuitive after
years of Windows and Linux desktop usage that I gave up on it. After I
build a couple of projects in Ruby, I might go back to Squeak. Is there
another freely-available Smalltalk implementation?

On 7/29/06, Chad P. [email protected] wrote:

On Sun, Jul 30, 2006 at 11:47:57AM +0900, M. Edward (Ed) Borasky wrote:

etc., etc., etc.

could you guys please take this to private email. It’s no longer about
Ruby,
it’s no longer interesting, it’s no longer appropriate for this mailing
list -
newsgroup - forum.

On Sun, Jul 30, 2006 at 03:47:38AM +0900, M. Edward (Ed) Borasky wrote:

of the code I write comes from the application domain rather than the
language. My main application domain is extracting performance data from
various text files and making coherent analytical models from it. A
combination of Perl 4, R, and relational databases is what I’ve evolved
over the years to do that, and that’s the code I write and maintain on a
daily basis.

That’s kind of a specious argument. Similarly, one never really needs
switch/case statements – you could always do it with if/else. In fact,
you don’t need if/else either – you could just do it with a series of
carefully crafted if statements. If that ends up being too ugly for
you, there’s always the option of creating a block from which you use
break statements (or equivalent for your language of choice) to
approximate elses.

. . . but it’s awfully convenient to have else and, occasionally,
switch/case statements.

the Perl dollar sign/at sign/percent sign syntax convention.
. . . and my point is that you shouldn’t have to “unlearn Perl”, and I
find it shortsighted and narrow to make that kind of statement with any
seriousness.

Actually, there is one true language. It’s called the “formal
semantics of programming languages”. :slight_smile: But more to the point, I think
there are far too many “general purpose” programming languages.

That sounds vaguely similar to the ridiculous arguments I hear from
Microsoft-fanboys who disparage the variety of GUIs available for Linux,
and the number of distros. You’re welcome to pretend you live in a
monoculture world, but please don’t do anything to convince anyone else
to agree with your fewer-choices-is-better approach to programming while
I’m in the world. I like having options. What’s to stop Python from
winning the choice-elimination war? I’d find programming considerably
less enjoyable.

A working programmer needs to know C, plus whatever languages are used
in his or her shop. Regardless of what the designers and communities for
those other languages intend(ed) them to be, they are in fact occupying
an economic niche. They are special-purpose languages by that definition.

Really? Funny, I’ve known quite a few excellent professional
programmers who never learned more C than is taught in a Programming 101
course, and a few that didn’t even learn that much. They seem to get by
just fine. Perhaps you should define your use of “working programmer”.

In this sense, Ruby is on the edge of becoming a special-purpose
language as the engine underneath Rails. I don’t have strong opinions
about whether that’s good or bad, but I do have a strong opinion that it
is the economic niche that Ruby will occupy for the foreseeable future.

I don’t see that happening. I see Rails getting a lot of attention, and
many people being attracted first to it then, by way of Rails, to Ruby
in general. Ultimately, people seem to be getting enamored with the
language, with Rails as merely the “gateway drug”. The number of people
I’ve run across who do one project in Rails, then go on to use Ruby
without ever touching Rails again, outnumbers the people who come to
Rails and don’t continue to use Ruby for anything else.

I once wrote a program in Java. This was in 1996 or thereabouts, and my
reasons for using Java were:

  1. It would run on Windows and all the flavors of UNIX that I was
    dealing with at the time. Visual Basic only runs on Windows.
  2. It had hashes, garbage collection, a reasonable object model, and
    useful compile-time error checking.
  3. It was faster than Perl for number crunching.

Those are good reasons.

Java was a new language at the time – I think it was Java 1.1. It was
certainly before Swing, Java 2, etc. I’ve never had an opportunity to do
any more Java programming, so I don’t know how it is to the folks who
use it for a living. What I do know, however, it that there are a
lot of high-quality applications written in Java.

That’s true, too. I still don’t like it – and, in many cases, I think
Java was chosen for those applications because of the excellent
marketing Java has received, rather than because Java was the Right Tool
For The Job. Some of those applications might have been better written
using other languages. That doesn’t mean they’re bad apps, though.

I think that’s quite enough off-topic rambling for one email. The point
of this last bit of nattering on, if it can be said to have a real
point, is that every (reasonable) language has its advantages and
disadvantages.
Even macro assembler? :slight_smile: This is about performance, right?

Yeah, even macro assembler. I’ll leave that work for someone else, for
the time being: it’s not my cup of tea.

On Sun, 2006-07-30 at 03:47 +0900, M. Edward (Ed) Borasky wrote:

I don’t think I’ve ever needed lexical closures.

Oh no ohh no… I think Chad hit it pretty well on the head with “well
you don’t need switch statements.” There are plenty of things in
programming languages you don’t need, but once you’ve gotten into
them, you find yourself missing them when you have to do without them.
The programming I get paid to do is largely in PHP and ActionScript 2.0
for Flash; once I got the hang of using anonymous functions in
ActionScript, which are (or at least try to be) lexical closures, I
found my life getting a lot easier. For writing very event-driven code,
such as responding to a GUI and responding to callbacks generated by
remoting, anonymous functions, (despite a strong orthodoxy in much of
the Flash community against their use) can be a great way to write
smaller, clearer code.

I submit to you that you use lexical closures all the time and don’t
even know it. You mention below that you’ve written Java, and I presume
you’ve written other object-oriented stuff. Guess what? Objects are
full of closures. The methods of an object are closures on the object
itself. If they weren’t, you wouldn’t be able to access instance
variables from them. Unless they started making everything global, and
then you may as well write in Fortran IV.

A working programmer needs to know C, plus whatever languages are used
in his or her shop. Regardless of what the designers and communities for
those other languages intend(ed) them to be, they are in fact occupying
an economic niche. They are special-purpose languages by that definition.

I only kinda-sorta know C; the university I went to didn’t use it as one
of its main teaching languages at the time (CS I and II were done in
Java, CS III in Ada 95, and I took a Programming Languages course that
used Scheme quite heavily). I picked up a little of C in an Operating
Systems course, just enough to do some programming assignments involving
POSIX threads in Linux. I’ve yet to have need of C in my paid work, but
should the occasion arise, I’ll learn it then.

Enough languages these days have inherited so many characteristics from
C, and C itself is a nice small-enough language with excellent
literature on it, that I don’t think it will be a major problem for any
reasonably experienced programmer to learn it when needed, and for the
same reason, I don’t think anyone really needs to know C unless
they’ll be working on certain kinds of projects such as a Linux kernel
module to drive some special device (the company I work at has a project
going on currently that includes just that, and also involves Java, PHP,
and ActionScript 3.0, and of course the usual amount of SQL).

In this sense, Ruby is on the edge of becoming a special-purpose
language as the engine underneath Rails.

So? C has already become something quite like a special-purpose
language as the engine underneath *nix. And why not? Writing Unix is
what C was pretty much invented for. This doesn’t imply that you can’t
do plenty of other things with it, nor that no one doesn’t do other
things with it, but a large amount of C’s usage today falls in a certain
niche. Probably the biggest part of C’s importance is the influence it
has had on other languages and on programming in general. I think it
would be just fine if Ruby followed a similar trajectory.

–ch–

On Sun, Jul 30, 2006 at 01:53:09PM +0900, M. Edward (Ed) Borasky wrote:

was unmaintainable. I needed to learn Perl, because my “awk” scripts had
become unmanageable and my boss said, “Perl’s the best language for that
sort of thing now.” Which it was. I wanted to learn Lisp, Forth, R,
and Ruby. I don’t want to become a better Perl programmer. I just want
to be “good enough” at it.

What does that have to do with “unlearning” Perl?

time/compiler/interperter/environment for Smalltalk.

I did try Squeak at one point. I found the GUI so counterintuitive after
years of Windows and Linux desktop usage that I gave up on it. After I
build a couple of projects in Ruby, I might go back to Squeak. Is there
another freely-available Smalltalk implementation?

I think there are a couple others. I haven’t much looked into it beyond
Squeak, I’m afraid.

On Sun, 2006-07-30 at 13:53 +0900, M. Edward (Ed) Borasky wrote:

I did try Squeak at one point. I found the GUI so counterintuitive after
years of Windows and Linux desktop usage that I gave up on it. After I
build a couple of projects in Ruby, I might go back to Squeak. Is there
another freely-available Smalltalk implementation?

http://smalltalk.cincom.com/downloads/index.ssp

On Mon, Jul 31, 2006 at 01:44:48AM +0900, Charles Hoffman wrote:

found my life getting a lot easier. For writing very event-driven code,
such as responding to a GUI and responding to callbacks generated by
remoting, anonymous functions, (despite a strong orthodoxy in much of
the Flash community against their use) can be a great way to write
smaller, clearer code.

  1. Sorry to hear you have to make your money primarily by writing PHP
    and ActionScript.

  2. That’s a pretty silly orthodoxy.

  3. I didn’t know you could do anything like a closure in ActionScript.
    Good to know. Thanks.

I submit to you that you use lexical closures all the time and don’t
even know it. You mention below that you’ve written Java, and I presume
you’ve written other object-oriented stuff. Guess what? Objects are
full of closures. The methods of an object are closures on the object
itself. If they weren’t, you wouldn’t be able to access instance
variables from them. Unless they started making everything global, and
then you may as well write in Fortran IV.

I tend to subscribe to the Schemers’ view, rather than the Java
programmers’ view: objects are like big, fat, complex, inelegant
closures. This is one of the reasons that I tend to be put off slightly
by languages that don’t support lexical closures – I like having the
ability to write my code with closures rather than objects sometimes.

has had on other languages and on programming in general. I think it
would be just fine if Ruby followed a similar trajectory.

. . . except that I think it would be a shame if Ruby’s niche were so
narrow as to be focused entirely on Rails.

If C is for Unix, Perl is for system administration, and PHP is for
lightweight server-side web programming, while Ruby is for Rails, it
sounds to me like Ruby’s going to go the way of the dinosaurs pretty
quickly while the other three will be around for some time to come.
Luckily, I don’t believe that Ruby’s major niche will be any more tied
to Rails than Perl’s was to CGI programming: CGI was Perl’s gateway
drug, and Rails is Ruby’s. In neither case is that likely to be the
thing for which the language is used most in the long run, I think.

Ruby, I predict, will have a rich and varied life ahead of it, and Rails
will only be a small (if interesting) part of that.

M. Edward (Ed) Borasky wrote:
-snip-

Is there another freely-available Smalltalk implementation?

There’s a better place to ask that question
http://groups.google.com/group/comp.lang.smalltalk

Isaac G. wrote:

Perhaps you could post the 5x5 Java and C programs on your website then
folk like Charles O Nutter can satisfy themselves that the numbers are
not bogus.

I will put together some pages tonight to get all the source code up.

On Mon, 2006-07-31 at 03:36 +0900, Chad P. wrote:

On Mon, Jul 31, 2006 at 01:44:48AM +0900, Charles Hoffman wrote:

On Sun, 2006-07-30 at 03:47 +0900, M. Edward (Ed) Borasky wrote:

  1. Sorry to hear you have to make your money primarily by writing PHP
    and ActionScript.

Meh, it’s a living. It’s my first paying gig out of school, and anyway
I like the company more than I like the code :wink: I’d like to try to
influence the company to consider Ruby more often. If any progress
happens in AMF4R (an open-source AMF remoting library for Ruby that
seems to have been at a standstill for a long time), that has a good
chance of happening.

  1. That’s a pretty silly orthodoxy.

I agree. I think the Flash world hasn’t traditionally been populated
with really serious programmer-types until very recently.

  1. I didn’t know you could do anything like a closure in ActionScript.
    Good to know. Thanks.

It’s based on the same ECMAScript standard as JavaScript. Not that the
implementation is all that great – the type system is pretty busted in
AS 2.0. Haven’t worked in 3.0 yet, though.