Objective C outside of the Apple realm

B

badbrain

Guest
Anyone interested in this language?

There are four options:

1. GNUStep + GCC (or Clang, recommended)

2. ObjFW + GCC (ObjFW license is either GPL or QPL, or commercial)

3. Mulle Objc + Mulle Clang

4. Portable Object Compiler (original Objc, not Apple's Objc 2.0 like the above).

And I want to ask if you prefer plain C or syntactic sugar compiled-to-C languages?

Plain C is too primitive to me. I'm so used with high level container and can't even code data structure like linked list my self. I couldn't live without Java ArrayList so I used LibCello but it syntax is rather unintuitive. Recently I found Ecere C, a language with C++ like syntax and compile to plain C. There're a bunch of such languages here: https://github.com/dbohdan/compilers-targeting-c
 
I like the idea of objective-c but have never taken time to learn it; mostly because it is rarely used outside of platforms providing a NS-like API. Just like Java, it is a little bit useless without the additional runtime libraries.

C++ is great but it is starting to get a bit messed up with some of the newer standards (async, modules, lambdas are some examples). I am fine not using them, unfortunately many other 3rd party developers are gimmicky little sh*ts and drag this stuff in as soon as they can to show off.

C is here to stay and is really worth getting good at it. With MACROs you can actually go an extremely long way towards memory safety (which is my only real concern with the language).

For lists, check out: https://github.com/osen/stent/blob/master/src/emptest/main.c
(do a search for the section within "FLOAT_VECTOR_TEST").
I basically used MACROS to create a type-safe vector clone and what I like to term "debug time" smart pointers. It is like libcello but less invasive and only focuses on memory safety.

The best thing about C is that it never changes. Code written in it just keeps working.
 
Plain C is too primitive to me.
There has to be some misconception here. C is "very low level", to the extent of having been (arguably rightfully) called a "portable assembler". It sure isn't "primitive".

The best thing about C is that it never changes. Code written in it just keeps working.
Well, almost. Of course new versions of C do appear. Most of the time, they are fully backwards-compatible, but there are some exceptions. For example, gets() was removed from the language for good. I'd expect some other things now marked deprecated to follow some time.
 
For example, gets() was removed from the language for good.

Yes, good point. The C standard library may change (albeit rarely) but the core language itself is very stable. A lot of these deprecated standard library functions are very easy to polyfill too.

Compare this to Objective-C where the garbage collector was deprecated and the whole language moved over to ARC, that must have been pretty awkward to maintain XD.
 
Don't get me wrong, I totally agree with you about the very high stability of C. The level is probably unreached by any other language (except if there wasn't any development to the language at all). Still there are some exceptions, not only in the standard library but also in the language itself. A prominent example is implicit int, which was removed in C99.

Indeed, in many other languages, following the current versions can become a major PITA. In C, it's rarely necessary to do anything at all, and if it is, the changes are small. That is, of course, assuming you only talk about code that already conforms to a version of the standard -- if not, you're in trouble anyways.
 
I like Objective-C, because it is C + Objects. Meaning, you have a full-fledged object programming environment when you need it and otherwise simply may use C for everything else.

For tools and daemons for FreeBSD I use mainly C, however, for some small, though important parts, I employed Objective-C. For example in my ContentCGI project, I use Objective-C for the request dispatcher in the various plugins. In scientific software also target to FreeBSD (not open source), I developed a Calculator class in Objective-C which I use for numerical evaluation of math. expressions, usually given by user input at runtime. For all this I don’t use any framework. The programs only need to be linked against devel/libobjc2. For a basic example see my thread on this forums: Howto: Programming in Objective-C without any framework.

For macOS, I wrote a number of GUI apps using the frameworks provided by Apple. I ported one application to Windows using The Cocotron.
 
IMHO there is no reason to be still using C unless for very low level stuff. These are pretty efficient (OCaml) and superior languages (Ada) for high level programming.
 
I like Objective-C, because it is C + Objects. Meaning, you have a full-fledged object programming environment when you need it and otherwise simply may use C for everything else.

For tools and daemons for FreeBSD I use mainly C, however, for some small, though important parts, I employed Objective-C. For example in my ContentCGI project, I use Objective-C for the request dispatcher in the various plugins. In scientific software also target to FreeBSD (not open source), I developed a Calculator class in Objective-C which I use for numerical evaluation of math. expressions, usually given by user input at runtime. For all this I don’t use any framework. The programs only need to be linked against devel/libobjc2. For a basic example see my thread on this forums: Howto: Programming in Objective-C without any framework.

For macOS, I wrote a number of GUI apps using the frameworks provided by Apple. I ported one application to Windows using The Cocotron.
Thanks for your implement of base class. I know I could use Objc without any framework and could define my own base class but I didn't have the knowledge to do so.

Since Objc doesn't have any standard library, in case you need cross platforms framework which helps life easier there's ObjFW, but the license term is unclear to me. I want to know I could make proprietary software using it or not, not a 'if QPL or GPL not fit you could contact for commercial license', which I didn't have the ability to read these wall of text and find for myself.

There's Mulle Objc which provide MulleFoundation, it has NSArray, NSDictionary,... like the Apple Foundation framework.
 
IMHO there is no reason to be still using C unless for very low level stuff. These are pretty efficient (OCaml) and superior languages (Ada) for high level programming.

It is the bindings to other OS specific functionality that makes C (and C++) so powerful for me. I don't need to hunt around for an i.e SDL2, libogg, bullet2 binding to use with my higher level language. Writing my own is too time consuming and error prone, especially if callbacks and void * userdata is involved.

