Navigation: /b/ - Random [Archive] | Search | [Home]
RandomArchive logo

C++ Thread NO POSTING HELLO WORLD SHIT FAGGOTS

The stories and information posted here are artistic works of fiction and falsehood.
Only a fool would take anything posted here as fact.

Thread replies: 258
Thread images: 19
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
>>
>>674490471
What are you talking about, this thread is awesome! Lot of people, different levels, and pretty much getting along
>>
>>674481979
are you talking to yourself
>>
>>674490947
Not really attacking anyone, just wanted to look like a script-kiddie

>TFW you actually dont know c++
>>
>>674491081
the code is from OP's image ...
>>
>>674490857
agree, and usually you can go around using variable/object references
>>
>>674485395
Using micro optimizations as a standard for all of the coding is a good practice though.
>>
var op = new Faggot();
>>
10 PRINT "FUCK"
20 GOTO 10
>>
>>674490254
I'll check in to those, thanks. I want to eventually do many things, some as hobbies and others for (hopefully) a career and other professional endeavors.

>>674490269
Not sure I'd call myself a good mathematician, but I really enjoy it and am motivated to learn more. That said CS is also really interesting to me, I'm just CA pleb when it comes to tech. I originally studied biology but ended up hating working in a lab. Now I'm wrapping up a math major and stats minor. I will be taking an introductory cs course in the fall for my major, but wanted to learn a language over the summer
>>
>>674490471
Don't forget std:: or the namespace. Or main's return type. Scrub.
>>
>>674491163
You see? Different levels! If you have dayjobs and that kindo of shit, i would try to learn from tge online course CS50. It isn't actually c++ but you will learn a lot about coding
>>
>>674491515
I'm sure he didn't forget.
>>
>>674490857
This whole post reads exactly like what people arguing for higher-level languages write. I think I'm done here, if you still don't see it, whatever. Good night anon.
>>
>>674491239
references aren't going to help when you need to keep track of large numbers of heap-created objects, and use them throughout your codebase. In cases like this you'll probably have some kind of factory doling out these objects to be used, and they need to be cleaned up when they aren't needed anymore

doing things like this without smart pointers is extremely error-prone and difficult. you'll either end up leaking resources because your manual reference counting has flaws, or the other worst case, you end up double-deleting an object and/or referencing an invalid object that was deleted elsewhere
>>
>>674490413
Negligible difference if there even is one really.

It's miles better to have managed pointers, raw pointers are just asking for a disaster, especially in larger programs.

For smaller things like coursework for a class at uni it's not too bad, but for everything else some kind of smart pointer is essential. (Especially if needed in the initialisation list in a constructor.)
>>
>>674491291
lolno

writing "optimized" code from the outset is a waste of time, and just makes the codebase harder to maintain. you optimize when you know you have an issue, not before
>>
>>674491795
Yes, at least shared_ptr avoids dangling pointers which is another nasty thing to deal if you lost track of it.
Also I already see some plp don't using pointers because "muh object will be deleted when its out of scope, that's what destructors are for, so I just let them be untill they reach the scope" so yeah...
>>
>>674491418
Than you are the perfect subject. I think your skill set is quite enough to take advantage of coding, as the other anon said it c and python are exelent choices, octave is freat too. One shouldn't exclude the other
>>
>>674491746
you make it seem like there's no valid reason to use C++, which couldn't be further from the truth

>hurr durr you should only use .NET or Java unless you're running on a super computing cluster
>>
>>674491746
If you can be sure you've not fucked up, lower level's are fine.

