Re: XBASIC to Perl translator: semantical equity
by gjb (Vicar) on Apr 16, 2004 at 11:54 UTC
|
| [reply] |
|
|
In general, there's no formal way to prove that two programs do the same thing
That is true, but in this particular case the OP would be generating the code himself and would not just be given two programs and asked if they are equivalent. Thus, he could just prove that he is converting all simple instructions properly, that the execution model is the same (eg. instructions are processed sequentially except in conditionals and loops and those are processed in equivalent ways) and the equivalence of the programs would follow.
The next best thing is to device as many test cases as feasible
This is a commendable suggestion at any rate.
The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket
| [reply] |
Re: XBASIC to Perl translator: semantical equity
by Vautrin (Hermit) on Apr 16, 2004 at 12:17 UTC
|
The form of BASIC I remember learning about 15 years ago was a very ugly language. There were no functions, so I would use gotos all over the place to roll my own. The code was a mess, and kludgy.
Even if a BASIC => Perl translator existed, or even if you could code one, you most likely would not want to translate your program. The 4000 lines of code would go from being maintainable in XBASIC to very cryptic perl and pretty hard to change without breaking anything.
I would recommend creating the program in Perl from scratch. Make use of an Object Oriented programming paradigm so your code is more efficient and maintainable, and write lots of test cases along the way to make sure everything does what it is supposed to.
Want to support the EFF and FSF by buying cool stuff? Click here.
| [reply] [d/l] |
|
|
Its a mess. The BASIC program just outputs some graphics. I would loved to have some numerical outputs that i could test against. But the code is just a mess and i fear breaking it during adding some functionility.
So its not trivial to collect output to test against.
| [reply] |
|
|
The BASIC program just outputs some graphics. I would loved to have some numerical outputs that i could test against. But the code is just a mess and i fear breaking it during adding some functionility.
With a bit of work, you can treat the graphics as "numerical outputs". If the output is supposed to be pixel-perfect, the graphics files produced by the two programs will be identical. If there's some acceptable range of variation, perhaps there's a way to use one of the image-processing modules on CPAN to help with the comparison.
| [reply] |
|
|
Re: XBASIC to Perl translator: semantical equity
by Roger (Parson) on Apr 16, 2004 at 17:02 UTC
|
Sounds like a future Star Trek episode...:-D
Captain Picard: "Computer"
Computer beeps quietly
Picard: "Please convert this rather antique BASIC code to a more advanced language, say, PERL"
Yes sir...
| [reply] |
|
|
Computer: "Sir, did you perchance mean 'Perl'?
Captain Picard: "Didn't I say that?"
Computer: "Yes, you didn't."
Captain Picard: "Very well, proceed at your discretion."
Computer: "Am I allowed to choose which version of Perl to use?"
Captain Picard: "Please do."
Computer: "Working..."
Computer: "Good evening, Dave. Would you like to play a game of chess?"
Captain Picard: "Not that version, you stupid machine!"
| [reply] |
Re: Mission critial code required: I have some code in BASIC and require it to be translated to perl
by dragonchild (Archbishop) on Apr 16, 2004 at 11:57 UTC
|
Don't use automated translators for mission-critical code. Hire someone to translate it for you. If it's mission-critical, it's worth something to someone, right? Well, make them prove it.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
| [reply] |
|
|
| [reply] |
|
|
BTW I thought about Inline'ing, but XBASIC isn't supported yet.
There is no specification - just code. The author did some comments within the scientific paper, but no mathematical formula or whatever were used to introduce the idea behind it. So i have the bare bone xbasic code which i want to play with. But i am reluctant to use xbasic, but prefer to have perl code (which the original author doesnt supply). I am looking forward to enhance it (DBI, XML, etc).
I especially fear that perl will suffer "numerical instabilities" when floating points were used.
20040417 Edit by Corion: Exchanged PRE tags for P tags
Edit2 by Chady: fixed link.
| [reply] |
|
|
Don't use automated translators for mission-critical code. Hire someone to translate it for you. If it's mission-critical, it's worth something to someone, right? Well, make them prove it.
I don't know. If you have a lot of source code in Foo then it can be more time efficient and less error prone to re-implement a Foo compiler that targets something else than it is to translate all the code by hand.
I once had to help shift a fair sized app (about 20KLOC) from some old PDP-11 hardware that was implemented in a home grown bastard offspring of Lisp and Prolog. Rather that translate the code we just re-implemented the language in Common Lisp. I guarantee that doing a manual translation of the code would have taken a heck of a lot longer, and probably introduced a bunch of errors into working code.
| [reply] |
|
|
That is one option. I tend to prefer, after a few times doing this, to rewrite the app. The number of improvements and bugs fixed tend to outweigh the number of errors. Granted, I have only worked with relatively young apps and rewriting them after they were implemented by junior developers. *shrugs* YMMV, as with everything.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
| [reply] |
|
|