4 ms·
I used to prefer car.drive(), now I prefer drive(car). I don't buy the auto-completion argument. Can my IDE really tell me all the ways I can use an Integer?
by mrkeen 7y ago
I used to prefer car.drive(), now I prefer drive(car).
I don't buy the auto-completion argument. Can my IDE really tell me all the ways I can use an Integer? I don't think so.
When it hit home for me was when Java 8 lacked Stream.takeWhile(predicate) and I decided to implement it for myself. I could implement takeWhile(predicate, stream), I could not implement stream.takeWhile(predicate).
- UserIsUnused 7y agoAlso, the autocomplete argument isn't a big argument, as writing is the less time consuming task in the process.
- stkdump 7y agoAutocomplete is one thing. Getting a list of suggestions is more important, because you might not know the name of the function.
- UserIsUnused 7y agoI agree, I guess that noum.verb() is indeed better to find those
- wvenable 7y agoKnowing what you can and can't do with an object is the time consuming part. Once you know that answer, the writing is relatively insignificant.
- coldtea 7y agoThat's not a big argument, as a process doesn't have to be "the most" time consuming part of programming to have a big negative impact. Annoying context switches and slowdowns to lookup function naming and possible options (without autocomplete) can still interfere with the flow of a programmer as he writes a program...
- scarejunba 7y agoTo test that this argument doesn't work, consider introducing a 400 ms delay on your keystrokes. Writing will still be the least time consuming task. Then compare with code you write without the delay. I have a reasonable hypothesis how the test will turn out.
- Hemospectrum 7y agoSome languages (eg. Swift, Rust, Kotlin; Dart is working on it) allow you to implement "extension methods" separately from the actual type definitions, even when the type in question is from another module/library. It's as if they're codifying the view that "OOP" is all a matter of syntactic convenience, and can't help us with the really hard problems.
- DonaldPShimoda 7y agoProtocols (the Swift name) are an attempt to give greater support to an OOP language in solving the Expression Problem [0] more generally. OOP does great for certain classes of problems all by itself, but it is not enough for everything. Similarly, FP is great for certain classes of problems, but is not enough for everything. I think protocols are neat, but I'm uncertain whether their usefulness outweighs the added mental burden of keeping track of them all (since they can be defined anywhere and take effect everywhere). [0] https://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt https://homepages.inf.ed.ac.uk/wadler/papers/expression/expr...
- beart 7y agoJava is the exception that proves the rule. In C# (and many other languages) you can easily extend the class with ".takeWhile".
- mrkeen 7y agoThat's what I thought before I tried it.
- coldtea 7y ago>Can my IDE really tell me all the ways I can use an Integer? I don't think so. Sure it can. E.g. (not an IDE, and some double underscore methods translate to operators, but the mapping is trivial): >>> dir(int) ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
- mrkeen 7y agowhere's .isPrime?
- coldtea 7y agoPython doesn't have such a function on the int type, so it will naturally wont show it. The IDE (or, here the "dir" method) shows everything _available_ to use as a method on an integer. If you meant "but can it show functions that are not on the integer type but that accept integers?" -- then many IDEs cannot, but it's not a difficult feature to add in an IDE for known libs/modules. Can't think of any other way a question like "Can my IDE really tell me all the ways I can use an Integer?" makes sense. Of course the IDE wont know about yet unwritten methods which still count as "ways to use an integer". But nobody claimed it can above, and the absence of that doesn't discard autocompletion as an argument (to using the noun first).
- deleted 7y ago[deleted]
- MeteorMarc 7y agoThe autocomplete search space for drive(car) can also be narrowed down by how you do your imports: import pandas as pd from pyspark.sql import functions as f
- cb504 7y agoFYI, in C# they have "extension methods" which give the syntax stream.takeWhile(predicate). Like a breath of fresh air.