Why I'm switching to C in 2019

preview_player
Показать описание
I'm not trying to convince anyone that C is better than C++. Switching to C is more to gain a greater perspective on programming languages and the many features more modern languages offer.

If you've got thoughts about C, C++ or even other languages you reckon might be better than C I'd love to hear about it in the comments!

CORRECTION: Flibitijibibo has never worked at Valve.
Рекомендации по теме
Комментарии
Автор

Programming languages come and go. C stays.

tunichtgut
Автор

This time next year I predict the same video but C to assembly

duke
Автор

As someone who is literally starting learning C for the main purpose of making something on the N64 (and also the possibility of PS1), it is extremely uplifting to find out that I'm not alone in this crazy desire.

pyxelpub
Автор

I like the term C-styled C++, a new language called "C+". Best of both worlds.

glee
Автор

It might be due to the fact that I've been academically trained to C/C++, but your argument seems meh at best. You're free to do whatever you want with whatever compiler you want, but I thought I'd share my opinions built from 30 years of coding:

1. You don't OOP because it's C++, you do OOP if you need OOP. If you need to keep/change the position of a player, you make a struct, if you have to handle 300 NPCs + players, maybe a more structured representation (classes with inheritance) is a better solution to avoid code duplication and enhance maintainability at scale.

2. "I don't like the tutorials I've used" or "I don't understand the language fully" screams of "find better sources". This comes ofc from my personal experience, as in 6 months as a junior in college I've learnt everything there was to learn about C99 and C++. Having the basics I never really had to use any online source, but I refuse to believe there's no better alternative. Of course, learning the pitfalls of the languages requires slow and "unrewarding" learning, which is why a lot of the poorly written material is just "copy/paste this and have your character move and jump and such in an evening". Fast rewarding paths don't make for good learning. Speaking of modern capabilities, I always suggest the book "Effective modern C++", it's a great source of learning.

3. The reason to use std::vector instead of a C style array[] is because you can't really mess up with a vector, while a typo or a perfectly working but badly designed code can completely wreck your life. A huge amount of OOB exploitation comes from poor array management. If you want to learn how to counter poor design go even lower, rather than stop at C. Using int[] instead of std::vector<int> because it's "simpler", it's quite silly. It still has a place, mind you, but for dynamically allocated resources, not so much.

4. The reason to use std::chrono instead of an #include <time.h>, is that std::chrono is platform independent. Want to use the best resolution possible whether you're compiling for Win or Linux? Use standard libraries, instead of reinventing the wheel.

5. The dev that responded "because it's idiomatic C++" is an idiot in my book, just like people following fugly practices because it's "more pythonic". I agree with you there, wholeheartidely. "You should do it like that because we do it like that, over here"… yeah, nah.

6. Just like in point 5, the fact that several C devs consider C++ as inferior, or vice versa, is stupid elitism. Facts matter over exclusivism. Linus is not the only one there, one of a major players in the secdev industry claimed that "we don't need C++ to replace C99 for security, we need better people to write better code", while claiming that he was an enlightened C99 dev who could write good code. Funny part is, that he has quite the number of exploitable code he personally written and committed, even post-talk. C is an inherently limited and more vulnerable language. But that doesn't matter if you don't have a C++ toolstack for the platform you're targeting, like NDS or PSX or whatever, so there's that.

7. There is *nothing wrong with C style C++*. Anyone who tells you otherwise is, well, wrong. In fact, the majority of code I wrote over the years could be considered C style C++. But with C++ you have the possibility to use everything you had in C99, better scoping, a better and stricter compiler, plus all the modern features you may use if you feel like it, such as std::string, just to name one.

8. Jumping to C99 when C++ modules are finally in sight feels wrong to my soul. I can't wait to drop the header+import+implementation and jump straight into modules (although I already head-started with in dev builds).

9. You can still code in assembly in both :P

