News for hackers. Stuff that matters.
Re:How Quaternions encode rotations: derivation and sample code by jordigh on Wednesday September 07, 2016 @10:45AM (#12443796)
This looks like C. Why do you call it "C/C++"? It could just as well be C/ObjC, right?
Re:How Quaternions encode rotations: derivation and sample code by generic_user on Wednesday September 07, 2016 @11:28AM (#12444177)
C and C++ share the same memory model and can be called quite easily form each other with the use of an 'extern "C"'.

It's a common practice to write libraries in C for flexibility, (many languages can ingest C) and use the 'extern "C"' for use in C++ code.

You can also write a thin C++ class wrapper for a more native object oriented interface.

Re:How Quaternions encode rotations: derivation and sample code by jordigh on Wednesday September 07, 2016 @11:34AM (#12444246)
But all of this is true for ObjC too. How come people write C/C++ to describe pure C code but not C/ObjC? C is as much of a subset of ObjC as it is a subset of C++.

It's funny people don't do this as much with other languages. For example, nobody describes pure Javascript as "js/html" even though you can have lots of js inside HTML code.

Re:How Quaternions encode rotations: derivation and sample code by generic_user on Wednesday September 07, 2016 @04:23PM (#12447219)
Its an interesting point.

C is actually part of of the C++ standard. Within the ISO C++11 standard there is the C99 standard with some adjustments and exclusions. The integration is quite tight. So one can say C/C++ with some clarity.

Library writers often go thorough a lot of work to write extensive object oriented interfaces around C libraries. And they intend that the user use the C++ version not just import the C version in there C++ code. So in that case it is a necessity to use C/C++ because there are two separate interfaces.

In the general case I would guess that 'most' C programmers write some C++ and vise versa. So you have a very large overlap of C/C++ programmers. Objective C on the other hand is probably a significantly smaller group and is simply not big enough for C/C++ communities to think to much about.

Re:How Quaternions encode rotations: derivation and sample code by jordigh on Wednesday September 07, 2016 @04:55PM (#12447587)
> In the general case I would guess that 'most' C programmers write some C++ and vise versa.

That's not what I've seen. People usually either write C++ exclusively or C exclusively and hate the other language (probably more C writers that hate C++ than C++ writers that hate C).

Some people write very C-accented C++, with mallocs and frees instead of news and deletes and so forth (these are usually people who prefer C over C++ but are writing C++ for whatever reason). I guess those people could be said to be writing "C/C++". But in general I think people overestimate how close the two language communities are. What I have seen is that people like one language and deride the other.

Re:How Quaternions encode rotations: derivation and sample code by generic_user on Wednesday September 07, 2016 @05:24PM (#12447855)
There are some people that probably get to worked up about it especially on the internet as you said. But in a professional environment where you have deadlines and a budget you don't have the luxury to be a language purist. You have to use libraries and choose from whats available and whats the best choice often that means mixing C and C++. I'm not saying that people necessarily like to code in C if they prefer C++ or the other way around but they will often have to. And so have some competency weather they like it or not.
Re:How Quaternions encode rotations: derivation and sample code by EllipticCurve on Wednesday September 07, 2016 @11:53AM (#12444397)
True. I'll skip the C++ mentioning, as it is clear for any C++ developer, that you could just use it as extern C.
Re:How Quaternions encode rotations: derivation and sample code by generic_user on Wednesday September 07, 2016 @03:39PM (#12446687)
If you intend for your library to be used in both C and C++ then your doing yourself a favor by using C/C++ for the simple fact that this is marketing to C++ programmers that they can use the library who may not be aware that that is the case.

so at the bare minimum C/C++ will possibly increase your user base.

(edit)

You should not assume that C++ programmers are going to wade through your library code and rewrite your library with the proper signatures. You as the library writer should have done that and tested it, then advertised to prospective users that your library is ready for use with C++.

Re:How Quaternions encode rotations: derivation and sample code by EllipticCurve on Wednesday September 07, 2016 @11:54AM (#12444403)
That was my thinking. But as most C++ developers already know this, I'll skip the C++ mentioning :)