[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
C++ Thread NO POSTING HELLO WORLD SHIT FAGGOTS
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.
The stories and information posted here are artistic works of fiction and falsehood.
Only a fool would take anything posted here as fact.
You are currently reading a thread in /b/ - Random

Thread replies: 164
Thread images: 11
File: 12ju3.jpg (486 KB, 2880x1620) Image search: [Google]
12ju3.jpg
486 KB, 2880x1620
C++ Thread NO POSTING HELLO WORLD SHIT FAGGOTS
>>
>>674477142
Yep. Sure is a programming language.
>>
File: kz768tok3i.png (24 KB, 695x556) Image search: [Google]
kz768tok3i.png
24 KB, 695x556
#include <iostream.h>

main()
{
for(;;)
{
cout << "Hello World! ";
}}
>>
>>674477517
>what are namespaces
>>
> starts C++ thread
> posts picture of C code
>>
#include "stdio.h"

void _(int O, int _O, char _0) {
for (; O<_O; ++O) {
printf("%c\n",_0);
_0++;
}
}

int main() {
_('O','o','O');
return 0;
}
>>
Who /learningjava/ here?
>>
>>674477142
hello world shit faggots
>>
File: 1457643751807.jpg (68 KB, 664x441) Image search: [Google]
1457643751807.jpg
68 KB, 664x441
If I printed to screen in the past tense, then I Saw Out
>>
>>674477517
thats not even right idiot
>>
>>674477142
How hard is c++ after c#?
>>
>>674477142
What book did you use to learn C++?
>>
>>674478125
The Bible.
>>
>>674477722
C++ style comments though.
>>
>>674477142
#include <iostream>
using namespace std;
int main(){
for(int i=0;i < 100000;i++){
cout << "Hello World!" << endl;
}
return 0;
}
>>
>>674477722
Is it really? ha stupid picture.
>>
>>674477629
>using namespace go-fuck-yourself;
>>
>>674477864
I was.. a long time ago
>>
>>674478792
What happened?
>>
>>674477864
java a shit
>>
>>674479286
Write once ,work anywhere bruh
>>
double DoAdd( double op1, double op2 )
{
//TODO: return the sum of op1 and op2
}
>>
main(t) {
for (t=0; ; t++)
putchar(
t * ((
(t>>12)|(t>>8)
) & (
63 & (t>>4)
))
);
}

pipe the output to speaker as unsigned 8 bit mono PCM @ 8000 Hz

eg
./a.out | aplay
>>
static long long MakeNegative(long long x)
{
/* find out how long to make it */
/* BUG #42: add 2, not 1, to make room for the NUL terminator
* Fixed 2001-03-24
*/
int len = 2 + ceil(log(x)/log(10));
char *p = malloc(len);
sprintf(p, "%+lld", x);
p[0] ^= 0x06;
return atoq(p);
}
>>
cout << "Hello World";
>>
>>674479140
tried PHP, JavaScript, Python, Java, C, C++, C#, Ruby, Lua, OCaml, x86 assembly, Scheme, Haskell, Idris, Prolog, Scala, R, Coq, Erlang, Rust, Swift, Kotlin

they all suck, I'd say Scala & Rust suck the least
>>
def main():
print "Hello World"

if __name__ == "__main__":
main()
>>
>>674479975
if (s) {
/* Bug #9612: Customer 153 reported memory leak using MakeNegative method
* Fixed 2001-03-25
*/
int carry = 1;
int i;
u64 *j;
for (i=4, j=&out->d; i>0; i--, j--) {
// *j = MakeNegative(*j);
*j = ~*j;
if (carry) (*j)++;
carry = (*j)==0;
}
}
>>
static int IsNegative(float arg)
{
char*p = (char*) malloc(20);
sprintf(p, "%f", arg);
return p[0]=='-';
}
>>
>>674480269
python2.7 fag
>>
>>674480251
what the hell anon, 'tried' them all? obviously you dont have a problem to solve, you are just kicking tires.
>>
>>674480251

F# is best.
>>
Cout << Nigger << endl;
>>
>>674479975
>static
>not a member of an object
>not referencing a static object
the fuck are you doing?
>>
while (*dest++ = *src++);
>>
>>674481035
lol THOSE are the problems you saw in that code?
>>
>>674477142
Fuck your implicitly typed functions
>>
>>674477142
it's funny cause that's C, not really C++
>>
>>674477142
omfg
for (mpointer = 0; mpointer < 32768; mpointer++) space[mpointer] = 0;

are you in primary school or something?
memset(space, 0, sizeof(space));
>>
Program I wrote when I was just starting to learn c++. It's pretty bad but it does work lol. pastebin below.
2YqsWpEp
>>
>>674481979
also
>not using defines for hard-coded constants

and is that the actual implementation of brainfuck? or just someone's version of it?
>>
>>674482229
i sure hope it's the latter.
also is brainfuck easily crashable normally? like "<." isnt exactly safe in this code.
>>
main = putStrLn "Hello, World!"
>>
>>674478527
namespace and include namespace are two different things and using namespaces is a good thing you authistic fucking nigger faggot.

>>674477629
They are like scope where everything you define under a namespace needs it's name to be called, std:: is a namespace for standard components you use, but using namespace std; omit this, which is bad
>>
>>674479592
Yeah, all you need is just the interpreter. Fuck all the other languages that don't need it and that work without it anywhere, Java works EVERYWHERE, as long as you got the interpreter of course.

Dumbass.
>>
>>674479638
please can someone explain this before I try it?
>>
>people coding C++ like its C
>using malloc / memset and shit

Jesus Tits... that's not how you code EFFICIENT C++
>>
>>674482722
>include namespace
wut

also, stop blindly putting "using namespace std;" everywhere, every time you use something from the STL, especially in header files
>>
>>674479638
>a.out
what year is it?
>>
>>674483149
yeah my mistake, I meant "using namespace std;"
>>
>>674483016
ikr these niggers probably using outdated tutorials "how to be a hacker master and use c++" but nobody who uses c++ is retarded so they dont push bs skid shit like that so they click on old C tutorials and theyre like "MEMSET YOU GOT HACKED LET ME STDIO YOUR BUFFER INSIDE OUT"
>>
>>674477142
>using c++
OP are you underage?
>>
>>674482722
depends how efficient you want your program to be
>>
>>674482990
It's pretty awesome, try it, I just did!
>>
post yer fizzbuzz
also >>>/g/
>>
>>674483401
you sound Asian
>>
>>674481035
>>674481338
Are you two fucking autistic retards? static function is about link-time visibility, fucking dipshits.
>>
#include iostream
#include string

int main () {
x = 1;
std::string a = "ur a faget";
while (x > 0) {cout << a << "\n":}
}
>>
Int main(){
Srand(time(NULL));
Int life = rand()%2;
If (life){
Cout << "yours is a faliure";
}
Else{
Cout<<" just do it, kill your self";
}
Return 0;
}
>>
>>674480251
Didn't try Julia eh, stupid cunt.
>>
>>674483520
>>674483520

srry I pref the blue pill

I will only ever run this if I can confirm it's safe, so alas I must learn what the symbols mean :(
>>
<h1>Hello World</h1>
<p>OP is a faggot.</p>
>>
>>674480269
Whitespace, newfag
>>
>>674483487
If you want efficiency you can acquire it on little things like doing ++i instead i++. using iterators for stl containers, and parallelizing tasks using thrust library or going raw on cuda, namespaces are not relevant for efficiency
>>
>>674483724
you are retarded

the static keyword literally does nothing in C++ if the method or object you're using it with is not a member of a class/struct.
>>
>>674480527
I love you, little bastard.
>>
>>674483902
>If you want efficiency you can acquire it on little things like doing ++i instead i++
If you don't know what that does, and let me tell you it has nothing to do with efficiency, then you're retarded. Stop programming.
>>
>>674483579
fn main() {
let fizz = "foo";
let buzz = "bar";

// IF
println!("if_fizzbuzz()");
for x in 1..101 {
if_fizzbuzz(x, &fizz, &buzz);
}

// New Line
println!("");

// MATCH
println!("match_fizzbuzz()");
for x in 1..101 {
match_fizzbuzz(x, &fizz, &buzz);
}
}

// Fizzbuzz using If Conditions
fn if_fizzbuzz(x: u64, fizz: &str, buzz: &str) {
if x%3 == 0 {print!("{}", &fizz);}
if x%5 == 0 {print!("{}", &buzz);}
if x%3 != 0 && x%5 != 0 {print!("{}", x)}
println!("");
}

// Fizzbuzz using Match Conditions
fn match_fizzbuzz(x: u64, fizz: &str, buzz: &str) {
let mut print = String::new();

match(x%3, x%5) {
(0, 0) => {
print.push_str(&fizz);
print.push_str(&buzz);
},
(0, _) => print.push_str(&fizz),
(_, 0) => print.push_str(&buzz),
_ => print.push_str(&x.to_string())
}
println!("{}", print);
}
>>
>>674483401
Yeah, and using pointers instead std::shared_ptr and really going around memory leaks, but well, stl containers must be asking too much from them...
>>
>>674481151
World's slowest strcpy. Only dumb niggers think this is neat.
>>
>>674483875
http://www.cplusplus.com/doc/tutorial/operators/

Should give you a basic idea.
>>
>>674481598
Where do you see a function, nigger?
>>
>>674483902
>If you want efficiency you can acquire it on little things like doing ++i instead i++.
that has absolutely nothing to do with efficiency. both do different things, they are different operators. but in the context of iterating in a for loop, they're literally identical
>>
>>674484135
not to mention horribly insecure to use
>>
>>674484087
If you use shared_ptr everywhere, you might aswell switch to Python, nigger
>>
>>674484039
niggers don't know what C++ is over C, damn you are a fucking retarded monkey

the variable "i" is an instance of a C++ class so i++/++i call the ++ operator on that class, the operator++ for POSTFIX, uses a temp variable to store the data, unlike ++i,
So really, go fucking learn instead of being a retarded faggot

>>674484294
look my comment for the faggot above.
>>
>>674484687
>I don't know how to write good code
get the fuck out of here
>>
>>674477722
>>674482722
>>674483788
>>674484044
checked
>>
>>674484687
sure anon sure
>>
A real man coding

<!DOCTYPE html>
<html>
<body>
<button onclick="op()">OP</button>
<script>
function op() {
document.write("Hello World");
}
</script>
</body>
</html>
>>
Kill me please
I lost my iPod
>>
File: 1397320879911.jpg (26 KB, 446x336) Image search: [Google]
1397320879911.jpg
26 KB, 446x336
>>674483487
Excellent bait
>>
File: senpainoticedme.jpg (25 KB, 1280x720) Image search: [Google]
senpainoticedme.jpg
25 KB, 1280x720
// CheckEM.cs
using System;

public class CheckEM
{
public static int Main(string[] args)
{
Console.WriteLine("CheckEM!");
return 0;
}
}
>>
>>674483902
>acquire it on little things like doing ++i instead i++
I SWEAR TO GOD I SEE ONE MORE NIGGER MAKE THIS RETARDED STATEMENT I WILL PUBLICLY MURDER THEM AND GO TO JAIL FOR THE REST OF MY LIFE. WHY THE FUCK WOULD YOU THINK ONE IS FASTER THAN THE OTHER? EVER HEARD OF A THING CALLED POST AND PRE INCREMENT? PROBABLY NOT BECAUSE YOUR TINY PEANUT BRAIN THINKS THAT'S ACTUALLY AN OPTIMIZATION RATHER THAN AN ACTUAL FEATURE. RETARD. GO BACK TO THE BASICS AND GET YOUR FAILED MICRO-OPTIMIZATIONS (THAT DON'T MEAN SHIT ANYMORE IN 2016) OUT OF MY FUCKING FACE AND OUT OF THIS FUCKING WORLD. YOU MOTHER FUCKING CUNTS LEARN TO PROGRAM.
>>
>>674482990
plays music
pretty neat
>>
>>674483875
Dude, it's printing stuff and you redirect that to a music player. It can't do more than play music. Fucking niggers in here.
>>
>>674485001
Hey faggot:
>>674484764
>>
if(i=0;i<5;i++)
>>
>>674484764
> the operator++ for POSTFIX, uses a temp variable to store the data, unlike ++i,
no it doesn't you mongoloid, look at the fucking asm the compiler spits out

