Misplaced Pages

Apache Groovy

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Apache Groovy is a Java -syntax-compatible object-oriented programming language for the Java platform . It is both a static and dynamic language with features similar to those of Python , Ruby , and Smalltalk . It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode , and interoperates seamlessly with other Java code and libraries . Groovy uses a curly-bracket syntax similar to Java's. Groovy supports closures , multiline strings, and expressions embedded in strings . Much of Groovy's power lies in its AST transformations, triggered through annotations.

#0

93-615: Groovy 1.0 was released on January 2, 2007, and Groovy 2.0 in July, 2012. Since version 2, Groovy can be compiled statically , offering type inference and performance near that of Java. Groovy 2.4 was the last major release under Pivotal Software 's sponsorship which ended in March 2015. Groovy has since changed its governance structure to a Project Management Committee in the Apache Software Foundation . James Strachan first talked about

186-475: A dependent type or an effect system , which enables even more program specifications to be verified by a type checker. Beyond simple value-type pairs, a virtual "region" of code is associated with an "effect" component describing what is being done with what , and enabling for example to "throw" an error report. Thus the symbolic system may be a type and effect system , which endows it with more safety checking than type checking alone. Whether automated by

279-446: A Perl 4 binary with Oracle Call Interface compiled in. This has however since been replaced by a library (Perl Module), DBD::Oracle . Other complex and task-oriented applications may incorporate and expose an embedded programming language to allow their users more control and give them more functionality than can be available through a user interface, no matter how sophisticated. For example, Autodesk Maya 3D authoring tools embed

372-745: A Windows Script Host engine (VBScript, JScript and VBA by default in Windows and third-party engines including implementations of Rexx, Perl, Tcl, Python, XSLT, Ruby, Modern Pascal, Delphi , and C). A majority of applications can access and use operating system components via the object models or its own functions. Other devices like programmable calculators may also have glue languages; the operating systems of PDAs such as Windows CE may have available native or third-party macro tools that glue applications together, in addition to implementations of common glue languages—including Windows NT , DOS , and some Unix shells , Rexx, Modern Pascal, PHP, and Perl. Depending upon

465-563: A domain-specific language (DSL) to express the changes in the class easily, similar to Ruby's open class concept: Groovy's changes in code through prototyping are not visible in Java, since each attribute/method invocation in Groovy goes through the metaclass registry. The changed code can only be accessed from Java by going to the metaclass registry. Groovy also allows overriding methods as getProperty() , propertyMissing() among others, enabling

558-402: A floating-point value , then the wrong result will be computed by the invoked function. The C compiler checks the types of the arguments passed to a function when it is called against the types of the parameters declared in the function's definition. If the types do not match, the compiler throws a compile-time error or warning. A compiler may also use the static type of a value to optimize

651-423: A runtime error . To prove the absence of these defects, other kinds of formal methods , collectively known as program analyses , are in common use. Alternatively, a sufficiently expressive type system, such as in dependently typed languages, can prevent these kinds of errors (for example, expressing the type of non-zero numbers ). In addition, software testing is an empirical method for finding errors that such

744-418: A "common" language, the user gets the advantage of being able to transfer skills from application to application. A more generic alternative is simply to provide a library (often a C library) that a general-purpose language can use to control the application, without modifying the language for the specific domain. JavaScript began as and primarily still is a language for scripting inside web browsers ; however,

837-565: A certain kind of value from being used with values of which that operation does not make sense (validity errors). Type systems allow defining interfaces between different parts of a computer program, and then checking that the parts have been connected in a consistent way. This checking can happen statically (at compile time ), dynamically (at run time ), or as a combination of both. Type systems have other purposes as well, such as expressing business rules, enabling certain compiler optimizations , allowing for multiple dispatch , and providing

930-459: A computer program, the shell. Calvin Mooers in his TRAC language is generally credited with inventing command substitution , the ability to embed commands in scripts that, when interpreted, insert a character string into the script. Multics calls these active functions . Louis Pouzin wrote an early processor for command scripts called RUNCOM for CTSS around 1964. Stuart Madnick at MIT wrote

1023-400: A data type, termed typing , gives meaning to a sequence of bits such as a value in memory or some object such as a variable . The hardware of a general purpose computer is unable to discriminate between for example a memory address and an instruction code , or between a character , an integer , or a floating-point number , because it makes no intrinsic distinction between any of

SECTION 10

#1732859154000

1116-801: A dynamic check is needed to verify that the operation is safe. This requirement is one of the criticisms of downcasting. By definition, dynamic type checking may cause a program to fail at runtime. In some programming languages, it is possible to anticipate and recover from these failures. In others, type-checking errors are considered fatal. Programming languages that include dynamic type checking but not static type checking are often called "dynamically typed programming languages". Some languages allow both static and dynamic typing. For example, Java and some other ostensibly statically typed languages support downcasting types to their subtypes , querying an object to discover its dynamic type and other type operations that depend on runtime type information. Another example

1209-405: A form of documentation . An example of a simple type system is that of the C language . The portions of a C program are the function definitions. One function is invoked by another function. The interface of a function states the name of the function and a list of parameters that are passed to the function's code. The code of an invoking function states the name of the invoked, along with

1302-436: A general-purpose language may later develop special domain-specific dialects. Script is a subjective characterization that generally includes the following attributes. A script is usually not compiled – at least not its usual meaning. Generally, they are interpreted directly from source code or from bytecode or run as native after just-in-time compilation . A script is generally relatively short and simple. As there

