Computer Science Canada

Turing -> C++ translator

Author:  Jake [ Sun Mar 12, 2006 6:43 pm ]
Post subject:  Turing -> C++ translator

I've been writing a turing to c++ translator the last few days, and I'm well on the way to having the entire base language (not the subprograms like Draw etc) done.

I was wondering if anyone has heard of a preexisting program that does this? I searched a lot first, and couldn't find one (or any Turing sites for that matter) I hope there isn't Razz

Author:  Delos [ Mon Mar 13, 2006 12:02 am ]
Post subject: 

Likely not. Not sure why you'd want to do this, it's like scanning in a printout from a dot-matrix printer and then reprinting it in a laserjet. Sure it'll work and do the job...but the laserjet can really do *so* much more.

Author:  Jake [ Mon Mar 13, 2006 1:31 pm ]
Post subject: 

My reasons:
1. Turing is slow. Recompiling it into c++ would speed stuff up by a factor of a bajillion (I'm thinking more for graphical stuff, having drawfillbox draw an OpenGL quad would be hella cool)
2. It would help some people I know learn c++ if they can see their code redone in it.
3. I'm bored, and it's fun

Anyways, thanks.

Author:  MysticVegeta [ Mon Mar 13, 2006 2:38 pm ]
Post subject: 

The OGL part is going to be hard I can tell you that if you have never dealth with Turing drawing fcns. But if you have good knowledge of turing which you say you do, you should do pretty good, as for me, I would really suck at doing this because I have really low level of C++ knowledge, but good luck Razz

Author:  person [ Mon Mar 13, 2006 2:55 pm ]
Post subject: 

I think what you're doing is actually a really great idea to help people learn a new language. I remember when I first learnt java, there was this turing to java/java to turing translator that helped me a lot (but it was a little buggy). But anyways good luck, and can you please submit the completed version when your done? I'm really eager to see the result. Thanks, and good luck.

Author:  MysticVegeta [ Mon Mar 13, 2006 7:28 pm ]
Post subject: 

person wrote:
turing to java/java to turing translator
Java to Turing translator would be impossible for most of the things because Java capabilities are far more greater than turing.

Author:  person [ Mon Mar 13, 2006 7:48 pm ]
Post subject: 

Quote:
Java to Turing translator would be impossible for most of the things because Java capabilities are far more greater than turing.


Same with Turing to C++.

Author:  MysticVegeta [ Mon Mar 13, 2006 7:54 pm ]
Post subject: 

no, all fcns made in turing exist in C++ I think you mean C++ to Turing

Author:  Mazer [ Mon Mar 13, 2006 8:41 pm ]
Post subject: 

I was actually considering writing something like that a year ago. It didn't seem too difficult. Especially the graphics, since you just translate the Turing graphics calls to SDL/OpenGL calls.

And bam. You'd have a free Turing compiler that's faster, can do 3D graphics, and it's cross platform.

But it's still Turing. What have you gained? A way to let people use a bad language quicker. Not really the greatest solution.

Author:  Imm0rtal [ Mon Mar 13, 2006 9:35 pm ]
Post subject: 

Ironically.. I was told that the turing compiler actually translates all its code into C++ and creates a sort of C++ run enviroment.

Also why bother reinventing the wheel.. if you have the ability to write all the C++ functions that associate with Turing.. why bother with turing in the first place.

C++ syntax is a annoying but you miss the whole point. C++ is unlike other languages such as basic/turing for a good reason. This is the same reason it is the most used language for most professional software.

But then.. what the hell do I know Rolling Eyes

Author:  [Gandalf] [ Tue Mar 14, 2006 1:11 am ]
Post subject: 

One advantage I can see is that it would be a good way to convince former Turing users to switch to another language (C++ in this case). Many people learn best by example, and this would definately provide them with a structure for learning by comparison. Yes, C++ is not best to go into directly after Turing, but who said they can't learn a language in between.

Author:  Imm0rtal [ Tue Mar 14, 2006 1:44 am ]
Post subject: 

[Gandalf] wrote:
One advantage I can see is that it would be a good way to convince former Turing users to switch to another language (C++ in this case). Many people learn best by example, and this would definately provide them with a structure for learning by comparison. Yes, C++ is not best to go into directly after Turing, but who said they can't learn a language in between.


Turing is a good intro for C++ as they work similar.. not = is more annoying then != but it does simplify the syntax.. I GUESS..

Note that Turing gets you away from the drag and drop Microsoft Only Basic languages (VB?).. Don't shoot yourself in the foot kids.. Linux users need software too.. Learn C++/ASM

Author:  [Gandalf] [ Tue Mar 14, 2006 1:58 am ]
Post subject: 

Turing and C++ work similarily? How so? Just because Turing was created in C++ does not mean the languages are the same, or similar.

Also:
Turing not= is the same as
C++ != is the same as
Turing ~=

Author:  Dan [ Tue Mar 14, 2006 2:01 am ]
Post subject: 

Acatualy, tho this may not be ture for newer versons, turing dose/used to just trasalte in to VC++ and then compie it. This is why turing is/was a psdo-code gnerator and not a real progaming langue.

Author:  Imm0rtal [ Tue Mar 14, 2006 2:06 am ]
Post subject: 

Hacker Dan wrote:
Acatualy, tho this may not be ture for newer versons, turing dose/used to just trasalte in to VC++ and then compie it. This is why turing is/was a psdo-code gnerator and not a real progaming langue.


Tis true.

Also note alot of the syntax is similar in how it works Example: you can create your own functions and procedures in Turing. You are mostly dealing with just code.
(IE no buttons you righ click on then type Text1.text = "hello World")

Yes you don't need to be as specific with turing. You don't need parameters or semicolons. The commenting works the same way.. so what?

I wasn't saying they were similar only that its a good introduction for someone who has never seen C++ before. They share common methods of thinking even if turing is much more generous as far as errors go.

Author:  [Gandalf] [ Tue Mar 14, 2006 2:16 am ]
Post subject: 

Sigh... I suggest you learn some more languages, and learn more about programming languages. Any decent programming language (in the 1000s out there) will allow you to create your own functions (or methods, whatever you wish to call them). Most languages only work with code, at least in the sense that I believe you mean it, not centering around GUIs like VB. Many programming languages use /* */ to signify multi-line comments, not just C++ and Turing.

Turing and C++ "share common methods of thinking" about as much as dozens of other languages share them with C++ (as an example). I believe you will find any procedural programming language shares "common methods of thinking" with Turing in many ways.

Author:  Imm0rtal [ Tue Mar 14, 2006 2:24 am ]
Post subject: 

[Gandalf] wrote:
Sigh... I suggest you learn some more languages, and learn more about programming languages. Any decent programming language (in the 1000s out there) will allow you to create your own functions (or methods, whatever you wish to call them). Most languages only work with code, at least in the sense that I believe you mean it, not centering around GUIs like VB. Many programming languages use /* */ to signify multi-line comments, not just C++ and Turing.

Turing and C++ "share common methods of thinking" about as much as dozens of other languages share them with C++ (as an example). I believe you will find any procedural programming language shares "common methods of thinking" with Turing in many ways.


Very true sir. But how many of those languages hold the simplicity of Turing which what were discussing.. an introduction into C++ or programming in general.

You won't learn C++ by programming in C# (Well Maybe...) or Python. Yes many languages hold similar rules but at that point.. what is the point? Eventually you need to dive into C++ and if you understand the core rules of how software is made its time to pull up your Managed C++ .Net Developement book and start learning about libraries and namespaces.

Haha just joking.. .NET is from Satan. Honestly though you only need so much information before its time to crack down and learn. If you are not capable of that then perhaps Software engineer isn't the profession for you. If you think the boat is stopping at C++ and we are gonna be using that in 15 years from now.. Oh my. Twisted Evil

I agree with you fully.. but would having turing commands translated into a console really be THAT usefull? I mean theres only so many different ways you can see printf before you have had enough and want to actually learn C++ instead of C&Ping out of a notepad.

Author:  [Gandalf] [ Tue Mar 14, 2006 2:37 am ]
Post subject: 

My point has already been made.

Turing will not teach you, or introduce you to C++ any better than Pascal, Python, Ruby, or anything else. Probably less so in most cases.

As for the rest of your post... Were we ever talking about "cracking down and learning"? I don't recall so. Did I ever say the boat stops at C++? I believe far from it. We were not talking about just converting text output and input to the console, but converting the whole interpreter into something which will also allow you to see the coresponding C++ code.

Really, this is veering off of what I meant in the first place. Something like this would no doubt be useful, but in the long run, if you want something new after Turing, go learn Ruby or some other language of your choosing from the start.

Author:  MysticVegeta [ Tue Mar 14, 2006 10:52 am ]
Post subject: 

Also, if you are doing Turing to Java or C++, then you would have to know what packages to import before hand you convert the code and also know more about different classes in Java, wtd would be I guess the bestperson to learn this from.

Author:  Imm0rtal [ Tue Mar 14, 2006 11:56 am ]
Post subject: 

[Gandalf] wrote:
My point has already been made.

Turing will not teach you, or introduce you to C++ any better than Pascal, Python, Ruby, or anything else. Probably less so in most cases.

As for the rest of your post... Were we ever talking about "cracking down and learning"? I don't recall so. Did I ever say the boat stops at C++? I believe far from it. We were not talking about just converting text output and input to the console, but converting the whole interpreter into something which will also allow you to see the coresponding C++ code.

Really, this is veering off of what I meant in the first place. Something like this would no doubt be useful, but in the long run, if you want something new after Turing, go learn Ruby or some other language of your choosing from the start.


Some people started with Assembly/ C++

Author:  [Gandalf] [ Tue Mar 14, 2006 7:02 pm ]
Post subject: 

Great for them, but I doubt it was the best, or easiest way to go about things. A large reason for higher level programming languages is to provide a better way of introducing programming to people.

Author:  MysticVegeta [ Tue Mar 14, 2006 7:58 pm ]
Post subject: 

I agree with Gandalf, to start off, ASM/Java/C++ would not be the best way, even Turing wont be, I would say Pascal, Python, VB and Ruby would be good.

Author:  Imm0rtal [ Wed Mar 15, 2006 1:30 pm ]
Post subject: 

MysticVegeta wrote:
I agree with Gandalf, to start off, ASM/Java/C++ would not be the best way, even Turing wont be, I would say Pascal, Python, VB and Ruby would be good.


Depending how you look at it. Python could be harder then C++. Thats just my opinion.

Author:  Jake [ Wed Mar 15, 2006 4:48 pm ]
Post subject: 

Heh, I'm gone for a day or two and this breaks out..

Okay, I think I'll clarify what I'm doing...

The project is written in C++. It opens up a turing .t file, parses it into a heirechy of classes (I'm normally very suspicious of OO, but it works magically here) An example of a class:

class function
-funcName
-typeSpec (e.g. int, float whatever)
-array of arguments
-subheiercy of other elements (the code in that function)

When parsing a file, say it comes across "function" at the beginning of a line. It creates a new function element, and tells that function to parse whats inside its code. So it's very recurssive.

For those wondering about the Draw subprogram thing, all it is in Turing (check your installations) is a module thats included in every program, with all (well most i think...) of the functions declared extern. i.e. they are in a seperate library created by holtsoft and not programmed in Turing. So, all I've got to do is write a replacement library, and that Draw module will parse (as it is included in every program) each time, and it will link to my library, no ugly hacks. OpenGL won't be a problem, especially with 2D stuff, I've got extensive experience using OpenGL/SDL, so it will be cross platform as well (I'm coding this on a Mac, and testing it at school on Windows)

The hardest part is forcing myself to check code for errors. It's really boring but must be done.

Since there seems to be at least some people interested, I'll make sure to link to the eventual release here.

1.0 will include support for (most of) the base language, and the Draw subroutine (and possibly a few others like Font and Pic) The code will be available +binaries, and the code will be under the BSD license if anyone wants to use it (can't see why tho)

Shouldn't be too long, a month at tops before I've got something out.

The "site" is http://ieatcrayons.net/turingplusplus

If anyone has an suggestions I'd love to hear them (keep in mind I'm not changing the language *at all*, if theres something like an artificial limitation in some part of Turing you don't like I probably won't change it for compatibility reasons)

p.s. Thank you Holtsoft for such an amazing documentation of your language. You made it all too easy.[/url]

Author:  Imm0rtal [ Wed Mar 15, 2006 6:55 pm ]
Post subject: 

Makes a fun Proof Of Concept. I will likely download it.. But excuse me if I still don't see the point. Very Happy

Author:  wtd [ Wed Mar 15, 2006 7:28 pm ]
Post subject: 

To really pull this off you'll have to write a complete Turing parser. That is not a trivial task, since Holtsoft does not make Turing open source and one cannot therefore be privy to a full, modern Turing grammer.

Please see the following Lambda the Ultimate discussion on transforming code written in one language into another.

http://lambda-the-ultimate.org/node/1255

Author:  Jake [ Wed Mar 15, 2006 8:08 pm ]
Post subject: 

Thanks for the reply!

Even though Turing isn't opensource, the helpfile/book it comes with has a complete description of the language (and subprograms) with a full description of syntax and what not, it's really fabulous.

If it were any other language I wouldn't dare even think of trying it, but Turing was designed to be very simple + easy to learn, its almost english looking, and consequently very easy to parse.

The hardest part is the sheer volume. The core of Turing isn't that big, but it's still a daunting task Smile

Author:  [Gandalf] [ Thu Mar 16, 2006 12:22 am ]
Post subject: 

A challenge will be to actually make the C++ code understandable, and not filled with too much overhead.

If you need testers, or some help with a specific function, I'll make every effort to help. Really, this will require quite a thorough understanding of most of the functions in Turing, for example, who ever uses condition? or tag? There are quite a few of these.

Good luck, I hope you are successful. Smile

Author:  Martin [ Thu Mar 16, 2006 1:59 am ]
Post subject: 

C++ is an awful language (there wtd, I said it) and is slowly dying out in favour of more modern languages (such as Java), especially in server applications. Really, don't bother with it. Learn C instead, or a fun language like Ruby or Haskell - you'll learn way more.

Author:  Jake [ Thu Mar 16, 2006 11:34 am ]
Post subject: 

Thanks Gandalf! I'll keep that in mind! Your right, the hardest part is making it readable to humans. OpenGL and its state machine nature isn't very "readable" when Turing is converted to it (since put etc have to be drawn on the opengl layer, it just looks horribly messy) I'm thinking of ditching OpenGL and just doing the graphics software-side.

Martin, I'm not going to get into a language pissing match, but you clearly don't understand what you're talking about. C++ is as widely used as it ever is, and Java is definantly not succeding it, at least not any time soon. I don't understand why you would say to learn C instead of C++, since C++ is just like a v2.0 of C, it's just as fast and can do everything C can, plus more. C is dying out to C++, if anything. Anyways peace. Language preference is up to the individual.

Author:  wtd [ Thu Mar 16, 2006 12:51 pm ]
Post subject: 

Quote:
C++ is an awful language (there wtd, I said it) and is slowly dying out in favour of more modern languages (such as Java), especially in server applications.


C++ is a beastly language to learn as a beginner, but I don't know that I'd go so far as to say it's an awful language. It has some interesting ideas like templates, but they're poorly implemented by most compilers.

In terms of widespread usage, yes, the likes of Java and C# are more visible, but there are plenty of C++ jobs still out there. No, Java is not more modern than C++. They are both firmly rooted in the 60s and 70s. Yes, there has been progress since then.

Quote:
Really, don't bother with it. Learn C instead


Do bother with it. At some point. It's worth the bother. Learn C too.

Quote:
C++ is just like a v2.0 of C


No, it really isn't, and if you think it is, then you need a much deeper understanding of the language. C++ is an entirely different programming language that just happens to be mostly compatible with C. If you want a truly pure extension of C, then I strongly encourage you to learn Objective-C, which is a fantastic programming language.

Quote:
Language preference is up to the individual.


Yes, it is. However, it must be founded on a good understanding of the options.

Author:  Dan [ Thu Mar 16, 2006 5:16 pm ]
Post subject: 

I think the moral of the story (topic) is that there is somthing to be gained from studying all langues and that sitcking or progaming only one will leave you quite static in your ablitys and probly unemoplyed in the futter.


: