I have just seen post where the person asking for help put up a block of code.
This block of code was a true eye sore, mixing C, C++, and C++/CLI all together. I'm just wondering if this is being taught in education establishments or if it is the people themselves trying to bounce around the net picking bits up from here, there, and everywhere and mashing it together in an unholy mess.
Should we raise concerns about this haphazard blending of languages when we see it or let the OPs get on with it? Are any others here concerned when they see such code, or is it just me?
To answer your question: Yes, it bothers me, and I think this is simply a result of self-learning. But what can we do about it? You won’t teach anybody good design, broad programming knowledge, and consistency in a few minutes. It takes years.
What I’m trying to say is that there is a limited set of things you can hope to explain in one post.
It’s better to concentrate on serious errors first, leaving not-so-great design (like buffer overflow possibilities, lack of error handling, etc.), and inconsistency for indefinite future.
Often on the Internet C code is said to be C++ and, for someone who doesn't know, C++/CLI may look the same as C++.
That mix is ( IMO ) a result of someone who doesn't know C++ at all but is trying for some reason to create a program by copy-pasting whatever finds on the net.
I always point it out to posters who seem to be doing things in a C style, the most common example being people using char arrays where they could use strings.
I think the problem goes beyond poor internet tutorials though, people who used to program a lot in C who then had to adapt to C++ and didn't like it, often seem to slip back into C whenever they can, and they go on to teach other people to program this way. There's even a lecturer in my university whose code examples always smell suspiciously like C.
C is the only language I really know, regardless of what language I'm using I'm almost always just writing C with different syntax. How do you solve this problem?
quirkyusername wrote:
people who used to program a lot in C who then had to adapt to C++ and didn't like it, often seem to slip back into C whenever they can
This is sort of me, but I started in C++, fell into programming in C because I couldn't be bothered with OOP (and still can't) and now I just use C all the time. I love C. All glory to the hypno-C...
C is the only language I really know, regardless of what language I'm using I'm almost always just writing C with different syntax. How do you solve this problem?
I like to see the opportunity to learn a new language as an opportunity to learn new ways to express myself. So when I'm learning a language I try to look at good code written by others to have an idea of how things are done. Also, when I feel I'm trying to do something in a clumsy way, I look for an idiomatic solution. If I find and like it, it's just naturally added to my repertoire. It works very well for me.
This is sort of me, but I started in C++, fell into programming in C because I couldn't be bothered with OOP (and still can't) and now I just use C all the time. I love C. All glory to the hypno-C...
I also started with C++ and fell into C, but more out of curiosity. Now I just love C and would prefer to use it over C++ whenever possible. It really is a lovely, beautiful language.
I'm just wondering if this is being taught in education establishments
Sure it could happen, I know one teacher who knows old turbo C but the schools requires him to learn C# and other languages like C++/CLI. The result is he still uses his old style of programming in teaching these modern languages :p
I also started with C++ and fell into C, but more out of curiosity. Now I just love C and would prefer to use it over C++ whenever possible. It really is a lovely, beautiful language.
Well, I'm not really sure why I started writing pure C. It was partly because of OOP but I doubt that was the only reason. And yes, it is an excellent language.
So is calling into question the learning/teaching methods the right/correct thing to do (after answering his question)? Or to put it another way; Is effectively saying, "where the f**K did you learn to code like that?", a bad thing?
Is effectively saying, "where the f**K did you learn to code like that?", a bad thing?
No. If someone has learned bad code practices they should put the effort in to correct them. I know I would if someone told me something I was doing was bad (and they weren't a complete idiot).
I find that a lot of tutorials and it seems C++ classes don't focus enough on good coding practices. They focus a lot on what C++ can do, but not necessarily when each of its features should be used. That's my view of the situation.
I think a lot of it might have to do with outdated resources. I started learning out of a book that taught #include<iostream.h> and other deprecated headers.