the ONLY difference is postfix returns the current value before an increment and prefix returns the value after the increment, it's just the ordering of the asm, neither is "faster" unless it's some specialized operator overload you've implemented that's expensive
>>
>>674484013
Being this retarded.

> static functions are functions that are only visible to other functions in the same file (more precisely the same translation unit).
>>
#include <iostream>
#include "Check.h"

using namespace std;

int main()
{
bool bored;
do{
cout << "Hello World!" << endl;
check_if(bored);
}while(!bored);
return 0;
}
>>
>>674485092
ARE YOU A FUCKING MONKEY OR WHAT? MICRO-OPTIMIZATIONS SUCH AS THAT DON'T MEAN SHIT ANYMORE. WHAT ARE YOU PROGRAMMING ON A NES CHIP? FUCK OUT OF HERE WITH YOUR STUPID BARBARIAN PROGRAMMING IDEALS AND GET WITH THE TIMES. UNLESS OF COURSE YOU'RE A POOR NIGGER WHO STILL USES AN AMIGA TO PROGRAM THEN GO RIGHT AHEAD AND USE THAT STUPID MICRO-OPTIMIZATION THAT STILL WON'T DO SHIT FOR YOU. I SWEAR THESE C PROGRAMMERS ARE GETTING MORE RETARDED THAN EVER WITH THE NEW GENERATION OF FAILED ABORTIONS COMING IN.
>>
>>674485001
ofc they mean, if you are programming for heavy shit like simulations using cuda and parallel programming where you use thousands of threads you want these "little optimizations" but not that you know what programming for these environments really are
>>
>failed abortions
>>
>>674485305
not in C++, go read the spec, that's not what that keyword means

