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

Discussion in 'Ruby' started by bwv549, May 7, 2010.

  1. bwv549

    bwv549 Guest

    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!
    bwv549, May 7, 2010
    #1
    1. Advertising

  2. bwv549

    Seebs Guest

    On 2010-05-07, bwv549 <> 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.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
    Seebs, May 7, 2010
    #2
    1. Advertising

  3. bwv549

    MrZombie Guest

    On 2010-05-07 15:50:11 -0400, Seebs said:

    > On 2010-05-07, bwv549 <> 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.
    MrZombie, May 10, 2010
    #3
  4. On Fri, 7 May 2010 09:16:36 -0700 (PDT), bwv549 <>
    wrote in
    <>:

    >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
    Charles Calvert, May 13, 2010
    #4
  5. bwv549

    bwv549 Guest

    Thanks to all for their thoughtful responses! I'll pass it along.
    bwv549, May 26, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelsey Bjarnason

    Ease of use...

    Kelsey Bjarnason, Jul 4, 2003, in forum: C Programming
    Replies:
    5
    Views:
    925
    Kelsey Bjarnason
    Jul 5, 2003
  2. Replies:
    1
    Views:
    303
    Edward Diener
    Apr 27, 2007
  3. teppic.xxviii

    Debug javascript with ease!

    teppic.xxviii, Jun 21, 2007, in forum: Javascript
    Replies:
    13
    Views:
    199
  4. gleery
    Replies:
    4
    Views:
    101
    Dr J R Stockton
    Jul 25, 2008
  5. mathog
    Replies:
    8
    Views:
    599
    Nobody
    May 5, 2012
Loading...

Share This Page