101 lines
5.3 KiB
Markdown
101 lines
5.3 KiB
Markdown
|
---
|
||
|
title: "My Experience With V"
|
||
|
date: 2022-06-26
|
||
|
draft: true
|
||
|
---
|
||
|
|
||
|
For the last half a year or so, I've written code nearly exclusively in the V
|
||
|
programming language (excluding college projects). In this time, I've learned a
|
||
|
lot about the language, as well as being an active member of the community.
|
||
|
|
||
|
I don't recall exactly how I discovered V. being the kind of nerd that has a
|
||
|
list of languages they wanna try, I probably saw it somewhere & added it.
|
||
|
Luckily, V was the one I wanted to try out the most. After visiting
|
||
|
[vlang.io](https://vlang.io/), I joined the Discord server & that's where the
|
||
|
fun began!
|
||
|
|
||
|
Before I talk about the language itself, I would like to take a moment to
|
||
|
appreciate the community. I felt welcome the moment I joined, and everyone
|
||
|
(especially the V developers) was very helpful with any questions I had. If it
|
||
|
wasn't for their help, [Vieter](https://git.rustybever.be/vieter-v/vieter)
|
||
|
probably wouldn't be as far along as it is today!
|
||
|
|
||
|
## What's V?
|
||
|
|
||
|
While I'm not interested in giving a full description of the language, a short
|
||
|
introduction is in order. V is a compiled programming language with a syntax
|
||
|
very similar to Go. The main compiler backend transpiles V to C, providing
|
||
|
interopt with C code without any effort. This also gives the compilation phase
|
||
|
access to all optimisations that C compilers have to offer, resulting in very
|
||
|
fast & optimized binaries. I'd list more things, but then it wouldn't be short
|
||
|
anymore!
|
||
|
|
||
|
## Developing in V
|
||
|
|
||
|
Now for the relevant part of this post, the actual developing!
|
||
|
|
||
|
Developing locally in V is pretty straightforward. Write some code, run `v .`,
|
||
|
blink, see if you made a mistake, repeat. For me, this is a very important
|
||
|
feature of V. Not only does the compiler handle the "build system" for you;
|
||
|
it's also incredibly fast. This is accomplished by using the tcc compiler, a
|
||
|
small & extremely fast C compiler, for development builds. Thanks to this,
|
||
|
compiling my code doesn't take me out of "the flow"; a problem that I've faced
|
||
|
when working with Rust code, as I'm very sensitive to losing focus.
|
||
|
|
||
|
Building optimized binaries is equally simple; just run `v -prod .`. This will
|
||
|
use either gcc or clang to compile your code using the max optimisation levels.
|
||
|
|
||
|
Due to the rapidly developing nature of V, it is possible that old code no
|
||
|
longer compiles on a newer compiler. This won't happen once the language is
|
||
|
stabilized, but as of today, changes can occur. I don't actually know how
|
||
|
others handle this, but I personally maintain a mirror of the compiler that I
|
||
|
update regularly. This way, I decide when code might break, meaning I can react
|
||
|
quickly to make sure nothing stays broken for long. This brings me to my CI
|
||
|
setup!
|
||
|
|
||
|
Because overengineering is fun, I have my own CI server that I use to test &
|
||
|
deploy basically everything I create; V software is no exception! Using Docker
|
||
|
buildx, I create multi-architecture Alpine-based images containing my compiler
|
||
|
fork & any C library dependencies that I use. These images are then used in my
|
||
|
CI to build statically compiled binaries that I can use to create the actual
|
||
|
Docker images! Due to V compiling to C, compiling static binaries is quite
|
||
|
simple; just build using a musl-based OS such as Alpine Linux.
|
||
|
|
||
|
Enough drooling over my CI, back to V! Yes, when I was writing code in V, I
|
||
|
encountered some bugs in the compiler. While a bit inconvenient at times, they
|
||
|
definitely weren't a showstopper for me. V is still a developing language; I'm
|
||
|
not gonna try to advertise that it isn't. The thing is though, I was able to
|
||
|
report these compiler bugs to the community immediately, many of which being
|
||
|
fixed within 24 hours by one of the V developers! V might still be in
|
||
|
development, but it's definitely already ready for developing projects. My
|
||
|
[vieter](https://git.rustybever.be/vieter-v/vieter) project has nearly 4k SLoC
|
||
|
and still compiles just as quickly as when I started it. The resulting binaries
|
||
|
are rock-solid; my personal Vieter instance has been running for months without
|
||
|
issues.
|
||
|
|
||
|
## Conclusion?
|
||
|
|
||
|
It's clear from this post that I've taken a liking to V. The amount of
|
||
|
evolution I've seen in the months that I've been using it is impressive, and
|
||
|
I'm certain that V will reach its goal of being a stable language. I'm fine
|
||
|
tagging along until that day comes :)
|
||
|
|
||
|
In the context of developing Vieter, I've written a multitude of software
|
||
|
pieces, ranging from a cron daemon to a rewrite of Arch Linux's `repo-add`
|
||
|
command. This variety gives me confidence that V can already be used to develop
|
||
|
varied & complex software.
|
||
|
|
||
|
Besides developing Vieter, I'd like to enrich the ecosystem with packages that
|
||
|
I think will be useful for everyone. To this end, I've started splitting off
|
||
|
modules of the Vieter codebase & developing them independently. My first goal
|
||
|
will be writing a Docker client
|
||
|
[library](https://git.rustybever.be/vieter-v/docker), as I find this to be very
|
||
|
useful for any language to have (and also I need it myself of course).
|
||
|
|
||
|
Now, I know using these new and/or developing languages is not for everyone.
|
||
|
Some just prefer sticking to the proven titans of the industry, and that's
|
||
|
fine. However, for those like me that love using these new langs, I really do
|
||
|
recommend checking out V. It's fast, it's of course free and open-source, and
|
||
|
using a language is one of the best ways of helping it move forward. Perhaps
|
||
|
when you join, you'll see a Chewing Bever babbling on ;)
|