Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Getting Started with V Programming
  • Toc
  • feedback
Getting Started with V Programming

Getting Started with V Programming

By : Pavan Kumar Rao
4.4 (16)
close
Getting Started with V Programming

Getting Started with V Programming

4.4 (16)
By: Pavan Kumar Rao

Overview of this book

A new language on the block, V comes with a promising set of features such as fast compilation and interoperability with other programming languages. This is the first book on the V programming language, packed with concise information and a walkthrough of all the features you need to know to get started with the language. The book begins by covering the fundamentals to help you learn about the basic features of V and the suite of built-in libraries available within the V ecosystem. You'll become familiar with primitive data types, declaring variables, arrays, and maps. In addition to basic programming, you'll develop a solid understanding of the building blocks of programming, including functions, structs, and modules in the V programming language. As you advance through the chapters, you'll learn how to implement concurrency in V Programming, and finally learn how to write test cases for functions. This book takes you through an end-to-end project that will guide you to build fast and maintainable RESTful microservices by leveraging the power of V and its built-in libraries. By the end of this V programming book, you'll be well-versed with the V programming language and be able to start writing your own programs and applications.
Table of Contents (19 chapters)
close
1
Section 1: Introduction to the V Programming Language
4
Section 2: Basics of V Programming
12
Section 3: Advanced Concepts in V Programming

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
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete