C vs C++

I'm obsessed with the idea of finding out the best general propose language for me, to use as a hobby, and eventually professionally.
I cannot decide between C++ and C.
I come from 6 years in which I've been working in C++ both at my job, and as a hobby.
I recently came across some wonderfully written C code, and now I'm questioning if I should change my "favorite language" and try to excel in the C techniques that actually make the difference.

It just looks more minimal, straight forward, easier to debug, portable, compatible, probably even better performance-wise (don't quote me on this one, though).
I also realized that with function pointers I can even do object oriented and polymorphic stuff, and there are procedures to "sanitize" void pointers, in order to make them kinda memory safe.

In this moment I fail to see any good reason to actually use C++14/17 over C11.

Do some of you prefer C++ over C?
What are your reasons?

Please restrain from using arguments that sounds like: "I'm super smart and if other people can't maintain my code it's because they are stupid"

Other urls found in this thread:

trends.builtwith.com/javascript/jQuery
edition.cnn.com/2016/05/26/us/pentagon-floppy-disks-nuclear/
theguardian.com/technology/2016/may/26/us-nuclear-arsenal-controlled-by-1970s-computers-8in-floppy-disks
youtube.com/watch?v=KlPC3O1DVcg
twitter.com/AnonBabble

Ada or you're a pleb.

All of them. It doesn't really matter where you start. Learn all of them. No I don't mean go from language to language reading documentation I mean learn to program in every fashion currently presented and then master whatever language you need at any given moment.

Rust is the only solution.

As in "If you don't use Ada, you are actually a pleb"?
Or as in "you, saying C is better then C++, which is more feature-rich and modern, sound as dumb, edgy and memey as a guy who would suggest Ada, sentencing you to be a pleb if you choose otherwise"?

Rust looks pretty damn solid and cool to me. On the other hand, the Mozilla foundation has really turned into an SJW headquarter.
Now: while I don't care if Rust is associated with fat feminists, I also enjoy the idea of a language that is maintained by a competent team, on the long run.

I've worked for a few start ups in software development before getting a more stable position as a systems admin for a company that offers server hosting for various gaming platforms, as well as a larger separate corporate division.

>general purpose hobby language
Java or Python/Lua. Both very easy to learn and very easy to work cross-platform. Java has tons of libraries.

>professional language
When it comes to getting an entry level job, nobody cares what language you know. Programming is constantly innovating and revolutionizing. This fancy Java library may be what's hot right now, but 7 months from now you may need to learn C# because a new popular device came out that uses C# to make third party apps for. As long as you understand Linux CLI and have a portfolio of real experience showing the ability that you can learn multiple languages, you should be able to get hired. it doesn't matter what those languages are.

>Do some of you prefer C++ over C?
C++, simply because most C libraries work in C++ as well but not the other way around.

Also: What stops you from trying "to excel in the C techniques that actually make the difference" in C++?

Also: I'm super smart and if other people can't maintain my code it's because they're stupid.

Also: Check more meme languages, like Loci or Zig

>and there are procedures to "sanitize" void pointers, in order to make them kinda memory safe.
That sounds like some extremely shuddy hack, similar to some macro based test framework and RAII thing I came across at some time.

Another user here: i started learning c++ for fun, mainly because i can make cross platform applications with qt. Is there such a thing for c? I know there's gtk, but it doesn't look very outside of gnome

*Doesn't look very good

>Also: What stops you from trying "to excel in the C techniques that actually make the difference" in C++?

A well written C code, using the edgiest, most secret techniques, it's still really easy to pick up, to understand, and to maintain.

A well written C++ code is impossible to read and to maintain.
I've been working in C++ the last 6 years, and when I recently come across some source code from the boost library (which is praised as the best C++ code ever written) it looked like a whole new language.
I could not understand anything without consulting a stack overflow article for every line. And even when I started to understand the whole structure, I realized that at the end of the day everything it's just extremely convoluted.

Theres libgui...
Unfortunately it uses Gtk on Linux.

>I cannot decide between C++ and C.

Java is the best general purpose language. C# is a better language, but Java is actively used across a wider variety of platforms and devices.

C++ is the worst language to learn. C teaches you about fundamentals, almost as well as assembly would. C++ is a waste of time.

Seriously, the only reason you see C++ pushed so hard on Sup Forums is because it's full of students and NEETs who think anything vaguely difficult makes them 1337. If you want challenging, learn Lisp or Haskell. Don't dick around with C++.

>A well written C code, using the edgiest, most secret techniques, it's still really easy to pick up, to understand, and to maintain.

But as long as it compiles with a c++ compiler like MSCC, it's still c++, even if it looks like c.

It's not like there is actually idiomatic code, that's cancer for cancerfags and cancer langs that need cancer workarounds to actually make sense.

Consider C#.

>What are your reasons?
1. STL containers
2. Smart pointers and RAII in general
3. Stronger typing than C
4. Built in regex
5. Templates and constexprs
6. Lambdas, closures, functors, std::function and other syntactic sugar allowing me to program functionally

Maybe try something like Nim or D?
Or Rust tho Sup Forums seems to hates its guts(well it's community).

>Maybe try [clusterfuck to C compiler with semantical leaks] or [language that killed its chance multiple times]
> Sup Forums seems to hates its guts
That means it's a good one, morty.

>program functionally
Kill yourself, faggot.

Butthurt imperative pleb detected

Pleb with a job. You can stay a jobless patrician, cumguzzling faggot. I don't give a fuck.

Not the same user.
Are you stating that there are more jobs for imperative languages?

Do you program for embedded systems?
Is it really a big job market slice, or just a niche?

user, I do have a job. As a C++ developer. If you don't know multiple programming paradigms, how can you call yourself a programmer?

All modern languages are multiparadigm languages, so why limit yourself to only using one, outdated, paradigm?

pick one you cuck

-t. saged

>I'm obsessed with the idea of finding out the best general propose language for me
I would start with English.

check out glib, which is used by gtk and plenty of other C libs. it literally recreates C++'s object and inheritance system in C, and it's ugly as fuck. for instance, a line of C++ code that looks like this:
file.zoom-level = 5;
ends up looking like this in C, because C has no such things as "objects":
g_object_set_property(G_OBJECT(file), "zoom-level", 5);

>Are you stating that there are more jobs for imperative languages?
Is this bait? I can't tell.

Considering that there are objectively more jobs in Java, C#, Python, JavaScript, PHP etc, all languages that draw heavily from multiple paradigms, as opposed to languages such as Smalltalk, Objective-C, C, etc aka """pure""" imperative languages.

Does it sound weird, or did I make some actual grammar errors?
I honestly can't tell.

i'm not the guy you were replying to but I suspect it was your misspelling of "purpose"

>all languages that draw heavily from multiple paradigms
Nobody uses functional shit in any serious project, it's your own business if you want to fuck with lambdas or closures, might as well write in Haskell.

>Nobody uses functional shit in any serious projec
But they do, you fucking moron. Even fucking jQuery uses map and reduce.

> it's your own business if you want to fuck with lambdas or closures, might as well write in Haskell.
There's a huge difference between using functional programming where it makes sense, and using imperative constructs other places, than to use only one single paradigm and refuse even to use basic I/O because it has side effects.

>Nobody uses functional shit in any serious project
Sure, nobody uses Boost, React, .NET, or any other modern framework.

>jquery
>serious

>Do some of you prefer C++ over C?
>What are your reasons?
RAII is the only reason I need. You cannot do it in C therefore C is way more vulnerable to accidental leaks. And these: Also C++ is as portable and compatible as C, where did you get that from? C++ has many features like threads that are portable while C have them only platform depended.
>easier to debug
Explain.

When you use C++ you can use all the "minimal, straightforward" features of C just fine, but when you use C you cannot use C++ features.
And C doesn't have any OOP which makes it way less suitable for large, high-level projecte(I mean software etc. not kernels/drivers).

Anyway: Rust > C++11 > C++ > C

>On the other hand, the Mozilla foundation has really turned into an SJW headquarter.
>caring for company who founded a tool that anybody can use
>Rust is associated with fat feminists
Who associate Rust with fat feminists outside of Sup Forums? I doubt any fat feminists could ever learn Rust to begin with.

Maybe you just don't know C++ as much as you thought?

It's widely used you sperg.

trends.builtwith.com/javascript/jQuery

Rust is a useless meme language.

D > *

It was widely used in mind 2010s, not now. Get with the program, gramps.

This is a useless meme reply.
At least provide some arguments and propose better alternative.

C is more than enough. C++ so much bloated that the entire language is like a gigantic pitfalls of segfault error.

C is pure and simple. No bullshit, only the truth. You want the real truth ? C will tell ya.

It's much easier to cause segfault errors in C than modern C++. RAII and smart pointer were created for a reason.

Don't call it C. Call it MISTER C.

Linux kernel is in C

Windows is in C++

That's the only argument that is needed to choose between C or C++. You have to choose your camp. Once you do, you choose the language the camp has chosen.

React or angular or whatever the webby wobby neo-hipsters use are also relying heavily on functional concepts.

>And C doesn't have any OOP which makes it way less suitable for large, high-level project
OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.

>Maybe you just don't know C++ as much as you thought?
Nobody can "know" the giant mishmash of random features that is C++.

The Windows NT kernel is in C though.
Nobody is actually retarded enough to write a kernel in C++.

What a retarded argument. Its already known Microsoft developers are incompetent so that doesn't really count.

>That's the only argument that is needed to choose between C or C++. You have to choose your camp. Once you do, you choose the language the camp has chosen.
No you don't.

I used to work as a C++ developer, now I work as a C developer. You can know both. The error is to try to program C++ as if it is C and vice versa, they are really two vastly different languages.

As in Ada is the superior language. Only being able to carry on one instruction at a time is so stuck in the 70s. If you have a processor with twelve cores, why don't you drop your cuck languages and use one that allows you to carry on twelve flows of instructions simultaneously?

>inb4 muh java has multiple subprocessing

HAHAHAHAHAHAHA not an argument. Reminder that the software that launches the nukes is written on Ada.

>Reminder that the software that launches the nukes is written on Ada.
Pretty sure that it outdates Ada.

edition.cnn.com/2016/05/26/us/pentagon-floppy-disks-nuclear/

theguardian.com/technology/2016/may/26/us-nuclear-arsenal-controlled-by-1970s-computers-8in-floppy-disks

1. Anything newer than Java is a useless meme language.
2. Rust is newer than Java.
Conclusion: Rust is a useless meme language.

Oh I get it, the language they're programmed in is... floppy disks? You must be seriously stupid if you don't understand the difference between hardware and software.

They're probably programmed in Pascal or ALGOL or something like that. Actually, it wouldn't surprise me if it was written in assembly.

Ada didn't become usable until Ada 95, long after said software was written.

JavaScript. Non-ironically.

I've worked in C, C++, C#, Java, PHP, Python, and JavaScript. I prefer JS even though I'm stuck with my current work in C++.

Windows kernel is in C as well...

Great argument. I'll give you a (You) for an attempt.

>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
But it works better. Of course you can make retarded, over-engineered OOP that will be hard to understand. But good design makes your code way more clear and modular, easy to extend and modify even for someone who is unfamiliar with whole project. Also without OOP you can't have templates, RAII, inherence which makes your code way larger, more complex and much less reusable.
I can't even imagine how would I solve most of the problems I actually do at job. Without OOP, I would have to force other devs who want to add eg. new powerup type to our game, to search and change switches and other code in at least 5 various places. It's super vulnerable for bugs and mistakes. Unless we would use some tricks to mimic vtables and inherence, but then they would probably not understand it and will surely not be able to debug it. Right now adding new powerup is literally just declaring new enum value with few parameters and/or lambdas, all in one place.

>Nobody can "know" the giant mishmash of random features that is C++.
Yes, but you just need to know the ones that are not deprecated or plain pointless. Unfortunately there is no clear way to check that, so many people focus on them instead of learning what really is useful.

>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
Unfortunately it is required for UI widgets. Every C GUI Widget library reimplements OOP poorly.

>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
C on the other hand provides no structure and any sided program made by a group results in long spaghetti trails of hacked in logic.

You clearly have no idea what procedural programming is.

As someone who's native language is C, I say that C++ is the best language for a program where the requirements are so far unknown. C++ makes polymorphism easier to add and adds some other useful features, while maintaining most of the useful C features (and the ones it doesn't maintain are compiler extensions in the good compilers anyway), and only adds a couple minor inconveniences. The STL is also a nice feature. Polymorphism in C isn't a huge issue to implement, but It's the kind of thing I'd never want to deal with in a team. Overall, C++ just lends itself the best to an arbitrary task.

Thats partially because boost sells itself as the se++cond coming. And they take the time to turn readable code into the fastest code the current standard allows.

Can you elaborate?

It could be a great language but it seems kinda all over the place currently.

The D language would be great if anyone actually used it. No one in the industry uses it so it's terrible.

>I'm obsessed with the idea of finding out the best general propose language for me, to use as a hobby, and eventually professionally.

It always - ALWAYS - depends on what you want to do. There is no "Silver bullet" langauge.

Generally C and Java are kinda the "basic languages" of programming, you can't really go wrong there. But honestly is Java much more power full (easy for web stuff, a lot of "ecosystem" languages).

So my advice would be get good in C and then you can kick ass in Java.


C++ is more like religion, either you think it's one of the worst and most cancerous langauges ever or you love it.


Also, sooner or later you might think about learning a scripting langauge like Python, Ruby, C# or Perl. They are slower but you can be a lot more productive with them for smaller tasks.


But first things first: start with C.
Just don't make the mistake to not learn other paradigms/langauges, a well-rouded programmer is a good programmer.

If you look at the design patterns that have developed in Java, it seems like a lot of them are just a way to implement functional programming in Java. IMO, Java is the weird middle ground of all programming language concepts all merged.

Wonderfully written C code? Pls share.

I'm slowly learning C, been looking for something like an example library of common things, like techniques, functions, famous algorithms, sort of like an index of good code.

I'm not a Java fan. I actually think Scala is "the better Java", but it's no good to learn Scala until you know Java..

But that's a reason to learn Java, because if know it, you can easily pick up something like Scala, Groovy or Clojure - even though they are very different in their syntax, they use the Java libraries and JVM.


But there are so many nice langauges out there..

If you're writing C, you have to figure that all out yourself. Apart from the seebs C faq and the Linux kernel conventions, there are no real standards on how to write C. If it's portable and doesn't invoke undefined behavior, that's good enough for C.

>C++ is a waste of time

I'm not talking about standards or conventions, I'm talking about "here's a good example of merge sort" and "this way to read files has x advantage" and "oh, look at this interesting loop!"

There's no correct way to write C, apart from code that had been benchmarked for performance.

With respect to reading a file, you either do it the way that the API intends or you do it wrong. Just look up any tutorial to find that out in C.

MM EE MM EE LL AA NN GG UU AA GG EE SS

poo in loo, C# is MS's shitty Java/C++ knockoff

What's a good Linux distro I can install in a VM to get started with Ada? I don't dare try putting the GNAT GPL toolset on my main OS

If you don't know how to use Linux, install Ubuntu with KDE or Ubuntu with MATE. Those seem like the most idiot-proof distros, with decent DEs.

I'm not talking about correct ways. Holy hell...

go read K&R and seebs faq then fuck off then. It's not that hard

C++ is too oldschool. Join the real world by learning a modern dynamically typed OOP language (python or ruby)

Who said anything about hard?

You seem to have completely misinterpreted what I was after.

>the real world
you mean webdev babies?

yeah, naaah.

There is literally nothing wrong with c++11

So... the same goes with Rust?

Facebook uses D, but that's about it. so yeah, pretty much no one

No. Actually more people in the industry use Rust right now than D.
Dropbox, for example.

They made too many mistakes to be taken seriously.

C++ is useless and inconsistent. C is better
Also, learn scheme/racket/lisp.

>C is better because it's better

>A well written C++ code is impossible to read and to maintain.
This. And then you encounter a part with metaprogramming on templates, and cry yourself to sleep before resigning as a C++ developer and humbling yourself to learn haskell instead

C is better because it is not trying to be what it's not designed to be. For instance: it does not have abominations bolted on top of it such as """""templates""""".
Also: you always know in C what the fuck does
x = i * j mean. In C++ you also have to know what class i and j are, and if they overload the * operator, which makes your program literally the most unreadable piece of shit ever.
Quoting C++ creator, Bjarne Stroustrup :
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."

this.

Without templates you get huge, repeating code which makes it super hard for extending. Of course you can use macros but they are unhygienic and debugging them is even worse.
You are supposed to implement operators in a way that is intuitive. You can make * operator that add but it's just stupid, it's no different from C where you have to know what functions do and name it properly to understand the program.
Overloading operators makes code more readable than using functions for the same way. Eg.
WorldPos = Matrix * (Vec.Norm().Cross(Vec2) * Constant + VecOffset)

Is way more readable than
WorldPos = mulMatVec(Matrix, addVec(mulVecScalar(crossProduct(normalize(Vec), Vec2), Constant), VecOffset))

*(file + OFFSET_ZOOMLVL) = 5// still valid C

That's a very clear expression because you can say what exactly it does.

I prefer C.
I know how C works, because it’s simple.
C++ is much richer, but much more complex, and it’s way harder to know what you’re doing.

Knowing what you’re doing is way worth it.

The only thing C lacks are good containers, but Go has proven that you don’t need generic containers, so I’m sure you’ll be able to figure something out.

>In this moment I fail to see any good reason to actually use C++14/17 over C11.

Autism. If it's not how we did it decades ago, it's not what we're going to do today.

youtube.com/watch?v=KlPC3O1DVcg

>It just looks more minimal,
The lack of features quickly becomes annoying. Also no one forces you to use a particular feature or write unnecessary code.

>straight forward,
I think that depends on who wrote the code

>easier to debug,
C debuggers are usually c++ debuggers in disguise.

>portable,
Some embedded architectures provide a c compiler but not a c++ compiler. If you need to target such a platform c is a reasonable choice.

>compatible,
In what way? Libraries? Interacting with other languages? Usually extern "c" is sufficient.

>probably even better performance-wise (don't quote me on this one, though).
Compile with fnoexcept and fnortti if you need soft real time guarantees

>function pointers
Use lambdas for less crufty syntax and to avoid the performance hit of going through a pointer.

>procedures to "sanitize" void pointers, in order to make them kinda memory safe.
Why not avoid void pointers all together by using a language with a proper type system?

>boost
>good
jesus christ

Anyone that can suggest a good book on c++? I already know how to program in c

>as long as it compiles with a c++ compiler
well written C doesn't compile with a C++ compiler

>but Go has proven that you don’t need generic containers