Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chitin

macrumors newbie
Original poster
Mar 23, 2008
9
0
Bilbao, Spain
I started to learn C in the mid 90s (on my own and with a few good books) and by 1999 I had a working prototype (for the 68K processor) of the only application I worked on. This is an application designed to help me with the research I was doing at the time; basically analysing graph properties for sets of intersecting lines and nodes (shortest routes and similar things).

I then modified the app to run on the PowerPC processor and tweaked bits of it until 2003 (under OS 9).

When I switched to a G5, and OS X (10.3.9), I bought a couple of books and started playing around a bit with Xcode and Objective C. My intention was to update the software to run native on OS X, but could not run CodeWarrior on the G5. Then, I stalled, I felt the effort of switching was too much.

However, I still use the software and I have been thinking about it again lately. Ideally, I’d like:
- To be abe to re-use most of the code I wrote (in C, although with quite a few calls to the old Mac Toolbox).
- Not spend ages reworking the GUI: I used mainly EasyApp by James E. Trudeau and ResEdit.
- Be able to add features (functions) relatively easily, for which I’d be quite comfortable using C.

I’ve read a number of threads in this forum before posting this and can’t find a similar case. My feeling is that to move on I’ll have to bite the bullet and, practically, start from scratch. In which case I’m not sure whether something like Python or RealBasic could be easier than Objective C (haven’t tried either).

Bear in mind that it is not general programming I’m after, but to work on this specific tool I’ve developed over many years. Not fussed about cross platform issues either (Mac is fine). And although I enjoy programming as an activity, I have less time than years ago to devote to it. Also, I’m still with the G5 and OS 10.3.9 (but would buy a new iMac if need be).

Any suggestions? Many thanks for your patience and any possible advice.
Chitin
 

chitin

macrumors newbie
Original poster
Mar 23, 2008
9
0
Bilbao, Spain
Thanks Cromulent, but I have some difficulties.

I did look into the document "Moving Projects from CodeWarrior to Xcode", that Apple produced at the time, but can't do the preparatory steps because the version I had of CodeWarrior (version 6) does not run in my G5 and the old computer (PowerPC 9500 with Mac OS 9) won't start anymore. And I don't think it's that productive to buy a newer version of CodeWarrior just for the conversion.

So the situation is that I have all the source code files and the resource file in my G5, but no CodeWarrior software to run or play with.

How difficult do you think it would be to create a new application with XCode, build the UI and add source code files one by one, changing them as I go along? Or can anyone see an easier route? Am I talking nonsense?
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
Carbon is good as its similar to the Macintosh Toolkit. So if you have code in that it will be easier to use Carbon. However Carbon isn't going 64 bit so going to Cocoa will be more future-proof. Cocoa is much more modern than Carbon, and it is a very communication centric development system which works very well. Like Carbon it is based on C so any raw C code will work with it however the UI stuff will have to be re-worked.

EDIT: When I talk about Cocoa I mean Cocoa with Objective C. As you know C that will be easier/faster than using Python with Cocoa. I would also strongly advise upgrading to Leopard for Xcode 3.0.
 

sord

macrumors 6502
Jun 16, 2004
352
0
Unfortunatelly, you won't be able to buy CodeWarrior (10) anymore. You may be in luck if you contact Freescale and explain your situation (not for commercial use, personal development, etc), but I'm not sure if they will be able to help.

I've never done a conversion from CodeWarrior to XCode, however if you don't care about giving up your code I can probably do it for you. (I'm using XCode 3, not sure if its backwards compatible).
 

kamo

macrumors member
Mar 21, 2008
34
0
I would look at Java. It's the cleanest and best supported object oriented language. With netbeans you get a UI builder. The APIs are awesome, much of what you had to code by hand ten years ago is most likely all available.

Get a head first java book (amazon it.) You'll be developing in no time.

And your program will run on anything.

-kamo
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
With netbeans you get a UI builder.

Java's UI stuff is notoriously poor.

The APIs are awesome, much of what you had to code by hand ten years ago is most likely all available.

Same applies to Cocoa. Java takes most of its ideas from that.

And your program will run on anything.

That is an advantage, but it won't look particularly good on any platform...
 

Cromulent

macrumors 604
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
I would look at Java. It's the cleanest and best supported object oriented language. With netbeans you get a UI builder. The APIs are awesome, much of what you had to code by hand ten years ago is most likely all available.

Get a head first java book (amazon it.) You'll be developing in no time.

And your program will run on anything.

-kamo

I wouldn't recommend Java really unless you need the cross platform nature of it. If he is going to have to learn (parts of) a new language I would think he would be much better served spending the time learning Objective-C and then Cocoa as it will give him the grounding he needs for Mac development for probably the next 10 - 20 years or so. I can't see Apple dropping Cocoa anytime soon.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

I'm not sure if this is a good strategy but I would suggest keeping your original C code and put some time into stripping out all the ui code to create a library which could be used as the 'back end' for your new app (I can't really see the point of rewriting everything in a new language). Once this is done you've got a few choices for creating the front end.

