Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are statistical programming languages like R/SAS considered functional or procedural [closed]

I still don't understand the difference after reading this

So, rather than asking what is the difference between functional vs procedural programming, I thought, maybe a language that I am familiar with can serve as an example.

Hence, my questions: Are the languages R/SAS considered procedural or functional?

like image 560
Victor Avatar asked Jun 30 '15 18:06

Victor


People also ask

Is R functional or procedural?

R, at its heart, is a functional language. This means that it has certain technical properties, but more importantly that it lends itself to a style of problem solving centred on functions.

Is R a procedural language?

A procedural language is a computer programming language that follows, in order, a set of commands. Examples of computer procedural languages are BASIC, C, FORTRAN, Java, and Pascal. Procedural languages are some of the common types of programming languages used by script and software programmers.

Is R functional or object-oriented?

At its heart, R is a functional programming language. But the R system includes some support for object-oriented programming (OOP).

What type of programming is SAS?

The SAS language is a computer programming language used for statistical analysis, created by Anthony James Barr at North Carolina State University. It can read in data from common spreadsheets and databases and output the results of statistical analyses in tables, graphs, and as RTF, HTML and PDF documents.


1 Answers

R is primarily a functional programming language. It does have some exceptions where things are done via side-effects, so it's not as entirely functional as Haskell. Nonetheless, if you are not willing to adapt your programing style to use functions, you will have quite a bit of difficulty in writing efficient R code. (The only reason I'm writing this answer is that calling R an object-oriented language will be misleading to people who come to it expecting to be able to send function messages to data-objects in the same manner as they do with Java. R uses an object's class as the dispatch selection mechanism for "generic" functions, but that's not the same paradigm as full OO-languages.)

R has between three, four, or five major object classes depending on how you think about them and associated function-types. The original S3 functions which dispatch only on the class of their first arguments are probably still the most commonly used, although the S4-class which may dispatch on multiple argument signatures is widely used in the BioConductor world. Reference-classed or R5 or proto-classed objects most resemble true object-oriented programming data types. I'm being a bit vague in that last sentence, because I lack much experience with them.

SAS is primarily a procedural language. You can define functions but it's not the way most people interact with SAS and its data SETs, at least at first. At least when I used it 15 years ago, it didn't really have an object model. I would argue that its main advantage is superior support for "report writing".

(The comment that data manipulation is "hard in R" just indicates lack of experience. The amount of code I need for data manipulation in R is a lot less than the code used by my SAS colleagues. If you started programming in SAS, then the conversion will be hard, but those of us who have changed generally have stuck with R.)

like image 101
IRTFM Avatar answered Oct 04 '22 18:10

IRTFM