C vs C++

C vs C++
Which is better and why?

Attached: s3.jpg (1280x720, 60K)

Other urls found in this thread:

godbolt.org/g/5GfydJ
twitter.com/SFWRedditGifs

+C is better

You can start with either, but C will give you better fundamental awareness that you can take into any other language.

C++ if you're making a gayme, Java for everything else. I know many won't like it but that's just how it is.

what about c# guise

Attached: 1524228389445.jpg (247x196, 15K)

C+= (C plus equality)

C is much simpler, so you can write your own things. And when it'll turn out to be shit, you got only yourself to blame.
C++ is going to be likely good if you restrain yourself from using most of the fancy stuff from std/stl

So if you can think for yourself, there's a smaller chance that you shit will fuck itself up - no matter the language.

I would go with a sane subset of C++. I only use C when I want to work with the machine or fit into Unix.

Also consider using Python, when you don't need C/C++ performance.

C++'s major problem is that the compile times go through the roof quickly. No precompiled headers or alternate build systems (ninja) can help you.

C

Attached: 1523503214754.jpg (1920x1080, 175K)

True. If quick compile times are important, go can be an interesting choice.

Really depends on what you're doing, user.

>inb4 python
pen-testing

C#

Anyone here knows fortran II?
Is it still useful for something?

>C++

Attached: 1452379365736.jpg (1280x720, 72K)

C++

>microsoft java
trash

New to this programming-stuff. Is C fun to learn?

Yes. C is a fun language.

completely depends on whether you want something on a screen quickly or if you enjoy the intricacies of the computer doing the seemingly magical stuff you just told it to do
if it's the former, you'll hate it

Thanks, was willing to give it a shot.

Does your platform support, and do you fancy OOP stuff? If yes, fine use c++. Otherwise just use c.

I personally just use c. C++ is can't be used for the stuff I work on.

Attached: 1514101836488.jpg (500x555, 70K)

>C++
bloated botnet

Learn c and a small amount of c++. Use c++ as a superset of c.

Retards say this is an antipattern but they say all kinds of stupid shit that is wrong in software

when will this meme die

++C is preffered, thanks.

Learn C89 and C++14.

Attached: 3qrfu.jpg (625x838, 132K)

Python

You know, I've been checking Go out, as you recommended.
This is a nice language. I wonder why I never bothered to look into it until now. I think it was the no generics thing. But it doesn't really matter to me since it has built in maps and lists and that covers 90% of sitations I need generics in.

Different advantages for different situations. That being said, I'd recommend learning C before C++ to help understand why C++ is what it is.

Kotlin

>Ansi C not C99
why?

That's microcuck. Windows supports only ansi C and sepples.

Even brainfuck is better than C++, so unless you are a masochist C is a better option.

Another reason to not touch winshit.

> Decide to use C for project because it's simpler
> Get to spot where I need a hashmap
> Easier to switch to c++ and use std::map than make one in C.
> End up switching every time.

lol what? I implemented type generic containers vector, hashmap, ring buffer and vector with free list and they all are dynamically expanding and it was only like 700 lines.
You could just use some library that provides containers or use some bigger general purpose library like glib.

Yeah. Programs that really want to remain pure C usually disolve into Macro-Madness at that point.
I mean, have you seen large C programs? Sure, C++ is a large language with a ton of language features, but at least those are standardized and work the same in every project. Also the compiler understands those and can optimize them.
In C, every single project invents its own macro-shit sub-language to approximate C++'s features, except without the compiler optimizations, the type safety, anyone understanding what the fuck is actually being generated and the power.

I prefer C+=2

How the fuck do you implement vectors in C? What chunk size should I use because obviously you don't want to realloc with every new member.

I'd multiply the capacity by two every time you need to re-allocate. For example, if you start with 5 elements and a 6th is appended, allocate 10. Then when an 11th is allocated, allocate 20 and so on.
If the user wants maximum performance by eliminating reallocations, they'll have to specify the desired capacity, like they do in C++.

C is a good starting language, especially if you plan on working on embedded systems.

C++ for object oriented. There's no better or worse user, it depends on what you want to do.

C++ is an objectively horrible language.

Sometimes I wonder if any of you fuckers even work at a corporate environment.

The debates you come up are ridiculous and petty.

Attached: 1403771387403.gif (320x234, 1.23M)

++C

>Sometimes I wonder if any of you fuckers even work
better question

I work for sometime so I know how an IT company work, but then Jow Forums is the biggest shitfest with people talking about anything as if they were experts in the field, but it turns out it's just nonsense.

The only thing you should really be using C++ for are as follows:

>Function overloading
>std::vector
>Templates (sparingly)

Learn C++ if you want a real job. C if your ok with working at Best Buy.

not OP, but does anyone have an good C++ code samples or even whole software code written in C++, maybe even vidya. for learning purposes.
asking for a friend ofcourse.

C++ is a superset of C.

That being said, it does get very complicated as the code gets bigger.

C++ obviously.
Everything in C is in C++, and C++ has extra features.

Macros are the only way to do inline functions correctly. Macros can be used well and not so well, like anything.

>C++ is a superset of C.
>t. Stroustrup
LOL

I'm quite certain the inline hint works on every compiler, even Microsoft's.
You probably haven't seen the source code of a real, large C project yet. Look it up. You'll see what I mean.

Can inline functions return values (making the inlining less trivial)?

On a test I'd rather get a C++ than a C.

Yes.

A B- you'd say?

The compiler will usually do a better job of these types of optimisations than you can, and if you really, really need it, you can use a gcc extension to force inlining.

++C is better, since it is INC whatever register, but not ADD whatever register, 1

Assembly. Fuck portability,software must be optimized for certain hardware manually.

Humans are much worse at optimizing code than modern compilers are. Especially when it comes to optimizing whole programs.

