Ruby vs Java vs c++

C

Charles D Hixson

Chilkat said:
About 20 years ago, when I graduated from University of Illinois' with
a BS in Computer Science / Engineering,
the department's philosophy was for students to acquire an
understanding of computers and programming
from the ground up. That meant from the electronic circuit level, to
the logic level (NAND and NOR gates),
to assembly programming, and on up. My answer to the original
question is based on this philosophy.
I recommend starting at the C/C++ level simply to gain a fundamental
understanding of the bits & bytes,
pointers, pointer arithmetic, structure layouts, byte ordering,
structure member alignment, dynamic memory
allocation on the heap as opposed to the stack, etc. Understanding
this gives you a good idea
as to what's going on "under the hood" with higher-level languages.
Things won't be so mysterious.
It'll pay off in the long run.

-Matt
From that perspective, I'd recommend starting with MIX & Knuth. But if
you want faster results pick Ruby or Python.

I'd NEVER recommend C++. C, perhaps, to establish a solid grounding in
the fundamentals...but not for anything serious. It takes too long.
One compiled language that you might try is D (Digital Mars D), with
links to C libraries to accomplish the things that aren't yet built in.

OTOH, for many uses Ruby and Python are BOTH hard to beat. I like Ruby
better as a language, but Python seems to have more bug-free libraries.
(Well, free of "show stopper" bugs.) And Python has a wider variety of
libraries. (Still, you find me here in the Ruby news group. I like
Ruby better.)

WARNING: NO LANGUAGE IS PERFECT!! Choose the language to suit the
problem. For some problems Java is the best available solution. (I'm
not aware of ANY problems for which I would choose C#, but that's
because of potential legal issues...so I won't even look at it.)
 
C

Charles D Hixson

Roseanne said:
Everybody here or somewhere else take that for granted: Java is slower
than C++, but actually that is not true.

I thought so too. However, my computational heavy practice proved, to
certain extent, otherwise.

Interesting enough, I was a very experienced C++ programmer, and
learning Java in 2000. I got an very heavy algorithm job. I write the
same code in Java and C++. When the algorithm was relatively simple, my
C++ code was about twice faster than Java c++/Java = 610/1085. However,
when my algorithm became extremely heavy iteration, the result was
c++/Java = 26000/12000. Java was more than twice faster than C++.

I asked several Java experts include Jason Hunter, Daniel Brookshier
about the question, why? The answers are the same, JIT!!!!
Your answer is processor cache relative. It also depends on how well
the C++ optimizer works.
OTOH, D (Digital Mars D) also turns in times faster than C++...probably
for similar reasons. And it's a compiled language. Theoretically, with
a good optimizer, this should be impossible...so I suspect the C optimizer.
 
G

Gregory Brown

Quick quiz -- how many vim users actually donate money to the orphanage
in Uganda?

Good question. I should do that sooner or later.
Actually, what made Vim my editor of choice was the GVim implementation
on Windows, not the Unix/Linux versions. After all, they already had vi,
and for those with enough memory, emacs. But the ability to do both "vi"
keystroke editing and Notepad-like cut and paste in GVim was what made
it indispensable to me.

Most of the time vi is just aliased to vim on newer systems.
(possibly in the ugly compatible mode). Yeah, I liked GVim a lot when
I was still using windows a lot, I find myself using command line vim
even on windows now, just because of my fear of the mouse.

The reason I started using vim maybe 7 years ago was because I opened
up emacs first, couldn't figure out how to edit a file or close it in
five seconds, and then had to kill the process. I opened up vim and
it told me how to do that right away. I think emacs has something to
that effect now.... But that was literally the arbitrary decision I
made. Now I'm just happy enough with vim that what others have shown
me in Emacs I can usually do in vim, so there is no compelling reason
for me to switch. So it keeps me out of holy wars usually, except for
the occasional support of Vim just to be loyal :)
ArchLinux, eh? I've forgotten -- is that a Debian derivative?

http://archlinux.org/about/

I think it was based on CRUX, actually.

They're *much* less concerned with licensing issues. I'm a bit of an
idealist when it comes to maintaining a free operating system, but
when I have hardware that free drivers barely support without pain,
I'm willing to slip a little. ;)

The real reason why I like ArchLinux though is because it offers the
flexibility and simplicity of something like Gentoo without waiting
weeks for things to compile :) (Yes, gentoo has binaries too, but it's
too tempting to use the shiny build system). Arch does have a decent
build system, when it is needed though.

I can probably fit the applications I use regularly onto my fingers,
so as simple a system as possible is what I crave. :)
 
M

M. Edward (Ed) Borasky