If you decide to go down the Objective-C/Cocoa route then you only need to learn enough to be able to implement your new UI. You'll be able to pick up Objective-C quickly, prototype the UI in Interface Builder, and pick your way through only the parts of Cocoa that you need to get the job done.

If you want to go down the RealBasic route, then you could use RealBasic for the UI and link it to the C library that you've created. I'd say picking up RealBasic will be a lot quicker than Cocoa (you could probably have a working UI in days), but it would be inferior to the Cocoa equivalent (there are more visual controls in Cocoa and they look and behave a lot better than the RealBasic counterparts).

Hope this helps!

b e n
 

chitin

macrumors newbie
Original poster
Mar 23, 2008
9
0
Bilbao, Spain
Many thanks to all

I'm grateful for all the contributions, and particularly to Sord for that generous offer of doing the porting.

When I fisrt chose C that many years ago, one of the criteria was that it had to be a language with a long term projection and I'm more than happy with how it has turned out (I'm very slow at this, I'm afraid). So, I think Cromulent's referece to the long term bet is good advice and that's the route I think I'll try (Objective C and Cocoa).

I also like Ben's suggestion, of stripping the code to the basics and build a new UI with Xcode. In fact, since much of the UI was in a set of files that I recycled from James Trudeau, the code I wrote is largely about the basic calculations, with little UI in them (just hooks to the menus and some window drawing behaviour).

So I'll probably be getting myself a new toy (a macbook with Leopard and Xcode 3) and get back to learning a bit of programming. I'm sure I'll be posting more requests for help when I get stuck with it.

All the best
 

psingh01

macrumors 68000
Apr 19, 2004
1,586
629
Had to dig for this:

http://www.mactech.com/articles/mactech/Vol.15/15.01/Jan99GettingStarted/index.html

For those suggesting to port to Carbon so that you can use most of the Mac Toolbox calls....Apple had a thing called the "Carbon Dater" that would tell you how much of your app needed to be changed to get Carbon compatible. Who knows if they still do such a thing.

Also, remember that Objective-C is just C plus some object oriented stuff. Anything that is compatible with C is also compatible with Objective-C.

Don't confuse Cocoa (apples new API) with the Objective-C language :)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Many parts of the Carbon UI has been modernized and they've even made lots of improvements for Leopard but I doubt that the next cat will add many features, if any at all. If you learn Carbon now without stepping into Cocoa, you'll eventually be behind at some point again. It's clear that Cocoa is the future :)
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
In case you don't have any system at the moment that actually compiles your old code, you could consider finding an old fruity-coloured iMac on eBay, and use it for the first phase of going to modern Carbon. It's a matter of preference. Some people prefer working with a working code base all the time, alternatively start XCode, create a new Carbon project, add all your source files, and fix all the compiler errors that you will get one after the other.

It is probably a good idea to separate all user interface code into separate functions at the same time.
 

balamw

Moderator emeritus
Aug 16, 2005
19,365
979
New England
I also like Ben's suggestion, of stripping the code to the basics and build a new UI with Xcode.

FWIW I've done this twice in trying to clean up someone else's C++ code for a Windows app.

Stripping it down to its pure essence is a great way to simplify and allow you to completely separate the UI from the bits that do the heavy lifting. As a bonus, straight C is portable to any platform supported by GCC, so think of it as future proofing.

B
 

zippyfly

macrumors regular
Mar 22, 2008
141
0
2 cents

I am just starting out also on Objective-C and it's just the first week but I feel it is a very elegant language once you get the hang of it.

I do have some basic Java experience, also from years ago and also learned on my own. Other languages (just for your reference) include Pascal and of course the ever popular BASIC.

