Qore (programming language)

{{Short description|Dynamic programming language}}

{{multiple issues|

{{COI|date=July 2019}}

{{Primary sources|date=July 2019}}

{{Notability|date=May 2023}}

}}

{{Infobox programming language

| name = Qore

| paradigm = multi-paradigm: thread safe/parallel/shared memory, functional, imperative, object-oriented (class-based), procedural, functional

| designer = David Nichols

| developer = David Nichols

| latest_release_version = [https://github.com/qorelanguage/qore/releases/tag/release-1.16.1 1.16.1]

| latest_release_date = {{Start date and age|2023|07|02}}

| turing-complete = Yes

| typing = Dynamic, Optionally Strong

| influenced_by = Perl, D, C++, Java

| programming_language = C++, Pthreads

| operating_system = Cross-platform

| license = MIT License, GNU General Public License, GNU Lesser General Public License

| website = {{URL|www.qore.org}}

| file_ext = .q, .qm, .qtest

}}

Qore is an interpreted, high-level, general-purpose, garbage collected dynamic programming language, featuring support for code embedding and sandboxing with optional strong typing and a focus on fundamental support for multithreading and SMP scalability.

Qore is unique because it is an interpreted scripting language with fundamental support for multithreading (meaning more than one part of the same code can run at the same time), and additionally because it features automatic memory management (meaning programmers do not have to allocate and free memory explicitly) while also supporting the RAII idiom with destructors for scope-based resource management and exception-safe programming.{{cite web|url=https://github.com/qorelanguage/qore/wiki/Why-Use-Qore%3F|title=Why use Qore?|publisher=Qore.org |date=2016-06-13|access-date=2016-06-14}} This is due to Qore's unique [https://github.com/qorelanguage/qore/wiki/Prompt-Collection prompt collection] implementation for garbage collection.

Qore Scripts

Qore scripts typically have the following extensions:

  • .q: for Qore scripts
  • .qm: for Qore user modules
  • .qtest: for Qore test scripts

Executable Qore scripts on Unix-like operating systems will typically start with a hashbang to specify the filename of the interpreter as follows:

#!/usr/bin/env qore

Syntax

Qore syntax is similar to and inspired from the following programming languages:{{cite web|url=https://github.com/qorelanguage/qore/blob/develop/ABOUT |title=qore/ABOUT at develop · qorelanguage/qore · GitHub |website=Github.com |access-date=2016-08-10}}

  • Perl: without %new-style, Qore's syntax is highly similar to Perl; the foreach statement, splice, push, pop, chomp operators, Perl5-compatible regular expressions, and more
  • Java: with %new-style, Qore code looks more similar to Java;{{cite web|url=https://docs.qore.org/current/lang/html/parse_directives.html#new-style |title=Qore Programming Language Reference Manual: Parse Directives |website=Docs.qore.org |access-date=2016-08-10}} the synchronized keyword, the instanceof operator, object and class implementation
  • C++: multiple inheritance, exception handling, static methods, abstract methods
  • D: the on_exit, on_success, and on_error statements provide exception-aware functionality similar to D's scope(exit), scope(failure), allowing exception-aware cleanup code to be placed next to the code requiring cleanup
  • Haskell: the map, foldl, foldr, and select operators with lazy evaluation of functional and list operators and statements

Data Types

Basic types include: boolean, string, integer, float, date, binary,{{cite web|url=http://docs.qore.org/current/lang/html/basic_data_types.html |title=Basic Data Types |publisher=Qore.org |access-date=2012-05-31}} list, hash (associative arrays), and object,{{cite web|url=https://docs.qore.org/current/lang/html/container_data_types.html |title=Qore Programming Language Reference Manual: Container Data Types |website=Docs.qore.org |access-date=2016-08-10}} as well as code code for code used as a data type.{{cite web|url=https://docs.qore.org/current/lang/html/code_data_types.html |title=Qore Programming Language Reference Manual: Code Data Types |website=Docs.qore.org |access-date=2016-08-10}}

Complex types are also supported such as hash<string, bool>, list<string>, reference<list<string>> as well as [https://docs.qore.org/current/lang/html/hashdecl.html type-safe hashes].

Multithreading

Despite being an interpreted language, Qore was designed to support multithreading as a fundamental design principle. All elements of Qore are thread-safe, and the language in general has been designed with SMP scalability in mind. Because all elements of the language were designed to support multithreading, Qore programs and scripts do not have to limit themselves to a subset of Qore's functionality, which is also why there is no Global interpreter lock in Qore.{{cite web|url=https://docs.qore.org/current/lang/html/threading.html |title=Qore Programming Language Reference Manual: Threading |website=Docs.qore.org |access-date=2016-08-10}}

Threading functionality in Qore is provided by the operating system's POSIX threads library.

Garbage Collection

Qore features a unique garbage collection approach called [https://github.com/qorelanguage/qore/wiki/Prompt-Collection prompt collection] that allows destructors to be run immediately when objects go out of scope, even if they have recursive references back to themselves. This allows for Qore to support the RAII idiom and also perform garbage collected automatic memory management.

Support for Code Embedding and Sandboxing

Qore was designed to support embedding and sandboxing logic in applications; this also applies to applications written in Qore as well as applications using the Qore library's public C++ API. By using the Program class which represents a logic container with sandboxing controls, discrete objects can be created and destroyed at runtime containing embedded code to extend or modify the behavior of your application in user-defined ways.{{cite web|url=https://docs.qore.org/current/lang/html/class_qore_1_1_program.html |title=Program Class |publisher=Qore.org |access-date=2016-06-13}}

Runtime Library

Qore's standard runtime library supports data mapping, APIs for communicating with databases (including high-level APIs for SQL operations, schema management, and DBA actions), client APIs and server infrastructure implementations for many protocols including HTTP, REST (with REST schema validation/code generation including Swagger support), client/server SOAP support (including code and message generation), WebSocket, RPC protocols, [https://docs.qore.org/current/modules/ConnectionProvider/html/index.html generic connector APIs], [https://docs.qore.org/current/modules/Mapper/html/index.html generic data mapping APIs], and many file format and file- and data-exchange protocols and more.{{cite web|url=https://github.com/qorelanguage/qore/wiki/Modules |title=Modules · qorelanguage/qore Wiki · GitHub |website=Github.com |date=2016-06-12 |access-date=2016-08-10}}

Testing

Qore supports testing through the [https://docs.qore.org/current/modules/QUnit/html/index.html QUnit module] which facilitates automated testing and Continuous integration processes for code written in Qore.

Availability

Qore's Git (software) repository is hosted on [https://github.com/qorelanguage/qore GitHub]. Binary packages are available as [http://software.opensuse.org/download.html?project=home%3Adavidnichols&package=qore RPM] s, in MacPorts and in FreeBSD Ports as well as for other operating systems, including Microsoft Windows; see [https://github.com/qorelanguage/qore/wiki/General-Source-and-Download-Info General Source and Download Info] on the Qore wiki for more information.

References

{{Reflist}}