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

Swift 3 removes ++ and --

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 73
Thread images: 4

File: Liam-Neeson[1].gif (2MB, 384x172px) Image search: [Google]
Liam-Neeson[1].gif
2MB, 384x172px
Apple's excuses:

>These operators increase the burden to learn Swift as a first programming language - or any other case where you don't already know these operators from a different language.

>Their expressive advantage is minimal - x++ is not much shorter than x += 1.
>>
>>58000360
these guys are fucking retarded++
>>
That's exactly why they're not in Python either.
>>
File: 1476582955822.png (203KB, 528x528px) Image search: [Google]
1476582955822.png
203KB, 528x528px
>not doing
x = x + 1;
>>
>>58000360
> what the fuck is x plus equals 1 supposed to mean! THATS NOT ENGLISH!

>I demand you change it to x = x + 1
>>
>>58000377
according to swift 3, retarded += 1
>>
>>58000360
To be honest, it's a bad operation that allows two assignments at once.
>>
x=1 wouldn't make any intuitive sense to me at all either, I don't understand the change desu
>>
>>58000736
x+= rather
>>
>>58000360

++ and -- (prefix or postfix) are stupid operators.

The only reason they exist is to allow retardedly 'clever' code in C.

while (*source)
*dest++ = *source++;


That doesn't offer any advantage over:

while (*source)
{
*dest = *source;
source += 1;
dest += 1;
}


And, generally speaking, I much prefer to run across the latter in software I take over.

And when it comes to C++ and objects, the postfix operators mean you have to create a fucking duplicate of the object to return. Horrible idea.
>>
>>58000377
It should be
>++these guys are fucking retarded
>>
>>58000805
I'm mentally challenged: the post.
>>
>>58000447
How is that better than x++
>>
>>58000360
jokes on you, why da actual fuck waste time a programming language by apple of all tech coprs??????

alright it must be to develop ios programs for the cash burning apple crowd, cant you develop native programs for ios directly on C or something?
>>
>>58000805
are u dum or somthing
>>
>>58000435
Python designers are retarded.>>58000435
>>
>>58001523
>>58001592

When you kids grow up, you'll realize that clever code is virtually useless.

The single most important thing in writing software is correctness. The next most important things are READABILITY and MAINTAINABILITY.

Cleverness works against READABILITY and MAINTAINABILITY.

Did I think "*dest++ = *source++" was neat when I was 17? Yes. Do I think it's neat now? No. It's a waste of company time.
>>
>>58001643
>*dest++ = *source++
The non readbility does not come from ++, it came from mixing postfix and prefix operators.
>>
>>58001643
What is it with you and "clever code"?
incrementing something as i++ is no "clever" and people who increment as such don't think it's clever
>>
>>58001700
>incrementing something as i++ is no "clever"

You are an idiot. "*dest++ = *source++;" contains an assignment, two dereferences, two copies, and two increments. All on one line.

That is a bad idea in production code. And for what? More compact code.

Compressing more operations into the same space makes code harder to maintain. This isn't some, "oh programmers have a hard time reading that" issue. This is "over the course of a decade, tens or hundreds of pairs of eyeballs will scan that line, and the 'clever' version will slow those eyeballs down, and set off a series of events resulting in a bug 1% of the time".

If you want to be a professional software engineer, you'd better start thinking about long-term scale, rather than /g/'s try-hard "oh so 1337" approach to life.
>>
> Two smart people and 10 dumb kids.
Stay good /g/
>>
swift is a yuppie numale language, so there's no reason to care
>>
>>58000467
>x = x + 1 // -x
>0 = 1
bravo programmers
it doesn't make sense
I demand every operator to make sense in simple mathematics
>>
>>58001591
it would be extremely painful
>>
Why is += and not =+?
>>
>>58002508
Because if you combine minus sign and equal sign, you get =-.
Whart kind of this expression would be?
a=-5;
>>
>>58000447
Lua doesn't have +=. That's the main thing I dislike about it. I can understand not including ++ though.
>>
>>58001658
+=1 is literally one more character. If you don't need the post and prefix behaviors why bother including ++ at all?
>>
>>58000805
it's even worse than that.

