Questions tagged [code-translation]

For questions regarding the translation of code from one programming language to another. NOTE that asking to have your code translated is not suitable for Stack Overflow.

Translating code from one programming language to another can be as tricky as translating between natural languages. This is due to the fact that languages implement different sets of features and are often designed with very different goals. What comes as a built-in function in one language may have to be developed from scratch (or at least require a library) to achieve the same functionality in another.

An appropriately formed question might be "How do I translate this statement", or "What are the differences between these two statements in different languages". It is not appropriate to ask for your code to be translated.

388 questions
23
votes
1 answer

C99 printf formatters vs C++11 user-defined-literals

This code: #define __STDC_FORMAT_MACROS #include #include #include #include int main(int argc,char **argv) { uint64_t val=1234567890; printf("%"PRId64"\n",val); exit(0); } Works for C99, C++03,…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
22
votes
5 answers

Automatically convert Scala code to Java code

I have an app written in Scala and some of my team members want a Java version of it. It is a demo app to use another API written in Scala, and they want a Java version of the app to be able to use the API from Java. However, the app is somewhat…
Jus12
  • 17,824
  • 28
  • 99
  • 157
22
votes
2 answers

Translating C to JavaScript

I've got a bunch of math/dsp algorithms in C. Single functions, one function per file, no fancy linking or includes or preprocessor directives, only c99 and standard library calls (mainly memset and memmoves to handle array copying etc). Translating…
janesconference
  • 6,333
  • 8
  • 55
  • 73
19
votes
2 answers

How can I easily convert FORTRAN code to Python code (real code, not wrappers)

I have a numerical library in FORTRAN (I believe FORTRAN IV) and I want to convert it to Python code. I want real source code that I can import on any Python virtual machine --- Windows, MacOS-X, Linux, Android. I started to do this by hand, but…
Peter Olsen
  • 301
  • 1
  • 2
  • 4
18
votes
6 answers

Tool to convert (translate) C to Go?

What tool to use to convert C source code into Go source code? For example, if the C code contains: struct Node { struct Node *left, *right; void *data; }; char charAt(char *s, int i) { return s[i]; } the corresponding Go code…
user811773
17
votes
6 answers

Converting Python Code to PHP

Is there a software converter out there that can automatically convert this python code to PHP? #!/usr/bin/python import math def calcNumEntropyBits(s): if len(s) <= 0: return 0.0 symCount = {} for c in s: if…
Kirk Ouimet
  • 27,280
  • 43
  • 127
  • 177
14
votes
3 answers

Translating imperative to functional code

I need to write a program that will translate imperative code to pure functional style. I'm not worried about I/O - I have some solutions in mind for that - but I do need to deal with heap objects as well as local variables. I suppose it could be…
rwallace
  • 31,405
  • 40
  • 123
  • 242
13
votes
4 answers

Writing code translator from Python to C?

I was asked to write a code translator that would take a Python program and produce a C program. Do you have any ideas how could I approach this problem or is it even possible?
bodacydo
  • 75,521
  • 93
  • 229
  • 319
12
votes
2 answers

Transpile TypeScript In Memory With Node

Is there a way to transpile TypeScript in memory with Node? I would like to be able to get the generated JavaScript in memory.
A2MetalCore
  • 1,621
  • 4
  • 25
  • 49
12
votes
3 answers

Build AST from C code

How can I build an AST (Abstract Syntax Tree) from gcc C code in order to make some modifications, like converting some int variables to float, and reproduce(generate) the code to C syntax again after that. Actually, for the moment, the only…
Asan
  • 199
  • 1
  • 1
  • 7
9
votes
3 answers

Neural Networks For Generating New Programming Language Grammars

I have recently had the need to create an ANTLR language grammar for the purpose of a transpiler (Converting one scripting language to another). It occurs to me that Google Translate does a pretty good job translating natural language. We have all…
9
votes
2 answers

Signing an F# Assembly (Strong name component)

I found this article on CodeProject: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus and thought it would be nice to give it a try, but in F#. So I came up with the following code: open System open System.IO open…
LA.27
  • 1,888
  • 19
  • 35
9
votes
9 answers

Translate algorithmic C to Python

I would like to translate some C code to Python code or bytecode. The C code in question is what i'd call purely algorithmic: platform independent, no I/O, just algorithms and in-memory data structures. An example would be a regular expression…
Constantin
  • 27,478
  • 10
  • 60
  • 79
9
votes
2 answers

Writing a transpiler to the point where the actual mapping takes place

I want to understand how a transpiler works. The best to do this is to write one ofcourse. I've been looking into a few resources to understand how this works, theoretically. And i understand the following: From what i understand i basically need to…
w00
  • 26,172
  • 30
  • 101
  • 147
8
votes
1 answer

Source-to-source compilation with LLVM

I need to convert x86 assembly source code to LLVM human-readable .ll file (aka LLVM assembly language). How can I do this? If there is no direct solution would it be possible to implement one within the LLVM infrastructure with as less efforts as…
bsa2000
  • 382
  • 2
  • 11
1
2
3
25 26