what's the difference between

template<typename T>
auto add1(const T& a, const T& b)
{ return a + b; }

and

template<typename T>
auto add2(T a, const T& b)
{ return a += b; }

?

@namark Lately I've been programming a front end in React and I have been converted to the glory of Javascript

Javascript is much better than C++....

@mew27 understandable, after all javascript is C for pussies...

1 + {} = "1[Object object]"

@namark @mew27

They're two different animals. C was developed for minicomputers that had teletypes and terminals connected to them. It was created so programmers didn't have to write everything in assembly language.

Javascript was written a couple decades later, shortly after the browser was invented, when personal computers were just beginning to become connected via the World Wide Web (WWW). They made Javascipt to run in the client browser so that web pages could be more interactive.

(But perhaps you just make the comparison so you could make the joke. :)

Follow

@Pat same philosophy, same quirky realization, same syntax, same primitives, same usage patterns... if you like one you'll like the other, sans prejudice.

@mew27

@namark @Pat @mew27 quirky realization? this is about C++, I believe. because it is, really, very quirky. but C was always consistent and have never had syntax sugar for pussies like C++.

@iron_bug to you any quirk of C is the word of god, so not sure what to argue here... just look up "quirks of C language"? Plenty of results.

Since we're doing arithmetic here suffice it to say:
unsigned short * unsigned short = insta-undefined-behavior-trollface

Also 2[a] is definitely syntax sugar for puppies only, I agree.

@Pat @mew27

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.