it's because to C people this strcpy is like the deepest and most elegant thing ever:
while (*dst++ = *src++);


Array decay, in-band C string termination (or overflowing!), and post-increment/decrement go hand in hand.

Preincrement/decrement is a fundamentally more efficient operator (compiler optimizations aside) since there's no implicit mandatory copy, but postfix unary operators generally lead to better readability by facilitating operation chains without parentheses forests.
>>
Say what you want. I find the ++ much clearer when trying to understand what's going on in the code.
Yes, there's more stuff going on in one line, but it's as easily understandable as another single line.
Personal preference, I guess. Or just years getting used to it.

So the only real argument remaining is that learning it is extra burden of knowledge.
And whether it's that much of a deal is down to Swift devs.
>>
>>58002621
Why not? i++ is one of the oldest meme in coding.

By the way I don't care about shitty swift.
>>
>>58000805
>C++
I think you mean C+=1
>>
>>58000360
>Apple removes features
Nothing new here.
>>
>>58000805
>I much prefer to run across the latter in software I take over.
Your parents were unfit to raise a child
>>
>>58002911
They copy M$.
>>
>>58002940
Nothing new here as well.
>>
>>58002872
no that's another language
https://github.com/ErisBlastar/cplusequality
>>
>>58003011
I'm not sure if this is a joke or not
>>
>mfw my company's senior programmer told me x+=1 was invalid syntax today

he's a .net guy though, don't know if it's invalid or unusual syntax there. still, i'm just a student worker, how the fuck am I teaching this guy anything?
>>
>>58002940
C# still has increment operators.

>>58003178
He's testing you.
>>
>>58003074
>Trigger Warning, this repository uses satire and sarcasm and other types of humor that could trigger Feminazis into rage fits.

FSF femisnt softw foundation
>>
>>58003202
Yes C# is a decent language.
>>
>>58003074
>>58003011
>>58003219


https://github.com/ErisBlastar/cplusequality/blob/master/fizzbuzz.Xe

 * - C+= considered phallic; replaced with (and pronounced) "Xe",
* source files have extension ".Xe"
*
* - header files are known as headHer files, with extension .Xir


#consider <FEMINIST_RAGE.Xir>

