News for hackers. Stuff that matters.
Re:Verb-Noun vs. Noun-Verb by mrkeen on Wednesday October 16, 2019 @12:18PM (#21272086)
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).

Re:Verb-Noun vs. Noun-Verb by coldtea on Wednesday October 16, 2019 @01:00PM (#21272643)
>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']
Re:Verb-Noun vs. Noun-Verb by mrkeen on Wednesday October 16, 2019 @02:56PM (#21274043)
where's .isPrime?
Re:Verb-Noun vs. Noun-Verb by coldtea on Wednesday October 16, 2019 @06:52PM (#21276891)
Python 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).

Re:Verb-Noun vs. Noun-Verb by Hemospectrum on Wednesday October 16, 2019 @12:33PM (#21272283)
Some 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.
Re:Verb-Noun vs. Noun-Verb by DonaldPShimoda on Wednesday October 16, 2019 @04:10PM (#21274929)
Protocols (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/expr...

Re:Verb-Noun vs. Noun-Verb by beart on Wednesday October 16, 2019 @12:36PM (#21272324)
Java is the exception that proves the rule. In C# (and many other languages) you can easily extend the class with ".takeWhile".
Re:Verb-Noun vs. Noun-Verb by mrkeen on Wednesday October 16, 2019 @02:59PM (#21274080)
That's what I thought before I tried it.
Re:Verb-Noun vs. Noun-Verb by UserIsUnused on Wednesday October 16, 2019 @12:32PM (#21272266)
Also, the autocomplete argument isn't a big argument, as writing is the less time consuming task in the process.
Re:Verb-Noun vs. Noun-Verb by stkdump on Wednesday October 16, 2019 @12:53PM (#21272546)
Autocomplete is one thing. Getting a list of suggestions is more important, because you might not know the name of the function.
Re:Verb-Noun vs. Noun-Verb by UserIsUnused on Wednesday October 16, 2019 @01:07PM (#21272719)
I agree, I guess that noum.verb() is indeed better to find those
Re:Verb-Noun vs. Noun-Verb by coldtea on Wednesday October 16, 2019 @01:05PM (#21272691)
That'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...

Re:Verb-Noun vs. Noun-Verb by wvenable on Wednesday October 16, 2019 @01:00PM (#21272629)
Knowing 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.
Re:Verb-Noun vs. Noun-Verb by scarejunba on Wednesday October 16, 2019 @03:23PM (#21274378)
To 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.
Re:Verb-Noun vs. Noun-Verb by MeteorMarc on Wednesday October 16, 2019 @02:00PM (#21273355)
The 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
Re:Verb-Noun vs. Noun-Verb by cb504 on Wednesday October 16, 2019 @05:13PM (#21275781)
FYI, in C# they have "extension methods" which give the syntax stream.takeWhile(predicate). Like a breath of fresh air.