NiallJG
NiallJG

Reputation: 1961

How can ported code be detected?

If you port code over from one language to another, how can this be detected?

Say you were porting code from c++ to Java, how could you tell?

What would be the difference between a program designed and implemented in Java, and a near identical program ported over to Java?

Upvotes: 1

Views: 282

Answers (2)

Valentin H
Valentin H

Reputation: 7438

Depending on how much effort was put into the intention to hide the porting it could be very easy to impossible to detect.

I would use pattern recognition for this task. Think about the "features" which would indicate code-similarities. Extract these feature from each code and compare them.

e.g: One feature could be similar symbol names. Extract all symbols using ctags or regular expressions, make all lower-case, make uniq sort of both lists and compare them. Another possible feature: List of class + number of members e.g:

MyClass1 10
...

List of method + sequence of controll blocks. e.g:

doSth() if, while, if, ix, case
...

Another easy way, is to represent the code as a picture - e.g. load the code as text in Word and set the font size to 1. Human beings are very good on comparing pictures. For another Ideas of code Visualization you may check http://www.se-radio.net/2009/03/episode-130-code-visualization-with-michele-lanza/

Upvotes: 0

Alex Martelli
Alex Martelli

Reputation: 881437

If the porting is done properly (by people expert in both languages and ready to translate the source language's idioms into the best similar idioms of the target language), there's no way you can tell that any porting has taken place.

If the porting is done incompetently, you can sometimes recognize goofily-transliterated idioms... but that can be hard to distinguish from people writing a new program in a language they know little just goofily transliterating the idioms from the language they do know;-).

Upvotes: 6

Related Questions