if you only want it visible within a translation unit, put it in an anonymous namespace within the cpp file, the linker won't use it anywhere else, stop using static everywhere in C++ for this
>>
>>674485287
that's my point, since overloading operators when you are coding is very common
>>
>>674484847
> muh performance
> shared_ptr errwhere cause I can't handle managing memory
> muh performance
>>
>>674485709
>mention just shared_ptr
>thinks its "shared_ptr" everywhere
>being this retarded
go back to pascal
>>
>>674485693
you rarely overload increment and decrement unless you're writing iterators, and my point still stands for built-in types like ints

there is literally no performance of functional difference between these:
>for(int ii=0; ii<count; ii++) { }
and
>>for(int ii=0; ii<count; ++ii) { }
>>
>@echo false
>echo "hello world"
>end
Did I do that right?
>>
>>674485709
EXCEPT THAT IT'S NOT ABOUT PERFORMANCE BUT MORE EFFICIENCY AND BETTER "READABILITY". WHAT'S SO HARD TO GET ABOUT THAT YOU FUCKING DONKEY. YOU STILL STUCK IN THE YEAR 1995? ARE YOU PROGRAMMING ATARI GAMES RIGHT NOW? MEMORY MANAGEMENT MAKES YOU COOL OR SOMETHING? THERE'S NOTHING COOL ABOUT MANAGING EVERY BIT OF FUCKING MEMORY IN A PROGRAM YOU ROTTEN LOBSTER. THE WORLD DOESN'T NEED ASS-BACKWARD PROGRAMMERS LIKE YOU AND FRANKLY THE INDUSTRY ITSELF WOULD BE A BETTER PLACE IF YOU JUST JUMPED OFF A BRIDGE WITH A N ATARI CONTROLLER CABLE TIED AROUND YOUR PENCIL NECK.
>>
>>674485959
I agree with built-in, the compiler will optimize.
But I mean for your defined objects and since I program focused on iterators / templates because of my work field it does difference on performance.
>>
>>674485709
you are exactly the kind of programmer I would never hire or want to work with. you have this massive ego that you write perfect code with no errors, and shouldn't use smart pointers, or things like implicit sharing, and any "new" idea from the last 20 years that wasn't used in C in the 80's