xe womain (xe RequestCount, strong *RequestList[]) {
//Always check your privilege
CheckPrivilege();


xe ThePlaceBetween accepts(present(0));

among(ThePlaceBetween accepts(ArbitraryBeginning),
ThePlaceBetween honors(ArbitraryEnd),
ThePlaceBetween improvesBy(present(1))) {

check(ThePlaceBetween envelops(present(3))) {
yell(present("Fizz"));
ENDMISOGYNY
recheck(ThePlaceBetween envelops(present(5))) {
yell(present("Buzz"));
>>
>>58001886
>>58001643
>>58000805

Your stupid example isn't even hard to read. It dereferences a pointer and then, as implied by the name *POSTFIX* increment, increments the pointer AFTER evaluating the expression. This is really fucking basic shit. Anyone who's touched C for more than a month will be able to understand that code, unless their problem is understanding pointers in which case they're screwed anyway.

These operators can be used in simple things like:

while(i++ < MAX)


Instead of something stupid like:

while((i = i + 1) < MAX)


Besides, this isn't an issue with the ++/-- operators. This is an issue you can get in ANY programming language that provides more expressibility than BASIC. It isn't the fault of the operator. If someone writes an unreadable mess of code because they're being "clever" with operators (your example is not very clever and easy to parse) then it's just a shitty programmer, which is not the fault of the operator.

People write "clever" code in Python too you know, despite the lack of the prefix/postfix operators. People also write stupid fucking shit with the ternary operator (the ?: operator), like this:

return i > 0 ? i << 2 : ~(i << 2) + 1;


Despite the fact that the operator is rather useful when you're doing something like:

pos = (pos != MAX) ? ++pos : 0;


Instead of:

if(pos == MAX) {
pos = 0;
} else {
pos++;
}


This is not "clever" and it's very easy to parse for both humans and machines.
>>
>>58002508
In the first version of C, it was. Then they realized that was a bad idea, and changed it. It's been that way ever since.
>>
>>58000360
>appletoddlers will defend this
>>
still rather use it than obj-c
>>
>>58002113
This.
>>
>>58000435
>Taking cues from a language that shit like $python $python2 $python2.6 $python3 $python3.5 binaries
>>
>>58001886
++ and -- are convenient to use in for/while loops
>>
>>58000447
# or just
x += 1
>>
>>58000447
Sauce
>>
>removing shit from your language because its hard for beginners to grasp

oh good idea. while you're at it, might as well remove conditionals, iteration, and any form of value assignment as well, since most people entering their first programming course fail it, and those who don't aren't going to suddenly get stuck on ++.
>>
>>58008851
>Think different
>>
File: 1465335287427.png (55KB, 704x290px) Image search: [Google]
1465335287427.png
55KB, 704x290px
>applel
>>
>>58000447
This is not obvious to beginers either. Lets do
first_sum_operand = x;
second_sum_operand = 1;
sum_result = first_sum_operand + second_sum_operand;
x = sum_result;
>>
File: 1460646088180.jpg (9KB, 300x216px) Image search: [Google]
1460646088180.jpg
9KB, 300x216px
>>58000360
x++
is explicitly banned at a place I work at. it's in our coding standards for C++11. I work for a large defense industry contractor that you've probably heard of and we even work on civilian tech (rockets etc).

It's banned because of bugs and readability issues that operator overloading introduces. Sometimes that ++ doesn't do what you'd think it does.

Don't know Swift but they're correct for completely removing it.
>>
>>58010105
whats so bad about that, you mouthbreading retard?
>>
This is part of the trend to try to dumb down / lock down languages to make them more appealing to normies. This is what you get with pajeet, rajeesh, mommy coders, and the push to teach every kid programming.
>>
>>58010205
>operator overloading
>Sometimes that ++ doesn't do what you'd think it does.

This is just as true for + by itself.
>>
>>58000360
Swiftfags will defend this.
>>
>>58010205
I think that's a problem with operator overloading and not ++ itself.
>>
This actually makes sense. x++ is not consistent because it's not obvious x is assigned a new value.

then again, autists who don't even use swift will never understand this. they'll rather program in old languages.
>>
>>58010119
Exactly. Let's ban any expressions where a variable occurs both on left hand and right hand side. They're so difficult to understand.
>>
>>58010375
>conditionals are obvious
>iteration is obvious
>pointers are obvious
>event handling is obvious
>inheritance is obvious
>overriding is obvious
>threads are obvious

But not ++. Fuck ++, amirite?
>>
>>58000360
>x++ is not much shorter than x += 1.

It's much shorter if you're actually using it properly to reference then increment.
>>
>>58010205
The only problem with ++ is if you use c++ when ++c should be used.
>>
>>58001643
the only waste of company time here are the employees who have trouble reading that or don't know what postfix or prefix increment is
>>
>>58010375
>because it's not obvious x is assigned a new value.
It is if you have fucking learned your operators.

It's not obvious to someone who hasn't coded before that == doesn't assign a new value. Should we remove ==?
>>
>>58000447
>not doing
asm ("incq %0" : "+m" (x));
>>
>>58000435
So they basically copied from other guys that are also known for being incapable of good language design?
>>
>>58000435
Did you know that python had a fucktarded dictionary implementation until 3.6? In 3.6, they finally implemented the naive version of dictionaries. The result they found? It was significantly faster and used significantly less space.
>>
>>58010375
it's not consistent with assignment because it's more than just an assigment. Post increment is not assigned right away.
Thread posts: 73
Thread images: 4


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


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