why sqrt is not a built-in function?

Michael F. Stemper mstemper at gmail.com
Fri Jan 15 15:39:43 EST 2021


On 15/01/2021 14.02, Chris Angelico wrote:
> On Sat, Jan 16, 2021 at 6:21 AM Michael F. Stemper <mstemper at gmail.com> wrote:
>> Here's the status of the square root function in various languages,
>> in the order that I encountered them:
>>
>> FORTRAN    Part of the language
>> Pascal     Part of the language
>> SNOBOL     Part of the language
>> c          Need to #include <math.h>
>> clisp      Part of the language
>> EcmaScript Part of the language
>> python     Need to import from math
>> Java       Need to import from java.math
>>
>> The four that appear to be in the most use currently are c,
>> EcmaScript, python, and Java. Of these, only EcmaScript has
>> Math.sqrt() as part of the language, and that could be partly
>> due to the fact that the language doesn't have any concept of
>> "import" or "include".
>>
> 
> Cool. Now tell me: Of all the languages that have a built-in global
> name SQRT (which does not include ECMAScript,

I wasn't looking at how the various languages spell it, I was just looking
at the fact that it could be used directly. Since ECMAScript has a
function Math.sqrt(), I counted it as being a direct part of the
language.

>  and for the record, ES
> does have imports),

I stand corrected. So I could say something like "import Math.*" and
then use "sqrt()" directly?

>   how many of them have a built-in or syntax for
> dictionaries/mappings?

Beats me. That wasn't what the OP was complaining about. I just did this
little ad-hoc survey to show that more modern languages don't have an
"inherent" square root function, so python's hardly unique.

>   I would put it to you that the ability to look
> up something by name in a tree, hashtable, or equivalent, is *at
> least* as useful as the ability to calculate a square root.

I don't think that I've used the square root function since I took a
course in geometry in the fall of 2019, so I have no grounds to dispute.

> Languages differ. I don't see why it's so important to focus on just
> one thing - and to complain that, even though it's in the standard
> library, you have to use an import command to get it.

You should probably direct this to the person who complained rather than
the person who showed that the complaint wasn't really consistent with
modern language direction, while python's handling of the square root
function is consistent.


-- 
Michael F. Stemper
Galatians 3:28


More information about the Python-list mailing list