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

I'm a Mac

macrumors 6502
Original poster
Nov 5, 2007
436
0
A lot of us in this forum are new to programming, and are confused as to which language to learn. It is to my understanding that objective-c is the main language to mac os x, but I'm not exactly sure what other languages do, other than that they may be based on C. Can some explain what languages do what (what are there purposes and what are they used for?) e.x. C, C++, objective-c, python, ruby, java, etc.

I noticed, however, that you have many different options of languages in Xcode.

Also, what are the differences between Carbon and Cocoa?
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
C - old language, very fast but doesn't offer much protection to the programmer. Doesn't have objects, or other modern features like garbage collection.
C++ - slight improvement of C that adds objects. Can run all C code natively.
Objective C - Also based on C and has objects, is only generally used on Macs, can run all C code natively. Allows objects to send "messages" to each other, which works really well.
FORTRAN - the first language, very old and fast, but C is probably slightly quicker, has an old syntax.
Java - A "web" language (that isn't used on the Web directly much if at all now) that can run on any platform (within reason) without a recompile, is very slightly slower, but has difficult UI tools, and is hard to "look right" on multiple platforms. Used a lot in business.
Python/Ruby, scripting languages that are designed for making a program very quickly with little code, they are used a lot on the web, however they are slow, especially compared to C (and probably Java).


Cocoa - Invented by NEXTSTEP (and later Apple), generally uses Objective C. Can make a program quickly (good frameworks) AND fast (as it is C based).
Carbon - Apple's old framework that uses C/C++.
 

psingh01

macrumors 68000
Apr 19, 2004
1,586
629
For the most part Java does the same thing as C/C++. I work on applications written completely in Java that are used to remotely configure servers. Very little GUI, mostly command line stuff. The nice thing about Java is the garbage collection (means you don't have to worry about memory management...this is a BIG THING!) and the rich Java framework.
 

I'm a Mac

macrumors 6502
Original poster
Nov 5, 2007
436
0
Ok, thanks for the info- maybe someone should make a guide so questions aren't repeated. But what about actual uses? What is a framework exactly?

Also, are most mac os x apps written in objective-c and use Cocoa?

Is C++ mostly for windows, and is Java good because of its compatibility with multiple OS's and websites?

Can apps contain multiple languages?

What about all of the options in Xcode? I see a ton of different language files there? Are all compatible with OS X?

Also, are Python and Ruby like more advanced versions of applescript?

Sorry for bombarding you guys with questions.

EDIT: Also, what is quartz composer?
 

Cromulent

macrumors 604
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
Ok, thanks for the info- maybe someone should make a guide so questions aren't repeated. But what about actual uses?

Hmm thats a bit like asking what are French, German and English used for?

They are just a means of giving the computer a set of commands to execute basically. All the languages you have mentioned are general purpose languages which means they are capable of doing anything pretty much.

Although C/C++ tend to be used more for low level operating system style programming and Python / Ruby tend to be used more in web style applications. But saying that they can (and are regularly) be used in any way you want.

If you can solve a problem with them then you can use them for that purpose.
 

I'm a Mac

macrumors 6502
Original poster
Nov 5, 2007
436
0
Sorry, I'm wrong Java isn't really used on websites anymore, that is mostly done with Flash now, I've updated my original post...

Java is still used in some games, and it is also used to connect to servers (e.g. citrix).

So I guess computer languages are really like human languages (what a surprise) but I wasn't sure what languages work on what. Programs written in obj-c work only on OS X, right? Or is that Cocoa? Can you make a "real" app for macs with anything other than cocoa or carbon? (By real I mean something like ichat, or photoshop, not that ruby/python and/or applescripts aren't real, I was under the impression that they tell other apps to do things, simplifying tedious tasks for the user)

What is the primary language (or framework) of windows?
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
So I guess computer languages are really like human languages (what a surprise)

Well sort of, but some are clearly better/worse for certain tasks unlike human languages.

but I wasn't sure what languages work on what. Programs written in obj-c work only on OS X, right? Or is that Cocoa?

Objective-C applications can run on other platforms but no-one uses it on other platforms. Cocoa is OS X only.

What is the primary language (or framework) of windows?

Win32. But .NET is gaining dominance but it can't do everything that Win32 can and it is a very poorly thought out framework.

For those you generally use C++ and C# (or VB.NET) respectively.
 

Cromulent

macrumors 604
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
Java is still used in some games, and it is also used to connect to servers (e.g. citrix).

Any language can be used to connect to a remote server. You may need to write the library yourself for some languages but there is nothing stopping you using a language in that manner.

So I guess computer languages are really like human languages (what a surprise) but I wasn't sure what languages work on what.

Any language will work on any device that has a compiler or interpreter for that particular language.

For instance you can use C on anything from Macs to Mobile Phones to DVD players.

Programs written in obj-c work only on OS X, right?

Nope. There are Objective-C compilers for Linux, Windows, Mac OS X and any other Unix operating system that supports GCC.

Or is that Cocoa?

Correct, Cocoa is a Mac OS X only set of APIs although it has been ported (badly) to Linux and the other Unix systems under the name of GNUStep.

Can you make a "real" app for macs with anything other than cocoa or carbon? (By real I mean something like ichat, or photoshop, not that ruby/python and/or applescripts aren't real)

Of course. You could use any of the following APIs: Qt, GTK+, Motif, X11 etc.

What is the primary language (or framework) of windows?

Lots. C#, C++ and Visual Basic are probably the most popular though.

As for APIs there is win32 and .NET which are the two most used APIs (excluding DirectX of course) I believe in the Windows world.
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Sorry, I'm wrong Java isn't really used on websites anymore, that is mostly done with Flash now, I've updated my original post...

Java applets have largely been obsolesced by Flash, it is true. Java is still a "web" language in the sense that it in the computing ecosystem, it is typically sitting found sitting behind a web or application server, as the back-end implementation of a web-app. The timeline of Java's genesis and growth coincided with that of the world-wide web, so within the Java platform (language + APIs) there is a heavy emphasis on web-centric tasks.

Java (like C# in the Windows world) is also distinguished by the fact that it executes in a 'managed environment' or 'sandbox' within a virtual machine, unlike C/C++/Obj-C which executes natively.
 

Eric5h5

macrumors 68020
Dec 9, 2004
2,494
604
Can apps contain multiple languages?

Languages compile down to machine code. The various languages are only there for the convenience of the programmer; it's all just different ways of doing the same thing. So an app is machine code, no matter what language was used to make it.

There are interpreted languages that aren't compiled to machine code ahead of time, but each line is converted on the fly. But what the computer runs is still, and always, machine code.

--Eric
 

psingh01

macrumors 68000
Apr 19, 2004
1,586
629
But what about actual uses? What is a framework exactly?

It's really hard to say what the uses are as they are so varied. For example Java can be used for code running on a server, web applications (servlets/JSP) down to things that run on your cell phone (non-iPhone).

A library is a collection code already written for you that you use to build your application. There is no need for you as a programmer to have to invent how to create a window or a button or how to make a network connection. These are common things that are provided by the operating system. So this code is already written for you to call. A framework is like a library, but more refined for a specific type of use. For example all networking code will go into one framework. All graphics code will go into another framework. It is more like a way of organizing libraries. Cocoa is a collection of frameworks for MacOSX. Java has frameworks that were modeled after Cocoa (when it wasn't called Cocoa). Microsoft's .Net has a framework that is modeled after the Java frameworks. So you see, once you know one, it should be relatively easy to learn another.



Also, are most mac os x apps written in objective-c and use Cocoa?

For the most part yes. Carbon exists because it is what used to be the system libraries for MacOS 9 and older. It was there to help people transition to OS X, but Apple has been slowly pushing/dragging people to Cocoa.

Is C++ mostly for windows, and is Java good because of its compatibility with multiple OS's and websites?

C++ can be used on any system. The people who invented C++ also invented Unix. I would gather that most applications that still use Carbon on OSX are written in C++. Of course the windows api's are in C++.

Java's compatibility with many systems was the original selling point, but now it is just a good language on it's own merits.

Can apps contain multiple languages?
Yes, specially if you think of apps as a collection of other programs that all work together to do one thing. For example one program can call another to do something, then use the output to do something else. Many free utilities available for OSX are nothing more than GUI applications that call command line applications. All they do is provide a pretty user friendly interface.

What about all of the options in Xcode? I see a ton of different language files there? Are all compatible with OS X?
If it's in Xcode then it works with OSX

EDIT: Also, what is quartz composer?
eck...I haven't played around with this too much, but it has to do with apple's technology called CoreImage. It let's you "program" filters for coreimage without really programming.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
People have covered most of the high points, but I thought I'd throw in my $.02.

I think you are wanting to know what tasks particular languages are best suited to, so I'll try to cover the languages mentioned in this thread and a few others:
C - This is one of the oldest languages in general use. It was developed in about 1977-1978. Fortran beat it out of the gates. It is very powerful, and very widespread, and is essentially the language of UNIX. Everything that UNIX operating systems provide to the programmer is done through C. C is used almost everywhere, for almost any task whether it's the "right" choice for said task or not. Most platforms, such as embedded controllers in toasters, etc. will have a C compiler, so it is often used in this sort of restrained environment.

FORTRAN - This was the first high-level language. Before this it was all Assembly and Machine code. When people say mean things about fortran, and its outdated syntax, etc. they are generally talking about Fortran 66/77, because very few people have used/seen Fortran 90, Fortran 95 or Fortran 2003 (that latter of which doesn't really have a compiler, but the standard is out there). The later revisions add some important syntactical changes such as the use of ==, >, etc. instead of the "dotted" operators .equal. .gt., etc. as well as better interaction between C/Fortran, more robust Object-Oriented support through modules, etc. Most people still say mean things about Fortran, but in its newer incarnations it is a pretty pleasant language to use and is very fast. It's niche is scientific computing.

C++ - Came along a few years after C. It is *not* a proper superset of C. There are things that behave differently in C and C++. You will probably never run in to them, but it's worth mentioning. C++ added Object-Oriented programming to C. A number of the Windows APIs such as COM, MFC, Win32, etc. use C++. It's quite fast, and quite popular. If an embedded platform supports more than C, C++ is normally what is added.

C# - This is a Microsoft invention. It is compiled to something called byte-code rather than machine code, so it does not run on actual hardware. It requires a runtime to be installed for it to run on top of. For Windows this is called the Common Language Runtime or CLR. This runtime is used for all .NET languages. This runtime is only available on Windows. There is an implementation of the CLR and compilation tools for C# for other platforms called Mono. Its developers and the code are now part of Novell. There are agreements between Novell and Microsoft, but Mono may violate Microsoft patents and may not be available longterm. Those are all political concerns, but I mention it because I would not consider this a serious option if you are not targeting Windows. C# is an Object-Oriented language with a very large library of supporting functions, and its primary uses are application programming on Windows. There is a subset of C#s libraries that can be used on a mobile CLR available on the Windows mobile platform, allowing its use on certain mobile devices.

Java - This is a Sun invention. Until recently Sun completely controlled the platform, but they have been making it open source recently so developers and users are not strictly at Sun's mercy any more. Java is, like, C#, compiled to byte-code. It is run on a platform called the Java Virtual Machine (JVM). JVMs are available on most popular platforms, and subsets of java and JVMs to support them are available on a number of portable platforms as well. Java is used on the server-side of a number of client-server applications, and for cross-platform client software. There is a Java bridge to Cocoa on OS X, but it is no longer being updated. This component would allow for native interfaces on OS X using Java for the main application code.

Python/Ruby - These are both modern scripting languages. They run on a runtime like Java or C#, but are distributed and run as source code/scripts instead of compiled to byte-code. These are popular for all sorts of scripting and application programming purposes. There is a bridge that is actively maintained to Cocoa for both of these, so they can be used for OS X applications with native interfaces and OS access.

Essentially these languages go from highest performance/lowest ease of programming to lowest performance/highest ease of programming. In these tiers C/Fortran are about the same, and Java/C# are about the same. With modern computers, however, speed is much less of an issue than it used to be.

I'm sure on some of the more subjective items people will disagree, but hopefully this gives some background on the languages mentioned and their general uses. Since all of these languages are Turing Complete any of them can really be used for any task. The real limitation is the APIs for the OS you are targeting. If you want to use Fortran on OS X for a GUI application, you will have to deal with interacting between Fortran/C/Objective-C, whereas if you just picked Objective-C you could interact with the Cocoa API (Application Programming Interface, don't know if we stated what that acronym was for yet) directly.

The Cocoa/Carbon difference has been covered. Essentially Carbon was created to allow for apps to run on OS 9 and OS X during the transition, and Cocoa is a NeXTSTEP/OS X only API. Cocoa is the new hotness, so any new OS X projects should really target this API if possible.

-Lee

P.S. On the question of whether apps can contain multiple languages: They certainly can. Even in the same program (not in pieces that are called independently). There are things like Embedded Mono for calling Mono routines from C and vice versa, JNI which is the same thing for Java, there is a standard means of calling Fortran from C and vice versa, etc. Objective-C is a proper superset of C, so any C can be called from Objective-C, etc. and there is Objective-C++ which allows for mixing the two if you need (I would expect this is normally if you have existing C++ code you want to use, as I think mixing the two object models would be confusing if it was not strictly required).

Edit 2:
I totally left out Objective-C, oops.
Objective-C is a proper superset of C, providing smalltalk-like message passing to objects. This language is primarily used in OS X. The Cocoa API is in Objective-C, making Objective-C the "first class" language for programming OS X applications. It is object-oriented, but does not share its object syntax and message-passing syntax with C++. In terms of speed it is a compiled language that is on par with C++ in terms of message passing vs. function invocation. It has recently reached version 2.0, adding features like garbage collection and for-each loop syntax which have made it even more competitive with languages like C# and Java in terms of ease of programming and language features.
 

psingh01

macrumors 68000
Apr 19, 2004
1,586
629
Actually the people who invented Unix were the ones who invented C not C++.

I was speaking in more general terms as they all came from AT&T Bell Labs, but yes some of the developers for Unix were directly responsible for C :)
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
C - This is one of the oldest languages in general use. It was developed in about 1977-1978.

According to Wikipedia it was developed in 1972.

Fortran beat it out of the gates.

To clarify this, Fortran came out in 1957, so it beat C out the door by a wide margin.

When people say mean things about fortran, and its outdated syntax, etc. they are generally talking about Fortran 66/77, because very few people have used/seen Fortran 90, Fortran 95 or Fortran 2003 (that latter of which doesn't really have a compiler, but the standard is out there).

True, its still got a different structure from C though.
 

MrStevieP

macrumors newbie
Feb 27, 2008
22
0
A lot of us in this forum are new to programming, and are confused as to which language to learn. It is to my understanding that objective-c is the main language to mac os x, but I'm not exactly sure what other languages do, other than that they may be based on C. Can some explain what languages do what (what are there purposes and what are they used for?) e.x. C, C++, objective-c, python, ruby, java, etc.

I noticed, however, that you have many different options of languages in Xcode.

Also, what are the differences between Carbon and Cocoa?

I think the real question you should be asking yourself is "what do I want to do?". What is the reason you want to learn programming? For example, are you interested in trying to get a job with a commercial company or do you just want to experiment with your computer? Either way, you need to know what you are going to write, then you can choose the most appropriate language to learn and develop your chosen application in (which is where this board and its wealth of experiaces comes in)

It seems to me that everyone has an opinions on which is the best overall language, but most languages have something something that they are partciularly good at (see the other posts here). However without knowing what you want to develop, you cannot make the best, or even and informed, choice about which to use.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
According to Wikipedia it was developed in 1972.
Oops. I guess it took a few years to publish "The C Programming Language". I would expect that it would have been difficult for people outside of Bell Labs to learn it before that. Developed was a poor choice of words. Codified?

True, its still got a different structure from C though.
It's not that much different than C, and I don't think being different than C is an automatic negative. It might not be the tradition, but you can write very clear Fortran free of labels and gotos and do some pretty nice things like array-slicing and aggregate boolean checks (all or any) that C does not do. It also has some nice memory-management features like checking if an allocatable is allocated, if a pointer is associated, the current size of a dynamically allocated array, etc. so you don't have to keep helper variables around to do some of that.

With that said, it has its shortcomings as anything does. I've always been pretty wide-open when it comes to what language I use. You can write terrible code in any language, and you can write beautiful code in any language. The biggest knock against Fortran right now is "who is going to program it and maintain it in 5 years?" to which the answer is either "No one" or "Someone who doesn't care what language they work in" and the latter seem to be hard to find. As such I pushed hard to start moving to Java (it was between that and C#, and some other engineers made me think long -term about Mono and decide against it). If nothing else I think it should be pretty easy to find a Java developer in 5 years, even if C# is 3x as popular by then.

-Lee
 

FelixMC

macrumors member
Jan 4, 2008
33
0
psingh01 said:
eck...I haven't played around with this too much, but it has to do with apple's technology called CoreImage. It let's you "program" filters for coreimage without really programming.
Not only that.. it's a pretty nifty tool.. You can create mathematical functions, use info from rss feeds, video input, sound input, host info (IP, username, specs), keyboard, mouse, open URL's on key press, use 3d objects like cubes, particle systems, spheres, and a lot of user respondent stuff, great tool for advanced screen savers and building the application "brain" for a basic apps, as it can handle boolean values, numbers, multiplexes, strings, structures, etc.. :p
It's quite addictive.. :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.