Pointers have the capacity to be so dangerous, smart pointers are worth the overhead like every single time. Coders are only human remember.
>>
File: berf.gif (33 KB, 300x100) Image search: [Google]
berf.gif
33 KB, 300x100
/thread/
>>
>>674490350
Thanks I was thinking about pursuing c over the summer. Been on /vr/ quite a bit lately and want to get into rom hacking. To my understanding, c is sort of like a portable assembly, so learning it first will set me up pretty well for that. I've also dabbled with bin / hex conversions and found that enjoyable, especially given some of the theorems I learned in algebraic structures. But like I said a pleb when it comes to actual tech and applying this sort of stuff
>>
>>674491990
It's worth keeping an eye on things, but yeah. Get it working first. Then fix as required.
>>
>>674492547
Once you've done C, you can try C++ too, it builds really well off it. Great language too, it's quite light too, it's not like Java which has a million things.
>>
File: java.jpg (26 KB, 499x327) Image search: [Google]
java.jpg
26 KB, 499x327
>>674477864
>>
>>674477864
I did, then moved to C++. Java's only good to have written on a CV.
>>
>>674492547
if rom hacking and low level stuff is your goal (and its awesome)stick with C untill you understands the memory and can implement more complex data structures like AVL-tree and a graph.
I think if you do that in less than 6 months you will be a good programmer..

If you want that I would like to suggest you some topics, learn the computer memory system, and the operational system aswell, virtual memory and pagination, understand how the memory works, what's under the hood, and you will rom hack everything, trust me on this one.
>>
>>674491381
underrated
>>
No lie I once interviewed a dude who told me that ++i was a decrementor.
>>
>>674493203
I hope he was just nervous and was mixing his terms up
>>
You->AreA(Faggot);
>>
>>674493203
How do you even manage that? It's got +'s in it for christ sake.
>>
>>674486654
>write once run everywhere
Pretty sure that's just about every language ever bro
>>
>>674493203
lol, what you told him? and please, share more stories
>>
>>674489750
I know
>>
>>674493324
you've never coded in your life, have you?

go write some non-trivial application to run on WIndows. Now go compile it on Linux and look at how many build errors you get. Unless you're using a framework specifically designed for it like Qt, you're going to have all kinds of defines and conditional includes to get things working on more than one platform
>>
>>674493324
Write once Compile anywhere is a thing.

Write once Run everywhere is really, really rare.
>>
>>674493203

OP here - interviewing unqualified people is cute the first few times but eventually it's just so fucking draining. That guy had jboss jcaps java j# all over his resume too.
>>
>>674477864
Java is like anal sex. It's great because it works with everything :^D
>>
>>674477517
Get your broke ass loop out of here, faggot.
>>
>>674478210
It's C99
>>
>>674491381
Mah BASIC Nigger right here
>>
>>674493649
Well sure, if you use a low level language like C++ to squeeze every bit of performance out of it you can. But you'd probably be developing it for nix because winblows/osx sucks. So your argument is pretty shit.

The fact that you're a Java fanboy indicates you've either haven't finished comp Sci or you haven't left the darkness of enterprise Java land. There are less terse, more portable and more performant languages out there that don't require the JVM.

That and docker kind of blows away the shitty Java argument of portability
>>
>>674494023
damn, I hate java and these jshit branchs.
When he told you about ++i you were able to not laugh or cry?
>>
>>674494552
>Java fanboy
where the fuck did you get that? I code C++ by profession, every day. And I use Qt so my shit builds on Windows and Linux 99% of the time with zero changes, once in awhile it requires some platform specific code, but it's fairly rare
>>
>>674494096
minecraf was writen in javascrip by the most inteligint progamer to ever live, notch

so its the best
>>
I'm working on a program that will destroy all of 4chan. Here's what I have so far:

#include <iostream>
void destroy_4chan(); // Destroy 4chan
int main()
{
std::cout<<"Destroying 4chan"<<<std::endl;
destroy_4chan();
return 0;
}

void destroy_4chan()
{
/* TODO: Figure out what to do here */
return;
}
>>
>>674494947
>I don't know the difference between java and javascript
>>
>>674492252
>>674492800
I will keep this in mind thnk you kind anons!

>>674493022
Awesome thank you! Took screen shot for future reference!
>>
File: 1436130603972.jpg (18 KB, 320x317) Image search: [Google]
1436130603972.jpg
18 KB, 320x317
#include <stdio.h>

char c[] = { 52, 33, 27, 21, 18, 4, 14, 12, 11, 9, 8 };
char d[] = { 0, 2, 0, 3, 3, 4, 7, 3, 4, 9, 4 };

int main()
{
int i, w;
for (i = 0; i < 11; i++)
{
w = i+2;
printf("%c", w*c[i] + d[i]);
}
}
>>
>>674495080
>I don't know what it's like to not have autism
>>
>>674494932
>I code C++ by profession, every day
You poor soul
>>
File: where.png (651 KB, 1067x800) Image search: [Google]
where.png
651 KB, 1067x800
>>674495312
>>
>>674494947
This motherfucker right here

Java != Javascript

I ain't even mad if you're just baiting
>>
>>674495359
it pays well and it's a very large, complex, and interesting project. If you've every written C++ with Qt, it makes it feel like a managed language, and actually usable, it's not bad. And their IDE is probably the best C++ IDE ever created
>>
>>674495163
More references then:
1)A good OS book is Operating System Concepts (2012) by Silberschatz, Galvin and Gagne. Also known as the "dinosaur book," due to the irrelevant dinosaurs gracing the covers of the book's many editions, this is a great introduction to OS design.

2)For Architecture / how the processor and CPU works (you will learn basic MIPS assembly here) so, get a copy of Hennessy and Patterson, a classic text, which uses MIPS throughout for its examples

Keep in mind I pointed 2 books for low level stuff, but from what you told me you like these so I hope they will help you, I love these 2 books so I hope they will turn to be useful for you :-)
>>
>>674495208
At that point, why even do line breaks?
>>
>>674495548
How can I into C++ sir. What should my daily regiment be and what reps am I to repeat until perfection?
>>
#include <stdio.h>
#define LEFT_BRACE {
#define RIGHT_BRACE }
#define LEFT_BRACKET [
#define RIGHT_BRACKET ]
#define LEFT_PARENTHESIS (
#define RIGHT_PARENTHESIS )
#define SEMICOLON ;
#define COMMA ,
#define EQUALS =
#define IS_EQUAL_TO ==
#define IS_NOT_EQUAL_TO !=
#define IS_LESS_THAN <
#define IS_GREATER_THAN >
#define IS_LESS_THAN_OR_EQUAL_TO <=
#define IS_GREATER_THAN_OR_EQUAL_T >=
#define MODULUS %
#define INCREMENT ++
#define DECREMENT --
#define AND &&
#define OR ||

int main LEFT_PARENTHESIS RIGHT_PARENTHESIS
LEFT_BRACE
int i SEMICOLON
for LEFT_PARENTHESIS i EQUALS 0 SEMICOLON i IS_LESS_THAN_OR_EQUAL_TO 100 SEMICOLON i INCREMENT RIGHT_PARENTHESIS
LEFT_BRACE
if LEFT_PARENTHESIS i MODULUS 3 IS_NOT_EQUAL_TO 0 AND i MODULUS 5 IS_NOT_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "%d" COMMA i RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 3 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Fizz" RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 5 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Buzz" RIGHT_PARENTHESIS SEMICOLON

printf LEFT_PARENTHESIS " " RIGHT_PARENTHESIS SEMICOLON
RIGHT_BRACE

printf LEFT_PARENTHESIS "\n" RIGHT_PARENTHESIS SEMICOLON
return 0 SEMICOLON
RIGHT_BRACE
>>
>>674496272
take this shit out of my view
>>
>>674496030
second this, had the same books for my OS and Architecture III courses in college
>>
>>674496255
go read Scott Meyer's books, Effective C++, More Effective C++, and there's a new one that covers C++11 and C++14

learn good coding practices, like smart pointers, forward declarations, pImpl (where appropriate), using const wherever possible, learning proper inheritance. you can spend years with C++ and still not know all the ins and outs of the language
>>
>>674495548
Hey C++ has its place, far sight better than Java. Hell it has better language specs than Java which is just fucking appalling for Oracle.

I can see it shrinking in importance though. As hardware gets better, the need for programmer memory management becomes less of a thing. And without memory management, you might as well use dot net or Golang. Orsomething functional because functional languages are fucking awesome
>>
>>674477142
C++ is detritus.
>>
void* a = malloc(4096);
a = NULL;
>>
>>674496699
thank you kind sir, all the best.
>>
>>674496736
well in my case, we need to interface with certain libraries, and hardware, and it would be a lot harder to do with a lot of managed languages. and in our case, performance is kind of a big deal because things need to happen near real-time, dealing with streamed data that can't really fall behind
>>
>>674497090
Now just put it in an infinite loop
>>
>>674496736
I doubt C++ will stop being highly used as hardware gets better so the need for even more powerful programs especially on simulations and gaming.
Also GPU is on high demand nowadays and you can't use java or some shitty tier to program on GPU.
The need for C/C++ will always be there, the problem is, to be good on C/C++ take years, so the jobs are not just "code monkeys" like a 5 month experienced java guy has
>>
>>674497090
>C++
>malloc