Charles said:
Your answer is processor cache relative. It also depends on how well
the C++ optimizer works. OTOH, D (Digital Mars D) also turns in times
faster than C++...probably for similar reasons. And it's a compiled
language. Theoretically, with a good optimizer, this should be
impossible...so I suspect the C optimizer.
The process of profiling/optimizing C++ is an iterative one, and most
folks have neither the patience nor the need for it. There's an
excellent (AMD-64/Intel x86-64 based) reference work on the subject at
http://www.agner.org/optimize/. But for the most common number crunching
tasks, dense matrix operations and Fast Fourier Transforms, I doubt
seriously if anybody's JIT can beat Atlas and FFTW. Tie them, perhaps,
but not beat them.
 
J

Joel VanderWerf

Friedrich said:
It's very C-ish but the libraries make the difference. However others
have written C-Interpreters also:
Eic (now abondoned)
Cint http://root.cern.ch/root/Cint.html
and another one which name I forgot...

There's tcc[1]. It's a C compiler for linux and (maybe) now windows that
is fast enough to use for scripting. This is not quite OT. It would be
great to use libtcc[2] with inline C code when compile time is more
critical than run time. And you don't have to muck with tempfiles.

[1] http://fabrice.bellard.free.fr/tcc/
[2] http://fabrice.bellard.free.fr/tcc/tcc-doc.html#SEC22
 
S

stef

Diego said:
Although I must agree that Paul was nitpicking too much, and I am
happy to be a bit flexible (for example lots of friends forget to
capitalize the first word of a sentence), some of those abbreviation
you used do take a while to be "processed".

You may think your readers will be happy to put up with it, but most
probably if they cannot work out one of your abbreviation in some
short time, they'll just give up and move to the next question.

So it's all a matter of who has the most interest in the
communication, if you or your reader.

That said, maybe you can set a small ruby script and everyone wins,
you get speed and the rest of us get clarity. :)

Diego

I didn't realize I was being so cryptic. I guess I'll have to remember
to post to this newsgroup in PLAIN and proper English.
Maybe I should make a script as you suggested.... ;)

--
 
C

Charles D Hixson

Jim said:
...
If you're not too attached to the mainstream, Eiffel could be another
choice - efficient (statically compiled, like C++), but higher-level
than C++; has GC but is better designed than Java, as far as the language
itself. Designed to facilitate writing correct programs. If this
interests you, do a bit of googling/research to learn about its
advantages and disadvantages and see if it's worth pursuing further.
(There are two GNU-licensed Eiffel compilers available:
http://eiffelzone.com/esd/studio/index.html
http://smarteiffel.loria.fr/
.)
...


Eiffel USED to be a good language. Unfortunately they started making a
lot of the wrong changes a few years ago. Now... well, it was a small
language to begin with, but it's split into at least three mutually
incomprehensible dialects. Also they've suppressed a lot of the good
features while trying to add compatibility with MS.NET and also while
adding tuples. During this process they broke many of the extant
libraries. If something survives from this, it might again be a decent
language to look at in a decade (perhaps slightly less). Unfortunately,
while they are feuding, other languages are progressing. I note that
Ada 2000 didn't add garbage collection, so it's still out of the loop,
but there are new contenders. My favorite among the compiled languages
is D (Digital Mars D), though I'm also giving a bit of consideration to
Gambit Scheme with Termite. (To be honest, the Scheme thing is probably
on indefinite hold...but Termite sounds quite interesting for a few
years from now when more than two processors/CPU becomes common.
[Currently I have an SMP system with two processors, so this wouldn't
buy me much, but how many CPU slices with my next computer have?])
 
S

stef

Ross said:
stef wrote:

/ ..


Translation for Earthlings:

"I am reading every single post in the thread, believe me. Thank
you for the information."

French is easier.

How about introducing an [OT][WHINE] subject prefix for this stuff?
So I know to skip your persistently-off-topic whining, of course...

You do have a point there. Some people are just plain A-N-A-L.....

--
 
C

Charles D Hixson

David said:
Isn't VBA rather similar to Ruby, anyway?
I stopped using VBA after I caught it making arithmetic mistakes. Not
rounding errors, outright mistakes. Now granted this was over 5 years
ago now, and they MAY have improved things...but I wouldn't trust it any
more. I actually rewrote things to use Excel macros to avoid doing
arithmetic in VBA. I never did figure out under what circumstances it
would do this, but ever since then I've had an extreme distrust of
everything programmed in MSOffice. I figure that Excel macros are
probably safe...because there would be so many eyes looking at them.
But I'm not sure. I never heard anyone else saying that they had caught
VBA (actually basic for MSAccess2000) in an arithmetic error, but I
definitely did. The numbers were small enough that a third grader would
have seen the error, and there wasn't ANYTHING subtle about the program.