One of the most frustrating things is that even with very popular languages such as Java or .NET, the bindings still become very out of date or have a large number of dependencies or constraints that I can simply avoid by using C or C++. Take JOGL for example, the main OpenGL Java binding is not available on OpenBSD. Instant no for me.

As far as solving this issue, the high level language Go at least allows me to use C functions directly (without a binding) but still has big issues passing around structs or callbacks.

I will always keep with C for libraries (because accessing, i.e Python functions from Java or OCaml functions from Ada is almost impossible) but if something better comes along to replace C++ and still consume native libraries, I will be very interested.
 
Ada bindings to C/C++ is not that bad, and indeed Ada has built-in support for that. :)

Here, here, and here.

[EDIT]

Also, OCaml has tons of libraries (and usually high quality[1]), those of course doesn't cover everything but they keep growing non-stop.

Irmin is a particularly nice thing.

[1] a lot of OCaml people, and specialy the ones leading the community, are PhD level.

[EDIT]

You may also want to know AdaCore is cooking a LLVM/GNAT compiler I think will come out still this year with at acceptable license (if not better than that). ;)
 
Ada bindings to C/C++ is not that bad, and indeed Ada has built-in support for that. :)

Here, here, and here.

[EDIT]

Also, OCaml has tons of libraries (and usually high quality[1]), those of course doesn't cover everything but they keep growing non-stop.

Irmin is a particularly nice thing.

[1] a lot of OCaml people, and specialy the ones leading the community, are PhD level.

[EDIT]

You may also want to know AdaCore is cooking a LLVM/GNAT compiler I think will come out still this year with at acceptable license (if not better than that). ;)
IMHO there is no reason to be still using C unless for very low level stuff. These are pretty efficient (OCaml) and superior languages (Ada) for high level programming.
Go out man. This is the place of curly brackets guy like us, 'begin..end' guy should not be there ;)

kpedersen What do you think about Ecere C? The syntax is very similar to C++ but it compile to plain C. I liked it because I found it to be familiar, not something completely foreign like LibCello syntax, which look like another language, not C anymore :)
 
kpedersen What do you think about Ecere C? The syntax is very similar to C++ but it compile to plain C. I liked it because I found it to be familiar, not something completely foreign like LibCello syntax, which look like another language, not C anymore :)

It looks quite cool. Compiling to plain C is nice for platforms that cannot support things like C++ (Plan 9, embedded etc.)

A slight issue I notice is this (in the OpenGL triangle demo):

Code:
class GLTriangle : Window
{
  ...
}

Not an issue with the language itself but Window is a class provided by them that presumably(?) calls into X11 on *nix, Cocoa on OSX, Win32 on Windows... Or will it? If the library hasn't been written to support my platform, I am going to have to write the code; I would personally rather just chuck in SDL or freeglut and continue with developing the actual software in C or C++.

For me, I don't really care about language (they all have flaws), but I hate bindings and maintaining platform libraries XD

You may also want to know AdaCore is cooking a LLVM/GNAT compiler I think will come out still this year with at acceptable license (if not better than that). ;)

I have a few projects written in Ada (I actually quite like the language and structure. In particular it can use RAII rather than a garbage collector so that gains bonus points from me :D.
But yep, bindings for Vulkan, OpenCL and Qt are still a little lacking last time I checked. Due to the vastness of these technologies, I fear that any binding developed will always be lagging behind a few revisions (yes, not a massive issue for a lot of projects but enough for me to just justify C++ without perhaps giving Ada a fair chance).
Even with the C integration layer, something like Vulkan would be a ginormous undertaking to safely wrap. I also hate *having* to leave things to others, I prefer being proactive and do it myself or avoid the issue entirely.

That said, this has always looked interesting to me: http://www.dragonlace.net/
If I ever find myself developing for Android, I will jump to Ada over Java like a shot (although disappointingly I will end up using the NDK because I am weak! XD)
 
I heard rumors around the Ada community about a gaming company interested in Ada to develop their tools, and so eventually something Vulkan may appear in the wild. Also nVidia selected Ada (SPARK in particular) for they critical projects. Just in case, there are bindings for Wayland already.

That Dragonlace compiler is in the ports tree, lang/gcc6-aux.

Btw, Ada2020 will bring memory ownership; however you already can test it if using the latest AdaCore-GNAT.
 
It looks quite cool. Compiling to plain C is nice for platforms that cannot support things like C++ (Plan 9, embedded etc.)

A slight issue I notice is this (in the OpenGL triangle demo):

Code:
class GLTriangle : Window
{
  ...
}

Not an issue with the language itself but Window is a class provided by them that presumably(?) calls into X11 on *nix, Cocoa on OSX, Win32 on Windows... Or will it? If the library hasn't been written to support my platform, I am going to have to write the code; I would personally rather just chuck in SDL or freeglut and continue with developing the actual software in C or C++.

For me, I don't really care about language (they all have flaws), but I hate bindings and maintaining platform libraries XD
This kind of language provide wrappers to native toolkits to be cross platform. It's something like Eclipse SWT. If you don't want it then don't import it and write your own.

I checked many languages compile to C and found I would rather prefer some extensions to the C language at runtime like LibCello. I checked Nitlanguage (nitpicking? Not a good name and use 'fun' as keyword for function only because it's three characters is laughable), Kit (I liked it until found it's written in Haskel, the transpiler). Nim (the best of the three, but suffers the same three chars nonsense 'proc', why not 'procedure', full word?). They all have shortcomings.
 
Back
Top