log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- RISCOSbits releases a new laptop solution (News:)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
- RISC OS London Show Report 2024 (News:1)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Converting from C to another language
 
  Converting from C to another language
  monkeyson2 (11:56 26/11/2002)
  Phlamethrower (12:11 26/11/2002)
    monkeyson2 (12:36 26/11/2002)
      johnstlr (17:03 26/11/2002)
      Phlamethrower (17:45 26/11/2002)
      takkaria (22:08 19/12/2002)
 
Phil Mellor Message #25149, posted by monkeyson2 at 11:56, 26/11/2002
monkeyson2Please don't let them make me be a monkey butler

Posts: 12380
Pick a language - any language. Know of a converter that will take C source files and convert them to it? Any language you fancy - Java, Perl or Python would be nice though.
  ^[ Log in to reply ]
 
Jeffrey Lee Message #25152, posted by Phlamethrower at 12:11, 26/11/2002, in reply to message #25149
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
Oooh! Oooh! I've got one!

It's called GCC (or LCC, or any other compiler). It takes C source files and converts them into assembler :P

*thinks a bit*

Depends what types of stuff you want to be able to convert. E.g. you aren't allowed to edit pointers in Java, so any C code using pointers would have to have them emulated via arrays or modified to use references (I'm guessing Java supports references :o). For Perl it shouldn't be too difficult though...

Any reason why you want to do this? ;)
  ^[ Log in to reply ]
 
Phil Mellor Message #25153, posted by monkeyson2 at 12:36, 26/11/2002, in reply to message #25152
monkeyson2Please don't let them make me be a monkey butler

Posts: 12380
Oooh! Oooh! I've got one!

It's called GCC (or LCC, or any other compiler). It takes C source files and converts them into assembler :P
:P that wasn't quite what I had in mind.

Depends what types of stuff you want to be able to convert. E.g. you aren't allowed to edit pointers in Java, so any C code using pointers would have to have them emulated via arrays or modified to use references (I'm guessing Java supports references :o). For Perl it shouldn't be too difficult though...
Any reason why you want to do this? ;)
Well - assume that I've written a bit of code with software longevity in mind, by following the examples suggested for C--.

I'm trying to demonstrate that a program written in C-- can be migrated to another language. You might want to do this when C becomes obselete in the future.

Why wouldn't Perl be too difficult?
  ^[ Log in to reply ]
 
Lee Johnston Message #25176, posted by johnstlr at 17:03, 26/11/2002, in reply to message #25153
Member
Posts: 193
Well - assume that I've written a bit of code with software longevity in mind, by following the examples suggested for C--.

I'm trying to demonstrate that a program written in C-- can be migrated to another language. You might want to do this when C becomes obselete in the future.
I don't think C or C++ are in any real danger of becoming obsolete soon for one simple reason. Very few other, non-assembler, languages can access the underlying hardware directly. Without this capability you have to resort to assembler to write device drivers and the libraries that the higher level languages require to operate. It's relatively little work to extend a C Runtime to support this kind of thing because a C runtime is much simpler than for other languages.

Also, despite what MS might want you to believe, the Win32 API is inherently C based and so are the *nix platforms. So while you're all being taught Java and Python and so on at uni, real systems work is still mainly done in assembler / C / C++, not to mention all the embedded devices (eg mobile phones, STBs).

Note C and C++ are rarely the languages of choice for apps developers - VB, Java, Delphi, C#, for all their shortcomings, are all more productive to work with.

Personally I wouldn't trust an automated translator. While such a program may get you going quickly I'm always doubtful that they can get the best out of the target language, especially if you're going from a functional language to an OO one. Often there are better ways to implement the same functionality when faced with a different programming paradigm.
  ^[ Log in to reply ]
 
Jeffrey Lee Message #25178, posted by Phlamethrower at 17:45, 26/11/2002, in reply to message #25153
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
*wonders how he managed to miss your reply for so long*

Well - assume that I've written a bit of code with software longevity in mind, by following the examples suggested for C--.

I'm trying to demonstrate that a program written in C-- can be migrated to another language. You might want to do this when C becomes obselete in the future.

Why wouldn't Perl be too difficult?
Because Perl has very weak typed language, so you don't have to worry about adding extra casts or anything. I haven't done that much perl though, so I've got no idea whether it supports pointers (But I guess it does). Although that may prevent C++ function overloading... I'll look at the C-- specs and see what I can come up with :)

[edit]

*reads C-- spec*

*puts on coding hat*

Right, see you in an hour or two :P

[edit #2]

Nope, too hard for me to do as a casual thing. Of course you could just write a backend for LCC that produces Java/Perl/whatever code ;)

[Edited by Phlamethrower at 19:18, 26/11/2002]
  ^[ Log in to reply ]
 
Andrew Sidwell Message #27479, posted by takkaria at 22:08, 19/12/2002, in reply to message #25153
Member
Posts: 324
Why wouldn't Perl be too difficult?
'cos it's got the Inline::C package which allows you to embed C code in perl! :laugh:

andy/takka.
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Converting from C to another language