fuck off
>>
>>674485539
Yes, even in C++. I read the spec for breakfast, nigger.

en.cppreference com/w/cpp/language/storage_duration
>>
>>674479286
I code both, and it really depends, but it definitely has a lot more applications than C++.
>>
Nobody here seems to care about fast and easy coding. If you guys think of creating efficient algorithms, than you should learn discrete mathematics and logic. Programming is already slow as it is, don't make your lifea shitier.
>>
>>674482775
>not having a java interpreter.

It basically is write once run everywhere

Dumbass.
>>
>>674486440
Yeah apparently I can code Java on 3 billion devices, including my coffee maker, my toaster, and my vibrating dildo. Last night I wrote an application for my dildo that made it vibrate twice as hard which made me cum four times in a row. But for that work I had to install an interpreter up my ass so Java could work because if I hadn't the compiler told me to go fuck myself.
>>
>>674486385
you didn't even read your own fucking reference you fucking retard

>The static specifier is only allowed in the declarations of objects
WITHIN OBJECTS, it says it right there

an anonymous function or object marked static literally means nothing, stop doing it

such as these:
>static const std::string MY_STR("SomeValue");

>static int makeValue(int input){ return 0; }
>>
>>674486518
that's why theres computer science and information systems, the later is for lazy dumb programmers
>>
>>674486218
No. What I'm saying is that if one advocates using reference-counted pointers everywhere (read the OP), one might want to reconsider language choice.

