DEV Community

Cover image for Hello V-Lang
Arpan Pandey
Arpan Pandey

Posted on • Originally published at blog.hackersreboot.tech

Hello V-Lang

V-lang is an extraordinarily powerful language that can help you create a variety of applications. Its features are very unique: it can be used to create web servers, cross-platform UIs, OSs etc. It is so powerful and compact that the whole compiler is only 10MB.

What is V-Lang?

The V-Lang is a very very fast language at both performance and compilation. The language and the binaries it creates are very very small in size (like in KBs mostly or some KBs). The language supports multiple Operating Systems and also allows you to cross-compile for other platforms. The language itself is very new but has managed to help in the creation of so many blazingly fast frameworks, tools and a lot of other good stuff.

Features of V-lang

V-lang has completely blown my mind with all these features it can offer and that too at this young age. Let's get down to discuss some of them.

Performace

The author(s) have claimed that V is as fast as C and we all know that, that is quite saying something. This is because of the unique ways in which it manages memory, has built-in serialization without runtime reflection and a whole host of other features that the creators of this masterpiece have managed to fit into it.

Fast Compilation

V compiles β‰ˆ110k (Clang backend) and β‰ˆ1 million (x64 and tcc backends) lines of code per second per CPU core. (Intel i5-7500, SM0256L SSD, no optimization)

V is written in V and compiles itself in under a second.

V's official website

V is very fast to compile and even complex programs take barely a second to compile. If that is not fast then I don't know what is. Also, it can be attributed to the minuscule size of the binaries that it produces.

Innovative memory management

V avoids a lot of unnecessary allocation in the first place by using value types and string buffers thus promoting a simple abstraction-free code style.
V also has this great auto-free engine that frees about 90-100% of objects at compile time via adding the necessary free commands. Most of all, this system is completely optional and you don't need to change a thing in your code (like Python, JS etc)

The small and easy-to-build compiler

The V compiler can be bootstrapped in under a second, yes you read that right, in under a second. The V compiler is only 10 Mb and can be built in nearly 0.3s.

C Translation

For all those who want to use V but already have projects in C, the V compiler can also translate (rather transpile) your C code to V and vice-versa.

Hot-code Reloading

We (especially web-devs) are way too used to hot-code reloading and to help y'all, V has taken care of that too, so enjoy the experience.

Powerful Graphics Libraries

Fancy graphics required? Look no further, V has:

Cross-platform drawing library built on top of GDI+/Cocoa Drawing, and an OpenGL based graphics library for more complex 2D/3D applications.

(For normies like me, they are both very powerful graphics libraries)

This library also gives us a ton of features like:

  • The ability to load complex 3D objects using textures
  • A Camera for moving and looking around
  • Skeletal Animations

Heck, they are even planning to support DirectX, Vulkan, and Metal.

Native cross-platform GUI library

Want to develop Great GUIs for multiple platforms and that too with one codebase? Again, V has got your back. You don't need to embed Web pages or hacks like that (cough, cough Electron). The V-UI package uses native GUI toolkits to help you develop easily and effortlessly.

Easy Cross Compilation

It is very very easy to cross-compile programs in V to run them on other platforms. Again quoting the official website,

To cross-compile your software simply run v -os windows. or v -os Linux. No extra steps are required, even for GUI and graphical apps!

Painless deployments and dependency management

You don't need complex Makefiles, headers, scripts etc to build a project, even the largest of V Projects can be built using v ..

It even has its own package manager called vpm, to install something all you need to do is v install [package].

Running it everywhere

V can emit human-readable C, thus enabling the great platform support of C with tools like GCC, Clang etc. The optimizations by GCC/Clang can thus be greatly utilised with V.

In fact, V can call C Code and any language with C-interop can call V Code.

Code formatting with vfmt for consistent style

V also gives you a tool to format your code out of the box. This helps maintain code style and best practices across packages. Also, no more code style debates. Just run:
v fmt -w [file_name].v

A built-in code profiler

Want to know all your function calls, average time per call etc in detail? V gives you a profiler to help with tasks like these to help debug, make reports etc.

JS Transpilation and WASM Support

V can also be very easily transpiled to JavaScript and also be compiled to WASM for all your web related needs. Just run:
v -o hello.js hello.v

Automatic documentation

V also provides vdoc, a tool that can generate documentation directly from the source code. Thus, eliminating one of the biggest developer struggles and helping us focus on the code itself.

Built-in testing framework

V has a built-in testing framework to help with testing your code more easily and without relying on a third party for that. All you need to do is prefix a test function with test_ and then use the familiar assert keyword.

Built-in web framework

V also provides an excellent web framework out of the box called vweb that can do a lot of the heavy lifting that you may need to write performant, compact and powerful web servers.

Built-in ORM

V also features an excellent ORM that absorbs the best qualities of many ORMs. It provides a lot of features while staying minimal and performant. Also, you can just write V instead of SQL while interacting with databases.

What kind of tools will I need?

V just works with awesome support for many of the popular code editors like VSCode, Sublime Text, Vim and others. The V Team and the community have created a ton of tools in pure V. These tools help the overall experience and showcase V's ability as a great and mature language. Some of them are:

  • Vinix- An open-source Operating System that can already run GCC, Bash, V etc.
  • Volt- A 300Kb native desktop client for Slack, Discord, Skype, Gmail, Twitter, Facebook, and more.
  • VSQL- A single-file SQL database written in pure V with no dependencies.
  • Gitly- Open-source light and fast alternative to GitHub/GitLab, written entirely in V.
  • Vorum- Right now it's a very basic forum/blogging software, but in the future, it will be a full-featured light alternative to Discourse. The V forum runs on Vorum.
  • Vgram- A bot library for Telegram Bot API.

Where to get V-Lang?

Oh, so you are interested in using V-Lang? Even if not, trust me you should definitely try it out. The official V-Lang website over at:

https://vlang.io/

Conclusion

V-lang is a great new language for doing all kinds of tasks from web servers to native GUIs, shell scripts and whatnot. It will be interesting to see how its future shapes up and how the community reacts to it. Is it an interesting and powerful tool? Absolutely. Should you try it? Again, absolutely.

See you in the next one!

Top comments (5)

Collapse
 
menard_codes profile image
Menard Maranan

I first saw this language on YouTube (YT Shorts). I think this is actually an interesting language to learn, though people might hesitate due to its very small market share (being a new language). It still needs to gain a lot of traction in order for devs to embrace it.

Collapse
 
ankitvats21 profile image
Ankit Mishra

I think languages which are backed up with Tech Giants gains faster traction even if their alternative is available. But if it really has great features then Market will adopt it very soon.

Collapse
 
hrbt profile image
Arpan Pandey

I 100% agree. In fact, the main aim of this article was to inform more and more people about it and bring some traction to it.

Collapse
 
_genjudev profile image
Larson • Edited

V also features an excellent ORM that absorbs the best qualities of many ORMs. It provides a lot of features while staying minimal and performant. Also, you can just write V instead of SQL while interacting with databases.

what does this even mean?

So we use V now because it's "easy"? But V is just C right? Is V not just like a toolkit?

Collapse
 
hrbt profile image
Arpan Pandey

Uhh not exactly, the built in ORM I talked about uses pure V code and translates it to SQL for you, or that is what I get. The select statements for example are like SQL but are native to V therefore you can use all sorts of dynamic operations.