Goddammit anon...
>>
> why the fuck won't this.gif print?
>>
>>674497289
Nah, better to hide it in a function that gets called once a minute.
That guy trying to figure out where all the RAM went after 180 days of uptime will have fun finding it.
>>
>>674497509
#include <cstdlib> // :^)
>>
>>674497595
>180 days
uh, it will run out of memory a lot faster than that. a 32 bit process will typically have less than 2GB of RAM to actually use before it just segfaults because the allocations start failing
>>
>>674497509
#define std::string char[4096]
>>
>>674497908
>2016
>32 bit process
>>
>>674498047
yeah, no. you'll get endless compile errors from that

>std::string myString("this is a string");
>char[4096] myString("this is a string");
>>
>>674497161
CPU cycles are cheap /b/ro. Something like Haskell is probably best for performance intensive streams anyway
>>
>>674498101
>2016
>I didn't know even my browsers are still 32-bit processes
>>
>>674497908
>compiling for 32 bit
The service I found leaking like that on an infrastructure server had eaten 13.7 GB of RAM.
>>
File: triforce.png (4 KB, 244x289) Image search: [Google]
triforce.png
4 KB, 244x289
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
const int height = 16;
const int width = 31;
bool row1[width], row2[width];
memset(row1,0,width);
row1[width/2]=1;
bool* top = row1;
bool* bottom = row2;
bool* tmp;
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << (top[col] ? '*' : ' ');
bool left = col == 0 ? 0 : top[col-1];
bool right = col == width-1 ? 0 : top[col+1];
bool mid = top[col];
int count = (int)left + (int)right + (int)mid;
bottom[col] = (count == 2 && mid) || (count== 1 && !mid);
}
tmp = bottom; bottom = top; top = tmp;
cout<<endl;
}
return 0;
}
>>
>>674497908
It won't segfault, malloc will just return NULL, and the other parts of the program that depend on malloc should have error handling for when malloc fails.
>>
>>674497390
Like I said, it has its place. It's just going to become less relevant. Especially when you have game engines supporting lua (lumberyard) and C# (cryengine) etc, C++ is slowly fading. But I agree, it will still be needed for quite some time
>>
File: 1458154584026.jpg (169 KB, 569x571) Image search: [Google]
1458154584026.jpg
169 KB, 569x571
#include <iostream>
using namespace std;

int main ()
{
while (true)
{
cout << "OP is a cool guy\n";
}

system("PAUSE")
return 0;
}

visual studio fag here
>>
File: 64_BIT_BROWSER.jpg (389 KB, 1908x1080) Image search: [Google]
64_BIT_BROWSER.jpg
389 KB, 1908x1080
>>674498381
nice try
>>
>>674499024
forgot ; after system("PAUSE")
>>
>>674499136
why pause after an infinite loop?
>>
>>674499024
Needs more
#pragma comment(lib, "kernel32")
>>
>>674499305
He's using windows so in order to the terminal window to not close as soon as it finish runs the program you use system("pause") to freeze the window after finishing your program, pretty shitty , on c++ you use std::cin.get()
>>
>>674499305
ah, don't know if i need it or not, so used to using it because you need it for the cmd window to stay open on visual studio. I guess I don't need it if it's an inf loop
>>
>>674499539
infinite loop
>as soon as it finish
>>
File: bump.jpg (20 KB, 470x313) Image search: [Google]
bump.jpg
20 KB, 470x313
>>
>>674499705
ops
>>
>>674477142
Hello world
Thread replies: 258
Thread images: 19


Navigation: /b/ - Random [Archive] | Search | [Home]
Navigation: /b/ - Random [Archive] | Search | [Home]


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.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.