If you ever need to optimize something the compiler can't, then feel free to use inline assembly in that instance. But usually you won't, because modern compilers are ridiculous.

Case in point: godbolt.org/g/5GfydJ
The compilers literally understand what we're trying to do with our code. And they can easily change between implementations that produce shorter programs (to fit better into the cache) and larger programs with unrolled loops etc. They can even choose which implementation of which function to use based on profiles of the program actually running.

In assembly, you'd have to rewrite everything to do that.

Also don't even get me started on SIMD instructions.

Bad idea, just amplify the probability of catastrophic bugs by mixing Cs lack of type safety. Seriously just write C++11 onwards idiomatic code using shit like RAII, auto etc.

Never prematurely optimize except on a structural basis, i.e which type of container to use, then actually profile your program and if say std::cout is too slow for your needs, use stdio.h functions instead. Also don't buy the meme that C is faster than C++, they're for all intents and purposes the same.

Not quite, humans are good at optimizing code, if you don't give them fancy toys like good CPUs.
But it is expensive and requires to be slav.

Please do get started on SIMD instructions, I'm curious.

lmao

I don't mean anything specific. But have you seen the crazy shit compilers can spit out to optimize loops using SIMD instructions? I bet less than 100 people in this world even know what half of those do.
There's no way a human writing in assembly could do that, especially not over one huge program. This isn't fizzbuzz we're talking about.
ESPECIALLY not when they need to figure out where it makes sense to use them and where it doesn't, since they, like everything else, aren't guaranteed to speed up your program.
A compiler with profile guided optimization could understand this and would simply generate different machine code from the source code.
An assembly developer would have to rewrite his source code.

It's infeasable to create a modern, large program entirely in Assembly. Maybe there was a time when compilers were stupid and couldn't optimize code well, but no longer.

C+= is the only acceptable answer

Why does the compiler ignore the inlines by default?

Because the compiler is generally better at knowing which functions should be inlined and which shouldn't be.
Unrolling things isn't always faster nowadays because it matters more whether code fits into the cache having a couple less subroutines.

uhhhh i personally prefer mainframe thx vry mch bb

>C++ if you're making a gayme, Java for everything else.
The only right answer.

I used to think Jow Forums would be a good place to talk about code but it seems like 90% of these threads are 2nd year CS students spouting ignorance as fact.

>maintaining the linux kernel isn't a real job
>being a literal millionaire from working on an open-source kernel isn't a job
Also:
>your
The irony.

>he wasn't here for /prog/

Nah I just lived on /d/ and /tg/ for a long time before paying attention to other boards.

Nothing in programming is fun. Once you understand how to do it decently, it's at best a satisfying tedium.

HolyC

Attached: fe.png (347x565, 262K)

This should answer all of your questions

Attached: c++.png (1620x774, 40K)

brainlets pls go

Attached: 1515132762979.png (1834x1200, 740K)

Don't forget Python for scripting (bash scripting should be fucking punishable by death in 2018, honestly) and Groovy if you need to provide a DSL/runtime scripting for end-users

Try writing the linux kernel in sepples.

Try writing a standards compliant web browser in C. Imagine all the security vulnerabilities.

Unrelated but on the topic of systems programming languages, I haven't seen much rust shilling lately. What happened?

Word on the street is fortran is better than C for strictly number crunching. Otherwise C is better (faster)

>Imagine all the security vulnerabilities
Being this stupid. Do you think TLS and SSL was implemented in sepples? Do you think sepples is just safe 100% of time because reasons. Stop being a retard. Everything is built of the shoulders of giants. If enough people worked a c project, it would be safe. I guess it's easier for retards like you to use others' work and not contribute while shitting on them.

>a simple single purpose cryptography library is the equivalent of a large scale project like a web browser

Why would I use python if I can just use bash?

Why use C++ when you could use C?
Why use C++ when you could use java?

C++ has unfortunately found itself in a well between languages more appropriate for any given use.

> driving nails through my cock is fun

>nginx is written purely in C and is the most robust web server out there
Are you done being stupid?

Python is a lot more powerful then bash. Bash is great for little stuff.

Because what kind of syntax nightmare are those if statements. Really all statements. The brackets are themselves supposed to be commands or something? Weird whitespace rules, everything's a string, there's 500 insane rules regarding subshells depending on how many parentheses you wrap around it, it's just

It's not good, user. Bash is a fine shell but it's not a language and it's not for scripting.

>there's 500 insane rules regarding subshells depending on how many parentheses you wrap around it,
I thought you were arguing FOR python, not against it

I don't care about python, I'm not the same user you were talking to. I just hate bash scripting and everything it stands for. Use something else. Python, node.js, php, I don't care, as long as it's not bash.

Also what exactly do you mean by that? What possible benefit does having a difference between $(ls) and $((ls)) serve?

it doesn't, but python tuples create horrendous ambiguity.

That they do

Whoa back up some, son. I sense you just don't how to use bash.

>The brackets are themselves supposed to be commands or something
You mean braces? Braces runs commands within your own shell. Brackets let you execute test conditions.

>Weird whitespace rules
It's called fields and records. A field separates items on a record(line). Fields by default are made of a space, horizontal tab, and a newline.

>everything's a string
Everything is a file. Bash and other gnu and unix like commands are all text based. You can still use int

>there's 500 insane rules regarding subshells depending on how many parentheses you wrap around it
Not sure what you mean by this. You use subshells when you want commands that aren't in your current shell(environment).

>Bash is a fine shell but it's not a language and it's not for scripting
Bash is a shell, not a language. Bash can interpret your scripts. You can a lot with bash scripting. It's preferable to python or C in some cases. Making changes to conf files, large text files, Americanizing the raspberry pi, etc.