|
-
January 26th, 2011, 01:51 PM
#1
converting pascal to java... "define before use" to "object oriented"... thoughts?
I'm taking a on programming languages in college. We are supposed to come up with a project proposal for a "program that writes other programs". The idea I came up with was to write something that converted pascal to java. I would be writing the program in java. My professor said that if I did this it would have to convert the "define before use" style of pascal into the "object oriented" style of java. I was just wondering if anyone would be kind enough to give me their thoughts on how you would interpret that?
-
January 26th, 2011, 02:19 PM
#2
Re: converting pascal to java... "define before use" to "object oriented"... thoughts
I don't know much about Pascal but the "define before use", as I understand it, means that a function or method must be defined before (or on a line above) it is called in the program. In java you can define the method after it is called in a class
Code:
public Class Car
{
public Car()
{
buildCar(); //method has not yet been defined
}
public static void buildCar() //method is defined after use
{
//build a car.
}
}
So it would seem that Pascal would need all the method/functions definitions above all method/function calls. Kinda like C. Though in C there is a way to define after use I believe.
This sounds fun. What class it this for?
-
January 26th, 2011, 02:26 PM
#3
Re: converting pascal to java... "define before use" to "object oriented"... thoughts
Yeah that's what I thought but he made a comment about it being harder than I probably think... when my initial reaction was it wouldn't be too hard. It's for CSE 655 at Ohio State. The title of the class is "Introduction to the Principles of Programming Languages". I'm taking it with a professor who leaves the project a little more open ended than the others. Most of the professors make you write a Lisp or Pascal compiler/interpreter. So far we've been covering things like recursive decent parsing and context free grammars.
-
January 27th, 2011, 12:13 AM
#4
Re: converting pascal to java... "define before use" to "object oriented"... thoughts
I'm afraid that's all a bit over my head at the moment. Still sloggin' through the 300s at UW. Lovin' it though! =D If you don't mind hearing what an undergraduate has to say I'd suggest thinking about what the project requires and if what you are trying to do is just to grand for what is required. Not that we shouldn't strive for the grand ideas but on a logistical level it would seem to be better to finish than it would be to "take on the world" so to speak. I would also ask "has this been done before?" If not then, assuming it is a (relatively) simple task, why hasn't it been done before.
Wish I could sound off with some more specific concerns but, as I said, I've got a ways to go. 
Best of luck.
-
January 27th, 2011, 09:00 AM
#5
Re: converting pascal to java... "define before use" to "object oriented"... thoughts
Yeah, turning a program written in pascal into an object oriented Java program would not be easy. It would actually be nearly impossible unless the pascal program was written so that you could extract like modules easily. What I mean by that is it can be done if the pascal program is separated into different files such that each file could represent a Java object.
However, you are going to have a hell of a time trying to give meaningful names to methods and classes being as most pascal I have seen is complete crap to read. Example of pascal (as you probably already know):
Code:
BEGIN
x := 'One,two,'; { two trailing spaces supplied }
y := 'three,four'; { fits exactly }
a := trim(x); { function trim removes trailing spaces }
b := a + y;
IF x = a THEN writeln(b);
writeln(index(b,'ee')); { function index locates 'ee' in b }
END.
Personally I have written a Java program that converted a made up language that we designed into ANSI C code and then compiled and ran it. That wasn't too difficult because I could guarantee the syntax of the code being written, since I created the made up language. I think something like that would be a lot easier than trying to be able to match all of the rules of pascal and map them into something meaningful in Java. Remember, Java doesn't have closures but pascal does, so there is one rule that you cannot map.
-
January 29th, 2011, 05:10 PM
#6
Re: converting pascal to java... "define before use" to "object oriented"... thoughts
Just a wild random thought if you are still on this subject. If Pascal has something that is too alien for a Java equivalent then would it be possible to use a third, possibly more common, language like C? I've never tried it but I hear that Java can be used to utilize C code directly. Maybe that could be some kinda back door fix for some things. Again I base this on very little knowledge and even less practice =D but sometimes I like to hear from the wingdings... Sometimes rattle the cage a bit ya know.
Cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|