C Compiler under Fedora

Can you give some examples? I have not to my knowledge encountered this.

Well, ignoring the existence of C99 (which the C++ standardization committee is certainly doing), even something as simple as:

int *a = malloc(sizeof(int));

will fail to compile with a type error.

Sure. This is a valid C program which is not valid C++:




#include <stdlib.h>
#include <stdio.h>

int main(void)
{
    int *buf;

    if (!(buf = malloc(23 * sizeof(*buf))))
        exit(EXIT_FAILURE);

    buf[0] = 5;

    printf("%d
", buf[0]);

    free(buf);

    return 0;
}

The problem (from the C++ perspective) is that I didn’t cast the return value of malloc(); that’s actually bad practice in C, as it can mask a failure to include stdlib.h and, worse, cause the compiler to treat the void* as an int before casting it back to a pointer. On 64-bit systems, where pointers are 64-bit but ints are typically 32-bit, this can be utterly catastrophic.

I could probably think of more, and worse, examples, but that example is, to me, emblematic of a serious underlying problem with how C++ extended C: It tried to make the type system ‘stricter’ but only succeeded in making it more annoying. You still have all (or almost all) of the same ‘type system escape hatches’ you do in C, so the compiler can’t necessarily optimize any better, but it tends to raise the meaningless error message noise floor unless your program really does fit cleanly into how C++ wants to do things.

Senegoid

You’re right on me being past the “Dummies” stage. I took a look through it last night and, as you and Derleth pointed out, the thing is a wretched waste of money.
I expect to have some specific questions when I actually get some of this stuff running. (I’m just vacuming-out and replacing some cards in my old PC right now) I think I may need something more in the line of generic programming. By that, I mean something that teaches me how to make an efficient and reliable program along with the best practices on doing things. I have written programs before, as I mentioned, but I was well aware that I was substituting persistence for knowledge. They worked in the end but were somewhat of a kludge. I picked C/C++ as they are standard and there is a huge body of knowledge on using them.
I used to write some hex fat-finger programs but you can bet they didn’t do much. Were you doing any kind of work with the dolphins? Or just enjoying them? I used to watch them body-surfing on the bow wave of the boat and loved those things.

Regards

Testy

Derleth
Well, color me embarrassed. I had made an assumption there that C++ being a newer language, was simply a superset of standard C. Now I ansure which, if either, would be usable for my purposes. I do apologize but most of your post is well over my head. For now, I think I will set my sights a bit lower and try to regain some knowledge of C and see what I can do with it. I will probably become a pest as the days go by.

Thank you

Testy

Yikes! This guy really wrote an encyclopedia on the problems of C++ didn’t he.
This really will encourage all comers to think twice (or more) before diving in.

My own knowledge of C++ goes only slightly beyond the “Hello World” level (but still well beyond the Dummies level), yet I had already started to notice at least a few of the problems he discusses.

This sooooooo much reminds me of Kernighan’s classic paper Why Pascal is Not My Favorite Programming Language only it looks like 10 times more so. (And I just spent a few minutes skimming a few pages of it.)

He really makes some scathing points, to the effects that
(a) For any type of project that you might wish to do with C++ you could do it better and easier either with plain-old-C or, if you really need OOP, then with Java or some other OOP language.
(b) Even for a highly experienced C++ programmer, it will be easier to learn a different OOP language from scratch and use it, rather than use C++
(c) Perhaps the only real justification for using C++ is where you have to work on an already-existing project that is already done in C++

[sup]Give me a little more time and I’ll write up something about what I was doing with all those dolphins. Hint: There were only two of them, actually, and involved language research, but we didn’t have C++ in those days. In the meantime, see http://www.dolphin-institute.org/ and in particular http://www.dolphin-institute.org/our_research/index.htm[/sup]

Senegoid

Well, by all accounts it seems that I am better off and possibly more productive if I restrict myself to C instead of C++ so I think I will do that for now. Thank you for all your help and advice on this.

When you mentioned the dolphins I thought you might have been working with Dr. John C. Lily. “Wow man, look at the colors!”:smiley:

Regards

Testy

Yes, the general scuttlebutt I have been hearing about C++ for a few years now, is that C is better. That said, C was always known as a programming language that was too easy to make too many obsure bugs, for a variety of reasons (and C++ as we’ve seen didn’t solve a lot of that as it aimed to do). For the size and complexity that today’s really major apps have become, and for the really critical nature of some of them (guiding rockets to Mars, controlling medical devices, controlling industrial processes, etc.), and given the increasing speed of CPU’s so that execution efficiency is not always so critical, the need has become apparent to have programming languages and disciplines that facilitate really accurate bug-free (as possible) programming. OOP is supposedly a big step forward in this. And so is the idea of “managed execution environments” that the above-mentioned article talks about so much.

[total hijack follows]
Now that Testy seems satisfied with all our answers to his OP, we can talk about other interesting stuff, right? About the same time John Lilly was doing his well-known work with teaching dolphins to say “Fa loves Pa” in psychedelic technicolor, Louis Herman of the University of Hawaii was studying dolphin language acquisition at Kewalo Basin Marine Mammal Laboratory. [Yes, that is the lab mentioned in that Onion satire about dolphins growing opposable thumbs.] – I worked there from 1981 through 1984, mostly doing programming (mostly in Apple II Basic), but I also participated in the training, care and feeding, and research sessions with the dolphins. On weekends, we cleaned the tank and after that people went swimming with them. Pretty much everybody disappeared for the Christmas/NewYear week each year, but I lived at the lab and didn’t go anywhere. So on Christmas Day one year, I was the ONLY one there. It was pouring rain, and I was out there with nothing on but trunks and sandals, feeding the dolphins. In Hawaii, you can be out in the rain like that, even on Christmas, without getting very cold. It was merely comfortably cool. I think the lab still exists but with a different name and in a newer location now. ETA: We tended to think of Lilly’s work as [del]kind of[/del] a laughing stock.

[sup]Yes, Lilly has acknowledged that he gave LSD to his dolphins too.[/sup]

I’d recommend heavily against Eclipse. Eclipse is wonderful for Java, but every time I’ve tried to use Eclipse for C/C++ it’s been an utter nightmare and roller coaster of unfun. Even the interface for creating a new C-file or project is confusing and can take some tinkering to work. On several installs of various OSs I’ve even had issues getting the default toolchains to work, and if there’s one thing you don’t want a newbie (or hell, most experienced programmers) working with, it’s toolchains.

Using an IDE makes things better for enterprise applications, but for any small-medium sized project I think finding a good text editor with C highlighting, and then learning how to use make properly is far superior for no reason other than you don’t have to figure out whether it’s you or your IDE that’s making your code fail to compile in strange new ways.

Jragon

Against the good advice of several people in the thread, I D/Led Code Blocks and gave it a try. They were right and you are right. It is a PITA and I think I would wind up learning more about the IDE than C.
In any event, I certainly don’t need an IDE for the “Hello World” level of programs I am doing at the moment.

Thanks and regards

Testy

Senegoid
Thank you for everything. I think I’ve got what I need to be going on with now.

[continuing total hijack] So, are dolphins as personable as they are made to seem? I’ve never had anything to do with them aside from watching a few wild ones. And giving a dolphin LSD seems a very assholish thing to do. What the hell was he thinking? Or was his brain too fried by that point?[/total hijack]

Best regards and many thanks

Testy

Huh, that makes me feel a lot better about having never bothered to learn C++.

Testy, here is a whole threadfull of recommendations for programming languages you should NOT learn! http://boards.straightdope.com/sdmb/showthread.php?p=14525728

Senegoid

Yikes! Oddly enough, I have seen almost all of those languages promoted as God’s gift to programmers at one time or another, usually when they first came out. I actually messed around with Fortran at one time. Fortran IV, I think. That was using actual Hollerith cards and an incredibly dumb terminal. I felt like a lottery winner every time something actually worked.

Regards

Testy

Well, to be fair, at the time Fortran was head-and-shoulders above anything else available. I mean, it was basically Fortran, COBOL, or assembly.

Chronos

Weirdly enough, at the time I actually found it easier to do machine code on a PDP-11. I’ve never had anything at all to do with COBOL but I understand it is still used a lot for business purposes.

Regards

Testy