I realise this is almost a year old video, and that the CTA hook at the end is just that, a hook, but since the YT algo brought me here I thought I'd share my view regardless, some younger kids/devs might find it interesting. Or not. You do you.

Varstahl
Автор

*"Linus Torvalds liked that."*

marxfan
Автор

From a non-coder who wants to learn, c seems far more understandable and readable than c++ to me.

sablesanctum
Автор

I like C more than C++ but only because of these reasons:
1. Even though you can develop a program faster in C++ using its abstractions, C++'s cost is that it's easier to make unmaintainable code AND debugging is alot more difficult than in C. C's lack of abstractions means that there's no hidden code or execution etc so it's easier to maintain and alot easier to debug.
2. C is a very simple and minimal language. It's alot easier to master than C++. I could argue that being a C expert would take at least 5 years minimum but C++ would take significantly longer.
3. If I wanted to make an API that can be used by other languages, you have to use C or you need to make a C interface for your C++ code. You could either make your C++ API and then make the C interface, or just implement the library in C.
4. C will force you to learn about the overall system and how computers work, which will overall make you a more powerful programmer.

GKNrd
Автор

I programmed in C from 1982 until 1989 when I changed over to C++. Object-oriented is the programming holy grail, but even if you never use classes, C++ is the way to go. If you examine my code you would say it is C more than C++. There is nothing in C++ that requires you do everything the object-oriented way. If you want to write in C then you still should use C++ for two features - default arguments and the ability to declare variables where you first use them rather than at the top of scope. It makes life so much easier and safer to tie declaration to initialization. It makes it simple to rearrange code and prevents access of a variable before it is resolved. Sometimes you decide to add an argument to a call, with C++ default arguments all you have to do is recompile. With C you have to find and correct every existing occurrence. So feel free to write in C, just compile with C++.

drwisdom
Автор

When the inventor of a language (Stroustrup, C++) says he doesn't expect most programmers to know ALL the language, I'm inclined to think that the language is just 'dangerous' because it becomes increasingly difficult to understand all the code you may come across and the consequences (side effects) of all the code you write yourself. Knowing all of C is much easier.

robswan
Автор

The argument in favor or against most languages is usually pointless. I program in C and C++ and I do not hate nor love any one in particular. If you ask me what to use for a microcontroller I would chose C if you ask me to write a complex application that makes extensive use of abstract data types were elements in lists or arrays can take on different types and such, then C++ and the STL are the way to go. There is no perfect technology out there a wise developer should chose the best fit for each application.

reiniertl
Автор

I made the transition from C to C++ in a team environment more than 20 years ago. What I discovered was that if C++ was to be marginally more of a benefit than a ball and chain, the people using it had to operate within almost impossibly tight programming standards. In my opinion 'OO' stands for Opportunity to Obfuscate.

daveayerstdavies
Автор

C styled C++ is the only legitimate one.

The ++ operator comes after the language identifier, so you don't update your style till after you have finished writing.

That's just elementary syntax

trueriver
Автор

As for me, I've studied a bachelor's degree in videogame design and development specialized in programming and finished like 3 years ago. One could say I've been using Object Oriented programming languages for almost 5 years, and it hasn't been until now that I realized how much unnecessary abstractions and superfluous ideas have been forced into my head.
Recently I've switched to pure C (trying to apply Data Oriented Programming principles) making me realize how much easier it is when you think in terms of what your computer needs to do. At the end of the day, code is read by humans but bytecode is executed by a machine, never forget that guys!
P.S: thanks to Mike Acton CppCon 2014 talk.

ilgibadominanto
Автор

Regardless of which language you use, you’re always going to get a million know-it-alls that tell you don’t do that! You should <insert random overly complex solution to simple problem here>!
And they never tell you why they think that would be the better way to do it. They just want to show you what “programming gods” they think they are when they actually just started to study programming last month. Or they are just parroting something they were told by somebody else without understanding it. Either way, they’re just trolls not worth your attention, that are most likely trying to compensate for their own insecurities.

