Skip to main content
2 of 6
added 24 characters in body
Nike Dattani
  • 847
  • 1
  • 6
  • 25

What are the disadvantages of being able to define a matrix without typing any words?

Introduction

In MATLAB, Octave and Julia, matrices are defined extremely easily. The following line defines a 2x2 matrix in any of those languages:

A = [1 3; 4 -1]

Case 1: Python

Someone who's "native" language is Python, told me that the simplest way to accomplish the above goal would be:

from numpy import matrix 
A = matrix(‘1 3;4 -1’)

I see that the official NumPy documentation recommends to use an even more verbose syntax:

"It is no longer recommended to use this class, even for linear algebra. Instead use regular arrays. The class may be removed in the future."

The simplest way to define the matrix is then even more verbose:

from numpy import array
A = array([[1,3],[1,9,-2,1]])

What are the advantages of requiring us to type "array" or "matrix", or the disadvantages that we sacrifice in other languages by not requiring any such words?

I understand that a lot of Python programs don't need matrices, but Python is used enormously in machine learning (it's the most popular language tag in the Artificial Intelligence Stack Exchange), and Quantum Computing (the Python program Qiskit is the most popular tag in the Quantum Computing Stack Exchange), and other areas with enormous usage of matrices, so I wonder what harm/disadvantages the type of functionality described in the first paragraph, would introduce?

Case 2: R

What surprises me even more, is the syntax in R. Unlike Python, which you might say is not designed specifically for numerical computation but is rather meant to be more of a "general purpose" language, R was designed specifically for numerical computing. There's several ways to define a matrix in R and they all seem to have syntax that's as cumbersome as the Python syntax. R has the matrix() function akin to the NumPy function that the official NumPy documentation recommends not to use, and it has other methods that also rely on typing out a function name in words, rather than just having a syntax that's reserved for defining matrices.

Nike Dattani
  • 847
  • 1
  • 6
  • 25