8 ms·
I have used Fortran 90+, Python with Numpy, R, and (rarely) Matlab/Octave, all of which allow operations on whole arrays and array sections. Would they be consi
by poster123 8y ago
I have used Fortran 90+, Python with Numpy, R, and (rarely) Matlab/Octave, all of which allow operations on whole arrays and array sections. Would they be considered array languages? What is qualitatively different about APL, J, and K?
- jacquesm 8y agoR is definitely an array programming language, but with the accent on statistics (historically, though you can do a lot more with it than that). Fortran and Python are much more general purpose languages that also happen to have array operations to speed things up. Matlab/Octave are more math oriented than any of the above and are far more than just programming languages, they are more like interactive notebooks, the IDE for Matlab (and for Octave too now, though I haven't worked much with it) is so closely coupled with the language that the language has no stand-alone right to existence. APL, J and K are all more closely related to each other than to any of the others, the closest of the others would be R.
- jgtrosh 8y agoMinor aside: when I worked at Scilab I couldn't bear having to interact with a GUI so I got used to working either in complete CLI mode or sometimes in the partial CLI mode if I wanted to use a specific GUI feature. I only needed it for interactive plots or interfaces (iirc), however if I had been using xcos I would have needed it. So I don't know about Matlab / octave but I don't think they're fundamentally linked to their GUI; at least not in the sense of the programming language.
- opencl 8y agoOctave only got a GUI 3 years ago, and spent 27 years not having one.
- stepvhen 8y agoJ (i and i assume APL/K to an extent) is called an arry language because arrays are, essentially, a primitive data type. There is no special syntax for arrays, either for creation or handling. The verbs in J just work with arrays, and in most cases, work better with arrays than if you were to manually break it down.
- geocar 8y agoNot by me. Not by most people I reckon. Consider the lone factorial problem: Every array programmer will do some kind of the product of, one plus array of all ints up to x apl: ×/⍳X q: prd 1+til x j: */1+i.x k: */1+!x Notice how similar they are? Now, how do you solve this problem in Fortran? In Python? In R? In Matlab? What's the first tool in your toolbox? Is it to iterate over the values? FUNCTION FACT(N) INTEGER N,I,FACT FACT=1 DO 10 I=1,N 10 FACT=FACT*I END def fact(n): result = 1 for i in range(1, n+1): result *= i return result function b=fact(a) b=1; for i=1:a b=b*i; end function fact = iter_fact(n) fact = 1; for i = 2:n fact = fact * i; endfor endfunction fact <- function(n) { f = 1 for (i in 2:n) f <- f * i f } If the native programmer's first impulse looks something like that, then it's not an array language because the programmer isn't thinking in terms of arrays.
- Athas 8y agoI like that definition! Not least because it means Futhark qualifies as an array language: i32.product (map (1+) (iota n)). I have also heard the more fundamentalist definition that if you have to say 'map', then it is not an array language.
- poster123 8y agoHere is a Fortran 95 program to compute the factorial of 0 through 5. The factorial can be computed as the product of an array created on the fly, without an explicit loop. program xfact integer :: i print*,fact([(i,i=0,5)]) contains elemental function fact(n) integer, intent(in) :: n integer :: i,fact fact = product([(i,i=1,n)]) end function fact end program xfact
- segmondy 8y agoAPL came before all of those. J/K are decendants of APL. Those languages that you used are copying APL features. Some of it is not too bad, but they don't have the entire power. In J for example, you could factor your code out. The way you factor mathematics. Their power lies in their notation. Outside of the notation, If you have a multidimensional array, you can operate on ranks of it. You can write loopless code, you don't need for, do, while loops. The compounding and combining of verbs allows for a very functional style of programming that you can never realize in the languages you mentioned. You have to understand APL was designed for describing algorithms before it got turned into a computer language.
- mamcx 8y ago> Would they be considered array languages? No. Is like claim "C" is a OO language. Is more correct to say it have "array capabilities". To be considered an "X" language it must that "X" be the most primitive/idiomatic/natural/default way to think and program on that. And also a primitive of the language! You can do OO on SQL, but that is hardly the idea! Similar, with a array language you see everything as arrays and as array manipulation and rarely deviate from that. This is the same on other languages. Even in multi-paradigm languages like python or C# maybe you put a little functional here or linq there but that portion of the code seriously look "alien"
- gugagore 8y agoI think I'll disagree mildly. In "slow" languages like MATLAB and Python/NumPy, often the most performant way to do computation is array primitives. So much so that the style becomes idiomatic over, say, for loops.
- disgruntledphd2 8y agoI think that it's intuitive for people working with large datasets/numerical data, and not otherwise. You can cheerfully write loops in Python for most problems, except the set of problems solved by Numpy. Mind you, I cut my teeth on R, so needing to use loops in other languages confused the hell out of me at first.