IS it similar to Ruby? I sure hope not.
 
M

M. Edward (Ed) Borasky

Charles said:
I'm also giving a bit of consideration to Gambit Scheme with Termite.
(To be honest, the Scheme thing is probably on indefinite hold...but
Termite sounds quite interesting for a few years from now when more
than two processors/CPU becomes common. [Currently I have an SMP
system with two processors, so this wouldn't buy me much, but how many
CPU slices with my next computer have?])
If you want a "core language", Gambit Scheme/Termite is a good choice.
For small/agile production, it's probably adequate. But if you want an
industrial strength large-product software development environment with
the same underlying concurrency semantics (more or less), you should
probably be looking at Erlang/OTP. It's open source (but standardized by
Ericksson) and has lots of infrastructure (compilers, interpreters,
correctness analysis tools, databases, etc.)
 
M

M. Edward (Ed) Borasky

Charles said:
I stopped using VBA after I caught it making arithmetic mistakes. Not
rounding errors, outright mistakes. Now granted this was over 5 years
ago now, and they MAY have improved things...but I wouldn't trust it
any more. I actually rewrote things to use Excel macros to avoid
doing arithmetic in VBA. I never did figure out under what
circumstances it would do this, but ever since then I've had an
extreme distrust of everything programmed in MSOffice. I figure that
Excel macros are probably safe...because there would be so many eyes
looking at them. But I'm not sure. I never heard anyone else saying
that they had caught VBA (actually basic for MSAccess2000) in an
arithmetic error, but I definitely did. The numbers were small enough
that a third grader would have seen the error, and there wasn't
ANYTHING subtle about the program.
Excel itself has a long and painful history of mathematical
incorrectness. To be fair, some of it came from the need to be upward
compatible from Lotus 1-2-3, which in turn needed to be upward
compatible from VisiCalc. A simple example is the belief in Excel that
1900 was a leap year. I'm not sure what Google query you can use to hunt
down this stuff, but I would not make business decisions based on
anything done with Excel. I use it as an X-Y plotter when I'm in a
hurry, but when I actually care about the numbers, I do things in R.
 
H

Hal Fulton

EB said:
I actually wrote some programs in RATFOR (Rational Fortran) .. man
I feel old.

Oh, so you own _Software Tools_, eh?

There was an option to order the software, you may
recall... not on CD, not on floppy... on tape.
Big honking reel-to-reel magnetic tape.

There was actually a _Software Tools in Pascal_, too,
which I still have somewhere.


Cheers,
Hal
 
G

gregarican

The corporate-owned, single-vendor product angle is a debatable point.
Couldn't you say that about --- hmm, lessee --- C being started at Bell
Labs, Smalltalk being started at Xerox PARC, Java being started at Sun,
etc.? Plenty of languages were started by companies and weren't
collaborative FOSS. That doesn't mean they are inherently flawed or
unworthy of consideration because of that. Now Microsoft being behind
languages such as C# and whatnot could restrict platform implementation
to Windows only. But then again look at Mono. Plus with Microsoft's
WPF/E the intent is to deploy .NET to a variety of devices, not just
Windows PC's. There will be a WPF/E plug-in for web browsers such as
Safari, Mozilla, Opera, etc.
 
E

EB

James said:
Sure, I *can*, but I'll be less inclined to undertake the effort of
reading something if it makes my eyes bleed. Failing to use proper
English is jarring to me. Most of us grew up reading books; the English
you use is not the English we are used to reading.

Boy, you are going to love this (frightening development, IMHO):

New Zealand students to use 'text-speak' in exams

The Associated Press

New Zealand's high school students will be able to use "text-speak"
-- the mobile phone text message language beloved of teenagers --
in national exams this year, officials said Friday.

Text-speak, a second language for thousands of teens, uses abbreviated
words and phrases such as "txt" for "text", "lol" for "laughing out
loud" or "lots of love," and "CU" for "see you."

The move has already divided students and educators who fear it could
damage the English language.

New Zealand's Qualifications Authority said that it still strongly
discourages students from using anything other than full English, but
that credit will be given if the answer "clearly shows the required
understanding," even if it contains text-speak.

The authority's deputy chief executive for qualifications, Bali Haque,
said students should aim to make their answers as clear as possible.

Confident that those grading papers would understand answers written
in text-speak, Haque stressed that in some exams, including English
-- where good language use is specifically required -- text
abbreviations would be penalized.

Post Primary Teachers' Association President Debbie Te Whaiti said the
authority's move reflects the classroom situation.

"Individual teachers are grappling with it (texting) every day," she
said

Teachers would have concerns if text slang became acceptable in
everyday written language in classrooms, she said.

