News for hackers. Stuff that matters.
Re:Remove the ++ and –- operators by manaskarekar on Thursday December 03, 2015 @04:08PM (#10672654)
> Their expressive advantage is minimal - x++ is not much shorter than x += 1

Personal opinion, but I definitely miss '++' every time I'm doing '+=' in Python.

Re:Remove the ++ and –- operators by isomorphic on Thursday December 03, 2015 @04:16PM (#10672699)
I think forcing me to use "+=" in Ruby reminds me that it's really a method call (which can be overridden), rather than an increment operation on primitive types.
Re:Remove the ++ and –- operators by BingsF on Thursday December 03, 2015 @08:48PM (#10674091)
++ and -- (both versions of each) would end up being method calls as well in Ruby or Python. They're even overridable in C++.
Re:Remove the ++ and –- operators by odonnellryan on Thursday December 03, 2015 @04:37PM (#10672847)
Yes, this exactly! While rarely a good idea, it does give you super powers when dealing with specialized libraries, or when writing your own :)
Re:Remove the ++ and –- operators by paulddraper on Friday December 04, 2015 @09:41AM (#10676536)
Have you ever written a container (with an iterator)?
Re:Remove the ++ and –- operators by akira2501 on Thursday December 03, 2015 @07:03PM (#10673691)
And yet, ruby still provides 4 unary operators that can be redefined.
Re:Remove the ++ and –- operators by tostitos1979 on Thursday December 03, 2015 @04:26PM (#10672771)
Agreed. In the list of disadvantages, we don't see "many professional programmers expect the ++ and -- operator" or "beginners will be confused because old code examples on the web will stop working".
Re:Remove the ++ and –- operators by joshavant on Thursday December 03, 2015 @04:28PM (#10672784)
This argument feels like 'legacy for legacy's sake'.
Re:Remove the ++ and –- operators by gozo on Thursday December 03, 2015 @04:53PM (#10672964)
Frankly I think discussions like these show how not all programmers are engineers. Cutting down on complexity and ambiguity is a good thing. Because even if you can handle something, when you have teams of 100+ people with 100 000+ lines of codes, all those potentials for errors quickly adds up.
Re:Remove the ++ and –- operators by legulere on Thursday December 03, 2015 @05:18PM (#10673147)
Which is actually quite common. Unicode is ASCII compatible and on Windows you still have to do carriage return before a line feed, although there are no teleprinters involved.
Re:Remove the ++ and –- operators by redthrowaway on Thursday December 03, 2015 @05:52PM (#10673336)
Which wipes out the "easier to learn as a first language" point, and then some. Copy-pasting code from stack or somesuch only to have it not work and not know why is incredibly frustrating for a beginning programmer. I certainly found that with wpgtr back in the day.
Re:Remove the ++ and –- operators by delinka on Thursday December 03, 2015 @04:11PM (#10672668)
I think I'd argue with the "not much shorter" because it's less typing to perform a `++` versus `+=1`; I hold shift, I type the = key, obtaining the +, then I have to pause typing long enough to release the shift key, type the = key again, and now my other hand has to get involved and type a 1. And that's without the spaces.
Re:Remove the ++ and –- operators by redblacktree on Thursday December 03, 2015 @04:39PM (#10672859)
Typing is not the bottleneck.
Re:Remove the ++ and –- operators by delinka on Friday December 04, 2015 @02:53PM (#10678675)
Yes, typing is indeed the bottleneck. Perhaps it doesn't add up to much time overall, but until we get brain-computer interfaces and the ability to will code or instructions into existence, I want every barrier to moving the solution from my head into the computer as small as possible.

I had a very similar conversation with a colleague about UX. This one operation might not happen often, but when it does, it should be intuitive and fast. The technology is here to serve the humans.

Re:Remove the ++ and –- operators by redblacktree on Friday December 04, 2015 @08:19PM (#10680343)
My point is just that a programmer spends a lot more time thinking about the problem domain; how to approach a particular problem; what patterns he might use; and details about the particular solution they've chosen, than he does typing.

That is, if you're optimizing typing, you're optimizing the wrong thing, and if you want to improve your ability to write software, you should instead be getting better at these other things. The typing part is good enough.

Edit: Or if typing really is the bottleneck, you're a much better programmer than me.

Re:Remove the ++ and –- operators by kuschku on Thursday December 03, 2015 @05:04PM (#10673045)
Well, I type the * key to get a +, then shift and 0 to get a =, then 1 to get a 1.

Slow, and my fingers have to jump completely over the keyboard.

What is far more annoying, and should be banned, are `these` (I have to press shift+' twice to get one `, otherwise I end up with á' instead of `a`), and {}[], as they are on AltGr+7/8/9/0

Re:Remove the ++ and –- operators by Nadya on Thursday December 03, 2015 @05:12PM (#10673105)
Which type of keyboard do you use? I know English-International has a similar issue with `'`, `"`, and `'`. I think QWERTZ or a German keyboard do as well? Can try changing it to English - US to get around that if you run Windows. Not sure about Mac/Linux.

I swapped the US out for international because it was important to me to type Pokémon properly. It is an annoyance to have to type ` followed by a space because it is waiting for a vowel to let me type ù. Same with ' which let's me type ç or " which lets me type ü... etc. I disable it when programming for the reason you cited. It can be annoying to deal with. Especially when my IDE tries to autocomplete " and I typed "" instead of " (followed by a space) and I get """".

Re:Remove the ++ and –- operators by kuschku on Thursday December 03, 2015 @06:04PM (#10673393)
I use a bastardized DE1 layout, as provided by linux.

So I have æ, but not å.

Actually, I’m gonna switch to DE3.

Still doesn’t solve these special characters.

Re:Remove the ++ and –- operators by Nadya on Thursday December 03, 2015 @07:02PM (#10673680)
I guessed the German QWERTZ properly at least...unfortunately I don't know a way of solving that without having an EN keyboard, using a keybind to swap between T1/EN as needed. Though depending how much German shows up in your programming... swapping every few characters probably isn't desirable either. :(
Re:Remove the ++ and –- operators by kuschku on Thursday December 03, 2015 @07:17PM (#10673753)
I write literally no German in code, but sometimes use it online.

And I seriously couldn’t work without the international layout - using proper Unicode characters in my comments is just non-negotiable.

If developers would have thought more about localization, and made less dumb assumptions...

But there are even minecraft mods that don’t work on QWERTZ, because they are hardcoded to keys that are dead keys on DE layout.

Re:Remove the ++ and –- operators by Nadya on Thursday December 03, 2015 @07:24PM (#10673777)
I press alt+shift and can switch between EN-International (which allows easy typing of é, è, ç, etc.) and EN-US (which doesn't easily allow them to be typed).

Therefore in EN I can {code} and then alt+shift and {comment with proper Unicode characters}. My suggestion would be to have a setup of T1/EN. Code in EN and comment in T1.

Sorry if I'm not being clear or if I'm being confusing...

>If developers would have thought more about localization, and made less dumb assumptions...

I18N can be time-consuming. Especially to test on every conceivable keyboard layout. Dumb assumption allows the mod to exist. I'm all in favor of I18N (and help translate things when I can!) but honestly it is a lot more work for what is often very little gains.

Would you rather spend 10 hours adding I18N for 100~ players or spend 10 hours improving the rest of the code base and adding new features for 10,000 players? Most devs choose the latter. Which really sucks if you're in the group of 100~ players.

Re:Remove the ++ and –- operators by kuschku on Thursday December 03, 2015 @08:13PM (#10673987)
Well, I actually modded the mod myself – and just made it use Minecrafts' integrated keybind tool.

And switch EN and T1 is not very useful. I’d have to relearn blind typing completely again.

Re:Remove the ++ and –- operators by y4mi on Friday December 04, 2015 @08:39AM (#10676211)
cant you use `+space to type one? it always worked for me with all keymaps... was awkward the first few times, but by now its become really easy.
Re:Remove the ++ and –- operators by kuschku on Saturday December 05, 2015 @06:43AM (#10681610)
Yes – but that’s still [Shift]+['] and then [Space]
Re:Remove the ++ and –- operators by iamsohungry on Thursday December 03, 2015 @05:12PM (#10673101)
If typing is the bottleneck in your development you're not solving difficult problems and could probably make more money solving difficult problems at a different job.
Re:Remove the ++ and –- operators by vlunkr on Thursday December 03, 2015 @06:02PM (#10673387)
I've always felt like Python and Ruby chose to drop these to discourage you from writing traditional loops, as they have their own enumerators to accomplish the same thing. And, as the author mentioned, so does Swift. Obviously you still have to do a '+=' occasionally, but I don't find myself doing that often.
Re:Remove the ++ and –- operators by rtpg on Thursday December 03, 2015 @08:53PM (#10674109)
Yeah, I think the core difference between i++ and i+=1 (expression vs statemrnt) is mainly useful in situations where higher level structures are available in languages that aren't C
Re:Remove the ++ and –- operators by amyjess on Thursday December 03, 2015 @04:17PM (#10672702)
I do too, but it's worth it to not have x++ and ++x thrown around inside of expression bodies (especially while loop conditions).
Re:Remove the ++ and –- operators by joaorj on Thursday December 03, 2015 @05:44PM (#10673295)
I did miss it too, for the first 2 weeks I started using python. After that it just seems ugly.
Re:Remove the ++ and –- operators by SilasX on Thursday December 03, 2015 @05:31PM (#10673229)
Then I take it you don't buy into the Python philosophy of "There should be one-- and preferably only one --obvious way to do it."

https://www.python.org/dev/peps/pep-0020/

Re:Remove the ++ and –- operators by nix0n on Thursday December 03, 2015 @06:11PM (#10673429)
To me, ++ is the one obvious way to increment. I use for loops constantly and think of incrementation as a different thing from addition.
Re:Remove the ++ and –- operators by SilasX on Thursday December 03, 2015 @07:12PM (#10673734)
Well yes, they are different from addition, but that still doesn't justify a special symbol for a special case of addition.

When your "increment by 1" is really just in the service of iterating over a set, then the natural, obvious way should be to use a separate idiom that abstracts the concept of iteration over that set, rather than dive into the details of how you get access to the next member. Which is what Python does: "for x in ...".

If the loop is not simply iterating over the set, but tweaking some value unpredictably and periodically checking, then there's nothing special about += 1 relative to += 2.

Re:Remove the ++ and –- operators by msellout on Thursday December 03, 2015 @07:23PM (#10673775)
Why are you incrementing inside a Python for-loop? Are you familiar with ``enumerate``? In most situations, Python provides an iterator that tracks state for you and it's not necessary to increment state explicitly in the loop.
Re:Remove the ++ and –- operators by nine_k on Thursday December 03, 2015 @07:36PM (#10673843)
In higher level languages, loops are not about incrementing.
Re:Remove the ++ and –- operators by koko775 on Thursday December 03, 2015 @07:09PM (#10673725)
To be clear, do you mean ++i or i++?
Re:Remove the ++ and –- operators by Grue3 on Friday December 04, 2015 @09:49AM (#10676576)
Neither does Python. For example, % operator and .format().