What is the concept of first class citizen in Gradle

(dinio.dinev) #1

Hi often if Gradle Documentation I find this concept for example:

Multi-project builds
Gradle's support for multi-project build is outstanding. Project dependencies are first class citizens.

What is the concept of first class citizens in Gradle. Sorry if this question look stupid but when I read something I want to understand it fully.


(Peter Niederwieser) #2

It means that “project dependency” is an explicit concept that is designed to interact well with Gradle’s other features, rather than being an afterthought or by-product. A more rigorous definition is that a feature is “first-class” if it has a runtime representation, and can be manipulated at runtime with ease. For example, functions are a first-class feature in Java 8 (in the form of lambdas), but not in earlier Java versions.

(dinio.dinev) #3

In programming language design, a first-class citizen (also object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as a parameter, returned from a function, assigned to a variable,can be constructed at run-time,has intrinsic identity (independent of any given name)

So project dependencies can be passed as parameter returned from a function, and assigned to a variable and that makes them first-class citizen??

Whereas lambdas in Java 8 are first-class citizen - functions because they can be used as arguments to other functions, can be returned as the values from other functions, and can be assigned to variables or can be sorted in data structures. And can be manipulated runtime?

(Peter Niederwieser) #4

If you read my answer, I said that’s a more rigorous definition. There is certainly a runtime representation for project dependencies, they can be passed around if needed, and they can be reasoned about at runtime.