1395-475: A language can be statically typed without requiring type declarations (examples include Haskell , Scala , OCaml , F# , Swift , and to a lesser extent C# and C++ ), so explicit type declaration is not a necessary requirement for static typing in all languages. Dynamic typing allows constructs that some (simple) static type checking would reject as illegal. For example, eval functions, which execute arbitrary data as code, become possible. An eval function

1488-474: A language for writing extensions to the browser itself, and several standard embedded languages for controlling the browser, including JavaScript (a dialect of ECMAScript ) or XUL . Scripting languages can be categorized into several different types, with a considerable degree of overlap among the types. Scripting is often contrasted with system programming , as in Ousterhout's dichotomy or " programming in

1581-405: A later point using delegation: Usually called partial application , this Groovy feature allows closures' parameters to be set to a default parameter in any of their arguments, creating a new closure with the bound value. Supplying one argument to the curry() method will fix argument one. Supplying N arguments will fix arguments 1 .. N. Curry can also be used in the reverse direction (fixing

1674-513: A line of code divides two integers, and is passed a string of letters instead of an integer. It is an unintended condition which might manifest in multiple stages of a program's development. Thus a facility for detection of the error is needed in the type system. In some languages, such as Haskell , for which type inference is automated, lint might be available to its compiler to aid in the detection of error. Type safety contributes to program correctness , but might only guarantee correctness at

1767-480: A macro language built into the editor, e.g., The SemWare Editor (TSE), vi improved (VIM), or using an external implementation, e.g., XEDIT , or both, e.g., KEDIT . Sometimes text editors and edit macros are used under the covers to provide other applications, e.g., FILELIST and RDRLIST in CMS . A major class of scripting languages has grown out of the automation of job control , which relates to starting and controlling

1860-469: A more finely grained rule set than basic type checking, but this comes at a price when the type inferences (and other properties) become undecidable , and when more attention must be paid by the programmer to annotate code or to consider computer-related operations and functioning. It is challenging to find a sufficiently expressive type system that satisfies all programming practices in a type safe manner. A programming language compiler can also implement

1953-425: A parameter to it, but exist in its declaration context, partial application (that it terms ' currying '), delegation, implicit, typed and untyped parameters. When working on Collections of a determined type, the closure passed to an operation on the collection can be inferred: A group of expressions can be written in a closure block without reference to an implementation and the responding object can be assigned at

SECTION 20

#1732859154000

2046-814: A reference whose static target type (or manifest type) is equal to either the object's run-time type (its latent type) or a supertype thereof. This is conformant with the Liskov substitution principle , which states that all operations performed on an instance of a given type can also be performed on an instance of a subtype. This concept is also known as subsumption or subtype polymorphism . In some languages subtypes may also possess covariant or contravariant return types and argument types respectively. Certain languages, for example Clojure , Common Lisp , or Cython are dynamically type checked by default, but allow programs to opt into static type checking by providing optional annotations. One reason to use such hints would be to optimize

2139-475: A scripting language for IBM's CP/CMS in 1966. He originally called this processor COMMAND, later named EXEC . Multics included an offshoot of CTSS RUNCOM, also called RUNCOM. EXEC was eventually replaced by EXEC 2 and REXX . Languages such as Tcl and Lua were specifically designed as general-purpose scripting languages that could be embedded in any application. Other languages such as Visual Basic for Applications (VBA) provided strong integration with

2232-530: A scripting language, notably the Google Chrome T-rex game. Early mainframe computers (in the 1950s) were non-interactive, instead using batch processing . IBM's Job Control Language (JCL) is the archetype of languages used to control batch processing. The first interactive shells were developed in the 1960s to enable remote operation of the first time-sharing systems, and these used shell scripts , which controlled running computer programs within

2325-447: A single application. A number of languages have been designed for the purpose of replacing application-specific scripting languages by being embeddable in application programs. The application programmer (working in C or another systems language) includes "hooks" where the scripting language can control the application. These languages may be technically equivalent to an application-specific extension language but when an application embeds

2418-402: A specific general-purpose language (e.g. QuakeC , modeled after C), they have custom features that distinguish them. Emacs Lisp , while a fully formed and capable dialect of Lisp , contains many special features that make it most useful for extending the editing functions of Emacs. An application-specific scripting language can be viewed as a domain-specific programming language specialized to

2511-420: A static type checker. The reason for this is that many useful features or properties are difficult or impossible to verify statically. For example, suppose that a program defines two types, A and B, where B is a subtype of A. If the program tries to convert a value of type A to type B, which is known as downcasting , then the operation is legal only if the value being converted is actually a value of type B. Thus,

2604-591: A streaming way through StreamingMarkupBuilder . To change the implementation to JSON, the MarkupBuilder can be swapped to JsonBuilder . To parse it and search for a functional language, Groovy's findAll method can serve: In Groovy, strings can be interpolated with variables and expressions by using GStrings: GStrings containing variables and expressions must be declared using double quotes. A complex expression must be enclosed in curly brackets. This prevents parts of it from being interpreted as belonging to

2697-407: A strict sense. Static type checking is the process of verifying the type safety of a program based on analysis of a program's text ( source code ). If a program passes a static type checker, then the program is guaranteed to satisfy some set of type safety properties for all possible inputs. Static type checking can be considered a limited form of program verification (see type safety ), and in

2790-581: A substantial amount of logic is written in script, it is better characterized as simply another software component, not "glue". Glue languages are especially useful for writing and maintaining: Glue language examples: Macro languages exposed to operating system or application components can serve as glue languages. These include Visual Basic for Applications , WordBasic , LotusScript , CorelScript , Hummingbird Basic, QuickScript, Rexx, SaxBasic , and WinWrap Basic. Other tools like AWK can also be considered glue languages, as can any language implemented by

2883-436: A term. For variables, the type system determines the allowed values of that term. Type systems formalize and enforce the otherwise implicit categories the programmer uses for algebraic data types , data structures , or other data types , such as "string", "array of float", "function returning boolean". Type systems are often specified as part of programming languages and built into interpreters and compilers , although

Apache Groovy - Misplaced Pages Continue

2976-613: A top-level project in November 2015. On February 7, 2020, Groovy 3.0 was released. Version 4.0 was released on January 25, 2022. Most valid Java files are also valid Groovy files. Although the two languages are similar, Groovy code can be more compact, because it does not need all the elements that Java needs. This makes it possible for Java programmers to learn Groovy gradually by starting with familiar Java syntax before acquiring more Groovy programming idioms . Groovy features not available in Java include both static and dynamic typing (with

3069-441: A touch-activated screen. These languages could in principle be used to control any GUI application; but, in practice their use is limited because their use needs support from the application and from the operating system . There are a few exceptions to this limitation. Some GUI scripting languages are based on recognizing graphical objects from their display screen pixels . These GUI scripting languages do not depend on support from

3162-467: A type checker would not detect. The process of verifying and enforcing the constraints of types— type checking —may occur at compile time (a static check) or at run-time (a dynamic check). If a language specification requires its typing rules strongly, more or less allowing only those automatic type conversions that do not lose information, one can refer to the process as strongly typed; i f not, as weakly typed . The terms are not usually used in

3255-447: A type-safe language, can also be considered an optimization. If a compiler can prove that a program is well-typed, then it does not need to emit dynamic safety checks, allowing the resulting compiled binary to run faster and to be smaller. Static type checking for Turing-complete languages is inherently conservative. That is, if a type system is both sound (meaning that it rejects all incorrect programs) and decidable (meaning that it

3348-436: A type. Even a type can become associated with a type. An implementation of a type system could in theory associate identifications called data type (a type of a value), class (a type of an object), and kind (a type of a type , or metatype). These are the abstractions that typing can go through, on a hierarchy of levels contained in a system. When a programming language evolves a more elaborate type system, it gains

3441-636: A value between any two types that have the same size, effectively subverting the type concept. Dynamic type checking is the process of verifying the type safety of a program at runtime. Implementations of dynamically type-checked languages generally associate each runtime object with a type tag (i.e., a reference to a type) containing its type information. This runtime type information (RTTI) can also be used to implement dynamic dispatch , late binding , downcasting , reflective programming (reflection), and similar features. Most type-safe languages include some form of dynamic type checking, even if they also have

3534-410: A way to bypass the type checker. Some languages allow programmers to choose between static and dynamic type safety. For example, historically C# declares variables statically, but C# 4.0 introduces the dynamic keyword, which is used to declare variables to be checked dynamically at runtime. Other languages allow writing code that is not type-safe; for example, in C , programmers can freely cast

3627-506: Is C++ RTTI . More generally, most programming languages include mechanisms for dispatching over different 'kinds' of data, such as disjoint unions , runtime polymorphism , and variant types . Even when not interacting with type annotations or type checking, such mechanisms are materially similar to dynamic typing implementations. See programming language for more discussion of the interactions between static and dynamic typing. Objects in object-oriented languages are usually accessed by

3720-407: Is a logical system comprising a set of rules that assigns a property called a type (for example, integer , floating point , string ) to every term (a word, phrase, or other set of symbols). Usually the terms are various language constructs of a computer program , such as variables , expressions , functions , or modules . A type system dictates the operations that can be performed on

3813-401: Is defined using the trait keyword: Then, it can be used like a normal interface using the keyword implements : Traits allow a wide range of abilities, from simple composition to testing. Notable examples of Groovy adoption include: Many integrated development environments (IDEs) and text editors support Groovy: Type system#STATIC In computer programming , a type system

Apache Groovy - Misplaced Pages Continue

3906-427: Is increased. Advocates of dependent typing , implemented in languages such as Dependent ML and Epigram , have suggested that almost all bugs can be considered type errors, if the types used in a program are properly declared by the programmer or correctly inferred by the compiler. Static typing usually results in compiled code that executes faster. When the compiler knows the exact data types that are in use (which

3999-500: Is necessary for static verification, either through declaration or inference) it can produce optimized machine code. Some dynamically typed languages such as Common Lisp allow optional type declarations for optimization for this reason. By contrast, dynamic typing may allow compilers to run faster and interpreters to dynamically load new code, because changes to source code in dynamically typed languages may result in less checking to perform and less code to revisit. This too may reduce

4092-427: Is no limit on size or complexity, script is subjective. A few lines of code without branching is probably considered a script. A codebase of multiple files, that performs sophisticated user or hardware interface or complicated algorithms or multiprogramming is probably not considered a script. A script usually automates a task that would otherwise be performed by a person in a more manual way. A language that

4185-402: Is possible to write an algorithm that determines whether a program is well-typed), then it must be incomplete (meaning there are correct programs, which are also rejected, even though they do not encounter runtime errors). For example, consider a program containing the code: Even if the expression <complex test> always evaluates to true at run-time, most type checkers will reject

4278-713: Is possible with static typing, but requires advanced uses of algebraic data types . Further, dynamic typing better accommodates transitional code and prototyping, such as allowing a placeholder data structure ( mock object ) to be transparently used in place of a full data structure (usually for the purposes of experimentation and testing). Dynamic typing typically allows duck typing (which enables easier code reuse ). Many languages with static typing also feature duck typing or other mechanisms like generic programming that also enable easier code reuse. Dynamic typing typically makes metaprogramming easier to use. For example, C++ templates are typically more cumbersome to write than

4371-424: Is primarily intended for scripting generally has limited capabilities compared to a general-purpose language. A scripting language may lack the functionality to write complex applications. Typically, a script starts executing at the first line of code whereas an application typically starts at a special point in the code called the entry point . For example, Java is not script-like since an application starts at

4464-432: Is sometimes referred to as very high-level programming language if it operates at a high level of abstraction, or as a control language , particularly for job control languages on mainframes. The term scripting language is sometimes used in a wider sense, to refer to dynamic high-level programming languages in general. Some are strictly interpreted languages , while others use a form of compilation. In this context,

4557-539: Is to let developers hook into the compilation process to be able to modify the AST before it is turned into bytecode that will be run by the JVM. AST Transformations provides Groovy with improved compile-time metaprogramming capabilities allowing powerful flexibility at the language level, without a runtime performance penalty." Examples of ASTs in Groovy are: among others. The testing framework Spock uses AST transformations to allow

4650-466: The Maya Embedded Language , or Blender which uses Python to fill this role. Some other types of applications that need faster feature addition or tweak-and-run cycles (e.g. game engines ) also use an embedded language. During the development, this allows them to prototype features faster and tweak more freely, without the need for the user to have intimate knowledge of the inner workings of

4743-1064: The OS version, WSH and the default script engines (VBScript and JScript) are available. Programmable calculators can be programmed in glue languages in three ways. For example, the Texas Instruments TI-92 , by factory default can be programmed with a command script language. Inclusion of the scripting and glue language Lua in the TI-NSpire series of calculators could be seen as a successor to this. The primary on-board high-level programming languages of most graphing calculators (most often Basic variants, sometimes Lisp derivatives, and more uncommonly, C derivatives) in many cases can glue together calculator functions—such as graphs, lists, matrices, etc. Third-party implementations of more comprehensive Basic version that may be closer to variants listed as glue languages in this article are available—and attempts to implement Perl, Rexx, or various operating system shells on

SECTION 50

#1732859154000

4836-544: The Spec Lead changed the status of JSR 241 to dormant. Strachan had left the project silently a year before the Groovy 1.0 release in 2007. In Oct 2016, Strachan stated "I still love groovy (jenkins pipelines are so groovy!), java, go, typescript and kotlin". On July 2, 2012, Groovy 2.0 was released, which, among other new features, added static compiling and static type checking . When the Pivotal Software joint venture

4929-481: The TI and HP graphing calculators are also mentioned. PC-based C cross-compilers for some of the TI and HP machines used with tools that convert between C and Perl, Rexx, AWK, and shell scripts to Perl, Modern Pascal, VBScript to and from Perl make it possible to write a program in a glue language for eventual implementation (as a compiled program) on the calculator. A number of text editors support macros written either using

5022-475: The advent of graphical user interfaces, a specialized kind of scripting language emerged for controlling a computer. These languages interact with the same graphic windows, menus, buttons, and so on, that a human user would. They do this by simulating the actions of a user. These languages are typically used to automate user actions. Such languages are also called " macros " when control is through simulated key presses or mouse clicks, as well as tapping or pressing on

5115-445: The automation facilities of an underlying system. Embedding of such general-purpose scripting languages instead of developing a new language for each application also had obvious benefits, relieving the application developer of the need to code a language translator from scratch and allowing the user to apply skills learned elsewhere. Some software incorporates several different scripting languages. Modern web browsers typically provide

5208-509: The behavior of system programs (in this sense, one might think of shells as being descendants of IBM's JCL, or Job Control Language , which was used for exactly this purpose). Many of these languages' interpreters double as command-line interpreters such as the Unix shell or the MS-DOS COMMAND.COM . Others, such as AppleScript offer the use of English-like commands to build scripts. With

5301-445: The combination of all places where values are created and all places where a certain value is used must be taken into account. A number of useful and common programming language features cannot be checked statically, such as downcasting . Thus, many languages will have both static and dynamic type checking; the static type checker verifies what it can, and dynamic checks verify the rest. Many languages with static type checking provide

5394-399: The compiler or specified by a programmer, a type system renders program behavior illegal if it falls outside the type-system rules. Advantages provided by programmer-specified type systems include: Advantages provided by compiler-specified type systems include: A type error occurs when an operation receives a different type of data than it expected. For example, a type error would happen if

5487-463: The cost of making the type checking itself an undecidable problem (as in the Halting problem ). In a type system with automated type checking, a program may prove to run incorrectly yet produce no compiler errors. Division by zero is an unsafe and incorrect operation, but a type checker which only runs at compile time does not scan for division by zero in most languages; that division would surface as

5580-480: The definition and manipulation of many types of heterogeneous data assets with a uniform and concise syntax and programming methodology. Unlike Java, a Groovy source code file can be executed as an (uncompiled) script , if it contains code outside any class definition, if it is a class with a main method, or if it is a Runnable or GroovyTestCase . A Groovy script is fully parsed, compiled, and generated before executing (similar to Python and Ruby). This occurs under

5673-478: The developer to intercept calls to an object and specify an action for them, in a simplified aspect-oriented way. The following code enables the class java.lang.String to respond to the hex property: The Grails framework uses metaprogramming extensively to enable GORM dynamic finders, like User.findByName('Josh') and others. Groovy's syntax permits omitting parentheses and dots in some situations. The following groovy code can be written as enabling

SECTION 60

#1732859154000

5766-495: The development of domain-specific languages (DSLs) that look like plain English. Although Groovy is mostly an object-oriented language, it also offers functional programming features. According to Groovy's documentation: "Closures in Groovy work similar to a 'method pointer', enabling code to be written and run in a later point in time". Groovy's closures support free variables, i.e. variables that have not been explicitly passed as

5859-605: The development of Groovy on his blog in August 2003. In March 2004, Groovy was submitted to the JCP as JSR 241 and accepted by ballot. Several versions were released between 2004 and 2006. After the Java Community Process (JCP) standardization effort began, the version numbering changed, and a version called "1.0" was released on January 2, 2007. After various betas and release candidates numbered 1.1, on December 7, 2007, Groovy 1.1 Final

5952-430: The differences between type systems that lead people to call them "strong" or "weak". Scripting language In computing, a script is a relatively short and simple set of instructions that typically automate an otherwise manual process. The act of writing a script is called scripting . Scripting language or script language describes a programming language that is used for scripting. Originally, scripting

6045-427: The edit-compile-test-debug cycle. Statically typed languages that lack type inference (such as C and Java prior to version 10 ) require that programmers declare the types that a method or function must use. This can serve as added program documentation, that is active and dynamic, instead of static. This allows a compiler to prevent it from drifting out of synchrony, and from being ignored by programmers. However,

6138-468: The equivalent Ruby or Python code since C++ has stronger rules regarding type definitions (for both functions and variables). This forces a developer to write more boilerplate code for a template than a Python developer would need to. More advanced run-time constructs such as metaclasses and introspection are often harder to use in statically typed languages. In some languages, such features may also be used e.g. to generate new types and behaviors on

6231-450: The fly, based on run-time data. Such advanced constructs are often provided by dynamic programming languages ; many of these are dynamically typed, although dynamic typing need not be related to dynamic programming languages . Languages are often colloquially referred to as strongly typed or weakly typed . In fact, there is no universally accepted definition of what these terms mean. In general, there are more precise terms to represent

6324-482: The function named main which need not be at the top of the code. The following code starts at main , then calls printHelloWorld which prints "Hello World". In contrast, the following Python code prints "Hello World" without the main function or other syntax such as a class definition required by Java. Scripts are often created or modified by the person executing them, but they are also often distributed, such as when large portions of games are written in

6417-709: The hood, and the compiled version is not saved as an artifact of the process. GroovyBeans are Groovy's version of JavaBeans . Groovy implicitly generates getters and setters. In the following code, setColor(String color) and getColor() are implicitly generated. The last two lines, which appear to access color directly, are actually calling the implicitly generated methods. Groovy offers simple, consistent syntax for handling lists and maps , reminiscent of Java's array syntax. Groovy offers support for prototype extension through ExpandoMetaClass , Extension Modules (only in Groovy 2), Objective-C-like Categories and DelegatingMetaClass . ExpandoMetaClass offers

6510-436: The keyword def ), operator overloading , native syntax for lists and associative arrays (maps), native support for regular expressions , polymorphic iteration, string interpolation , added helper methods, and the safe navigation operator ?. to check automatically for null pointers (for example, variable?.method() , or variable?.field ). Since version 2 Groovy also supports modularity (being able to ship only

6603-432: The large and programming in the small ". In this view, scripting is glue code , connecting software components , and a language specialized for this purpose is a glue language . Pipelines and shell scripting are archetypal examples of glue languages, and Perl was initially developed to fill this same role. Web development can be considered a use of glue languages, interfacing between a database and web server . But if

6696-473: The last N arguments) using rcurry() . Groovy also supports lazy evaluation , reduce/fold , infinite structures and immutability , among others. On JavaScript Object Notation ( JSON ) and XML processing, Groovy employs the Builder pattern , making the production of the data structure less verbose. For example, the following XML: can be generated via the following Groovy code: and also can be processed in

6789-511: The manner of their evaluation affect the typing of the language. A programming language may further associate an operation with various resolutions for each type, in the case of type polymorphism . Type theory is the study of type systems. The concrete types of some programming languages, such as integers and strings, depend on practical issues of computer architecture , compiler implementation, and language design . Formally, type theory studies type systems. A programming language must have

6882-411: The names of variables that hold values to pass to it. During a computer program 's execution, the values are placed into temporary storage, then execution jumps to the code of the invoked function. The invoked function's code accesses the values and makes use of them. If the instructions inside the function are written with the assumption of receiving an integer value, but the calling code passed

6975-502: The needed jars according to the project needs, thus reducing the size of Groovy's library), type checking, static compiling, Project Coin syntax enhancements, multicatch blocks and ongoing performance enhancements using the invokedynamic instruction introduced in Java 7 . Groovy provides native support for various markup languages such as XML and HTML , accomplished via an inline Document Object Model (DOM) syntax. This feature enables

7068-515: The operating system or application. When the GUI provides the appropriate interfaces, as in the IBM Workplace Shell , a generic scripting language, e.g. OREXX , can be used for writing GUI scripts. Application specific languages can be split in many different categories, i.e. standalone based app languages (executable) or internal application specific languages (postscript, xml, gscript as some of

7161-452: The opportunity to type check using the type system whether at compile time or runtime, manually annotated or automatically inferred. As Mark Manasse concisely put it: The fundamental problem addressed by a type theory is to ensure that programs have meaning. The fundamental problem caused by a type theory is that meaningful programs may not have meanings ascribed to them. The quest for richer type systems results from this tension. Assigning

7254-499: The performance of critical sections of a program. This is formalized by gradual typing . The programming environment DrRacket , a pedagogic environment based on Lisp, and a precursor of the language Racket is also soft-typed. Conversely, as of version 4.0, the C# language provides a way to indicate that a variable should not be statically type checked. A variable whose type is dynamic will not be subject to static type checking. Instead,

7347-485: The possible values that a sequence of bits might mean . Associating a sequence of bits with a type conveys that meaning to the programmable hardware to form a symbolic system composed of that hardware and some program. A program associates each value with at least one specific type, but it also can occur that one value is associated with many subtypes . Other entities, such as objects , modules , communication channels , and dependencies can become associated with

7440-415: The program as ill-typed, because it is difficult (if not impossible) for a static analyzer to determine that the else branch will not be taken. Consequently, a static type checker will quickly detect type errors in rarely used code paths. Without static type checking, even code coverage tests with 100% coverage may be unable to find such type errors. The tests may fail to detect such type errors, because

7533-502: The program relies on runtime type information to determine how the variable may be used. In Rust , the dyn std :: any :: Any type provides dynamic typing of ' static types. The choice between static and dynamic typing requires certain trade-offs . Static typing can find type errors reliably at compile time, which increases the reliability of the delivered program. However, programmers disagree over how commonly type errors occur, resulting in further disagreements over

7626-507: The programmer to write tests in a syntax not supported by Groovy, but the relevant code is then manipulated in the AST to valid code. An example of such a test is: According to Groovy's documentation, " Traits are a structural construct of the language that allows: composition of behaviors, runtime implementation of interfaces, behavior overriding, and compatibility with static type checking/compilation." Traits can be seen as interfaces carrying both default implementations and state. A trait

7719-409: The proportion of those bugs that are coded that would be caught by appropriately representing the designed types in code. Static typing advocates believe programs are more reliable when they have been well type-checked, whereas dynamic-typing advocates point to distributed code that has proven reliable and to small bug databases. The value of static typing increases as the strength of the type system

7812-559: The standardization of the language as ECMAScript has made it popular as a general-purpose embeddable language. In particular, the Mozilla implementation SpiderMonkey is embedded in several environments such as the Yahoo! Widget Engine . Other applications embedding ECMAScript implementations include the Adobe products Adobe Flash ( ActionScript ) and Adobe Acrobat (for scripting PDF files). Tcl

7905-472: The storage it needs and the choice of algorithms for operations on the value. In many C compilers the float data type , for example, is represented in 32 bits , in accord with the IEEE specification for single-precision floating point numbers . They will thus use floating-point-specific microprocessor operations on those values (floating-point addition, multiplication, etc.). The depth of type constraints and

7998-432: The surrounding string instead of to the expression: Expression evaluation can be deferred by employing arrow syntax: According to Groovy's own documentation, "When the Groovy compiler compiles Groovy scripts and classes, at some point in the process, the source code will end up being represented in memory in the form of a Concrete Syntax Tree, then transformed into an Abstract Syntax Tree. The purpose of AST Transformations

8091-434: The term script refers to a small program in such a language; typically, contained in a single file, and no larger than a few thousand lines of code. The scope of scripting languages ranges from small to large, and from highly domain-specific language to general-purpose programming languages . A language may start as small and highly domain-specific and later develop into a portable and general-purpose language; conversely,

8184-430: The type system of a language can be extended by optional tools that perform added checks using the language's original type syntax and grammar . The main purpose of a type system in a programming language is to reduce possibilities for bugs in computer programs due to type errors . The given type system in question determines what constitutes a type error, but in general, the aim is to prevent operations expecting

8277-444: The widely distributed scripts, respectively implemented by Adobe, MS and Google) among others include an idiomatic scripting language tailored to the needs of the application user. Likewise, many computer game systems use a custom scripting language to express the programmed actions of non-player characters and the game environment. Languages of this sort are designed for a single application; and, while they may superficially resemble

8370-451: Was created as an extension language but has come to be used more frequently as a general-purpose language in roles similar to Python , Perl , and Ruby . On the other hand, Rexx was originally created as a job control language, but is widely used as an extension language as well as a general-purpose language. Perl is a general-purpose language, but had the Oraperl (1990) dialect, consisting of

8463-467: Was limited to automating an operating system shell and languages were relatively simple. Today, scripting is more pervasive and some languages include modern features that allow them to be used for application development as well as scripting. A scripting language can be a general purpose language or a domain-specific language for a particular environment. When embedded in an application, it may be called an extension language . A scripting language

8556-431: Was released and immediately renumbered as Groovy 1.5 to reflect the many changes made. In 2007, Groovy won the first prize at JAX 2007 innovation award. In 2008, Grails , a Groovy web framework , won the second prize at JAX 2008 innovation award. In November 2008, SpringSource acquired the Groovy and Grails company (G2One). In August 2009 VMware acquired SpringSource. In April 2012, after eight years of inactivity,

8649-529: Was spun-off by EMC Corporation (EMC) and VMware in April 2013, Groovy and Grails formed part of its product portfolio. Pivotal ceased sponsoring Groovy and Grails from April 2015. That same month, Groovy changed its governance structure from a Codehaus repository to a Project Management Committee (PMC) in the Apache Software Foundation via its incubator. Groovy graduated from Apache's incubator and became

#0