News for hackers. Stuff that matters.
Re:Why artificially limit your code to C? by TheNewAndy on Saturday April 14, 2012 @01:25AM (#3840004)
No one there mentions symbol scrambling, and how it makes C++ libraries unportable across multiple compilers for the same platform.
Re:Why artificially limit your code to C? by georgemcbay on Saturday April 14, 2012 @02:38AM (#3840127)
Actually this is mentioned by "Rhythmic Fistman", but the post only got 6 points.

From a purely practical standpoint, the lack of an ABI is the #1 reason I don't bother with C++ anymore because chances are pretty good that I'll want to interface the lower-level code with something like Python or Go, both of which integrate with C code much more easily than C++.

Re:Why artificially limit your code to C? by cageface on Saturday April 14, 2012 @05:56AM (#3840427)
This is exactly the problem with C++ today. C++ "wants to be on top". Unlike C, it makes for a very uncooperative lower layer for other languages to build on. Unlike C, it's difficult to build up component libraries in C++ that can be easily used by the rest of your code. C++ makes more sense if you're writing your entire application in C++ but that's just way too much hassle for most applications.
Re:Why artificially limit your code to C? by pjmlp on Saturday April 14, 2012 @02:16AM (#3840087)
Everyone loves to bash the lack of a C++ ABI. Now please name another language with native implementations with a standard ABI across different compilers.

C implementations have a standard ABI, because they usually are the operating system ABI.

Re:Why artificially limit your code to C? by TheNewAndy on Saturday April 14, 2012 @02:20AM (#3840096)
I'm not sure what you mean here by "name another language". Do you mean other than C? I don't understand what that would demonstrate.
Re:Why artificially limit your code to C? by pjmlp on Saturday April 14, 2012 @10:17AM (#3840885)
For example, Lisp, Scheme, Ada, Modula-3, Delphi, D, Go, Oberon don't have compiler implementations that produce object files compatible across vendors.

Usually you are only able to link to libraries compiled with the same compiler. The same way as it happens to C++.

Re:Why artificially limit your code to C? by batista on Saturday April 14, 2012 @07:15AM (#3840556)
That it's not that common?
Re:Why artificially limit your code to C? by pjmlp on Sunday April 15, 2012 @04:52AM (#3843178)
No, because language standards only specify the language itself not the implementations.

So each vendor comes up with its own library format and tricks how to make the language usable in dynamic libraries. And as far as I know, they seldom talk among themselves about common ABIs.

C ends up being used as universal ABI, because in the end all implementations that generate native code need to interface with the operating system, which usually is developed in C.

But this was not always like this. Before C won its place as system programming language outside the UNIX world, there were other systems programming languages in use. On those systems there was no C ABI as such.

The Pascal calling convention ABI exists, because on the early 80s a few operating systems were developed in extended version of Pascal, like the first MacOS, for example.

Re:Why artificially limit your code to C? by angersock on Saturday April 14, 2012 @02:42AM (#3840135)
We love to bash it because it's shit.

Also, to answer your question: Java, C#/Mono.

Re:Why artificially limit your code to C? by pjmlp on Saturday April 14, 2012 @10:19AM (#3840889)
Ok, there you have a point, thanks to the bytecode as ABI.

I forgot about that, as I was thinking about compilation directly to native code, as I wrote my comment.

Re:Why artificially limit your code to C? by cageface on Saturday April 14, 2012 @06:36AM (#3840502)
It's also much easier to specify a C abi. You don't have to worry about name mangling, exception propagation, inheritance relationships, templates etc.
Re:Why artificially limit your code to C? by zvrba on Saturday April 14, 2012 @02:05AM (#3840067)
That's what I thought too, until I found that there exists C++ ABI on linux. I tried to link together two small files, both using iostreams, one compiled with Intel C++, the other with g++, and it worked.

Though I'm in doubt [haven't tested it yet] whether it would have worked had I tried to use something std::vector across functions compiled with different compilers.

Re:Why artificially limit your code to C? by TheNewAndy on Saturday April 14, 2012 @02:17AM (#3840089)
It is less of an issue in linux where there is a healthy ecosystem of libraries where you have access to source code and can reasonably expect to be able to compile everything with the same compiler. (Obviously there are times when this is not practical, but for most cases, it is ok).

Under Windows, the whole situation is a mess.

For current interesting platforms, the problem is often solved by either having no C++ compiler, or just one (e.g. the Qualcomm QDSP, which I think only recently gained a C compiler lacks a C++ compiler, and I don't imagine this changing soon).

Re:Why artificially limit your code to C? by dzorz on Saturday April 14, 2012 @04:14AM (#3840252)
clang uses the same ABI as gcc and if you find that something is binary incompatible then it is a bug.
Re:Why artificially limit your code to C? by ruediger on Saturday April 14, 2012 @05:33AM (#3840382)
Linux and *BSD have a fixed ABI for C++.