Math.TAU

# Marius Gundersen (10 years ago)

I propose the tau constant be added to the Math object and be defined as 2*Math.PI, as described in the tau manifesto: tauday.com/tau-manifesto

(I couldn't find any discussion about this when searching esdiscuss.org, so sorry if this has been discussed before)

Marius Gundersen

# Brendan Eich (10 years ago)

Ok, nerdbait -- but I'll take it and champion it at the next TC39 meeting. Thanks,

# Rick Waldron (10 years ago)

On Saturday, June 28, 2014, Brendan Eich <brendan at mozilla.org> wrote:

Ok, nerdbait -- but I'll take it and champion it at the next TC39 meeting. Thanks,

Yes, if you hadn't I would've :)

I doubt there will be an opposition, but for anyone interested, Section 2 (especially 2.1) of the Tau Manifesto is particularly compelling.

# Michael Haufe (10 years ago)

FYI: www.thepimanifesto.com

On Sat, Jun 28, 2014 at 9:28 AM, Marius Gundersen <gundersen at gmail.com>

wrote:

I propose the tau constant be added to the Math object and be defined as

# C. Scott Ananian (10 years ago)

I'll admit to being a pi-ist, rather than a tau-ist, but I don't object to adding Math.TAU. It's a fairly harmless easter egg.

# Jonathan Barronville (10 years ago)

NO! π all the things! Just kidding ;) ... +1 adding the τ constant.

# Mark Hansen (10 years ago)

Another +1. Would save me doing Math.TAU = 2 * Math.PI; at the top of all my trignometry files :-)

# Andreas Rossberg (10 years ago)

On 28 June 2014 20:23, Rick Waldron <waldron.rick at gmail.com> wrote:

On Saturday, June 28, 2014, Brendan Eich <brendan at mozilla.org> wrote:

Ok, nerdbait -- but I'll take it and champion it at the next TC39 meeting. Thanks,

Yes, if you hadn't I would've :)

I doubt there will be an opposition, but for anyone interested, Section 2 (especially 2.1) of the Tau Manifesto is particularly compelling.

Sigh. See the rebuttal Michael Haufe already linked to (www.thepimanifesto.com). To most serious mathematicians, tau is rather crackpot territory. I'd indeed be opposed.

(OT, though somewhat related, this interesting and amusing talk about crank physics: www.youtube.com/watch?v=HXSgp755DSA Relevant observation: most cranks are engineers. Probable explanation: they are used to being able to construct the world to their liking, and some can't deal with this not being possible in math and physics.)

# alawatthe (10 years ago)

Although I'm a mathematician, I don't want to argue from a mathematical point of view against the inclusion of Math.TAU (For this please read the www.thepimanifesto.com which was already posted above by Michael). But instead from a JavaScript point of view:

The only arguments in favor of Math.TAU so far were:

Another +1. Would save me doing Math.TAU = 2 * Math.PI; at the top of all my trignometry files :-)

That is not really a compelling argument for Math.TAU. And seeing the smiley I don't even think you meant it serious.

[…] It's a fairly harmless easter egg.

Yes, it is. But (apart from the question whether we should include easter eggs in the language) aren't there easter eggs, which have to do more with JavaScript and less with a pointless math argument?

Are those really the two best arguments for Math.TAU?

So now to the reasons against Math.TAU:

I don't know a single programming language which includes the tau constant. Why should we?

But the real reason why I'm against the inclusion of Math.TAU is the following:

Brendan you said once that "Math is becoming a dumping ground" see here esdiscuss/2013-November/034610 (So it surprised me much, that you want to champion Math.TAU at the next TC39 meeting.)

I don't think that Math is a dumping ground (or becoming one), but I see no reason to include a property we don't need and make the Math object even more looking like a dumping ground to some people. Instead of tau we could add more useful things to the Math object like the gamma function and the error function. (I’m pretty sure that as soon as I propose those functions, someone will come with the dumping ground argument.)

-- alawatthe aka alex

# Frankie Bagnardi (10 years ago)

It's pretty useless to have. If you need the TAO constant often, rather than setting it on Math you'd be better off having local variables. This is both for conciseness and minification (minified Math.TAO is Math.TAO, minified TAO is a single character).

