[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
So "C" has structures, functions and pointers... Prove
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 63
Thread images: 3
File: C++.png (68 KB, 600x600) Image search: [Google]
C++.png
68 KB, 600x600
So "C" has structures, functions and pointers...

Prove to me why I would need the bloated pile of fucktardery called "C++".

Protip, you can't.
>>
>>54202719
Templates.
>>
Classes.
>>
smart pointers

think you can perfectly allocate and deallocate memory? with hundreds of thousands of lines of code? protip: u can't
>>
>>54203086
Yeah, you're 20 years too late with that comment genius. It's called garbage collection and automatic memory management, and is rather trivial to implement in C.
>>
>>54203086
Not OP, but I've been holding off on learning C++ for similar reasons.

What is a smart pointer? Sounds interesting.
>>
>>54203120
> Garbage collection
> in C
> trivial

hahahaha
>>
You don't. OO is garbage enough alone but C++'s implementation of it is a clusterfuck.
>>
>>54203192
When I read your post I know that there is hope for humanity. Some, like you, know the truth.
>>
>>54203182
Oh look, a dumb kid that doesn't know how to program.
>PLEASE MANAGE MY MEMORY FOR ME PROGRAM I AM TOO GODDAMN STUPID TO DO SOMETHING SO MIND-NUMBINGLY SIMPLE LIKE FREEING MEMORY I AM NO LONGER USING OH GOD SO COMPLICATED
>>
>>54202719
Portability. That's it.
You can waste your time writing C code using pthread, unistd and all sorts of OS specific libs but in the real world, I'd rather use std::thread than write code in pthread and have to port it to a windows equivalent later on.
>>
>>54203212
alright genius let me know how to implement garbage collection easily mmkay?
>>
>>54203120

Garbage collection requires a babbyshit run-time library to stall your program and wipe its ass, and it is not a replacement for automatic resource management. Take note the difference between "resource" and "memory". Garbage collection does not do a good job of cleaning up dangling file handles, database references, or any other kind of non-memory resource.

Shitty half-baked "solutions" like this is exactly why C++ is necessary improvement over C. Someone show me their generic containers/algorthms written in C so I can laugh at how unnecessarily inefficient and unsafe they are. Someone show me a project over 10,000 LoC that isn't an unfollowable mess of inefficient and unsafe malloc/free calls.

Honestly if you don't understand why you need C++ instead of C, you have yet to graduate from writing hello world.
>>
>>54203229

Why not use Object Pascal then?
>>
>>54203258
Because it's shit.
>>
>>54203249
So Linux kernel is shit?
>>
>>54202719
C is perfect for real programmers who like to do OS development and make good optimized applications.
C++ is for programmers who are too fucking stupid and need a huge bloated standard library because they can't get into small external c libraries.
>Don't get me started on Go, fucking piece of shit language.
>>
>another C++ thread
Wow can't wait to read some interesting Google copy pasted arguments for the thousandth time
>>
Would you recommend C as a first language for someone who has never done anything outside of CSS/html? I was going to either pick C or javascript. But I don't really want to make ae website very much anyway. I want to make a text game. Can I do this kind of thing in C? I'm interested in Unix and since Unix and C go together like candy and children I want to try it. But it seems very complicated.
>>
>>54203244
>garbage collection
THERE IS NO GARBAGE COLLECTION ON C, THAT'S THE POINT, YOU RETARD.

YOU DO IT YOURSELF.
>>
>>54203320
>I was going to either pick C or javascript.
Syntax and core-functionality-wise, they are largely similar, barring static/dynamic-typing and pointers. JS, like C, is also expression-orientated and lets you pass functions around as parameters. Learn one, the other shouldn't be that much more difficult to learn
>>
>>54203249
>Honestly if you don't understand why you need C++ instead of C, you have yet to graduate from writing hello world.
This.
C programming starts out "perfect" but as it progresses you'll end up trying to maintain a hoard of structs and init/del functions that handle your malloced memory, and if it's multithreaded...lets not even go there.
>>
C++ is obsolete. If I wanted to create an application I would just use C# or Java. If that application has to be as fast as possible I could just use C as well.
>>
>>54203366
>functions that handle your malloced memory, and if it's multithreaded
you just googled that shit. creathing threads with C isn't any more difficult than with C++
>>
>>54203351
I bet you have never done anything complicated in C. Memory management can be a real bitch. C++ is a lot nicer because you can hide it in constructors/destructors.
>>
>>54203437
>I bet you have never done anything complicated in C.
I have
>Memory management can be a real bitch.
Maybe if your IQ is lower than 100
>>
>>54203366
C++ programming starts out as "perfect" but as it progresses you'll end up trying to maintain a fucking spaghetti code mess of objects and other OO nightmare bullshit and have its memory "management" never do what you want it to do, making you not in control of your own goddamn program. And managing all that with a multithreaded program... HAHAHAHAHHAHHAHHHAHAHANope.

C++ is garbage.
>>
>>54202719
Templates
Polyhmorphism
Real OOP

And seriously, templates are one of the best features of C++. You can do compilation calculation, inflation of code to reduce functions calls. Pretty much trading compilation time for execution time.

If you don't want to do low level stuff, but want more of a desktop app project, go with C++
>>
File: PICT1163.jpg (196 KB, 1024x768) Image search: [Google]
PICT1163.jpg
196 KB, 1024x768
So "Pascal" has structures, functions, and pointers...

Prove to me why I would need the bloated pile of fucktardery called "C".

Protip, you can't.
>>
>>54202719
Constructors, destructors, and automatic guaranteed deterministic memory management.

Also templates, per the dozen other responses
>>
>>54203417

Creating and managing threads IS more difficult in C, I think this is a blatant example that you have never worked with both pthread and std::thread.

Most C++ bashers are kiddies anyways, so all is forgiven.
>>
>>54203580
>pthreads vs std::thread
Completely this.
pthreads is neat and all, but std::thread is undeniably better in its usability
>>
>>54202719
Destructors/RAII
>>
>>54203491
Actually C++ improved from a security standpoint.

Please tell me how memory management is complicated in C++ ? It's because you're a baby that needs a garbage collector and can't keep track of your memory usage ?

And how is threading complicated in C++ ? it's easier than in C
>>
c++ is worse than Java.
>>
Why would you use C++ when there is either C for systems programming or C# for desktop applications? C++ is deprecated.
>>
>>54203735
this
>>
>>54203279

Wanna know how I know you're not a professional programmer?
>>
>>54203244
find a memory allocator library that does it for you and start using it instead of the stdlib stuff

but you should kill yourself first, all that stuff is good for is telling you how shit you are at C in the first place

>>54203320
the basics of C are easy to learn, it's just incredibly tedious to do anything serious and too easy to fuck up

every programmer should know it though since everything ever was either written in it or copied its syntax
>>
>>54203735
Because C# is a Microsoft thing?
>>
>>54203735
Please point me to C# templates
>>
>>54202719
Polymorphism
Templates
the Auto keyword.
more memory safe
parameter overloading
function overloading
smart pointers
...

A better question would be, why are you still using C when C++ exist which is basically C with a bunch quality of life updates.
>But muh bloat
None of these are mandatory. Use what you need.

>But muh C#/Java/other bytecode shit languages
none of these are even remotely good for high performance programs
>>
>>54203086
You can if you aren't a Pajeet who got his "degree" from Kumar Patel University where you did 4 years of HTML and CSS.

C++ exists because Pajeets and bootcampfags can't into C
>>
Rust is the solution
>>
>>54202719
Maybe function and operator overloading. But no OOP, its crap, no templates. C is all we need
>>
>>54203086
>poor man's garbage collection
might as well use Java
>>
>>54203652
I can attest to this. std::thread is so goddamn easy compared to cthread
>>
>>54204416
std::thread and lambda abuse is fucking magical

shit's so easy and clean to write now
>>
>my language with no features is better than those with more
>>
>>54203249
> Garbage collection does not do a good job of cleaning up dangling file handles, database references, or any other kind of non-memory resource.
Furthermore, garbage collection *denies* any possibility for efficient automatic management of resources in general case. Precisely because all resources are stored in the memory one way or another and you have absolutely no idea when it's safe to free them before GC tells you that it's going to free this memory.

There are things like try-with-resources and shit, but they are not safe. You can accidentally store a reference to the resource somewhere, and then use it after it was closed.

Garbage collection 'solves' only one issue with memory safe: use-after-free which usually leads to crashes because of segmentation mechanisms of the operating system. And it solves it in the most dumb and straightforward way possible: don't free memory when it can be used. Even if it means 'never'. And it's totally fine with data races and your program having corrupted memory. The only thing GC cares is that you don't have dangling references to memory locations. And because of this you MUST manage every fucking other resource manually.

Though, arguably this is an acceptable... don't way to say 'solution'... yeah, an acceptable way to sweep problems under the rag for all this CRUD and GUI shit where the only resource you actually use is memory because all your program does is moving data from one place to another while converting it from one format to another.
>>
>>54202761
PIMPL & CRTP idioms
>>
>>54202719
Because people have jobs
Homeless shit
>>
C++ is really good for desktop applications where your focus is not the how it is done but the end result.
C is really good for systems where you want a better level of control.

A simplified example is strings.
Strings in C is a pointer to the first letter and it will stop reading when it comes to a zero.
This is a simple implementation which is easy for a computer to deal with and as long as there is a zero char at the end, it works.

In C++ it is a class.
How it is implemented is not important to the person who writes the application.
But since it is a class, it can do much more.
You can get the size of the string, you can overload the operators so that string + string can mean that you concatenate the strings.
These things are suddenly trivial because you have dedicated a class to be a string rather than having a array of letters.

Operator overloading is not something that should be used for everything, but it makes a lot of sense in certain cases.

I do a lot of matrix operations, and thus having a good matrix class where you can write it like your application like you would write the matrix calculations is really valuable.
If I had to multiply(matA,matB) it would become a mess to read really fast.
It also means the C++ language becomes a mess as the language is very different to read if you use a different library.
>>
>>54202719
C doesn't even have passing by reference
>>
>>54205699
It has, we call it pointer.
>>
File: rtrd.gif (480 KB, 493x342) Image search: [Google]
rtrd.gif
480 KB, 493x342
>>54205699
>C doesn't even have passing by reference
>>
>>54202719
Scalability.
>>
>>54205758
dereferencing the pointer passed to the function isn't the same thing as passing by reference
>>54205845
poo in loo
>>
>>54205699
Hmmm. Did you really write that?
>>
>>54205962
RETARD
>>
>>54205968
>>54205984
holy shit, /g/ is really pathetic. most retards here act like C is the only good language and they don't even know its basics
>>
>>54205962
>dereferencing the pointer passed to the function isn't the same thing as passing by reference
It literally is though - in fact that is how references are implemented under the hood in every c++ compiler.
>>
>>54205600
So what? Glib has classes too but it's a C library.
Thread replies: 63
Thread images: 3

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.