V (Vlang) 0.2
github.com
github.com
Very excited about this release.
This is the first major release after 0.1.
The focus has been on stability and compile-time memory management. The demo of that was posted here recently [0].
7600 commits, 4110 handled pull requests, 340 contributors, 20k GitHub stars. What a journey!
The GUI library renders everything, and the result looks very similar to the native widgets:
https://raw.githubusercontent.com/vlang/ui/c2f802a137b5171da...
We are going to support native widgets, for example TextBox will be native due to accessibility and support for Chinese/Japanese/Korean/R2L input.
However things like text rendering will always be handled by the V graphics library, since GDI+ is just way too slow (calculating text bounds is ~10 times slower than in V), and Apple's drawing API is not very nice to use, and it's also 2-3 times slower at rendering text.
Does V's text library support the kinds of shaping and nested bidirectional layout needed to render Arabic text? I've heard that's a cause of a lot of complexity and slowness in text rendering, so stripping it out would be an easy performance win for people like me who can't read Arabic anyway.
https://www.youtube.com/watch?v=fIijYm1MfmI&feature=youtu.be
The UI library will support mobile asap, since it'll receive lots of attention now that 0.2 is out, and we now have 2 people contributing to it.
Also garbage collection. What are you doing for that? ARC?
V avoids doing unnecessary allocations in the first place by using value types, string buffers, promoting a simple abstraction-free code style.
Most objects (~90-100%) are freed by V's autofree engine: the compiler inserts necessary free calls automatically during compilation. Remaining small percentage of objects is freed via reference counting.
The developer doesn't need to change anything in their code. "It just works", like in Python, Go, or Java, except there's no heavy GC tracing everything or expensive RC for each object.
For developers willing to have more low level control, autofree can be disabled with -noautofree.
Note: right now autofree is hidden behind the -autofree flag. It will be enabled by default in V 0.3.
---
So yes, for the ~0-10% of objects not freed by V's autofree, ARC will be used. We will implement weak references and probably have a simple cycle detector, so pretty much a minimal GC.
Unlike in Go or Swift, it won't be used on all objects, but only on the small percentage that couldn't be handled by autofree.
In the YouTube demo I posted, 100% of all allocations in the text editor is handled by autofree.
https://github.com/vlang/v/blob/master/vlib/v/tests/valgrind...
It has lots of comments and will give you a good picture.
For example:
x = [1, 2, 3] // is this stack or heap allocated?
foo(&x) // how does the compiler know if x needs to be ref counted or not?
return &x // is this valid or UB or a compilation error?
Swift also has value types, and optimization passes to promote heap-allocated objects and closures to the stack where possible using escape analysis.
I don't want to be a hater and I'm genuinely impressed by the project. But it's honestly very hard to trust anything about this when all kinds of claims pop up, always with a big caveat at the end, usually after being questioned in forums and not in the official documentation.
What happens today if i don't pass in -autofree? If it was working it would be enabled right? And if it's not working, then how do i code without it? Sure, the language has a 0.x-version number but it's not exactly being advertised as something that is incomplete unless i dig very deep into documentation or twitter-threads. Some kind of roadmap of promised/planned/delivered features would greatly improve the confidence in this being not vaporware.
That should free most objects in a simple scenario, but how do you free objects in a cycle without a garbage collector?
Do you have any plans to resume working on Volt (the original V app)? I thought the idea behind it was great, but there hasn't been an update in 1.5 years.
Yes, it has been blocked by the memory management work and the 0.2 release, both of which took a while, especially since most of the compiler had to be re-written from scratch (using an AST). The UI library was also re-written several times as we tried different approaches (native vs custom rendering).
The good news is that Volt was always being updated and made compilable, and a public beta is also coming this month.
I'm already using Volt as my primary Discord client (and my 8 GB RAM laptop thanks me for that, since I've freed 2 GB of RAM).
Here's a sneak peek:
https://media.discordapp.net/attachments/731265552395534357/...
Some layout issues, and Chinese/Japanese/emoji not being rendered correctly, but the latter has been fixed on a branch.
The moral of the story is: if you want to deliver a software application quickly, don't write a new language/stdlib/ui lib for it from scratch.
At least I got to create a cool language and share it with the world :)
We use Sokol, an amazing wrapper library, and it only supports the big 3.
Vulkan is supported pretty well on Apple through MoltenVK: https://github.com/KhronosGroup/MoltenVK
Mesa does software implementation of Vulkan, too: https://en.wikipedia.org/wiki/Mesa_(computer_graphics)
We'll see how it goes, maybe at some point Vulkan will be supported by Sokol, this library is growing very quickly.
Though I guess "VLang" works.
For some context here’s the last of a series of posts examining some of Vs claims https://christine.website/blog/vlang-update-2020-06-17
> Git is a dependency, which means perl is a dependency, which means a shell is a dependency, which means glibc is a dependency, which means that a lot of other things (including posix threads) are also dependencies. Pedantically, you could even go as far as saying that you could count the Linux kernel, the processor being used and the like as dependencies, but that's a bit out of scope for this.
What's the point of such nitpicking? You don't need git to use V, and the point of the no dependency claim is that bootstrapping V is as simple as `cc v.c` and the V compiler produces single file binaries, that are easy to deploy, without any dependencies on an interpreter/environment/libs etc.
I'm actually going to write a post debunking all of the claims in these articles, since I see them mentioned quite often (including measuring the compilation speed by using an unoptimized debug build + running vfmt + rebuilding the standard library with each compilation + using a 2x slower backend).
Nitpicking nitpicks is still nitpicking.
See the YouTube demo I posted which shows how V removes 100% of leaks in a complex graphical application (text editor).
https://www.youtube.com/watch?v=gmB8ea8uLsM
You can also download it and try it yourself.
As for compilation speed, here's V compiling itself in 0.2 seconds:
https://pbs.twimg.com/media/EoAx9fsWMAE2M4U?format=jpg&name=...
The entire V compiler is built from scratch.
(Disclaimer: I'm the creator and main developer of V.)no stake on either side, but the post specifically mentions this (though that was on vlang 0.1)
> I claim that the V compiler has dependencies because it requires other libraries or programs in order to function. For an example, see the output of ldd (a program that lists the dynamically linked dependencies of other programs) on the V compiler and a hello world program:
$ ldd ./v
linux-vdso.so.1 (0x00007fff2d044000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2fb3e4c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2fb3a5b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2fb4345000)
$ ldd ./hello
linux-vdso.so.1 (0x00007ffdfdff2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed25771000)
/lib64/ld-linux-x86-64.so.2 (0x00007fed25d88000)
> If these binaries were really as dependency-free as the V website claims, the output of ldd would look something like this: $ ldd $HOME/bin/dhall
not a dynamic executableGo tried, and went back to linking to libc, because of constant syscall changes.
So I don't view having libc a dependency, it'd be like saying that macOS is a dependency.
You can also use musl on Linux with V for 100% static binaries.
The only stable system API is the linux kernel syscalls. Those basically don't break.
I'd also note that given you then banned her from the issue tracker after that post went up rather than discussing it, your claims of bias on her part seem a trifle strange.
Are you on Windows? Can you create a GitHub issue with `v doctor` so that it can be resolved asap.
Indeed, this is a silly matter. In both sides.
My personal conclusion from my reading was - if you wish to go use V, go ahead, but I'd exercise caution when relying on anything about it.
[1]: https://twitter.com/v_language/status/1234586123424456705
[2]: https://github.com/vlang/v/blob/bc288019932c35cc09dcf7b438bc...
[3]: https://github.com/vlang/v/tree/bc288019932c35cc09dcf7b438bc...
There is no controversy but the one you are trying to build up. This language is obvious quite young in development, isn't backed by mega corp Z with billions of $ at its disposal, yet it is trying to manage to find a solution to multiple issues Go couldn't even resolve in 10+ years. cut it some slacks.
Before making such a rude conjecture, at least check the dev's github page [1] first. Most of his git commits are related to V and he has been actively working on it for a couple of years, even over weekends. V may fail like many new languages, but at least the dev has paid the efforts. He has my respect.
> Good question. I haven't mentioned memory management because it's not done yet. I know for sure there won't be a GC or reference counting. [0]
> What I mean is `a = sort(a)` will be optimized to `sort(&a)` which can mutate internally. [1]
Do look at the entire threads - I don't think the claims are too out of context as quoted.
Disclaimer: I don't know V authors nor I'm part of V community.
I remember eC [1, 2] from Ecere being one such example of an “exciting new C”: it had traditional class-based OO, no header files (!), cross platform, reflection, etc etc etc. It came with a huge runtime library with tons of demos. It started 16 years ago (!!). There’s of course D as well (which is more often pitched as a C++ replacement), and its own Walter Bright frequently seen around here, and some companies use it, but it hasn’t truly exploded into mainstream use.
Can interested folks (or the author) comment? Are you bored and want a fun new take on programming? Or are you truly, in practice, extremely dissatisfied with the current marketplace of C alternatives and V actually is a take that “gets things right”?
[1] https://en.m.wikipedia.org/wiki/EC_(programming_language)
I think the reason is something else: It's not the demand that's amazing, it's the supply.
A lot of people like making languages, and full working environments to go with them. It's fun! If you're into that sort of thing, it might be the most attractive kind of project, with a kind of geek gravity that draws you in when you've got the bug.
A new language and its environment is an interesting exercise, even if it takes years. It's something to do to hone your craft. It's not particularly difficult, if you go for it, it just takes time. You can add all those ideas you wish other languages had but never do. Probably if you're into making languages you have a lot of ideas like that.
There's lots of interesting things to learn, lots of puzzles to solve, and then you have an artifact at the end which other people can appreciate. They might even find it useful, which is another reward, another bit of satisfaction.
If that's a major reason for new languages, why C-like?
I think C-like hits a design sweet-spot that is easy to understand and easy to branch out from. But it's also something you know other people are likely to understand and appreciate. It's not too exotic, at least at first glance. With so much supply and a lot less demand, you want your language to be noticed, to be useful and seen as useful. Being C-like boosts chances of acceptance as a language to take that bit more seriously.
I company I worked for a very long time ago wrote a hardware compiler, with a front-end language for hardware called Handel which was a DSL in Standard ML (great language. ML. by the way).
It was used, but it got more popular when they wrote a C-like front end and called it Handel-C. There was no real difference to the language, and Handel-C was in many ways less powerful (because there was no ML with which to manipulate the syntax tree), but the C-like syntax made it a look familiar, and therefore marketable.
Nothing wrong with that.
Developers won't stop creating languages until something that really succeed in replacing C is created.
Would be nice if you would credit it, though.
- https://github.com/nim-lang/RFCs/issues/178
- https://nim-lang.org/docs/manual_experimental.html#view-type...
Nim's views (and also their ORC system) is closer to Rust/Swift/C++ than it is to Lobster, in the sense that it is all very explicitly programmer driven with explicit type annotations.
Lobster's system is fully automatic and almost entirely transparent to the user.
- No null
- No err != nil checks (replaced by option types)
- Immutability by default
- Generics
- Sum types (type Expr = IfExpr | StringLiteral | IntLiteral )
- If and match expressions (including sum type matches)
This might be my personal project goto language for 2021.
As in ‘considered harmful’?
I’m staying away from any language with vulnerabilities like these: https://christine.website/blog/OVE-20190623-0001
As for the vulnerability, while it is real, it's not related to the language.
And not even sure what "I’m staying away from any language with vulnerabilities like these" even means. As if other languages/compilers/etc, even established ones like C/Clang-GCC, Java, Javascript, etc don't have any?
It's great to see that it's not s hoax, and it starts to somehow flesh out.
Would disagree with "nothing to show for them" though.
The V compiler was written in V from the start at the time of the release, which already shows the maturity of the language, and it did compile itself in less than a second. Bootstrapping it has always been as simple as `cc v.c`. It had a graphics library from the start with a working Tetris game example, hot code reloading, etc
It was definitely rough around the edges due to being a one man project, so it's good that it received help from hundreds of contributors. It's much more stable now.
Regarding compile times, why do you claim less than one second when your own tracking shows 2.5 seconds and trending upwards? (fast.vlang.io) Aren't you concerned that as the compiler and language are actually implemented, compile times will continue to worsen? Have you considered that perhaps that's why there are so few languages that claim that kind of bootstrap time?
That seems completely contrary to my engineering training. The engineer motto is about "be prepared for the unexpected" i.e. escape hatches, manual override, overprovisioning, assume that your temporary "train", "power plant", "airplane" will be in service for 40 years instead of 20, make it serviceable even without infrastructure.
The author made lots of unsubstantiated and even nonsensical promises such as green threads with no runtime or the supposed C++ to V translator which would be a HUGE breakthrough in compiler technology because such a tool would be (as was exactly shown in an example) able to understand programmer's intent.
He just stringed together attractive looking words and phrases without really understanding what they mean.
And of course, none of the promises actually materialized, so either Medvednikov is grossly incompetent or a pathological liar. You decide which is the case.
At the moment its still incomplete. And this is the most interesting part of the whole language. ARC, weak refs, autofree also working together needs to be done, only then will this language be of weight. Garbage collection is a difficult problem to be fair and it definitely determines the performance of many languages. Not to mention multi-threaded GC is difficult. I am excited to see how the author pulls this one through. See you again with V 0.3. Till then best of luck!
Here is Tetris in V:
https://github.com/vlang/v/blob/master/examples/tetris/tetri...
In the old site I implemented a slider with 7 small examples, I'll bring it back.
There's also a large Examples link on top.
> Pure functions by default
but all this means by their definition is: no global mutable variables, sort of, because you can enable them per compiler flag.
darkstar$ ../../v run tetris.v
Compilation with tcc failed. Retrying with cc ...
ATTENTION: default value of option vblank_mode overridden by environment.
gg error: GLX: failed to create GL context
Terminated by signal 6 (SIGABRT)
Graphics:
Device-1: AMD RS690M [Radeon Xpress 1200/1250/1270] driver: radeon
v: kernel
Display: server: X.Org 1.18.3 driver: radeon resolution: 1680x1050~61Hz
OpenGL: renderer: Gallium 0.4 on ATI RS690 v: 2.1 Mesa 13.0.6It'll be possible to use `[noautofree]` in modules and use manual memory management with or without arena allocation.
Arena allocation should also work with -autofree, I don't see why not, it's just malloc() and free().
Maybe this project had a rough start, but right now anyone claiming this is not real should probably re-evaluate those feelings.
- autofree not only leaks memory but in some cases causes double frees or use after free resulting in UB. Look at issues tagged autofree on their repo.
- No UB is claimed but the compiler does nothing to stop you from doing it and V is a very thin layer on top of C so it's trivial to cause UB. Signed integer overflow in V: instant UB.
- hot code reloading literally just overwrites the library in memory as the application is running. Better hope your compiler laid everything out exactly the same way or it will segfault and it usually does.
- Generics. Only one type argument is supported. The built in std types don't even use them because the implementation is so broken.
- option types: why have Some(T) | None when you can mix error handling in too and have Some(T) | None | Error(E)? That's right, option types three values. (Tri-state booleans anyone?)
- Compilation speed: V translates to C and then runs a C compiler. V isn't going to compile any faster than your C will. The only reasons that it's pretty fast right now are because most programs are very small and so is the std library and because they use tcc which performs no optimizations at all. If you want your C code to compile as fast as V does, just use tcc.
- Runtime speed: No rigorous benchmarks have been done. The claim of within 3% is a goal they have no idea how to achieve. Given their memory system relies on ref counting and optimizing out increments and decrements, they won't be able to hit that only taking memory management into account. Other design aspects have serious implications in terms of performance such as array copying being implicit. (b = a) copies all of a into a new array.
This is fine for a learning experience and I hope everyone involved is learning a lot but pitching this as some kind of project that people should learn and write real code in is crazy.
Why was it necessary to create a temporary account to write your post? I can probably guess who you are since there are only a few folks really vocal and on some kind of personal mission to shoot this down at every opportunity. What a waste of time. What a sad thing to do to an open source project.
Even for critical things like the memory management strategy, no one other than Alex has any idea how it is supposed to work (beyond some references to Lobster). Even when it's pointed out that Lobster makes some concessions that V does not so that the memory management system can work, there is still no discussion.
The V community and team seem far more interested in generating hype and publicity than actually doing the hard parts of language design.
I don't actually think the community is trying to be malicious. If you hang out in their discord, they're generally quite friendly. What they lack is focus.
The language and canonical backends aren't anywhere close to complete and there's already attention bring split to build an x86_64 backend and a wasm backend. Neither of these are anything more than toys even in comparison to the C one. At the same time, std is lacking critical things like a map type that doesn't require your keys to be strings. And yet they're working on a discord client and a websocket implementation. V-os and v-browser are seriously discussed with promises like "we'll start on that after 0.3".
V is sort of the ultimate yack shave. The author wanted to make a thin discord client but first they needed a new text editor so then they needed a language to write it in. It's really only a matter of time before the next project comes up and the author leaves V in the same state as his other projects.
P.S. This language looks amazing
Will add it to the changelog.
[edit] Sorry, edited before there was a reply. You're very fast!
This is a frequently asked question, so I had it covered.
Things V improves on Go:
Awesome work, sure it will get there either way :)
Concurrency is WIP, and will be the main feature of 0.3.
We already have channels, locks, and thread safe typed arrays/maps.
1. Will they be as heavy as Go's ? Go has 2 mutexes and some other fluff
2. Are they "close-safe" like, if I send something to the channel, and it is nil or closed, will it panic crash or stuck forever like Go does, or V is trying to be "panic-free"? Will "prohibited" operation return an error or panic/stuck?
3. If channels are closeable, will I be able to close them twice without panic (closing closed door might creak, but IMHO should not burn the house down...)
(At some point in the past I did suggest adding an error to channel operations so it will not panic if I am ready to intercept an error, but that was rejected)Btw, there is another saga (drama?) unfolding on github proposal discussions over sum types [2], and judging by the past experience I don't have high hopes for it to get into the language.
[1] https://github.com/golang/go/issues/33502
[2] just one last I saw today, but there are more tickets about same or connected issue https://github.com/golang/go/issues/41716
1. "Heavy" is a vague term and I think that it is even used polemically here. Every channel implementation needs methods to avoid race conditions and I think Go uses what is needed for reliable operation, but not more (even when there is a "mutex" in their code it's not a real OS-mutex - Go's channel implementation is actually very efficient). V's implementation uses mostly atomics and sometimes spin-locks.
2. There are no "nil-channels" in V, but a channel can be closed. As in Go, just sending to a closed channel causes a panic - that's a design decision. The point is: not to panic requires some kind of error handling. In a language like C++ this can be done by throwing an exception (which has to be caught elsewhere). But neither Go nor V have exception (that is also a design decision). In V a failure due to a closed channel can be trapped using `or` (https://github.com/vlang/v/blob/master/doc/docs.md#syntax-an...) on the receiving side or by using `select` (https://github.com/vlang/v/blob/master/doc/docs.md#channel-s...) on the sending side or the receiving side.
3. Closing an already closed channel should not cause any panic.
1. I would politely disagree with Go channels are efficient. If they would be efficient, they would be actively used internally as a synchronization primitive. I don't remember seeing external libraries using it past notification mechanism of "it is done" kind either. There would be some nifty tricks possible if cost of channels is much lower, or compiler would be able to use some "very light" channels if it sees it is possible (not sure if it even theoretically possible, but I am not an CS theory guru...)
2. That's kind of unfortunate, I would prefer if error is requested, just return an error
err := ch <- data_to_send
vs ch <- data_to_send
which might panic. But looks like neither of languages allow this. I proposed the syntax above to Go, but it was rejected.3. That's nice. Is there an error to catch if needed?
err := close(ch) err := close(ch)
to handle case when you don't want a panic on closing of closed channel. The first one was discussed on golang-nuts, but it died there.Channel operations involve task switches - especially on unbuffered channels. How expensive these are depends on the scheduler, but basically they are expensive on all operating systems.
Other synchronization primitives (like mutexes, semaphores, atomics) can be implemented in a way that the scheduler is not involved when no (long) blocking is needed (futex, spin-locks, ...).
The Go people took the path to implement their own scheduler, which is highly optimized for channel operations, on top of the OS (similar to a virtual machine). So, they don't use OS-threads or OS-mutexes. This does result in better channel performance, but still there are task switches. And this approach has other drawbacks concerning C interoperability.
V sticks to OS-threads and the OS-scheduler (and not re-implementing these could be called "lightweight"). This means better C interoperability but channel operations are even more expensive.
For this reason I've also implemented `shared` objects into the V core language as a more efficient way of sharing data (see also https://github.com/vlang/v/blob/master/doc/upcoming.md#varia...):
shared x := ...
go f(shared x)
lock x {
// modify x
}
rlock x {
// read x
}
2./3. Syntax considerations should be consistent within the whole language. As @illuminate has already pointed out we discuss these things on discord (https://discord.gg/vlang). There's also a channel #syntax.At the least I'd say he's over optimistic, but the work is getting done.
it implies the presence of other nice-to-haves, like ergonomic struct iteration and linting against schema
and it gracefully enables low-code API frameworks if you can annotate RBAC + visibility rules
v install ui