var PI = Math.PI, TAO = PI * 2;
var area = (r) => PI * (r * r)

var circ = (r) => TAO * r

Or even:

var π = Math.PI, τ = π * 2;
var area = r => π * (r * r)

var circ = r => τ * r
# Benjamin (Inglor) Gruenbaum (10 years ago)

I'd just like to add that "joke requests" like Math.TAU that have no place in the language specification itself generate a considerable amount of overhead for those of us who keep up with the mailing list.

Especially since the other topics discussed are interesting (e.g. ModuleImport ). I think it would be best if we refrain from them in the future as this mailing list is already noisy.

# Jan Keromnes (10 years ago)

I'd just like to add that "joke requests" like Math.TAU that have no place in the language specification itself generate a considerable amount of overhead for those of us who keep up with the mailing list.

I don't think asking for Math.TAU was a "joke request". It's rather a request for a convenient short-cut to the value Math.PI * 2, of which the utility and judiciousness can be debated. Sorry if I'm adding noise to this less-interesting thread, but I feel the issue is being dismissed without adequate consideration. I'm looking forward to Brendan championning it at the next TC39 meeting, so that we can accept or dismiss it with a proper review.

My take is that having Math.TAU would end this kind of madness: search?q="Math.PI*2"&ref=searchresults&type=Code

The gains would admittedly be small:

  • Using Math.TAU instead of Math.PI * 2 is only slightly more handy, and would benefit a limited number of developers,
  • The unnecessary constant multiplications are trivial to optimize,
  • We would save 50 KB of code across all GitHub repositories,
  • Or 16 bytes in the minified version of the popular threejs.org library.

But they might be worth the negligible implementation and maintenance costs.

Here is a proposed implementation of Math.TAU in the Firefox runtime: bugzilla.mozilla.org/show_bug.cgi?id=1032203

Jan

# Rick Waldron (10 years ago)

On Mon, Jun 30, 2014 at 10:27 AM, Jan Keromnes <jan at mozilla.com> wrote:

I'd just like to add that "joke requests" like Math.TAU that have no

place in the language specification itself generate a considerable amount of overhead for those of us who keep up with the mailing list.

I don't think asking for Math.TAU was a "joke request". It's rather a request for a convenient short-cut to the value Math.PI * 2, of which the utility and judiciousness can be debated. Sorry if I'm adding noise to this less-interesting thread, but I feel the issue is being dismissed without adequate consideration. I'm looking forward to Brendan championning it at the next TC39 meeting, so that we can accept or dismiss it with a proper review.

My take is that having Math.TAU would end this kind of madness: search?q="Math.PI*2"&ref=searchresults&type=Code

Probably not-so-coincidentally, I have almost the same search url saved in notes I'm preparing for discussion at the next TC39 meeting. If you remove the "Math." part, there are 20,288 more matches: search?q="PI2%22&type=Code&ref=searchresults if you add spaces between PI, , 2 there are over 3000 more matches. When the parts of the term are flipped around as "2PI": search?q="2PI%22&type=Code&ref=searchresults (137,134 matches for those that don't want to click). Then variations of "math.PI", "Math.PI" with or without spaces will yield several thousand more for each.

Just because other languages don't include a TAU constant doesn't mean ECMAScript cannot.

Just because "serious mathematicians" think this is "crackpot territory", doesn't mean it's not useful (the condescension of that claim certainly isn't).

# C. Scott Ananian (10 years ago)

On Mon, Jun 30, 2014 at 1:01 PM, Rick Waldron <waldron.rick at gmail.com>

wrote:

Just because other languages don't include a TAU constant doesn't mean ECMAScript cannot.

Just because "serious mathematicians" think this is "crackpot territory", doesn't mean it's not useful (the condescension of that claim certainly isn't).

As I mentioned, although I am a pi-ist, I think Math.TAU is harmless. But I will qualify the "not useful" part -- there is no numerical accuracy benefit to using Math.TAU (only the floating point exponent changes), nor is there likely to be any emitted-code improvement (constant propagation being a standard part of any reasonable runtime). So the benefit is solely the single character minimized code size improvement from '2*Math.PI' to 'Math.TAU' (if this were significant wouldn't the minimizers be assigning this to a single-character variable already?), and the the code readability improvement of using Math.TAU (assuming the readers of your code are also tau-ists).

So I would be highly skeptical of any claim to "utility". I am, however, sympathetic to the idea that many users will feel TAU to be "fun" -- which does have its (limited) place in language design.

# Andreas Rossberg (10 years ago)

On 30 June 2014 19:01, Rick Waldron <waldron.rick at gmail.com> wrote:

On Mon, Jun 30, 2014 at 10:27 AM, Jan Keromnes <jan at mozilla.com> wrote:

I'd just like to add that "joke requests" like Math.TAU that have no place in the language specification itself generate a considerable amount of overhead for those of us who keep up with the mailing list.

I don't think asking for Math.TAU was a "joke request". It's rather a request for a convenient short-cut to the value Math.PI * 2, of which the utility and judiciousness can be debated. Sorry if I'm adding noise to this less-interesting thread, but I feel the issue is being dismissed without adequate consideration. I'm looking forward to Brendan championning it at the next TC39 meeting, so that we can accept or dismiss it with a proper review.

My take is that having Math.TAU would end this kind of madness: search?q="Math.PI*2"&ref=searchresults&type=Code

Probably not-so-coincidentally, I have almost the same search url saved in notes I'm preparing for discussion at the next TC39 meeting. If you remove the "Math." part, there are 20,288 more matches: search?q="PI2%22&type=Code&ref=searchresults if you add spaces between PI, , 2 there are over 3000 more matches. When the parts of the term are flipped around as "2PI": search?q="2PI%22&type=Code&ref=searchresults (137,134 matches for those that don't want to click). Then variations of "math.PI", "Math.PI" with or without spaces will yield several thousand more for each.

Come on. By that metric, we should immediately introduce a toplevel binding OP as a synonym for Object.prototype, because a gazillion lines of JS code out there contain it -- that would actually save 14 characters each, as opposed to 1 for Math.TAU. And we could probably come up with 100 more constants and abbreviations of equivalent utility in less than 3 minutes.

# Rick Waldron (10 years ago)

On Mon, Jun 30, 2014 at 1:26 PM, Andreas Rossberg <rossberg at google.com>

wrote:

On 30 June 2014 19:01, Rick Waldron <waldron.rick at gmail.com> wrote:

On Mon, Jun 30, 2014 at 10:27 AM, Jan Keromnes <jan at mozilla.com> wrote:

I'd just like to add that "joke requests" like Math.TAU that have no place in the language specification itself generate a considerable amount of overhead for those of us who keep up with the mailing list.

I don't think asking for Math.TAU was a "joke request". It's rather a request for a convenient short-cut to the value Math.PI * 2, of which the

utility and judiciousness can be debated. Sorry if I'm adding noise to this

less-interesting thread, but I feel the issue is being dismissed without adequate consideration. I'm looking forward to Brendan championning it at

the next TC39 meeting, so that we can accept or dismiss it with a proper review.

My take is that having Math.TAU would end this kind of madness: search?q="Math.PI*2"&ref=searchresults&type=Code

Probably not-so-coincidentally, I have almost the same search url saved in notes I'm preparing for discussion at the next TC39 meeting. If you remove the "Math." part, there are 20,288 more matches: search?q="PI2%22&type=Code&ref=searchresults if you add spaces between PI, , 2 there are over 3000 more matches. When the parts of the term are flipped around as "2PI": search?q="2PI%22&type=Code&ref=searchresults (137,134 matches for those that don't want to click). Then variations of "math.PI", "Math.PI" with or without spaces will yield several thousand more for each.

Come on. By that metric, we should immediately introduce a toplevel binding OP as a synonym for Object.prototype, because a gazillion lines of JS code out there contain it -- that would actually save 14 characters each, as opposed to 1 for Math.TAU.

If I were arguing for MP as a synonym for Math.PI then this argument would hold, but I'm not so it doesn't.

And we could probably

come up with 100 more constants and abbreviations of equivalent utility in less than 3 minutes.

We're not talking about simple abbreviations.

# Brendan Eich (10 years ago)

alawatthe wrote:

Brendan you said once that "Math is becoming a dumping ground" see here esdiscuss/2013-November/034610 (So it surprised me much, that you want to champion Math.TAU at the next TC39 meeting.)

Champion is TC39 code-word for advocate, but I don't have a dog in this hunt. I am opposed to "-isms" or ideologies in general, so specifically I'm against "tau-ism". I'll give Math.TAU a fair shake, but won't take too much of TC39's valuable time.

I don't think that Math is a dumping ground (or becoming one), but I see no reason to include a property we don't need and make the Math object even more looking like a dumping ground to some people. Instead of tau we could add more useful things to the Math object like the gamma function and the error function. (I’m pretty sure that as soon as I propose those functions, someone will come with the dumping ground argument.)

No, those are plausible, and IIRC they came up back in ES3 days (Waldemar may recall better). Good context for the Math.TAU discussion.

# Alex Kocharin (10 years ago)

An HTML attachment was scrubbed... URL: esdiscuss/attachments/20140701/2617bd16/attachment

# Frankie Bagnardi (10 years ago)

String.prototype.endsWith and Object.is are functions, and their JS implementations are nontrivial to memorize and type (although not the worst examples). Memorizing PI to more than a few digits is nontrivial. Same with Math.E, or Math.atan2, or most of the other Math functions and properties.

Remembering that PI*2 is TAO is required to even make use of it, unless/until mathematicians, books, and wikipedia start using TAO where 2 PI is currently used, you have to convert them. So if you decide to used it, you already know the definition. The alternative to other things in JavaScript (for the most part) spending time researching how to implement it, comparing existing implementations, or having to look up a constant value (e.g. 3.141592653589793).

Seems a little silly, and I'd rather see some of the use cases for it end up on Math if anything.

# Rick Waldron (10 years ago)

On Monday, June 30, 2014, Frankie Bagnardi <f.bagnardi at gmail.com> wrote:

String.prototype.endsWith and Object.is are functions, and their JS implementations are nontrivial to memorize and type (although not the worst examples). Memorizing PI to more than a few digits is nontrivial. Same with Math.E, or Math.atan2, or most of the other Math functions and properties.

Remembering that PI*2 is TAO is required to even make use of it, unless/until mathematicians, books, and wikipedia start using TAO where 2 PI is currently used, you have to convert them. So if you decide to used it, you already know the definition. The alternative to other things in JavaScript (for the most part) spending time researching how to implement it, comparing existing implementations, or having to look up a constant value (e.g. 3.141592653589793).

Seems a little silly, and I'd rather see some of the use cases for it end up on Math if anything.

I'm sorry that no one corrected you in your previous post, but "tao" is a Chinese term for "the way" or "the path". Tau is a letter in the Greek alphabet—they are not related in anyway whatsoever.

# joe (10 years ago)

If we're going to have convenience multiples of PI, they should be a) non-ideological, and b) include more than one (PI/2 comes up a lot in vector math, for example).

Why not have:

Math.PI Math.DPI //double pi Math.HPI //half pi

Or perhaps we should just let people define their own constants. This does seem a bit silly.

Joe

# Brendan Eich (10 years ago)

joe wrote:

If we're going to have convenience multiples of PI, they should be a) non-ideological, and b) include more than one (PI/2 comes up a lot in vector math, for example).

Why not have:

Math.PI Math.DPI //double pi

TAU

Math.HPI //half pi

ETA, conventionally.

Or perhaps we should just let people define their own constants. This does seem a bit silly.

The ideology is silly, or worse.

Don't worry, as a champion (advocate for spec-canonization of a proposal), I will face an advocatus diaboli -- probably many. I'll also make sure to balance the proposal by listing other candidates for Math (erf, gamma, ETA) and sorting by observed frequency of use, importance as built-in vs. self-hosted, etc.

I hope people can hold fire now and let es-discuss focus on better topics. But if you have something related to Math to propose, please start a new thread.

# Alex Kocharin (10 years ago)

An HTML attachment was scrubbed... URL: esdiscuss/attachments/20140702/6fb82c34/attachment

# A Matías Quezada (10 years ago)

This is not a character-count issue, neither a "is mathematically calculable" issue. It's a readability and maintainability issue. When developing games we have 3 options:

  1. Use Math.PI * 2 everywhere
  2. Create a TAU constant on every file
  3. Create a TAU constant on a single file and require this file from everywhere just for this

For readability I should choose the second one, for maintainability the third one, if it's on Math it's both maintainable and readable. This kind of problems creates distractions when creating a game.

I don't see the problem, it's a simple solution for a recurrent issue.


A. Matías Quezada Senior Javascript Developer amatiasq at gmail.com

2014-07-02 11:14 GMT+02:00 Alex Kocharin <alex at kocharin.ru>:

# Thaddee Tyl (10 years ago)

On Wed, Jul 2, 2014 at 5:52 PM, A Matías Quezada <amatiasq at gmail.com> wrote:

  1. Use Math.PI * 2 everywhere
  2. Create a TAU constant on every file
  3. Create a TAU constant on a single file and require this file from everywhere just for this
  1. Do Math.TAU = Math.PI * 2 once somewhere. It even works in node.js, inside of the same process, leaking through require()s.

And some do it: search?q="Math.TAU"&type=Code&ref=searchresults

# A Matías Quezada (10 years ago)

Extending host objects? I don't think that favors readability and maintainability.

If I don't know TAU (or some one read my code and doesn't know it) and see this I will look for Math.TAU on MDN, not on the project and if by chance I guess it's defined somewhere in the project how will I know? there is no reference to the file where the variable is created.

