# Tag Info

### Why do programming languages use the asterisk * for multiplication?

I believe the first language to use * for multiplication was FORTRAN, in its original specification in 1956 (with earlier drafts). None of the other symbols you ...
• 13.1k

### Why do programming languages use the asterisk * for multiplication?

The other answers have covered the first uses of * in programming languages. To these I will add that the asterisk has been used as a symbol for multiplication in ...
• 20k
Accepted

### Why is array access not an infix operator?

The answer to "why" questions is often partly historical - unless there is a good reason to be different, following existing conventions helps limit a new language's "strangeness budget&...
• 2,458

### Why does MATLAB have left division/solve?

Non-commutativity of multiplication a/b calculates $a \cdot b^{-1}$, whereas b\a calculates $b^{-1} \cdot a$. Since matrix ...
• 1,007

### Why do programming languages use the asterisk * for multiplication?

The fundamental reason is because neither true multiplication symbols × nor were (or are) common on US keyboards. Using ...
• 748
Accepted

### Why do programming languages use the asterisk * for multiplication?

Maybe FORTRAN, maybe MATH-MATIC FORTRAN's Preliminary Report in 1954 anticipated using the × symbol for multiplication (and ×× ...
• 4,991
Accepted

### Why do relational comparison operators never short-circuit?

The saving is rare The benefit of short-circuiting is that you don't have to compute the second operand. But there is only one value the first operand can have where short-circuiting is possible ─ ...
• 20k

### Why is array access not an infix operator?

There are a couple of arguments in favour of the x[y] syntax for arrays, over an infix operator. One is that we want array access to bind the left operand more ...
• 20k

### Why is array access not an infix operator?

it is, sometimes In Haskell, array access is the binary operator !!. In APL, one of the ways of doing array access is the dyadic function ...
• 1,641
Accepted

### What are the syntax options for implementing a ternary "if" operator?

Here are some options (including the ones you mentioned): C-family languages (e.g., C, C++, Java, JavaScript): Syntax: condition ? ifTrue : ifFalse Advantage: ...
• 1,528

### What syntax could be used to implement both an exponentiation operator and XOR?

Demote xor Unless you're in C or a similarly low-level language, you're not going to be doing a lot of bit-level manipulation. So the bitwise operations really don't need to be using up those juicy ...
• 3,047

### Why add an increment/decrement operator when compound assignments exist?

While x += 1 may be replaced by ++x, x++ is special in that it is essentially temp = x, x += 1, temp. I am making a C-like which ...
• 1,115
Accepted

### Why are expressions in languages so prone to integer overflow?

Overflow checking has a (small) cost The hardware will always overflow. It doesn't care. In order to check if an overflow happened, you need extra instructions (typically just a single ...
• 4,412

### What syntax could be used to implement both an exponentiation operator and XOR?

Double star Many languages have a ** operator for exponentiation. This is reasonably intuitive, as exponentiation is just the hyperoperation after multiplication. <...
• 8,513

### What syntax could be used to implement both an exponentiation operator and XOR?

I think most of the problem comes from functions being in the form op(a, b), which is verbose and doesn't read well when expressions get complicated. So why not use ...
• 1,441

### Prior art on pipelines of function calls

There are several different traditions for this in real-world languages. Many of them have colonised previously-unused punctuation, rather than having a strong design ethos to them. The semantics also ...
• 13.1k

### Advantages/disavantages of including the comma operator?

The benefit of the comma operator is that it allows you to include a sub-expression for its side-effects only. In languages without a comma operator, there are often ways around this ─ suppose ...
• 20k
Accepted

### Ternary operators other than ?:

Wikipedia lists the following ones, which I let here operate on arguments a, b and c: The ...
• 1,503

### Why add an increment/decrement operator when compound assignments exist?

C isn't a language that comes with fancy iteration constructs like foreach or map. This means programmers need to increment ...
• 1,811

### What are the syntax options for implementing a ternary "if" operator?

There's always the Smalltalk postfix form. result = condition ifTrue: [ ... ] ifFalse: [ ... ]. This has the benefit of not even being special syntax. It's just an ...
• 3,047
Accepted

### What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

I wouldn't store them as arrays, but you can certainly implement such a syntax efficiently. If you translate x[0] to x & 1 ...
• 146
Accepted

### Unambiguous syntax for a ternary comparison operator

There are several plausible approaches here, some of which work with the ambiguity and some sidestep it entirely. Some imply significant semantic choices about the language more broadly. A function, ...
• 13.1k

Using names instead To rectify this problem, you can use names instead of symbols for the names of operator functions. For example, take a look at Kotlin: ...
• 2,743
Accepted

Rust-style traits In Rust, operator overloading is implemented using core traits built into the language, which allow the operators to be named, without conflicting with methods which have the same ...
• 4,412

### Why add an increment/decrement operator when compound assignments exist?

The ++ and -- operators aren't really necessary. There are languages that get along just fine with ...
• 1,969
Accepted

### How do you correctly compile the chained comparison operators like ones that exist in Python (a < b < c), if b might have side-effects?

The trite answer is that if evaluating b twice is wrong, then it should only be evaluated once... Disclaimer: I don't know AEC, so I'm going to make up syntax. ...
• 3,133
Accepted

### Distinguishing modulo (Euclidean division) from remainder

Given the usefulness of a proper modulo operator to wrap an integer into a range [0, n) e.g. for an array index or generating a random integer in this range, I find ...
• 20k

### What are pros/cons of ternary conditional operators?

Pro: Readability While plenty of people talk about the readability problems with misused ternary operators, there are also situations where using a full if/...
• 4,412