Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:47:44+00:00 2026-06-01T00:47:44+00:00

I often write codes in MATLAB/Python to test whether my algorithm is feasible (&

  • 0

I often write codes in MATLAB/Python to test whether my algorithm is feasible (& actually works). I then need to convert the entire code into C and sometimes, in FORTRAN90.

What would be a good way to manually convert a medium sized code from one language to another?

I have tried :

  • Converting the entire code from one into another and then testing it.
    (Sometimes, there are errors and bugs which just won’t go away and the finding the source of the error becomes a problem)

  • Go line by line and check for consistency of outputs every few lines.
    (Too time consuming)

  • Use converters like f2c.
    (In my experience, they are extremely horrible. I link to a lot of libraries which have different function calls for C and Fortran)

Also,:

  • I am fairly conversant with the programming languages I deal with so I don’t need manuals or reference guides for my work (i.e. I know the syntax).

  • I am not asking this question specifically about MATLAB and C but rather as a translation paradigm.

  • Regarding the size, the codes are less than 100 lines long.

  • I dont want to call the code of one language to another. Please don’t suggest that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:47:45+00:00Added an answer on June 1, 2026 at 12:47 am

    Different languages call for different paradigms. You definitely don’t write and design code the same way in eg. Matlab, Python, C# or C++. Even object hierarchies will change a lot depending on the language.

    That said, if your code consists in a few interconnected procedures, then you may go away with a direct line by line translation (every language allow you to write two or three interconnected functions while remaining idiomatic). But this is the case only for the simplest programs.

    Prototyping in a high level language and then implementing the same idea in a robust and clean way in a “production” language is a very good practice, but involves two very different things :

    1. Prototype in whatever language you want. Test, experiment, and convince yourself that the idea works. Pay attention to the big picture, don’t focus on performance but on the high level ideas. Pay also attention to difficulties that you encounter when implementing, as you’ll face them again in step 2.
    2. Implement from scratch the idea in the production environment in language X. It will be quicker than if you did not do the prototyping stage, since most of the difficulties have been met in stage 1. Use idiomatic X, and focus on correctness. Pay attention to corner cases, general robustness, and once it works correctly, performance. You’ll notice that roughly half of your code is made of new things which did not appear in 1. (eg. error checking, corner case handling, input/output, unit testing, etc).

    You can see that line by line translation is obviously not a good idea, since you don’t translate into the same program.

    Also, when not prototyping, I find myself throwing away the first version and making another one that I like better, ie. I find myself prototyping ! Implementing the same thing twice is not a loss of time, it is normal development flow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Often, I find myself wanting to write a unit test for a portion of
I often write little Python scripts to iterate through all rows of a DB-table.
I often find I want to write code something like this in C#, but
Often, programmers write code that generates other code. (The technical term is metaprogramming ,
When I code, I always write little pieces of unit, and compile it often.
I often write classes with a DLL export/import specification, but this seems to confuse
In my classes I often write a quick operator!= by returning !(*this == rhs)
I always work in windows environment and most often to write the program in
I'm using Squirrel SQL with Oracle. I often have to write quick queries for
When we write a program which supports both unicode and multibytes, we often use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.