Sounds like create a global variable, we know the consequences this has for readability and maintainability.


A. Matías Quezada Senior Javascript Developer amatiasq at gmail.com

2014-07-03 9:47 GMT+02:00 Thaddee Tyl <thaddee.tyl at gmail.com>:

# A Matías Quezada (10 years ago)

PS: Also in ES6 modules it will be not possible to extend module Math.


A. Matías Quezada Senior Javascript Developer amatiasq at gmail.com

2014-07-03 15:02 GMT+02:00 A Matías Quezada <amatiasq at gmail.com>:

# C. Scott Ananian (10 years ago)

On Jul 3, 2014 9:15 AM, "A Matías Quezada" <amatiasq at gmail.com> wrote:

PS: Also in ES6 modules it will be not possible to extend module Math.

Really? That will be quite problematic when it comes time to write es7-shim.

# A Matías Quezada (10 years ago)

people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-module-objects

A Module object is an exotic object whose own properties corresponding

corresponding to the ExportedBindings of the module identifed by the ModuleImport FromClause. Each property name is the StringValue of the corresponding exported binding. These are the only properties of an Module object. Each one is a read-only property with attributes {[[Configurable]]: false, [[Enumerable]]: true}. Module objects are not extensible.

Maybe this is still under discussion, below you can see