I'm not advocating not using shared_ptr. I'm constantly using C++11 and some 14 features, actually.
>>
File: Oh_Really.jpg (60 KB, 555x435) Image search: [Google]
Oh_Really.jpg
60 KB, 555x435
>>674486156
>>
>>674486156
Exactly, and that's why there's nothing cool about still writing in C++. You cunt are making my point for me!
>>
>>674486891
that makes no sense. if you're using good coding practices, you should move to another language, that might not be fit for what you chose C++ for in the first place
>>
>>674485959
> Using `ii`
>>
I knew /b/ was a bunch of CS edge lords
>>
>>674479286
Java a job.
>>
>>674486820
Still, as an computer engineer student i think the abc of software is easy. The hard part is dealing with such subjects. For programmers i strongly advise for them to seek building and solving complete software rather than persuing the small and efficient solutions
>>
>>674487189
>not using "ii" or "jj" or "kk"
I hate using single "i" 's as loop iterators
>>
File: 1457932199814.jpg (127 KB, 577x564) Image search: [Google]
1457932199814.jpg
127 KB, 577x564
>>674487251
Codemonkey job maybe
>>
>>674486809
LOL are you fucking kidding me?? Can't you finish reading a single sentence because you got all excited that you were right? You aren't. Here's the full sentence for you

> The static specifier is only allowed in the declarations of objects (...), declarations of functions (...), and declarations of anonymous unions.

And further down:

> Any of the following names declared at namespace scope have internal linkage
variables, functions, or function templates declared static

Now please do yourself a favor and stop believing you know C++. You clearly don't.
>>
>>674487364
Well, programming is a really extensive field, you have commercial and it-solutions-blabla where performance isn't really an issue and you have scientific research fields where every O(log n) optimization does matter a lot.

You will find very difficult to do one thing while on a course that does not focus on that.
>>
File: danny devito.jpg (54 KB, 612x612) Image search: [Google]
danny devito.jpg
54 KB, 612x612
rollen
>>
>>674487148
If "good coding practices" are basically "avoid language's features at all cost and use library X everywhere instead", then yes, that language has failed.
>>
do you guys know how to use && ? which cases I want to use it?
>>
File: 1448339367539.jpg (9 KB, 544x240) Image search: [Google]
1448339367539.jpg
9 KB, 544x240
>>674487369
>>
>>674487369
why?
>>
>>674487591
it's unnecessary when used in anonymous namespaces, it will already have internal linkage, there's no way the linker will use that reference anywhere else in your code even if they're named the same

