Can I put C# and Java code in the same file to make porting my code easier? -


i porting code c# java. i'm finding it's easy miss code or make other mistakes. i'm thinking if can have both versions of code exist in same file, cut down on these mistakes. edit 1 file, 2 parts of file.

if java had pre-processor c#'s (i know projects available allow this), write this:

#if c_sharp namespace mymath {     class naivefib     {         public int run(int n)         {             if (n == 0) return 1;             if (n == 1) return 1;             return run(n - 1) + run(n - 2);         }     } } #elif java package mymath;  public class naivefib {     public int run(int n)     {         if (n == 0) return 1;         if (n == 1) return 1;         return run(n - 1) + run(n - 2);     } } #endif 

i still have problem ide recognizing file contains compilable code given java files named *.java , c# files named *.cs. looks can have visual studio think *.java files c# files if check right settings. wouldn't have make changes java ide (eclipse).

is possible? , idea or more trouble it's worth?

i idea good, code hard read. mess. maybe if have simple codebase... in reality result big chaos!

you maybe spend lot of time looking @ wrong code, scrolling n down , getting more confused. clean code in files have focus, when open java project know work java. , when open c# know c# etc.

do java branch , c# branch of code. more easy maintain , keep clean.

think of situation want upgrade environment, why wasting time/money recompile java code while upgrade c# code, etc!

will port php, ruby, perl, python etc in same files ?

just let programmers open code want see , work with, separate files!

some java programmers might jump out of window when see c# code! thought it? ;)


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -