Re:The C Object System: Using C as a High-Level Object-Orien...
by kraemate on Monday March 15, 2010 @09:13AM
(#1192832)
How is this different or superior to languages like Objective-C and C++ ? Both provide C like syntax and have similar features as the system described here.
[ Parent
| on HN ]
Re:The C Object System: Using C as a High-Level Object-Orien...
by dfox on Monday March 15, 2010 @09:29AM
(#1192857)
1) Objective C certainly does not provide generic functions and I doubt that Objective C++ does (C++'s static overloading is something completely different, although it might look similar).
2) And this is different exactly in that it is not a complete language, but a library of CPP macros and some supporting infrastructure.
Re:The C Object System: Using C as a High-Level Object-Orien...
by m_eiman on Monday March 15, 2010 @09:44AM
(#1192877)
C macros, surely.
Re:The C Object System: Using C as a High-Level Object-Orien...
by dfox on Monday March 15, 2010 @09:53AM
(#1192905)
CPP is "C PreProcessor", so your "C macros" are simply some subset of uses of "CPP macros". CPP can be (ab)used to preprocess other things than C source.
Re:The C Object System: Using C as a High-Level Object-Orien...
by m_eiman on Monday March 15, 2010 @10:54AM
(#1193078)
slaps forehead
I blame my confusion on the .cpp extensions!
Re:The C Object System: Using C as a High-Level Object-Orien...
by dfox on Monday March 15, 2010 @05:04PM
(#1194116)
and this confusion is exactly why I tend to use .cxx for C++ sources
Re:The C Object System: Using C as a High-Level Object-Orien...
by ragh on Monday March 15, 2010 @09:53AM
(#1192903)
CPP is the C Preprocessor, not to be confused with C++.
Re:The C Object System: Using C as a High-Level Object-Orien...
by jedbrown on Monday March 15, 2010 @09:23AM
(#1192846)
This compiles with a standard C compiler, so it's more appropriate to compare to something like GLib. Cos has faster single dispatch than Objective-C and has extensible multiple dispatch with significantly better performance than C++ (as implemented using Visitor, which is only extensible in one argument).
Re:The C Object System: Using C as a High-Level Object-Orien...
by plesn on Monday March 15, 2010 @10:13AM
(#1192948)
So ok, I just peeked at the paper and it seems great, but the disadvantage of being in C is that you end up with a lot of macros (like e.g. `defclass`): what with debugging?
Re:The C Object System: Using C as a High-Level Object-Orien...
by jedbrown on Monday March 15, 2010 @11:18AM
(#1193129)
This is a very good point and is the fatal flaw of most metaprogramming. It does seem easy to generate quite confusing error messages by making minor typos. Clang does a much better job with macro expansion errors than gcc, but it's still not great. As for actually using debuggers, it looks like you're on your own to understand the implementation enough to be useful. I don't know if it would be feasible to write a gdb plugin to improve the experience.
OTOH, Cos offers more compile-time type safety than GLib, so you might hope that you'd need to spend less time in the debugger.
Re:The C Object System: Using C as a High-Level Object-Orien...
by malkia on Monday March 15, 2010 @01:43PM
(#1193519)
The C preprocessor would emit #line <number> to preserver the original line numbers, this way the debugger won't get problems understanding it. This off course if the macro does not expand multiple-lines (if it does, you'll just skip all over that).
Re:The C Object System: Using C as a High-Level Object-Orien...
by huhtenberg on Monday March 15, 2010 @01:29PM
(#1193475)
> Objective-C
As a friend of mine likes to put it - "Objective-C is C raped by Smalltalk without proper understanding of the language anatomy". Not exactly accurate, but fairly close still :)