and a static non-member function in C++ means absolutely nothing
>>
>>674477142
hello world. i used to fuck all ur moms.
she'd come over sometimes while her boyfriend was away after school.

once the door would close she'd almost instantly get naked. most times she'd put on her favorite song and start sucking. then she would cry. her tears and makeup would drip down her face onto my dick. its surprising how cold tears are. eventually i finally asked her what was wrong. in between licks she told me that her favorite song was also her bfs favorite song. so even though she loved hearing it and it totally got her pussy wet, it also made her think about the fact that she was cheating on her boyfriend. i dont think i ever came harder down somebodies throat then right after she told me that. she was beautiful. we dont hang out anymore. wanna get lunch?


this was the song:

https://www.youtube.com/watch?v=2tgwFpMA61c
>>
I'm having some trouble learning this language, c++. Any tips for the beginners out there?
>>
File: flat,800x800,075,t.u5.jpg (106 KB, 800x800) Image search: [Google]
flat,800x800,075,t.u5.jpg
106 KB, 800x800
include <your mom>

int main(){

OP neck_beard;

if(neck_beard.isAFaggot(){

std::cout << "FAGGOT"<<std::endl;
}

return 0;
}
>>
>>674487990
how is using smart pointers avoiding language features? they're part of the fucking STL and C++ standard
>>
>>674488198
Start with c
>>
>>674477142
GO > C++
>>
>>674488301
no fuck that I need real life advice man.
>>
>>674488172
Dude I just showed you exactly what a static non-member function means, I gave you the link and then quoted the part for you. How stubborn are you?
>>
>>674488198
Just talk to your computer abstractly, tell it how to send electrons through the gates to the desired location in memory
>>
>>674488198
Pluralsight
>>
>>674488423
no really start with C it builds upon what c++ is with the STL stuff
>>
>>674488055
because it's less clear to read to me when you have a single character, especially i, scattered within a for loop

> object.at(i); object[i];
are less clear to mean than
> object.at(ii);; object[ii];

personal preference
>>
>>674486820
is Information Systems that bad?
>not 4 me m8 my buddy is doing that major
>>
File: 1456546089828.png (215 KB, 640x464) Image search: [Google]
1456546089828.png
215 KB, 640x464
>>674488423
Fine stay pleb then
>>
>>674487038
YOU FUCKING DONKEY OF A THIRD DEGREE. USING ANY LANGUAGE IS NOT COOL. THERE'S NO SUCH THING AS A COOL PROGRAMMER. WE'RE ALL FUCKING LOSERS, BUT AT LEAST SOME OF US AREN'T IN DENIAL LIKE YOURSELF. "BUT USE PYTHON ITS EASIER" YEAH USE A LANGUAGE THAT TOOK THREE POPULAR SYNTAXES, THREW THEM IN A BLENDER, TAKE THAT OUTPUT AND GIVE IT TO A MONKEY TO WIPE ITS ASS WITH IT THEN GIVE THE DIRTY ASS SMELLING THING THE NAME OF A FUCKING SNAKE. YEAH ABSOLUTELY LET ME GO USE IT RIGHT NOW. EXCEPT I WON'T BECAUSE ANYONE WITH A BRAIN THE SIZE OF A MOLECULE CAN UNDERSTAND THE BASICS OF ALL THESE "HARD" LANGUAGES THAT YOU COMPLAIN ARE "SO HARD TO USE". GO PROGRAM IN VISUAL BASIC OR SOMETHING STOP WASTING EVERYBODY'S TIME YOU CHILD OF THE HIGH KING OF MONKEY VILLAGE.
>>
>>674488285
DO NOT USE RAW POINTERS, EVER. USE vector, shared_ptr, auto_ptr (oh no, that was a mistake, better unique_ptr). Yeah right.
DO NOT USE FUNCTIONS, USE FUNCTORS.
>>
>>674487705
Yes. For being such an extensive field there is not much gain in trying to master it all. Especially in the short term. I once helped the physics department in a simulation of atomic clouds (though it soind awesome, i didn't do much besides looking) and yes, the care they have to optimize everything is amazing
>>
>>674488301
don't do that, there's no reason to unless you're going to be a Linux kernel dev
>>
cout << "meowwww! << endl;
>>
>>674488670
Do you feel better now? Was it really worth it?
>>
>>674488670
I think you're a student and have never worked on a real-world large C++ code-base.
>>
>>674488562
Like I said, it depends on the work field you are aiming, Information Systems (at least in my country) focuses on business and techonology in general, they don't care why heapsort is better than bubblesort or how I'm able to span threads efficiently.

They focus on business solutions and such, the problem is when people with this knowledge think coding is just what they saw on the course and don't know optimization exists and think they are worthless and too hard to understand for example, to do a good program without memory leaks one must understand how the memory works internally
>>
>>674488691
I don't even understand what you're arguing anymore. smart pointers are good, and you should use them everywhere. you should always use objects to manage resources unless you have a good fucking reason not to
>>
>>674488738
yes, at these places we want to use ++i instead i++ for your custom objects because every little efficiency matters.
I'm currently working with fluid simulation, like air or blood, you spam literally millions of threads, if you don't code optimizing everything your pc will explode
>>
Computers and programming have a wide range of applications, such as counting money for business men, and various digital dancing simulations.
>>
>>674489134
> smart pointers are good, and you should use them everywhere
> use them everywhere
> everywhere
This is exactly what I'm arguing against. Use them where it makes sense. Or, if you literally use them everywhere, embrace it and go for a language which makes this behaviour a default, not tacked on.

> you should always use objects
OOP is not the magic solution to everything that you should always use.
>>
>>674489376
right, but don't mindlessly do micro-optimizations, especially if it makes the code harder to read and maintain. you should only ever be doing it after it all actually works, and you've profiled it to prove there's a real performance hit that matters. then if you must. optimize where you need to, and add comments explaining why this horrible block of code is written the way it is
>>
>>674489431
hey this is fun!
>>
>>674489376
I know a fair amount of math but have never coded anything in my life. I fear I will get bored doing babby exercises if I choose the wrong language to learn first. Any suggestions for a first one? Preferably one that let's me start using all of the cool math I've learned early on
>>
>>674489548
>This is exactly what I'm arguing against. Use them where it makes sense. Or, if you literally use them everywhere, embrace it and go for a language which makes this behaviour a default, not tacked on.
if you're using C++, you probably have a good reason for it, why would you jump ship to something much slower, or ill-fitting just because you're using smart pointers?

besides your personal hangups against smart pointers, why would you NOT happily use them everywhere?
>>
>>674489858
practically any language will let you do math, what do you actually want to learn or accomplish?

if you want to just do the math with minimal coding you could use something like NumPy in Python that's made for things like that
>>
>>674489858
You are absolutely right about being bored, yet, if you are a good mathematician you SHOULD definitely give it a try. After the first steps it starts to actually be fun, that is if you are only learning
>>
>>674489858
Math? you could aim for matlab or octave, there are lots of nice stuff you can do with them, python too, they have a math and linear algebra library that's awesome, but C++ is your goal for performance and math, but it's a harder language for beginners, learn the basics , play with python and C for example and later on go to C++. Don't rush things

>>674489713
Yes, only where it matters and for sure I maintain my code to be as readable to the next guy as it is to me, comment everything that's worth and make things simpler like using "auto" instead the huge iterator type name
>>
>>674490064
Only good reasons for C++ are, imo:

1. performance. shared_ptr ruin performance
2. legacy. you're fucked anyways

Any other reasons I'm missing?
>>
#include <iostream>

main()
{
cout<<"Fuck u op"<<endl;
}
>>
>>674490413
if smart pointers ruins your performance, either you're doing it wrong, or have a specific use case where raw pointers actually make a difference, in which case you have to make damn sure you're being careful with allocations and deletions

in 99.9999% of cases, the small overhead of the reference counting more than makes up for the performance hit you likely will never notice without profiling
Thread replies: 164
Thread images: 11

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.