jscorpio
Автор

I have been coding for 36 years. C is by far my favorite. I have used C, C++, Asm for various systems, Basic, Pascal, AMOS, more scripts languages than I can remember, and so on. I think there are more than 50 languages if I count them all. No language hits that sweet spot quite like C does. A really good choice switching to it.

MikaelIsaksson
Автор

So there are a ton of misconceptions in this video and in the comment section, as an avid c++ programmer I'd like to access them:
1 - OO programing is bad - this is partially true, the OO approach does incentivize new programmers to write bad enterprise code, but just because you can eat tide pods, doesn't mean you should! Use the language features when you should, not when you can, this decisions are your job as a software engineer/ computer scientist.
2 - C++ "idioms" are nothing but syntax sugar and aren't better than the equivalent c code - this is false, when using this abstractions, not only are you using code that has been written and re-written by a lot of really dedicated coders, but also, it helps the compiler when optimizing your code. (The std string library, for example, isn't just a wrapper around char*, it does a lot of small string optimizations that would take a lot of function calls in c, but are implicit in c++)
3 - There is no hidden code execution in C - partially true, C++'s abstractions may have hidden run-time costs if used incorrectly, and these aren't well documented, but in C there is also hidden code being executed that most people don't know about. Did you know that malloc isn't a kernel call?
4 - C is minimal and easier to master - true, C++ is really complex (some would say bloated but I don't think so), and because of this it isn't uncommon to look at standard C++ and not understand what the code is doing. But I'd also say that if you aren't able/ willing to learn new tech, then this really isn't a profession for you. :(
5 - You need C to make an API to talk to other languages - Partially true, C++'s OO approach makes it easier to interface with high level languages, and if you really want/ need the c bindings, is as easy as putting your functions inside an "extern C" block.
6 - C will force you to learn how computers work making you a better programmer - false, If you really want to learn about "how computers work" program in assembly, there's a reason we don't do that... Multi-threads are a nightmare in C, making it easier in C++ doesn't make you a worst programmer, just makes you a more efficient one, high level abstractions aren't an excuse to not learn about your hardware.
7 - C works on all OS - true, but so does C++, fun fact: C++ used to be transpiled to C, a language can work in all OS as long as there is a compiler for them, and there is one for C++ on most OS.
8 - Debugging in C is better as there is no hidden code - false, in C++ (and in C as well) you should be sure that the "hidden code" (either from a library or the std) doesn't have any errors so there is no need to debug it (you wouldn't debug malloc for example). If the code you are referring to was written by you, then it isn't hidden and you can very easily jump into it.


As a side note I'd like to say that just because people miss use inheritance that doesn't mean that it's inherently bad (pun intended), most of the time, you shouldn't be using it, but when you should it is really useful and makes your code base easier to maintain. Also, if you have setters and getters who only set and get a variable (without any additional steps like setting a flag for example) those variables can and should be made public. Another example of bad enterprise coders, and miss informed YouTube tutorials being confused with a language flaw...

andrebotelho
Автор

The thing is that when you write c code you know that you are programming a computer. You know what the computer will internally do with your code. This sensation is totally lost with java or modern c++ or python or whatever. That's why I like c

tremon
Автор

I'm a simple man, I like simple languages. Seriously, though. I might be a programmer, but I'm not very smart. The complexity of C++ had my head spinning.
Plus, coming from Java, I love OOP, but I also like to understand the implications of my code. C++ hides too much. With C, I understand what my code does.

qaulwart
Автор

I've been programming in C for nearly 30 years, and during that time I've made several forays into different languages including C++. I abhor C++. Sure, it has some conveniences, but I've found that I prefer the bare-bones simplicity of C. I feel like I'm in complete control of my code. While there's generally a hiccup mostly due to the occasional misplaced pointer or memory leak, but, if you're as meticulous a coder as I, these problems are usually very easy to track down. So, @ C++.

yapdog