Native support for units [was: custom literals]
On 4/3/22 11:52, Brian McCall wrote:
If you had asked me twenty years ago if I thought units should be a native part of any programming language, I would have said absolutely - because in my youthful ignorance I had no idea what it would take to make such a thing work. Five years later, I would have said "not worth it". Now I'm back where I started. The lack of native language support for SI units is a problem for an entire segment of programmers. Programming languages took a big step forward in deciding that EVERYTHING is a pointer/reference, and EVERYTHING is an object. They need to take another step forward to say that EVERY number has a unit, including "unitless". Not having this language feature is becoming (or already is) a problem. The question is, is it Python's problem?
On 4/3/22 14:20, Ricky Teachey wrote:
The libraries out there- pint is probably the biggest one- have filled those gap as much as they can, but there are so many shortfalls...
The old engineering disciplines- mine (civil engineering), structural, electrical, etc- are the next frontier in the "software eats the world" revolution, and they desperately need a language with native units support. I was just on an interview call yesterday for a senior engineer role at a large multinational earth works engineering firm and we spent 15 minutes talking about software and what we see coming down the road when it comes to the need for our discipline to grow in its software creation capabilities.
Python SHOULD be that language we do this with. It is awesome in every other way. But if it isn't DEAD SIMPLE to use units in python, it won't happen.
Well, if we're spit-balling ideas, what about: 63_lbs or 77_km/hr ? Variables cannot start with a number, so there'd be no ambiguity there; we started allowing underbars for separating digits a few versions ago, so there is some precedent. We could use the asterisk, although I find the underbar easeir to read. Mechanically, are `lbs`, `km`, `hr`, etc., something that is imported, or are they tags attached to the numbers? If attached to the numbers, memory size would increase and performance might decrease -- but, how often do we have a number that is truly without a unit? How old are you? 35 years How much do you weigh? 300 kg What temperature do you cook bread at? 350 F -- ~Ethan~
participants (20)
-
André Roberge
-
Ben Rudiak-Gould
-
Brian McCall
-
Chris Angelico
-
Christopher Barker
-
David Mertz, Ph.D.
-
dn
-
Ethan Furman
-
Greg Ewing
-
Ken Kundert
-
Luca Baldini
-
Matt del Valle
-
Mike Miller
-
Paul Moore
-
python@shalmirane.com
-
Ricky Teachey
-
Sebastian Berg
-
Simão Afonso
-
Stephen J. Turnbull
-
Steven D'Aprano