Needs to decide whether a module object is an ordinary or an exotic

object. Whether properties are accessor or defined via [[Get]], etc.

But for now the draft says they're not extensible.


A. Matías Quezada Senior Javascript Developer amatiasq at gmail.com

2014-07-03 16:15 GMT+02:00 C. Scott Ananian <ecmascript at cscott.net>:

# Till Schneidereit (10 years ago)

That doesn't mean that you cannot extend builtins - if you don't explicitly load a module into its own Realm using the ModuleLoader, it shares builtins with all other modules.

Also note that a Module object isn't the scope for a module script. It's a reflection of the internal metadata about the module. The script itself runs in a global which in browers is the Window object by default.

# A Matías Quezada (10 years ago)

Till: we can discuss that on another thread, we are missing the main point here...


A. Matías Quezada Senior Javascript Developer amatiasq at gmail.com

2014-07-03 17:09 GMT+02:00 Till Schneidereit <till at tillschneidereit.net>:

# Brendan Eich (10 years ago)

No Math.TAU in Harmony, per the meeting notes:

esdiscuss.org/notes/2014-07-31#5-1-math-tau

MarkM's argument fits on one line: "one letter shorter, not well known, not well taught. PI is known, taught and ubiquitous."

This is a courtesy FYI and (I hope) a tombstone for this thread. Don't rehash. New insights (they had better be new and good) in new thread.