42 ms·
this trend of `a: float` always reminds me of the Rich Hickey "you don't want types, you want proper names" talk. I really hate this (feels to me Go inspired) t
by Barrin92 3y ago
this trend of `a: float` always reminds me of the Rich Hickey "you don't want types, you want proper names" talk. I really hate this (feels to me Go inspired) tendency of undescriptive single letter variable, with the type system abused as a naming assistant.
Names can convey proper semantic information about what your program does, use them godammit
- alexmolas 3y agoI agree with you that better names are always preferable. But type hints also work as documentation. We can have both. However, in this particular case the undescriptive names are like this for historical reasons. I agree these are not the best names, but are the names used in the literature. If I was working in a physics I would probably use "c" as the speed of light or "kb" as the Boltzmann constant, which are non very descriptive names.
- planb 3y agoThis is right, but if you are implementing a formula known in the domain or documented elsewhere, you can (and should) use the letters used in the formula (in this case, b and k1) instead of making up names.
- sampo 3y ago> tendency of undescriptive single letter variable There are 2 schools of thought on which one is clearer, F = G * m1 * m2 / r**2 or force = gravitational_constant * mass_of_body_1 * mass_of_body_2 / distance_between_bodies ** 2
- trashtester 3y agoPhycisist : > F = G * m1 * m2 / r**2 Computer scientist: nonrelativistic_gravitational_force = ( Physics.NonRelativistic.Gravity.gravitational_constant * body1.NonRelativistic.mass() * body2.NonRelativistic.mass() / body1.NonRelativistic.distanceTo(body2) ** 2 )*
- ZaoLahma 3y agoSoftware engineer straight out of uni: # Get force of gravity as below to be used later F = G * m1 * m2 / r*2 Software engineer 5 years after uni: gravitational_force = ( PhysicsContextConstructorFactory.createByRelativisticEnum(SystemConfig.getRelativisticEnum()).construct().getGravitationalConstant().value() * body1.getRelativisticContext(SystemConfig.getRelativisticEnum()).mass().value() * body2.getRelativisticContext(SystemConfig.getRelativisticEnum()).mass().value() / SystemConfig.getRelativisticContext(SystemConfig.getRelativisticEnum()).distanceTo(body1, body2).value() \* PlatformUnsignedInt(PlatformMinMaxAwareUnsignedInt(2).value()).getUnsignedInt().value() )* Software engineer after 15 years: # Newton's law of universal gravitation is well within wanted margin of error F = G * m1 * m2 / r*2
- lloeki 3y agoSadly the 5y SE forgot about dependency injecting the computation... after all we're always on the brink of new physics discovery, we'd hate to have to rewrite all that code when we can readily swap in fresh laws with the proper architecture!
- ZaoLahma 3y agoOh, but that comes as a needs-to-be-fixed to the pull request from the 6y SE, so no worries at all.
- cabalamat 3y agoShort names are OK if they are explained somewhere. I often explain them in a comment at the start of a class or function.