My suggestion to you (take with grain of salt as I am just a newbie) is to go with Xcode and Objective-C. You can "reuse" most of your C code, since ObjC is basically C with OOP stuff put on top. You can use C syntax completely if you do not want to do the OOP stuff.

So what you can do is figure out how to OOP your original code, and create an OOP version of the core logic (without the UI stuff) and then use Xcode's Interface Builder to create the interaction later.

This would allow you to later extend the code easily, since it's OOPed.

I would not recommend going to REALbasic, or any other of those languages, not even Java. Forget Java. You already know C, and therefore can pick up Objective-C in about a day or two (really). How much you grok the OOP stuff depends on yourself but from what you wrote I don't think you will have much trouble going that route.

There are very few Objective-C books out there though (someone correct me if I am wrong). I think only about 3 or 4 of them actually, for OS X and Xcode.
 

chitin

macrumors newbie
Original poster
Mar 23, 2008
9
0
Bilbao, Spain
Might try Carbon...

Whilst I get the impression that the Objective-C route is the more future-proof, after seein psingh01's message and the MacTech article I am tempted to give Carbon a go.

Unfortunately, the Carbon Dater tool doesn't seem to be available anymore for a preliminary check (can't find it in the ADC Carbon section), but if it is true that most of the Toolbox routines of the old Mac OS are supported in Carbon, it might be a relatively quick effort.

On the other hand, if I find too many difficulties I'll move over to Cocoa and start cleaning up the old code...
 

Monkaaay

macrumors 6502
Jun 19, 2006
258
0
Richmond, VA
If you already know C and want to develop for OS X only, working with Objective-C and Cocoa is definitely the way to go. It shouldn't be a terribly difficult transition with a C background.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
Whilst I get the impression that the Objective-C route is the more future-proof, after seein psingh01's message and the MacTech article I am tempted to give Carbon a go.

Cocoa is a far better framework too. Its one of the best frameworks on any platform.
 

gary hayenga

macrumors newbie
Mar 7, 2008
3
0
If you already know C and want to develop for OS X only, working with Objective-C and Cocoa is definitely the way to go. It shouldn't be a terribly difficult transition with a C background.

I would agree with Monkaaay here.

I've updated some old codewarrior apps to XCode universal binaries and most of the old resEdit resource files just don't work anymore. Plus you need at least CodeWarrior 8.3 and preferably 9.1 or higher to do the auto translation to XCode.

If you only need to write for a Mac then InterfaceBuilder and Cocoa is probably the way to go.

If you need cross platform, Mac, Window and Linux from the same code, or have a lot of complicated GUI that needs to get done really quickly, then REALBasic is definitely the way to go.

gary hayenga
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
If you need cross platform, Mac, Window and Linux from the same code, or have a lot of complicated GUI that needs to get done really quickly, then REALBasic is definitely the way to go.

gary hayenga

Ack! No, ditch REALBasic (or any variety of BASIC) and use Qt (or wxWidgets, but Qt is better) if you need to do cross platform GUI development.
 

gary hayenga

macrumors newbie
Mar 7, 2008
3
0
Ack! No, ditch REALBasic (or any variety of BASIC) and use Qt (or wxWidgets, but Qt is better) if you need to do cross platform GUI development.

You clearly have no idea what REALBasic is if you try to equate it with any other variety of BASIC. BASIC is just the syntax it uses.

It's an excellent tool for fast, cross-platform, object-oriented, GUI development that natively compiles to machine code for Mac, Windows and Linux.

If those aren't the things that you need then there may be better tools for your specific need. But if those are the things you need then you can just get stuff done with it.

gary hayenga
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
I know what REALBasic is. Despite the OO guff and an expanded library, it's still Basic. Which is ultimately just a matter of taste (Basic = the Rodney Dangerfield of languages), but more importantly, unlike Qt Open Source edition, RealBASIC isn't free (by a long shot).
 

Monkaaay

macrumors 6502
Jun 19, 2006
258
0
Richmond, VA
You clearly have no idea what REALBasic is if you try to equate it with any other variety of BASIC. BASIC is just the syntax it uses.

It's an excellent tool for fast, cross-platform, object-oriented, GUI development that natively compiles to machine code for Mac, Windows and Linux.

If those aren't the things that you need then there may be better tools for your specific need. But if those are the things you need then you can just get stuff done with it.

gary hayenga

Sounds like a more efficient version of Java to me. :thumbup:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.