# Optional Multiplication Sign

**URL:** <https://es.discourse.group/t/optional-multiplication-sign/1710>\
**Category:** 💡 Ideas\
**Created:** [May 22, 2023, 11:19am UTC](https://es.discourse.group/t/optional-multiplication-sign/1710 "2023-05-22T11:19:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethanlal04](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ethanlal04/32/918_2.png) [@ethanlal04](https://es.discourse.group/u/ethanlal04)\
**Post date:** [May 22, 2023, 11:19am UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/1 "2023-05-22T11:19:14Z")

</div>

It's common in math to omit the `×` symbol and write stuff like:

```javascript
2x + 4(3x + 3log y + z) = 4sin(x) // mathematical jargon

```

Even some programming languages like Julia do this to make code look way cooler.

## Examples

```javascript
n * (n + 1)

```

```javascript
n(n + 1) || (n + 1)n

```

```javascript
2 * Math.PI

```

```javascript
2Math.PI

```

```javascript
(1 / 3) * 12 * getPerson().age // Convert years to months and divide by 3

```

```javascript
(1 / 3)12getPerson().age // Kinda confusing, perhaps ok with proper highlighting?

```

```javascript
(x - 4) * (3 * y + 2)

```

```javascript
(x - 4)(3y + 2) // So better

```

You can also use this to rid the brackets in some cases.

```javascript
2 / (3 * x)

```

```javascript
2 / 3x

```

This not just improves readability but can also speed up finger scripting. Just a subtle yet nice addition. Your thoughts?

Note: The multiplier must immediately precede the multiplicand (with no whitespaces), otherwise, it's a syntax error. This is to rid some confusion.

---

<div class="post-metadata">

**Author:** ![Josh-Cena](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/josh-cena/32/1408_2.png) [@Josh-Cena](https://es.discourse.group/u/Josh-Cena)\
**Post date:** [May 22, 2023, 3:06pm UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/2 "2023-05-22T15:06:14Z")

</div>

> [@ethanlal04](#):
>
> `n(n + 1)`  
> `(x - 4)(3y + 2)`

These are already valid syntaxes for a function call.

```js
nx
n12

```

These are valid identifiers.

You may be interested in [GitHub - tc39/proposal-extended-numeric-literals: Extensible numeric literals for JavaScript](https://github.com/tc39/proposal-extended-numeric-literals), which uses the same syntax space and kind of offers the same semantics.

---

<div class="post-metadata">

**Author:** ![DiriectorDoc](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/diriectordoc/32/987_2.png) [@DiriectorDoc](https://es.discourse.group/u/DiriectorDoc)\
**Post date:** [May 22, 2023, 4:36pm UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/3 "2023-05-22T16:36:01Z")

</div>

As much as I would like to see a programming language resemble the notation of algebra, I can see this causing many problems; primarily logic errors.

---

<div class="post-metadata">

**Author:** ![Josh-Cena](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/josh-cena/32/1408_2.png) [@Josh-Cena](https://es.discourse.group/u/Josh-Cena)\
**Post date:** [May 23, 2023, 3:27am UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/4 "2023-05-23T03:27:37Z")

</div>

FWIW, Mathematica is one language I know that allows omitting the multiplication sign—two primary expressions (in ES terms) side-by-side is always a multiplication.

---

<div class="post-metadata">

**Author:** ![ethanlal04](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ethanlal04/32/918_2.png) [@ethanlal04](https://es.discourse.group/u/ethanlal04)\
**Post date:** [May 23, 2023, 10:54am UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/5 "2023-05-23T10:54:59Z")

</div>

> [@Josh-Cena](#):
>
> > [@ethanlal04](#):
> >
> > `n(n + 1)`  
> > `(x - 4)(3y + 2)`
> 
> These are already valid syntaxes for a function call.

Yeah, dumb of me not to notice that, but u know what? That's actually rather nice as it shuts the door to many confusing variations of the syntax. If we only allow for a number multiplier (on the left) and a multiplicand restricted to a numeric variable identifier, there would be zero ambiguity and it will be more than enough for most cases. This means we can still do stuff like `2Math.PI` and `2 / 3x`. Personally, I think it's best suited for those cases too. Bcuz, something like `aDozenmangoes` looks awful compared to `aDozen * mangoes` but `12 * mangoes` is way awful than just `12mangoes`. Get what I mean?

---

<div class="post-metadata">

**Author:** ![theScottyJam](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/thescottyjam/32/616_2.png) [@theScottyJam](https://es.discourse.group/u/theScottyJam)\
**Post date:** [May 23, 2023, 2:07pm UTC](https://es.discourse.group/t/optional-multiplication-sign/1710/6 "2023-05-23T14:07:57Z")

</div>

Just make sure you don't try to multiply with the "n" variable, otherwise you'll run into other pitfalls.

```javascript
const n = 2;
const y = 3n;

```

What does `y` equal? The BigInt "3n". That's already valid syntax that can't break :).
