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

ArrayDecay

macrumors 6502
Original poster
Feb 21, 2019
351
532
Greater Seattle Area
I understand that most macOS app development occurs in ObjC and Swift, but I'm curious if C has a useful role in the Mac world outside of kernel-level programming.
 

casperes1996

macrumors 604
Jan 26, 2014
7,599
5,771
Horsens, Denmark
Yes, in various ways, but for application code it’s generally not the bulk of it though there may still be individual C source files in there. OpenGL shaders, OpenCL and Metal Shaders are basically written in C as well. It’s technically a separate language but it’s based on, I believe C99. Though remember that while it doesn’t change dramatically, C and C++ are still alive languages and do get evolved, even if it’s not like a full modernization at least for standard C.
But yeah you might fairly often find an algorithm in C that is called from another language. Swift is very good about C COmputability as well so you can fairly easily call a C function and such. There are also a lot of open source projects out there that you can use as dependencies that will have C codee
It’s a good language to have some familiarity with though not necessarily expertise. I doubt there’s much in user land written solely in C, but C interop is prevalent.
 
  • Like
Reactions: xodh and ArrayDecay

2984839

Cancelled
Apr 19, 2014
2,114
2,241
Pretty much all of the base command line utilities and libraries that Apple imports from GNU and the BSDs are written in plain C. Not sure if that counts for your question as technically most of that stuff is developed outside of Apple and imported, but Apple devs do get involved with some of it.
 
  • Like
Reactions: ArrayDecay

casperes1996

macrumors 604
Jan 26, 2014
7,599
5,771
Horsens, Denmark
Pretty much all of the base command line utilities and libraries that Apple imports from GNU and the BSDs are written in plain C. Not sure if that counts for your question as technically most of that stuff is developed outside of Apple and imported, but Apple devs do get involved with some of it.

A lot of the tools are Apple specific forks, yeah. Usually not super modified but a bit and of course general improvements and fixes get pushed upstream.
 
  • Like
Reactions: ArrayDecay

Senor Cuete

macrumors 6502
Nov 9, 2011
430
31
A Mac application typically has a rich and complex Graphical User Interface. GUIs are programmed with object-oriented programming with the Cocoa framework using Swift or Objective C. Cocoa is so complete that many applications can probably be programmed with Cocoa only but many things you might want to do aren't part of Cocoa and would be programmed with C. Objective C is a superset of C that allow you to use it as an object-oriented language so a lot of the code encapsulated in your Objective C code is C. The additions that Objective C adds to C are pretty simple and if you are a C programmer you can probably learn them in a few hours. But no, you can't program Cocoa with C, only Objective C.
 

DanTheMan827

macrumors regular
May 9, 2012
220
302
Applications like Retroarch and Kodi are written largely in C++ with some Objective-C thrown in to bridge the gap to native Apple APIs.

I'd think the bigger question though would be "is serious development occurring in plain old c?" and for that, I'd have to say yes... but a lot is also in C++
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.