- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"Err, wait, do you meant C-sharp? Because I've worked quote a bit with the .NET Frame—"
Admin
C++ does not allow you to assign without a cast.
so you get:
While in C it is acceptable (in fact, correct) to assign a void* to another pointer without cast.
Admin
Um, C is procedural, C++ is OO .. or that appears to be the intention from the design of them.
Javascript and Java are pretty different too .. did I miss your joke???
Admin
right, and if you actually read that AT&T Research PDF you link to...
I quote:
B.2 C/C++ Compatibility With minor exceptions, C++ is a superset of C (meaning C89, defined by ISO/IEC 9899:1990). Most differences stem from C++’s greater emphasis on type checking. Well-written C programs tend to be C++ programs as well. A compiler can diagnose every difference between C++ and C.
Admin
you know, OKCupid runs and develops its webserver entirely in C. It's incredibly efficient and stable and great. Oh and wait what language is Apache again?
Admin
I ceased to call these WTF long ago. Rather, I'd call them "the sad reality".
Admin
Admin
I was wondering if someone was going to bring up that example ^_^
More websites are written in c cgi then people probably think. It isn't generally recommended since the skill set is uncommon but you can do some pretty powerful (and fast) stuff when you don't have to worry about all the extra layers and simplifications that web-centric languages have.
Admin
Then you greatly underestimate how C++ really differs from C. C++ is monstrously complicated compared to C and getting it right takes much, much longer than "a few hours" even coming from a C background. I know this because I learned C++ from a C background myself.
Prior experience with OOP reduces the learning curve, obviously, but some things such as exception safety can be pretty difficult to grasp. I remember I picked up the book Exceptional C++ some years ago thinking I already knew everything and came away with the realization that I knew nothing.
Admin
Admin
You should try glueing them on, or one of those pitbull-clamps.
Admin
+1.
I've done exactly the same thing. Long C background but have been learning and using C++ over the last year and a half or so.
The Scott Meyers books on C++ really opened my eyes to how hugely complicated C++ is and how thoroughly little I knew about it, despite writing C for many years and studying C++ seriously.
I think a C programmer would be able to mostly follow along with C++ code (given a small primer on the STL and maybe template syntax), but in no way would that C programmer be able to write good, safe code that works properly without a fair amount of actual C++ programming experience.
Take for instance virtual destructors. If you have a derived class where either the parent or the child class either does not declare any destructor or does NOT declare its destructor virtual, the child's destructor is never called when the object is destroyed. You receive no warnings about this behaviour.
This tiny, absolutely puny little detail will leave your program riddled with serious, impossible to find bugs and resource leaks. You need to know specifically of this behvaiour before you can fix it.
This is merely one example of probably thousands of such tiny little details of complexity that a C programmer would simply have no clue about - details which will render your programs utterly useless if you don't know about them. And even if you know about them, there are so many things to remember that you WILL forget some of them from time to time. Even experts can write C++ code that is just wrong.
A C++ programmer should be able to write decent C. On the othe rhand, I would not expect a C programmer to write even half-decent C++.
Admin
Ridiculous. That`s why HR exists. I think the CIA guy was testing the candidate on his ability to deal with adversity in a partially-understood context. The candidate failed. The arrows obviously never mattered.
Admin
I've got it. The CIA guy was actually doing a drop for a spy, and the suggestions about the arrows were a code phrase used to identify the correct person to receive the microfilm.
Had the OP been savvy enough to detect this obvious spy behaviour, he might have landed his hands on something awesome, which he could be sharing with us now instead.
I submit that the arrows matter tremendously.
Admin
Admin
Or I could just walk everywhere and dream about how wonderful it would be if there just was a way to get there faster, more comfortable and less exhausting.
So you like C and I like C++.
Admin
Next time, add the last time line in the 'additional information' section down the bottom of your resume and hit in: "On my free time I sit on my father's right side passing down judgements on the living and the dead."
Works like a miracle.
Admin
Im my job I have to write documentation as well as software. I wouldn't hire someone with a poorly formatted CV, it you can't be bothered to make something that important look nice, will you be bothered to format a document properly?
I'm not talking about 'I don't like that style', but things that make it harder to read and harder to skim for the details.
Same goes for poor grammer and spelling. I've probably made a mistake or two in this post, but it's not something that I'm trying to use to get a job!
Admin
The real WTF is Alex's grammar:
"a certain founded-and-headquartered-in-the-Netherlands electronics company was hiring ". OK, if you are going to use this disturbingly convoluted adjectival construction, it is correct to hyphenate it, but this is supposed to be English, not German or Jedi. I'm a confused-by-your-use-of-verbal-clauses person...
Admin
Also, the errata section of the K&R2 now tells not to put an explicit cast between a pointer and a call to malloc(), which means that an officially recommended ANSI C convention won't compile in C++.
About the 3 : Yes, patenting in the states has become a WTF.
Admin
Seriously that has to be one of the lamest, won't compile in C++ examples I've ever seen. Simply replace the #ifdef with #ifdef __cplusplus #define class _class #define template _template #define new _new #endif
And OMG, minus the malloc issue it will compile. And the malloc casting thing is mainly a non issue. Regardless, the argument is whether C++ is a proper superset of ANSI C. Which we all know it isn't, but the porpoises are pretty sure that 99% of the time it is.
C99 does actually have features not in C++.
Admin
It's possible to deliberately write a program so as to be simultaneously valid C and C++. Doing this directly leads to a program which is bad style in C and very bad style in C++; however, it's possible to make it good C style (but not good C++ style) by using macros or similar to wrap around the differences. Unfortunately, that makes it harder to read. So choosing one and sticking to it is usually better.
Admin
There's a reason it says that, which is that when K&R2 was written, the authors didn't have a C89 compiler (due to the standard only just having come out), so they had to use a C++ compiler instead. Many programmers consider unnecessary casts to be bad style because they hide compiler warnings (forgetting to include <stdlib.h> is a somewhat common mistake, and will often result in code that works on a 32-bit system but not on a 64-bit system), and take up space for no reason.
Admin
Besides, char* is generally quite a bit larger than char; 4's a common value for the sizeof char*, although I've seen both 2 and 8 before, and there may be weirder values out there.
Admin
LOL
Admin
(BTW, for someone in the Intelligence business, she doesn't appear to be acting very intelligently...)
-- IByte (looking for a non-WTF job)
Admin
Admin
[quote user="Leak"] Ewww... if anything, that should be "puppies with ketchup". Just try eating one without ketchup...
Barbarian -- everyone knows it's mustard on puppies and barbecue sauce on kittens.
Admin
In a certain POSIX real-time processng book I have one comment that sticks in my mind is that becuase of virtual function pointers inherent in C++, it isn't a true realtime language. Using C allows a predictable control flow that can be evaluated.
Just thought I'd add to the already growing C differences.
Admin
Admin
There is nothing inherent about virtual function pointers in C++. As with other language features, you only get them if you ask for them. It's a bit like using gets.
Admin
Weak troll attempt, FTFY.
If you take Software Engineering, that is Engineering and is typically awarded by either a Bachelor or Master of Engineering degree. Typically Computer Science courses award a BSc. (In the UK at least)
Admin
C++ and C today are quite distinct languages. You might be able to include C headers into a C++ program, but that's about it.
It starts the way how pointer typing works in those language.
In C you write:
In C++ you do:
Note the typecasting in C++, which without it you will get a error if compiled with a C++ compiler. OTOH doing that typecast is utterly wrong in C, since typecasting may allow for type reinterpretation, however the C standard states, that the value of a type void* must be able to be assigned to any kind of pointer without changing the value (casting may change it!). Most compilers will do it right, if explicitly typecasting things and not complain, but the standard would allow it. For the sake of compatibility most libraries written in C (like GLib, GTK) do explicit typecasting of void* but it may break if a compiler insists on exploiting this subtelty of the C language.
Admin
As you can see, it's trickier than you thought!
Admin
I think we've done that one already. So to add more fuel, if you don't want to typecast in C but need it to work in C++, do this:
#ifdef __cplusplus #define mallocPlus(x,y) (y)malloc(x) #else #define mallocPlus(x,y) malloc(x) #endif
Then call char str = mallocPlus(len, char);
It is called mallocPlus for two reasons. One because it will annoy people who would write it malloc_plus and two because it is half way between C & C++.
Now you have code that will compile in C & C++ and also won't cast in C.
Admin
Admin
Stop bitching about C++ people! He did it for us all.
Admin
A closer analogy would be an automatic vs stick shift.
Or perhaps 'car you can work on yourself' vs 'car that can only be worked on by a shop'. Car analogies only go so far.
Incorrect.
I like both. I use C in places where C shines, and C++ in places where C++ shines. There are times where C's simplicity and control are simply more useful then C++'s sugar, complexity, redundancy, side effects, and obfuscation turn from helpful to hurtful.
Admin
Admin
Actually this is a common problem with C++ and real time applications. While it is true that C++ only inserts implicit functions (like the constructors, destructors, overloaded operators, etc) if you ask for them, the ease at which is slips them in and the lack of clear syntax makes figuring out exactly what will execute quite difficult. C++ obfusicates these details because normally the programmer doesn't need to know, but if the programmer DOES need to know what execution side effects a line has in it, it can be quite difficult to figure out. C++ is just too unpredictable when you need predictability.
There have been many times that I've had to actually use a disassembler on a C++ object file to figure out what gets run between point A and point B.
Admin
I still get too many with the relevant skills so I adopt the easiest means of eliminating a chunk. It's pretty common practise.
Admin
Indeed, but spelling "grammar" as "grammer" always strikes me as particularly ironic.
Admin
The biggest problem I have is getting swamped with hack resumes with little or no relevance. These are guys that just e-mail their crappy resumes without regard for applicability.
What I do, and I find it works very well, is to put in the posting specific instructions, e.g.
In your cover letter, please address the first and second requirements [or some other specific task] ... You may also fax your resume, attention [my name].
From that it's fairly easy to check these points:
Dear [generic] cover letter missing didn't address specific requirements
Any of the above implies lack of attention to detail and the applicant is filtered out. Last time maybe one percent of the resumes got through this "intensive" filtering process.
When I apply for a position, I tailor the cover letter and resume, do some research on the company, just basically visualize myself working there.
In the old snail mail days, applicants would stoop to adding rice or whatever to envelopes to make them rattle!
Admin
I three seconds I could do at least one of the following :
-Skim the resume for a computer language of choice. -Skim the resume for the highest degree the person claims. -Skim the resume and make sure that "Microsoft Word" is not mentioned in the same bullet point as the applicant's primary programming qualifications. -Eliminate all resumes decorated with obnoxious clip-art.
Granted, any one of these has a small possibility of eliminating a good candidate with a poorly formatted resume. (Or even a good candidate with unusual but acceptable qualifications.) But if I had hundreds of resume's to get through, I think this would be a reasonable first pass at dealing with them.
Admin
The process of selecting whom to hire via interview is much like capitalism and standardized testing: it's the worst possible system to achieve the goal... except for all of the other systems.
I mean, I don't actually know of any systems to filter through prospective hires besides the interview, but I'm just saying it's not that great.
There is something you, the potential hire-ee can do about it though. You have to apply all over the place to as many companies as you can think of.
Putting puppies in envelopes probably isn't a good idea. However, with really crazy interviewers, who can ever say for sure?
-- Furry cows moo and decompress.
Admin
I've actually worked at the Patent Office examining compiler patents. I'm interested when Dan M. applied, but I can assure him, he dodged a bullet there.
Admin
But, IMHO show me a website running on straight C and I'll show you a buffer-overflow-leads-to-root-access bug just begging to happen.
-- Furry cows moo and decompress.
Admin
The only time I can see it making sense is if you're working on a project that has started in C that just keeps growing and growing. You know that, at some point in the future, it's probably going to grow so much that Object Oriented really is the way to go. So you start pushing for re-writes to get things as C++ compatible as you can in preparation for The Big Switch.
The MAME project is kind of like that right now. I mean I don't think they have any plans to ever switch to C++, but as it's moved on and on they've been re-writing things more and more in a more object-ish oriented-ish paradigm.
If you find yourself in a project that is written in C and you know you need to re-write it object oriented because of the project's behemoth-like size and complexity, C++ is the logical choice.
-- Furry cows moo and decompress.
Admin
But, in all fairness, it's not a strawman argument. A strawman argument is when you throw up a silly/weak example to try to make your broad grand point, and in so doing, distort things badly. This isn't a strawman because the assertion under dispute was very logical and mathy. Suppose I made the assertion: "ALL animals have symmetrical body structure." Well my assertion would be incorrect because the sponge is considered to be an animal and it does not have symmetric body structure.
The strawman problem comes into play in more real-world debate scenarios with many shades of grey, subtleties, and complexities and then someone frames the argument in such a way as to make it appear that a very weak example is representative of the whole thing, and then proceeds to destroy the weak example.
An example of strawman would be if I were to talk about the bogusness of the point of view of a specific nutball religious extremest, and then went on to generalize from that, that all religious persons are nuts. That's strawman.
The specific claim that he was trying to refute was that "C++ is a proper superset of C". "proper superset" is a precise mathematical term and it has a precise mathematical meaning. When we apply that term to the previous assertion, we see that it should mean, in part, that every C program will compile under C++. This is not the case. The fact that the bug in question might be trivial and easy to fix is not itself trivial. If there is even one (trivial) C program that cannot compile under C++ without first being modified then there exists a computer program within the set of valid C programs that is not an element within the set of valid C++ programs.
Therefore, C++ is not a proper superset of C.
Maybe we should make up a new term like... fuzzy superset. :-) We could then call C++ a fuzzy superset of C. Yeah. That sounds good.
Admin
You really think we give a damn, huh?