Critics said the National Certificate of Educational Achievement or
NCEA, the main qualification for high school students, would be
degraded by the authority allowing text speak use in exams.

The minor United Future Party said in a statement: "Untd Futr is
cncernd bout da xeptnce of txt spk 2 b allwd in ritn xams 4 NCEA
(United Future is concerned about the acceptance of text speak to be
allowed in written exams for NCEA)."

"Skoolz r ther 2 educ8 + raze litracy 2 certn standrds (Schools are
there to educate and raise literacy to certain standards," the
statement quoted United Future lawmaker Judy Turner as saying." NCEA
shudnt let da standrd b decidd by informl pop cultr of da time."

High School principal Denis Pyatt said he wouldn't encourage students
to use text abbreviations in exams -- but he was excited by the
language development.

"I think text messaging is one of the most exciting things that has
happened in a long time. It is another development in that wonderful
thing we call the English language," he said.

Internet blogger Phil Stevens was not amused by the
announcement. "nzqa(New Zealand Qualifications Authority): u mst b
joking," Stevens wrote. "or r u smoking sumthg


http://www.iht.com/articles/ap/2006/11/09/asia/AS_ODD_New_Zealand_Text_Exam.php
http://www.cnn.com/2006/WORLD/asiapcf/11/11/nz.text.ap/index.html


EB
 
H

Henry Maddocks

'd love some comments that might help me consider my options and
pick a
path (c++, java or ruby) w/ a higher level of confidence..... i
know that
people here will be biased towards Ruby, but that is fine: i want
to hear
about it....

I have been thinking, and talking, about this quite a bit lately.
Here is my take...

Learn Ruby and C. With Ruby you can write programs fast, with C you
can write fast programs, ie write your system in Ruby and then
rewrite the slow bits in C (rubyinline?).

C++'s days are numbered unless you are doing seriously performance
critical stuff (visualisation, some games, etc). Java is an
improvement but then Ruby is at another level.
 
M

M. Edward (Ed) Borasky

Henry said:
C++'s days are numbered unless you are doing seriously performance
critical stuff (visualisation, some games, etc). Java is an
improvement but then Ruby is at another level.
How does C++ deliver "seriously performance critical" applications where
C can't? Are the optimizers/code generators better for C++ than they are
for C? I would think a pure C code would have *better* performance,
simply because the language is simpler and easier to optimize.
 
J

Jon Egil Strand

My literacy is just fine, thank you very much. For the sake of speed, I
use shortcuts.

Please do understand that it is not _your_ literacy that's important, it's
_my_ litereacy you should care about. If I am to help you, which I am more
than happy to do if I can, I need to understand.

I understand your question faster and better when communication is clear,
potentially leading to faster and better answers.

So, in advance, thank you for your help.

All the best
JE
 
D

David Vallner

--------------enig5C97633BEC5EEA52E7F1E77B
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

M. Edward (Ed) Borasky said:
How does C++ deliver "seriously performance critical" applications wher= e
C can't? Are the optimizers/code generators better for C++ than they ar= e
for C? I would think a pure C code would have *better* performance,
simply because the language is simpler and easier to optimize.
=20

And conversely, what's the problem with using C++ instead of C for
performance-critical Ruby extensions or any "fast code"? It's not THAT
much overhead compared to pure C, and I'd bet money on that it'll be
less than the cost of interpreter callouts (in doing data structure
marshalling or manipulating Ruby objects as opposed to not having to for
a straight C++ app) is. The heaps and piles (I know, I can get cream for
that) of inconsistency inside C would make that overhead worth it for
me, as well as the fact that doing robust code is horrible busywork.

Also, for gaming, .NET seems to be gaining hold recently, if the
(sometimes amusingly tangled) dependencies new stuff has on it are a
reliable hint, although I can't tell which of the C# syntax flavours it
is that's being used, obviously.

David Vallner


--------------enig5C97633BEC5EEA52E7F1E77B
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFY0KHy6MhrS8astoRAg1wAJ9zXE7eefk72JD7jCpodd7t/fKoSgCcD+Cs
XSbEJFRrajNDSSijASQMFo0=
=RHEG
-----END PGP SIGNATURE-----

--------------enig5C97633BEC5EEA52E7F1E77B--
 
M

M. Edward (Ed) Borasky

David said:
And conversely, what's the problem with using C++ instead of C for
performance-critical Ruby extensions or any "fast code"?
Absolutely nothing. I know of several high-performance (and quite
well-structured) scientific libraries that are written in C++, and I've
even seen a couple of decent OS microkernels done in C++. I simply find
C++ unreadable, which is why I'm such a big fan of SWIG. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top