« first day    last day (36 days later) » 

02:15
@user1271772 I'm not sure most languages have exponentiation baked in, although yeah, there is an operator for it in a lot of them. Do note that it's much easier to have syntax for exponentiation than for factorial (requires postfix operators) and sqrt (requires unicode)
Also, sqrt and other math functions exist in pretty much every language's stdlib, so I'm not sure what the problem is
Do you just not want to import math (or whatever your language's equivalent is)?
@user Factorial and Sqrt can be done just with factorial() and sqrt(), so there's no need for postfix operators or unicode.
sqrt() already exists in standard libraries, then
@user In FORTRAN/Fortran we have all of these functions available natively in the language.
And as the highest-voted answer points out, factorial is not much use on fixed-size integers
@user The question says so many times, that the focus is on functions that can be accessed without importing a library.
02:22
@user1271772 Was/is Fortran not used for a lot of math-heavy stuff? General-purpose languages like Java and Python don't care about that
@user1271772 Is it really that hard to type math.sqrt? There's no need to pollute the global namespace
@user You're right, Fortran is used for math, but I don't see why Java and Python can't do these basic things "natively".
@user By not polluting the global namespace, we are polluting our code.
Only some programmers need square roots all the time
@user1271772 wdym?
@user1271772 There's just no reason to
Only some programmers need GO TO and WHILE loops, but languages still provide them natively.
@user is there a reason not to?
Yeah, it pollutes the global namespace
The reason to make them available, is that it would be convenient for some programmers. So there is a reason to.
02:25
Also, if you're going to add math builtins for people doing math work, you'd have to start adding builtins to appease other programmers too
@user What is an example of that?
Python would have to start allowing everything from itertools to appease the programmers using that
@user1271772 Builtins that other programmers use?
Someone writing code that works on files would want all the I/O stuff available without importing
Someone writing code for servers might want networking and concurrency stuff available without importing
There's a reason standard libraries are organized into modules/packages/whatever
It's more convenient to not have to import stuff but it also makes it confusing to keep track of everything
@user There's a big difference between the sqrt() function, and itertools. Square root functions are provided in elementary school level pocket calculators.
@user how is it confusing if sqrt is the reserved for the sqrt operator?
@user1271772 Elementary schoolers and programmers have different things to do
@user1271772 But you're not talking about just sqrt, you're talking about allowing every "simple" math function
And since there's no reason to treat math specially, you'd also be opening the floodgates to all sorts of stuff being put at the top level
@user Most people working on I/O or networking or concurrency, will be able to benefit from the sqrt() function, whereas most people that use the sqrt() function won't be using a networking library.
@user then why can we do powers natively (e.g. 5**3 in Python)?
02:32
I think you're seriously overestimating how useful sqrt is
@user1271772 I have no idea why they added that
Took it from Fortran, maybe?
@user maybe, but they didn't take sin and cos :)
Sure they did, it's in the math module
It's simply a matter of doing from math import sin
@user For 5**3 you do not need to import the math module.
So?
Perhaps their thought processes was that pow(5, 3) is really annoying to type, so it'd be better to have an operator for that even if it's not used often. But there was no use making an operator for, say, sin, and if it's going to be a function rather than a special operator, it might as well go into the appropriate model since it's so rarely used
03:35
@user how can pow(5,3) be too annoying if adding import math and adding math. to the beginning of everything is not?
Hello @ChrisCundy!
 
19 hours later…
22:51
@user1271772 you understand that for organizational purposes it's pretty standard that languages put most functions in different modules that one has to import. How is math any different than I/O? UI? Networking? Etc? In fact, those three are likely used far more than the math functions. Most of the specialized math that's required by the other operations has been abstracted to the point that they're not necessary for >95% of programmers.

« first day    last day (36 days later) »