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
2
votes
2 answers

Translate Matlab's vector assignment into Python form

I'm trying to translate some Matlab code into Python (using NumPy). I'm not very familiar with Matlab, and I've encountered a line that I'm having trouble parsing: w(idx(1:p, 1), 1) = v(idx(1:p, 1), 1) - theta; I'd hazard a guess that a p-long head…
eapi
  • 23
  • 1
  • 3
2
votes
1 answer

Is it possible to compile C code to Javascript code?

I've found a programming tool called emscripten that can compile c++ code to Javascript code using LLVM. Is it possible to compile C to Javascript using Emscripten (or a similar tool?)
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
2
votes
5 answers

Counterpart to anonymous interface implementations in C#

I'm working on translating some code from Java to C# but am having some trouble, maybe someone out there can help? I have problems trying to replicate anonymous interface implementations that are widely used in Java, but have no idea how to. An…
evilpilaf
  • 1,991
  • 2
  • 21
  • 38
2
votes
7 answers

C code to Haskell

So, i would like to convert a part of C code to Haskell. I wrote this part (it's a simplified example of what I want to do) in C, but being the newbie I am in Haskell, I can't really make it work. float g(int n, float a, float p, float s) { int…
user1823812
  • 199
  • 1
  • 11
2
votes
1 answer

How to convert opencv to javacv code

i have trouble to convert the following code to javacv: ((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] whats the tranlation of this?For me it look's like an array, but the type of value is float. i don't know how to set the value to…
501 - not implemented
  • 2,638
  • 4
  • 39
  • 74
2
votes
7 answers

Automatic Java to C++ conversion

Has anyone tried automatic Java to C++ conversion for speed improvements? Is it a maintenance nightmare in the long run? Just read that is used to generate the HTML5 parsing engine in Gecko http://ejohn.org/blog/html-5-parsing/
Jiayao Yu
  • 808
  • 1
  • 7
  • 14
1
vote
2 answers

SQL Script converted to MySQL

I am trying to fix this migration history problem but can't get this to work in MySQL SELECT * INTO [TempMigrationHistory] FROM [__MigrationHistory] DROP TABLE [__MigrationHistory] EXEC sp_rename 'TempMigrationHistory', '__MigrationHistory' How…
Andy
  • 18,723
  • 12
  • 46
  • 54
1
vote
3 answers

Is there a language that is designed with one-way translation into more than one other popular language?

CoffeeScript gets converted to JavaScript, Groovy to Java. Is there a language that was designed to allow its functions to be converted into multiple languages? One could write string manipulation or HTML snippet generation that could be used as a…
700 Software
  • 85,281
  • 83
  • 234
  • 341
1
vote
1 answer

Comma at the end of True Basic if statement

I've been working on translating a simulation written in True Basic to C, and eventually into CUDA. Considering I have never worked with True Basic, let alone basic, everything has been going smooth. One item that I would like some clarification on…
John
  • 81
  • 2
  • 5
1
vote
1 answer

Empowering language by writing code translator: why is it a bad idea?

When I was learning C++ may years before, I had a few ideas like: "Why not to add some useful lexical structures in language by writing a unified program with unified syntax that would get a pre-source-code through few translation-modules (written…
Ben Usman
  • 7,969
  • 6
  • 46
  • 66
1
vote
1 answer

Assembly how to translate JNE to C Code without ZF flag access

ASM to C Code emulating nearly done.. just trying to solve these second pass problems. Lets say I got this ASM function 401040 MOV EAX,DWORD PTR [ESP+8] 401044 MOV EDX,DWORD PTR [ESP+4] 401048 PUSH ESI 401049 MOV ESI,ECX 40104B MOV…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
1
vote
1 answer

Assembly How to translate IMUL opcode (with only one oprand) to C code

Say I got EDX = 0xA28 EAX = 0x0A280105 I run this ASM code IMUL EDX which to my understand only uses EAX.. if one oprand is specified So in C code it should be like EAX *= EDX; correct? After looking in debugger.. I found out EDX got altered…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
1
vote
0 answers

Can I Convert PHP Code to Perl in a Semi-Automated Way?

There are some newer web technologies that seem to lack Perl libraries (for example WebAuthn). However, most of these technologies do have PHP implementations, alongside other common languages like Python or Ruby. Since PHP is generally similar in…
Timothy R. Butler
  • 1,097
  • 7
  • 20
1
vote
1 answer

translate C# code to R for converting table to vector

I have a table like: 12 34 45 45 56 23 45 56 77 77 14 94 15 45 56 15 38 25 84 65 72 35 35 4 57 18 14 45 47 56 42 34 55 55 59 I would like to get in a vector the sum of the columns like vector[0]= 12+23+14+15+72+18+42 vector[1]=…
edgarmtze
  • 24,683
  • 80
  • 235
  • 386
1
vote
1 answer

Node.js: How to import/require a file, run its commands and access its updated variables like in Python?

In python you can just have file1.py with a class called "class1" like this: class class1: def __init_(self, var1, var2): self.var3 = var1 self.var4 = var2 self.callFunction(self.var3, self.var4) def…
j. cole
  • 39
  • 1
  • 6