[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Stop saying "C/C++"

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 154
Thread images: 6

File: ccpp.jpg (19KB, 1024x768px) Image search: [Google]
ccpp.jpg
19KB, 1024x768px
Enough of this shit already. They are two different languages, with different goals and different best practices.

Saying "C/C++" proves you know nothing about either language, or programming in general.
>>
But C++ is a superset of C.
>>
>>62186971
So why can you run c code while having files and c++ flags in the compiler?
>>
>>62186971
C++ is just C with objects.
>>
>>62187022
>>62186990
low quality bait guys
>>
But... but... I want to refer to both languages!...
>>
>>62187042
nice arguement brainlet
>>
>>62186971
>>62187042
#ifdef __cplusplus
extern "C" {
#endif
>>
c/c++c/c++c/c++c/c++c/c++
>>
>>62187042
>muh restrict
>>
>>62187124
That isn't how extern "C" works.
>>
>>62186990
int *p = malloc(sizeof(int));

Try compiling that in C++.
>>
>>62187049
Just write C+++C
>>
>>62187011
because some of the syntax is similar and you can make libraries that work for either.
Are you really dumb enough to be confused by this?
>>
>>62186971
>They are two different languages, with different goals and different best practices.
theyre not different, C programs will almost always compile in a C++ compiler, especially if you use the C11 standard
>>
>>62187281
unless you malloc anything
>>
>>62187194
so C++ doesn't automatically promote void pointers, big deal. Use a cast.
>>
>>62187324
>unless you malloc anything
oh look, Im using templates, thats COMPLETELY DIFFERENT than C, so they are completely different languages
>>
Yeah everyone knows C/C++ simplifies to 1/C.
>>
>>62187372
the fuck do templates have to do with anything
>>
>>62187350
You missed his entire point.
There exists valid C that is not valid C++, so C++ is not a superset of C.
There are actually shitloads of semantic differences between the languages, even for code which is syntactically the same.

>>62187372
What on earth does that have to do with automatic void * conversions?
>>
>>62187384
youre using a C++ feature to say that C is different, its not different, its just that C++ has features added
>>
>>62187251
Underrated
>>
>>62186990
http://www.stroustrup.com/bs_faq.html#C-is-subset
fuck off brainlet
>>
>>62187403
but malloc is C
>>
>>62187438
you can use malloc in C++
>>
>>62187447
not without a useless cast
>>
>>62187447
but you cannot initialize a non-void pointer type with malloc, which is common practice in C
>>
>>62187493
an example of a minor edge case
>>
>>62187519
A common edge case, idiot.
>>
you usually learn C++ after covering C, which is why people generalise these languages
>>
>>62187256
No shit, the fact is that both languages are so similar but they're still two different languages because one has way more libraries thus giving it more flexibility in terms of getting things done.
>>
>>62186990
>what is auto
>>
Shit tier: "Modern" C++14, C++17

Low tier: C++11 with heavy use of templates, boost, RAII, etc.

Mid tier: C99, C++11 with minimal use of STL

Top tier: C89

God Tier: C++03 with minimal use of STL

Just as software almost always gets worse each year and iteration (see: Firefox, Ubuntu, Windows 8 / Windows 10, YouTube 2017, KDE, Microsoft Office), C++ is also getting worse after each new iteration. As Terry Davis says, only MIT niggers are amazed by complexity, the professional should strive for simplicity and readability.
>>
>>62186971
Let's call it C(++) instead.
>>
>>62186971
I say C/C++ when reffering to shit I write in C++ because I don't know a language and I'm aware that what I write isn't a valid C++ but more like C with streams, classes and templates.
One day I will learn C++ and then I'll start saying just C++.
>>
>>62188184
I like my C99 tbqhladdesu
>>
Shit tier: >>62188184

Who cares what a schizo says.
>>
MIT nigger tier: >>62188367

Who cares what a flat design-worshiping, mobile & "cloud"-promoting, subscription-based software-shilling nigger says.
>>
>>62188498
>implying I promote those things
>>
>>62187375
Yet 1C is one of the shittiest languages.
>>
>>62188498
What does any of that have to do with the STL, templates or smartpointers?
>>
>>62188543
Nigger I brew my own beer at home while you purchase your own ovaltine spooge at the store like a faggot.
>>
>>62188346
Isn't Modern C just a meme in the real world, though?
>>
>>62188636
>implying you'd knew beer from piss
see >>62188630
>>
Java / JavaScript
>>
>>62188184
God I love C89, but sometimes I forget that all variables must be declared at the beginning of the scope.
>>
>>62188772
Can you not write something like for(int i = 0; blah blah; blah blah)?
>>
>>62188184
>C++03
lol that guy using all the new shinies. C++98/<vector>/<string>/<iostream>/<limits> is the only standard target.
>>
>>62188839
STL without move semantics is not worth it
>>
>>62188802
nope
this is valid
void func()
{
int i;
do_stuff();
for(i=0;i<10;i++)
{
int q = 0;
printf("%d\n", q);
}
}


this is not valid
void func()
{
do_stuff();
int i;
for(i=0;i<10;i++)
{
int q = 0;
printf("%d\n", q);
}
}
>>
>>62188929
You wrote the same thing, but I got the gist. Damn, that is awkward coming from a Java or C++ background
>>
>>62188950
it's not the same thing, notice where int i; is?

The second one doesn't work because it's after other code in the block.
>>
File: 1373509022197.jpg (39KB, 210x182px) Image search: [Google]
1373509022197.jpg
39KB, 210x182px
>>62188950
Oh, I just saw the difference, that's crazier than I thought.
>>
>>62188839
C++98 and C++03 are identical
>>
>>62188966
And I suppose you can't declare in a for loop too.
>>
>>62186971
C++ = C+Python
>>
>>62186971
It's more like C+C++ but that looks pretty awkward
>>
>>62189106
This guys gets it
>>
>>62188184
>God Tier: C++03 with minimal use of STL
that 0.5% performance is really worth quintupling the size of the code and increasing error rate 1000fold
>>
>>62189081
Can't do that either in C89.
In C99 it works and you can declare variables anywhere, not just at the beginning of the scope.
One time I had to port a project from C++03 to C89 and it was hell, but I liked how elegant C89 was, even compared to C99.
>>
>>62189013
It adds some clarifications in the standards, so coding to C++98 is avoiding those things that were broken. eg, avoid

const int Z = 1;
template <int X = Z, int Z> class A {};
>>
>>62189148
>Port a project from C++03 to C89
For what purpose?
>>
>>62189081
as long as its at the beginning of a scope. a loop creates its own scope.
>>
So what's the difference between them?
What's better?
As a C# programmer, is it worth me learning one or both of these? If so, which?
Would you ever write a normal GUI application in one of these languages? Why not C#, Java, or another high level language?
>>
>>62189167
>C# programmer
if you don't mind not ever being considered for jobs that aren't MS-only...
>>
>>62189167
>What's the difference
One was ready to implement OOP from the start, the other wasn't. So there are no such things as classes in C.
>What's better
Incoming Language War
>As a C# programmer, is it worth learning one or both?
Only you can answer that question, really. You could learn C for its amazing effiency, but it's whatever you think you'll need. C# is basically just if C++ and Java had an non-ugly child.
>Would you ever write a normal GUI application in one of these?
Both support GUI, some hate GUI in C though, but it is possible.
>Why not use a high level language
Everyone likes what they like
>>
>>62189165
For some weird proprietary microcontroller. The toolchain we had to use only supported up to C89, but the original project was a PC application.
>>
>>62189261
Oh, so you were porting your application to a microcontroller? Holy shit.
>>
>>62189167
C for open gl shaders
C++ any real application or game
You better off with Java than c# it's useless unless you jerk it to Microsoft and unity
>>
Let's just retire C

when you need C-like stuff there's C++ in archaic mode
>>
>>62189316
The C++ crowd has been trying their hardest, but they haven't done it in the 30 or more years the language has been around, they're not gonna end up doing it now.

Let's All Love C
>>
>C project in Visual Studio 2017
>clean, build a handful of times
>average compile time 24.3 seconds
>rename .c to .cpp, don't change any code
>clean, build a handful of times
>average compile time 45.8 seconds
>>
>>62186971
I'm taking a C++ class and I've literally never heard anyone refer to it as C/C++ irl or in any of the books I read
>>
>>62189316
C++ should have been its own language.

A C clone with a strong and expressive type system and without headers is all I really wanted.
>>
>>62189341
>they're not gonna end up doing it now.
C fags are literally dying out

C++ is taking over one Mountain Dew OD at a time
>>
>>62189222
C# is cross-platform though. I've written Linux software using it.
>>
>>62189378
Rust, my friend. Rust.
>>
How do people even design their software in C when it doesn't suppose classes?
>>
>>62189463
Rust is too different for that. The language I'm envisioning is somewhere in between C++ and Rust.
>>
>>62189378
>without headers
Who are these faggots who want this?
There has never been any good language without headers, so why do people think they are bad all of a sudden?
Don't you guys have editors that can deal with this?
>>
>>62189463
name one field or industry that unironically uses Rust because of its growing ecosystem advantages
>>
>>62189490
C barely understands any scoping rules at all.
>>
>>62189490
>needing classes
For what purpose?
I code almost entirely in C but have used some C++ and classes just seem unnecessary.
>>
>>62189378
>C++ should have been its own language.

It wouldn't have been adopted in the 90s if it was its "own language."
>>
>>62186971
(Facepalm)
Fucking ignorant c/c++ is practically one language.
C++ extends C by definition, c++ is a superset of C.
Everything before c++11 is the true c/c++, it's not anybody's fault that they created an abomination of a language with the release of c++11 and with the later releases.
Otoh, c++, used with the correct preprocessor and compiler, is translated back to c and then to asm.
C is c++ agnostic, because c was created first, but c++ and all of its compilers know how to handle c code, headers and libraries.
If you are using c++ and load at least one c function or use c_str() you are using c/c++.
EOF
>>
>>62186971
Every c program is a valid c++ program.

We should kill c and just leave c++ then.
>>
>>62189497
tbf, you can get used to any syntax differences after a few weeks
>>
>>62189504
It's a newer language, but the design is great and it has good backing, and it's growing in popularity. There are actually lots of people using Rust: https://www.rust-lang.org/en-US/friends.html
>>
>>62189504
Fintech, surprisingly a lot of it. Specifically where you have high security standards and need high performance.
>>
>>62189504
*crickets*
>>
>>62189498
Headers are just ugly, old legacy shit. What's even the advantage to them? Why would you want them? Aside from C and C++, every popular language avoids headers (e.g. Java, C#).
>>
>>62189523
Well, personally I've always worked with object-oriented languages like Java and C#, so I think in OOP terms and am very familiar designing software like that. The idea of going to something that doesn't even have classes seems bizarre to me. How do you design your software architecture?
>>
>>62189583
You can do it pretty much the same way. Design data types and the functions that operate over them.
>>
>>62189583
Structs, and passing pointers to structs as function arguments.
>>
>>62189624
isn't that just a roundabout way of OOP?
>>
>>62189658
yep

though of course it isn't "true" OOP until you have polymorphism and inheritance
>>
>>62189658
Yes, but I'm not using classes. Minor distinction.
I find it produces more understandable code overall.
>>
>>62189658
Yes, if you have to emulate OOP in C then it probably means you shouldn't be using C in that project anyway.
Seriously, C is assembly tier language now. It's good for those extra few bytes and 1% better performance in embedded systems or microcontrollers but with any project larger than 20k lines of code you're bound to make code that's extremely dificult to maintain.
>>
>>62189726
C++ can already be optimized just as heavily as C. There are very few low-level facilities open to you in C that do not exist in C++. At the same time it is possible to write abstract code with little overhead, giving you the freedom to optimize only where necessary.
>>
>>62189431
Did you enjoy carefully treading around the parts that are gutted?
>>
>>62189726
What would you use instead for larger projects?
>>
>>62189788
In principle yes, but the language encourages using slow data structures so in practice it's much slower unless you make effort to steer clear from solutions whose inner workings you are not aware of.
>>
>>62189844
STL is pretty hazardous when it comes to high performance data structures, but you have the freedom to replace those with special and fast alternatives where you need to.
C++ has a reputation for being slower than C but the fact is that it's only slow if you write it to be slow.
>>
>>62189378
Jai is coming out.
From what I have seen it seems pretty good.
Kind of what you (and me) want.
>>
>>62189827
It all depends on what exactly you're doing.
C++ is well suited for stuff that needs acceptable performance but doesn't need to be optimized to hell and back. Vidya, graphical design tools, stuff like that.
Code monkey tier projects, aka get stuff from database, do some shit to it and display to end user can be quickly done with the tired combo of Java+JS/CSS/HTML.
Quick window applicatons (a map editor for a game, for example) can be made in some shit like Visual Basic, idk
>>
>>62189490
Classes and OOP are a waste of time and space, not only for you, but also your computer.
If you want to write good C you must think of everything in a data oriented way, where you have your data, and do corresponding transforms on it to reach a certain output.
This thinking is essential to writing high performing code.
If you want to gain some insight watch this talk by mike acton https://www.youtube.com/watch?v=rX0ItVEVjHc
>>
>>62189868
Not only STL, but a big part of OOP-style libraries.
In traditional C, the data structures are created in the calling function and then operated on by the library functions, so the programmer is aware of the data and can take a reasonable guess on the time usage of called functions, and sometimes design other functions to work on similar data structures.
In OOP, every library is essentially a big black box with internal data structure and state. After giving the parameters to the initializer, you pretty much have to check the source to know if it works reasonably fast for your needs. Sometimes the data also has to be needlessly copied around.
It's not necessarily about optimisation, but rather what the library is designed for. OOP libraries are often intended for general use, which makes them slow for any specific use.
>>
>>62187350
Most C code does not do this, and the C standard explicitly says that a cast is redundant.
>>
>>62190005
Most of the time you don't need to write well performing code. As long as it doesn't hog the processor for 15 minutes it should be fine.
The biggest bottleneck in modern software development is not computer time, it's developer time. OOP allows developers to write easily understandable, relatively bug free code quickly. That's why it has gained so much traction.
>>
>>62190075
I do it anyway. fuck it.
>>
>>62190005
Thanks
>>
>>62190076
Most of the time companies just need some pajeet-tier code that works halfway, so that the company hiring the programmers can sell that piece of shit.
If time matters then it will matter a lot.
If it doesn't, why not use a better paradigm?
OOPs promise of "easily understandable and relatively bug free code" never bore fruit.
It doesn't provide more simplicity than a data driven design.
Functional programming for example does though, so why not switch to it if your performance doesn't matter?
>>
>>62189422
>C fags are dying out
Hello NEET
>>
>>62187194
>int *p = malloc(sizeof(int));
retard
int *p = malloc(sizeof(*p));
>>
>>62189562
a-are you retarded? java makes use of header files too just differently. where do you declare your constructors?
>>
>>62191590
What are you talking about? Java just has individual source files for each class. Everything for the class goes in one file. C# is the same, although you can optionally split classes across multiple files.
>>
>>62186990
so is python
>>
>>62190005
>>62190076
Golang I think meets in the middle. Sacrifice tiny bits of performance (through idiomatic Go) for readability/maintainability. But it also forces you into a data-driven mindset where often-times the idiomatic way is the most performant way. For times that it is not, you can do things that break from the idioms and get you high performing code.

I would argue that readability/maintainability lend themselves to much easier shifts to performant code that code that was prematurely optimized.
>>
>>62192035
obligatory gopher.
>>
File: DigbyScene2Shadows.png (687KB, 2869x2921px) Image search: [Google]
DigbyScene2Shadows.png
687KB, 2869x2921px
I don't know how to internet today.
>>
>>62189498
>using editor capabilites as an excuse for shitty language designs
>>
>>62186971
t. first year college kid
Most jobs that require C++ also require some C. That is why you see them written together all the time.
>>
>>62189548
>>62189554
so nothing, okay.
>>
>>62186971

>Saying "C/C++" proves you know nothing about either language, or programming in general.

So why should people who know nothing about it stop saying it? Why would you want novices to be less easy to identify?
>>
>>62186971
Bonus points when you see this in job postings.
"Am I going to work in C? C++? 30 yo C code base with some classes and a few other cute 'C++' parts?"
>>
>>62187481
I'm afraid you don't get the whole point of C++ if you think a cast from void * to T * should be implicit.
>>
>>62186971

>hurr, there are two obscure operations in C that aren't in C++, so it's totally not a subset
>hurr, we are such special snowflakes

It's C/C++, deal with it.
>>
>>62190674
Spotted the autistic sperg who knows nothing yet thinks he's right
>>
>>62188184

>simplicity and readability.

Brainlet excuses.
>>
File: ss-2017-09-01-16-51-05.png (30KB, 999x218px) Image search: [Google]
ss-2017-09-01-16-51-05.png
30KB, 999x218px
>>62186971
but there's a lot of software written in C/C++
>>
>>62186971
C++ is the same as C, but with added objects and classes. You can literally compile any code written in C with C++ compiler and it will work.
>>
>>62186971
I don't.
>>
>>62196200
The new operator would have solved this whole malloc problem if it weren't for array decay.
>>
>>62200334
>array decay
Rust shill detected
>>
>>62200531
>Knowing C and C++ makes you a Rust shill
???
>>
>>62199933

> compile any code
> any
>>
C++ community has bunch of these do-gooders whose only job is to explain other people how c++ works. They are the cheerleaders, they write books, give talks on conferences and travel from company to company helping then unravel the mess c++ has created. They never solve real problems only problems which get created when somebody tries to solve a problem with c++. If you look at their history, they have spend last 25 years doing the same thing.
It's in their best interest too keep c++ as complicated as possible. It's what sells books and gets them invited to do company internal training sessions. Just like lawyers who draft over complex legislation and then get hired as consultants to private industry to deal with that legislation, for them the bureaucracy is what keeps the bread on the table.
>>
>>62200538
People who actually know C/C++ understand that arrays and pointers are the same thing, "array decay" is a scare word created by its opponents
>>
>>62190674
>int *p = malloc(sizeof(*p));
retard
int *p = malloc(sizeof *p);
>>
>>62190674
>the absolute state of /g/
>>
>>62189533
>load at least one c function
>load
hello webshit
>>
>>62197624
>obscure operations
>assigning the result of malloc
back to your mongojs
>>
>>62201040
>int *p = malloc(sizeof *p);
int* p = (int*)malloc(sizeof(int))

you had a space in the middle of your data type
>>
>>62200538
>Knowing C and C++
there's no need to lie on the internet
>>
>>62188184

Bonus points for somehow thinking of a way to not just troll on the tech level, but also now on the political level by using racist language
>>
>>62201011
yeah, arrays are pointers and pointers are ints
>>
>>62189498
Life *is* better when receiving good *head*ers
>>
>>62189583
OOP basically teaches the opposite of architecture. It teaches you to hide your complexity is arbitrary objects so the programmer doesn't know what the hell is really going on in there.

True architecture is based on an abstract mathematical foundation. Classes and objects hide mutations and state change instead of elegantly architecting that type of computation in a transparently reusable manner. C, Rust, and Go get closer to the way large complex systems should be designed - using pure mathematical functions where possible, and limiting impure computations as much as possible to their own procedures or, in Haskell-like languages, datatypes (monads, comonads, and crap).
>>
File: a12.jpg (94KB, 500x375px) Image search: [Google]
a12.jpg
94KB, 500x375px
>>62186971
IS c++ ACCEPTABLE FOR FUNCTIONAL PROGRAMMING?

WHAT ABOUT MULTI THREADING AND CONCURRENCY?
>>
>>62201011
>C/C++
Way to discredit yourself.
>>
>>62194525
>Most jobs that require C++ also require some C. That is why you see them written together all the time.
This tbqh. Not that the NEETs of /g/ would ever know.
>>
>>62186971
>not writing your RTOS in ASM/C/C++, and embedding JS on top.
>>
>>62186971
Fuck you faggot I don't care what you tell me
>inb4 archive and you can't respond to me bahahahaha
Thread posts: 154
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.