Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ease of porting (translating) ruby to C (vs. python)?

Reply
Thread Tools

ease of porting (translating) ruby to C (vs. python)?

 
 
bwv549
Guest
Posts: n/a
 
      05-07-2010
In a very small bioinformatics group I know of, they are deciding
whether to code mostly in python or ruby. The lead knows that python
can "easily be ported to C because of its strictness."

How easy is it to port (translate) ruby code into C? Anyone with
experience in doing this? I've done a little and it seemed very easy,
but I've never translated python into C so I can't compare.

Discussion on alternatives (Inline, using C extensions, NArray,
#include ruby, etc.) is welcome, but I'd like to keep the main focus
on translating to C for this thread.

Thanks in advance!
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      05-07-2010
On 2010-05-07, bwv549 <(E-Mail Removed)> wrote:
> In a very small bioinformatics group I know of, they are deciding
> whether to code mostly in python or ruby. The lead knows that python
> can "easily be ported to C because of its strictness."


Let me be as polite as possible:

That's a bunch of bullshit.

I would find it reasonably difficult to port code from ANY scripting
language to C -- and I'm pretty good at C. "Strictness" does not make it
easier to port python to C. Nor does it make it easy to port shell to C,
or perl to C, or anything else. I am afraid the lead is full of crap.
Sometimes this happens.

Furthermore, porting stuff from an OO language to C is almost certainly
absolutely the wrong thing to do. The correct solution might be to write
a plugin module for the language which translates specific functionality into
raw C calls for performance reasons, but if you have a design that makes any
sense at all in an OO language, translating it to C is stupid.

In any event, what you have here is a social problem, not a technical
problem -- you have someone in charge who doesn't know what's going on.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
 
Reply With Quote
 
 
 
 
MrZombie
Guest
Posts: n/a
 
      05-10-2010
On 2010-05-07 15:50:11 -0400, Seebs said:

> On 2010-05-07, bwv549 <(E-Mail Removed)> wrote:
>> In a very small bioinformatics group I know of, they are deciding
>> whether to code mostly in python or ruby. The lead knows that python
>> can "easily be ported to C because of its strictness."

>
> Furthermore, porting stuff from an OO language to C is almost certainly
> absolutely the wrong thing to do. The correct solution might be to write
> a plugin module for the language which translates specific functionality into
> raw C calls for performance reasons, but if you have a design that makes any
> sense at all in an OO language, translating it to C is stupid.


From my understanding, both Python and Ruby are able to use native
C extensions. It means you could use C for any speed-critical number-crunching
function. For the sake of clarity, I'd suggest sticking to the least
amount of C
you can manage, and use either Python or Ruby to glue the rest together.

The rest is a matter of choice and comfort. While I prefer Ruby for its
flexibility,
others might prefer Python for clarity. Now, understand that Python
code doesn't
magically make sense for those who read the source, it just enforces
significant
formatting that will ensure the source is uniform (at least to some extent).

As the significant number-crunching could be done using C, I doubt the speed
would be greatly impaired by using any of the other two languages. So yeah,
that's that.

 
Reply With Quote
 
Charles Calvert
Guest
Posts: n/a
 
      05-13-2010
On Fri, 7 May 2010 09:16:36 -0700 (PDT), bwv549 <(E-Mail Removed)>
wrote in
<(E-Mail Removed)>:

>In a very small bioinformatics group I know of, they are deciding
>whether to code mostly in python or ruby. The lead knows that python
>can "easily be ported to C because of its strictness."


First, I agree with Peter Seebach that this is nonsense.

Second, why would you port code from either language to C? Is it to
gain performance in areas of the code where Ruby/Python isn't
sufficiently performant? If so, then you're putting the cart before
the horse. Here is the correct order:

1. Write the code.
2. Test performance.
3. If performance is not acceptable, profile the code and identify the
bottlenecks.
4. Examine the bottlenecks to see if the performance can be improved
in the current language, e.g. by switching algorithms or tweaking
generic algorithms to work better with your specific data.
5. Make those changes and retest. You might need to experiment with a
few versions.
6. If the changes result in insufficient improvement, then look at
implementing them in C, compiling to a library and calling into that
from Ruby/Python.

Note that this assumes that you do not have a current code base
written in C. If you do, and it is well tested and performant, then
do this instead:

1. Write the code that you need and that does not exist in C, using
Ruby/Python.
2. Write the wrappers for the C code and integrate.
3. Follow steps 1 .. 6 above, applying step 6 to the code written in
Ruby/Python.

[snip rest]
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
 
Reply With Quote
 
bwv549
Guest
Posts: n/a
 
      05-26-2010
Thanks to all for their thoughtful responses! I'll pass it along.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Penguins, put my mind at ease... Toolman Tim Computer Support 7 08-23-2005 01:53 AM
Security vs. ease of use Gregg Hill Wireless Networking 3 04-28-2005 07:05 AM
Best digital camera- EASE, FACES, EVENTS Rebecca Webb Digital Photography 0 03-29-2005 05:08 PM
1Ds Mark II ease of use fore first time buyer? Mike Digital Photography 42 02-01-2004 11:20 PM
Ease of use... Kelsey Bjarnason C Programming 5 07-05-2003 07:18 PM



Advertisments