V as a framework
With the suite of packages V comes with, it can be considered equivalent to a framework. A framework generally comprises all the features of full-blown programming, along with the ability to smoothly plug and play the external packages. Using V, you can write enterprise-grade software, even though it is still in development. In the following sections of this chapter, we will look at the various suites of libraries and features that are written and implemented using V, which will help us build robust software applications.
Memory management using the autofree engine
V offers robust memory management with automatic garbage collection capabilities. Most of the objects are freed by V's autofree engine. Starting with V version 0.3, the autofree engine is enabled by default. You can also forcefully enable the autofree engine using the -autofree
flag.
With the help of the autofree engine, the V compiler invokes the necessary calls to automatically free up objects during compilation. A small fraction of the objects is released from memory via reference counting. V also offers the ability to turn off the automatic garbage collection capability with the help of the -noautofree
flag.
Built-in ORM
It is unlikely that a programming language will be available with a built-in Object Relational Mapper (ORM ), but V is. Though the orm
library is in an alpha state at the time of writing this book, it has all the basic features, which are enough to implement data-driven applications that have relational databases as backends.
Currently, the orm
library supports SQLite, MySQL, and Postgres and has planned support for popular relational databases such as MS SQL and Oracle.
The built-in orm
eases the development time by offering you the standard V-based queries to interact with all the aforementioned relational databases. You will learn more about ORM in Chapter 13, Introduction to JSON and ORM.
Built-in web server
The vweb
web server is a built-in library. Though it is in an alpha state at the time of writing this book, it offers various features in its current state, including the following:
- Built-in routing.
- Handling parameters.
- Templating engine.
- Very fast performance, like C on the web.
- Building the project using
vweb
generates a single binary, thus simplifying deployments.
You will learn how to implement a microservice with RESTful endpoints using vweb
, along with other libraries such as orm
and json
, in Chapter 14, Building a Microservice.
Native cross-platform GUI library
V has a cross-platform ui
library. Using this library, you can leverage the power of building cross-platform GUI applications. The ui
library can be found at the official GitHub repository at https://github.com/vlang/ui, which is licensed under GPL 3.0.
V has a ui
module that uses native GUI toolkits: WinAPI/GDI+ on Windows and Cocoa on macOS. On Linux, custom drawing is used.
Vinix – an OS kernel written in V
Vinix is an effort to write a modern, fast, and useful OS using V. Vinix is purposefully built to facilitate writing low-level software.
The Vinix OS is licensed under GPL 2.0, and you can find its entire source code on its official GitHub repository at https://github.com/vlang/vinix. You can always download the latest version of the Vinix OS in the form of ISO from the official link: https://builds.vinix-os.org/repos/files/vinix/latest/vinix.iso.
Vinix aims to have the following features:
- Make a usable OS that can run on emulators, virtual machines, and physical hardware
- Target modern 64-bit architectures, CPU features, and multi-core computing
- Maintain good source-level compatibility with Linux, which helps with porting programs between Vinix and Linux
- Explore V's capabilities in bare-metal programming
- Improve the compiler in response to the uncommon needs of bare-metal programming