[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++ > java You can't prove me wrong
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: 79
Thread images: 9
File: pNqP8a2.jpg (79 KB, 1280x720) Image search: [Google]
pNqP8a2.jpg
79 KB, 1280x720
C++ > java

You can't prove me wrong
>>
>>54021391
Apples > Orange

You can't prove me wrong
>>
2D > 3D

You can't prove me wrong
>>
>>54021391
You are right, we can't and we don't want to.
>>
>>54021407
Oranges aren't built on top of Apples
>>
>>54021391
Second best girl is always right.
>>
>>54021391

java > c++ when you're trying to debug large software projects?
>>
File: 1459818636447.jpg (132 KB, 744x1052) Image search: [Google]
1459818636447.jpg
132 KB, 744x1052
>>54021422
That's a God Given fact
>>
>>54021391
I cannot. Have a good day.
>>
File: solargaysistem.gif (2 MB, 400x354) Image search: [Google]
solargaysistem.gif
2 MB, 400x354
>>54021391
Why would I ?
Never interrupt your enemy when he is making a mistake...
>>
>>54021391
Java > Javascript

Prove me wrong epic lulz totally valid comparison here.
>>
Today: a thread entirely made of facts
>>
>>54021730
I did debugging large software project in C++. No problem with it. Most programmers who are saying that java is better are dumb idiots who just belong to java, because if language doesn't force them to have at least the tiniest bit of some standard of their code, they have none.
>>
>>54021391
Pointers.
Goto statements.
>>
File: 1406702991227.png (99 KB, 660x557) Image search: [Google]
1406702991227.png
99 KB, 660x557
C++ is the only language recognized by g. Javascript, Java, ruby, c#, etc. etc., are all baby languages and will never earn you respect no matter how much money companies might throw at you to program in them. Working in teams is for normalfags. Choosing the right language for implementing features or meeting time constraints for customers is for cucks. Working on the frontend is for clowns. People who make mobile apps aren't real programmers. If you can't create a 100,000+ line C++ program for something like real time AI, you are nothing.

>inb4 frontend "engineers" argue with me
>>
>>54022143
Why are gotos bad?
Why are pointers bad?
>>
>>54022225
you're actually wrong. The unique languages recognized here are :
ASM, C, lisp, haskel
Anything else is shit and you know it
>>
>>54022225
Meanwhile, you're doing nothing. Neat. Or should I say NEET?
>>
>>54022315
>Why are pointers bad?
they aren't
>Why are gotos bad?
tricky question
https://en.wikipedia.org/wiki/Goto#Criticism
make your own idea
>>
>>54022338
frontend engineer detected
>>
>>54022315
>Why are gotos bad?
Don't use them.
Just don't.
>>
>>54022225
>will never earn you respect no matter how much money companies might throw at you to program in them.
I'll take a ton of money over respect.
>Working in teams is for normalfags.
And the opposite of normalfag is a robot, right? Yeah it's definitely my ambition in life to be a robot.
>Choosing the right language for implementing features or meeting time constraints for customers is for cucks.
Bait?
>Working on the frontend is for clowns.
No, it's for women.
>People who make mobile apps aren't real programmers.
They are software engineers.
>If you can't create a 100,000+ line C++ program for something like real time AI, you are nothing.
No, it means we're too busy with life/work/family/friends. If I had to do it at work, I would.
>>
File: 1458479751369.png (170 KB, 930x436) Image search: [Google]
1458479751369.png
170 KB, 930x436
>>54021391
http://yosefk.com/c++fqa/
C++ is a mess. Java is for getting things done. Use C for some really performance critical small programs, but Java is fast enough in 99,99% of cases and much faster to write in and easier to maintain .
https://benchmarksgame.alioth.debian.org/u64q/java.html
>>
>>54022433
Not even close, but nice rhetoric.
>>
>>54022520
>but Java is fast enough in 99,99% of cases
"Stands still and does nothing because the garbage collector kicked in" is not "fast enough" for even 50% of all cases, unless you hate usability.
>>
>>54022554
What the fuck when does the garbage collector randomly decide to "kick in"?
>>
File: go-language-logo.png (26 KB, 480x270) Image search: [Google]
go-language-logo.png
26 KB, 480x270
>>54021391
Golang > everything else

You can't prove me wrong
>>
>>54022518
>writing a serious reply to that
>>
File: 1460153505440.jpg (16 KB, 600x600) Image search: [Google]
1460153505440.jpg
16 KB, 600x600
>>54021391
>>
File: 1460288439869.png (12 KB, 246x200) Image search: [Google]
1460288439869.png
12 KB, 246x200
>>54022520
>99.99%
top kek

>>54022577
why are you shilling java if you don't even know how it works m8
>>
>>54022617
A-fucking-men.
>>
>>54022554
>Stands still and does nothing because the garbage collector kicked in
bullshit. noticeable garbage collection lags are a myth. enjoy reinventing GC everyday in C++
>>
C++ is a mess but it's better for certain things. I wouldn't bother using it for most uses
>>
>>54022342
>>54022500
I consider myself a somewhat skilled programmer. I know goto criticism. I know why gotos are considered bad. I just disagree with idiots who blindly follow the rules made by other programers without deep understanding of the problem. It's like bashing singletons. You can cite others whatever you like, but if you don't understand the problem, you're just like the guys who use it.

And no, I don't really use gotos, but if I had a situation where goto would make things much clearer, or if I were generating a code(e.g. writing macros in Lisp), I wouldn't think twice.
>>
At least Java has a consistent syntax. C++ is a clusterfuck.
MyClass a(args)
MyClass* b = MyClass(args)

Both do the same thing, *b is equal to a in value, but for some reason C++ kept the standard int a = 2 syntax for pointer that it got from C and everyone has used for ages, while initializing variables is done by int a(2) which is retarded and adds nothing. It's breaking a standard for no reason.
>>
Java is objectively better for MOST purposes, C++'s only advantage is literally speed and that only matters with video games today.
So yes, if you want to be le game dev then C++ is better. Java is better for everyone else who wants to create useful and productive applications.
>>
>>54022795
Why do you use the word 'literally' in a context where it's not only wrong, but if it was right it would be irrelevant? Are you a little girl who needs big words to add emphasis to her tumblr posts?

>speed only matters for games
Christ.
>>
>>54022784
You just don't know C++ m8. Did you even try to compile this shit you've just dropped? They don't do the same thing, they don't take the same time, they don't result in the same thing, *b _might_ be equal to a in value, but you don't know it from this code. C++ is sometimes messy, but for completely different reasons, retard.
>>
>>54021422
You can't make 2D cum
Sex with another intelligent being is just as enjoyable for me as it is for them because I get off by getting them off.

Do you know what that's like?
>>
>>54022784
>Both do the same thing
They don't.

a is an object that is limited to the current scope, whereas b is allocated and exists outside the scope.
>>
>>54022795
"So I've wrote this web browser in Java, it takes 20s to start up and gc runs for like 5s every two minutes, but hey, at least it's a productive and useful application that no one would write in C++ because it's impossibru".
>>
>>54022850
"So I've wrote this web browser in Java, it takes 20s to start up and gc runs for like 5s every two minutes, but hey, at least it's a productive and useful application that no one would write in C++ because it's impossibru".
-Nobody Ever

ftfy
>>
>>54022870
thx m8
>>
>>54022870
>So saw made this game that requires about ten times as many resources as it should and everyone loves it and the garbage collector occasionally kills the player
>gotta replicate that
>>
>>54022895
Why are you writing a game in Java? That's literally the only situation where C++ has a meaningful advantage.
>>
>>54022795
I used to be very proficient with Java 2 10 years ago.

Has Java changed a lot during that time?

What's the best new feature that Java introduced during the last 10 years?

C# is dead, right? Java is still the OOP King and rightfully so.
>>
>>54022922
Notch did and now there's a bunch of fucknuts who think it's an okay thing to do.
>>
>>54022821
>*b _might_ be equal to a in value, but you don't know it from this code.
The only difference will be if the constructor isn't functional and for fuck's sake, that's outside the scope of my point. I'm just arguing as to why the syntax for constructor calls has to be different depending on the cast.

>>54022843
a and b are not the same thing, sure, but other than that they're both calls to the constructor. One just adds a pointer cast.
My only point is, why couldn't variables use constructor calls with the same syntax? Why change it?
MyClass a = MyClass(args)
MyClass* b = &(new MyClass(args))

There, same syntax. Why can't we have this?
>>
>>54022940
Are any of them replies to this thread?
>>
>>54022959
Meant to write
MyClass a = new MyClass(args)
MyClass* b = &(new MyClass(args))
>>
Java is actually faster than C++ with the Run-time type identification, which is used in most non-toy C++ projects
>>
>>54022959
>My only point is, why couldn't variables use constructor calls with the same syntax? Why change it?
They can.

int a(2); // this is valid C++


As for
MyClass a = MyClass(args);

The problem with this is how would you distinguish a constructor from the assignment constructor?

Both are important in implementing RAII features such as smart pointers.
>>
>>54022937
>Has Java changed a lot during that time?
a lot
>What's the best new feature that Java introduced during the last 10 years?
FP stuff like higher order functions, map reduce etc
>>
>>54022997
>The problem with this is how would you distinguish a constructor from the assignment constructor?
I have no idea what's the difference between a constructor and an assignment constructor.
So can I do
MyClass a = MyClass(args);

and if I can, what sort of constructor am I using?
>>
>>54023061
>I have no idea what's the difference between a constructor and an assignment constructor.
The constructor is what is called when you do this:
MyClass a(args);
new MyClass(args);


The assignment constructor is called when you do this:
MyClass b = a;


>and if I can, what sort of constructor am I using?
It's not valid syntax, but if it was then it would go like this:

You're first constructing an anonymous MyClass instance, then you're calling a's assignment constructor and then destroying the original anonymous object. In the worst case scenario when the compiler is unable to optimise, you end up calling three functions where you should just call one.
>>
>>54022959
What the fuck is this abomination? Not only does it make little sense, but you need to write more just to achieve the same thing. Additional mental overhead for some shady reason is not an argument.

And if you don't see that b is of type MyClass*, a is of type MyClass, a = MyClass() allocates on stack, new MyClass() allocates on heap, and that you're leaking because there's no delete on sight whereas a will get destructed automatically when it gets out of scope, then it's perfectly allright.

Anyway, here's some better code for the comparison:

MyClass a(arg1, arg2);
MyClass* b = new MyClass(arg1, arg2);
/*...*/
delete b;

Or, better yet:

http://ideone.com/EPWY3t
>>
>>54021391
Money from java > regular salary > money from c++
>>
>>54023108
Consistent syntax isn't a shady reason.

>>54023103
Ok, got it, the constructor on the right of the = gets called, that anonymous object's value gets assigned and then the anonymous object gets removed.
But for example, right now I have this:
Node *node;
if (node->ID == -1) {
*node = Node(nodeID);
}

Is there a way to immediately assign the value from a constructor for a pointer to a class object? Something like
Node *node;
if (node->ID == -1) {
(*node)(nodeID);
}

This doesn't compile.
>>
>>54023178
Isn't node->ID uninitialised?

Anyways...
>*node = Node(nodeID)
Well, this is calling the copy constructor.

I don't know why you'd do this, you could just do this instead:
Node* node = nullptr; // or NULL if you're using an old C++
if (somecondition) {
node = new Node(nodeID);
}
>>
>>54023178
It is. I'd much prefer a language with "inconsistent syntax", then a language where I have to type out a fucking poem before doing anything, because I have to be "consistent".

Plus, what is the point of the discussion when you clearly lack the basics of C and C++?

>>54023103
There's no such thing as an assignment constructor. You've got ctor, copy ctor, move ctor, assignment operator, move assignment operator, dtor. What you call assignment ctor is copy ctor:

http://ideone.com/EPWY3t
>>
>>54023217
>Isn't node->ID uninitialised?
No, it's in a vector and I needed an initialization value that wasn't NULL, and 0 wouldn't work.
>node = new Node(nodeID);
Doesn't this have the same problem you mentioned before? Creates an anonymous object, assigns through copy, deleted anonymous object?
Also thanks for your time.

>>54023233
I'm sorry you consider the word "new" too long.
>>
>>54023233
>There's no such thing as an assignment constructor.
I meant assignment operator.
>>
>>54023263
Then you're wrong, copy constructor is called in this context.
>>
>>54023258
>No, it's in a vector and I needed an initialization value that wasn't NULL, and 0 wouldn't work.
In your example it was though.

>Doesn't this have the same problem you mentioned before? Creates an anonymous object, assigns through copy, deleted anonymous object?
No, because node is a pointer. You're only assigning the pointer, not copying the object.

But post the entire code.
>>
>>54023258
I'm not talking about the word new, but some &() strange thing you proposed. Moreover, new serves different purpose in Java than C++, and that's the point you're missing. Did you learn C++? There's huge difference between internals and you seem to ignore it.
>>
>>54023293
>some &() strange thing you proposed
Right, I'm the one who doesn't grasp C.

>>54023289
>No, because node is a pointer.
Oh right, pointer assignment doesn't copy.
>But post the entire code.
It's 200 lines long and I have to go, can't summarise. You've helped a lot btw.
>>
>>54023272
Yeah, you're correct.

I was a bit too quick.
>>
>>54023325
Let's get one thing straight.
* is a dereference operator, it gets you the value under the adress.
& is reference operator, it gets you the address of the variable.

Now let's look at your code and see if types match(since you can't assign variables that don't match types):

MyClass* b : this has a type of MyClass*
new MyClass() -> this has a type of MyClass*
&(MyClass*) = MyClass**

Now how the fuck does MyClass* == MyClass**?

Not to mention that "new MyClass" isn't even lvalue.
>>
Java is pretty sweet if you follow good code writing guidelines and don't use fucking factory design patterns.

Kotlin is definitely better though, and it 100% interoperable with Java. Learn it, it was created by the guys behind IntelliJ, the best fucking Java IDE ever.
>>
>>54023347
I was surprised too when I first discovered it.
>>
>>54023447
Well, it's not my first time though.

I haven't programmed C++ in almost one and a half year now and the different constructors was the first thing to go out of memory. But yeah, maybe it's time to read my Scott Meyers books again.
>>
File: cpp_vs_java_diagram.png (21 KB, 800x600) Image search: [Google]
cpp_vs_java_diagram.png
21 KB, 800x600
>>54022850
>"So I've wrote this web browser in Java, it takes 20s to start up and gc runs for like 5s every two minutes, but hey, at least it's a productive and useful application that no one would write in C++ because it's impossibru".
retard
http://blog.cfelde.com/2010/06/c-vs-java-performance/
and java has been heavily optimized since then
>>
>>54023471
>>54023447
But anyways, cheers for correcting me.
>>
>>54023431
+1 for Kotlin, just for the fact I don't have to end every statement with a damn ;.
>>
>>54023482
np, I also haven't touched C++ for over half a year now. The knowledge tries to escape.
>>
>>54022116

This isn't even close to correct.
>>
>>54023431

IntelliJ skates on its reputation from ten years ago when Eclipse was a mess.

They're pretty neck and neck now
>>
>>54022775
goto userRegistration;)
>>
>>54022617
>You can't prove me wrong
interface{}
Thread replies: 79
Thread images: 9

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.