forked from vlang/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1320 lines (1010 loc) · 32.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@t header
<style>
.software{
margin-top:30px;
}
.note {
font-size: 80%;
}
</style>
<script>
@if .
alert("You've been subscribed. Thanks!")
@end
function isMob() {
return typeof( window.orientation ) !== "undefined" ||
navigator.userAgent.indexOf('IEMobile') !== -1;
}
document.addEventListener("DOMContentLoaded", function(event) {
})
var ex_id = 1;
const nr_exs = 5;
function prev() {
ex_id--;
if (ex_id < 1) ex_id = nr_exs;
update_ex()
}
function next() {
//var old = ex_id;
ex_id++;
if (ex_id > nr_exs) ex_id = 1;
update_ex()
}
function update_ex() {
var elems = document.querySelectorAll('.hello_devs');
for (var index = 0 ; index < elems.length; index++) {
//document.getElementById('ex' + old).style.display = 'none';
elems[index].style.display = 'none';
}
document.getElementById('ex' + ex_id).style.display = 'table-cell';
if (ex_id <= 3) {
document.getElementById('ex' + ex_id).style.fontSize = '100%';
}
else {
document.getElementById('ex' + ex_id).style.fontSize = '80%';
}
var select = document.getElementById("select") ;
select.value = ex_id;
getAjax('/next')
}
function change_ex() {
var select = document.getElementById("select") ;
ex_id = select.value - 1;
//if (ex_id < 1) ex_id=1;
next();
}
function getAjax(url) {
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xhr.open('GET', url);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.send();
return xhr;
}
function size_note() {
alert(`
Of course, it's not a very fair comparison. All these languages have a lot more features and support more platforms.
However, V's numbers are unlikely to become more than 10 MB / 1 second.
`)
}
/*
function comp_note() {
alert(`
In this example DOOM is translated from C to V and then compiled directly to x64 machine code.
V to x64 takes 0.3 seconds.
Compilation to x64 is at an early stage, and right now only Mach-O is supported.
Most likely for now you'll have to use compilation to C for your projects, then the compilation time
drops to about 150k lines/second, which is still pretty fast.
Once the C++ translator is more mature later this year, it will be possible to compile Doom 3 with V
as well.
The C++ translator will be done as well, then it will be possible to compile Doom 3 with V.
`)
}
*/
function comp_note() {
alert(`Direct machine code generation is at a very early stage. Right now only x64/Mach-O platform is supported.
This means that for now you'll have to use compilation to C. By the end of this year x64 generation should be stable enough.
`)
/*
alert(`
In this example DOOM is translated from C to V.
For now it takes much longer to compile DOOM with V (0.7 instead of 0.2 seconds) because x64 generation is not mature enough for this project yet.
It's still about 25 times faster than compiling DOOM with C.
By the end of this year x64 generation should be mature enough to compile DOOM in 0.2 seconds.
`)
*/
}
</script>
<div class='sep' style='padding:0'></div>
<div id='lang-links' style='width:100px'>
</div>
<div id='downloads' style='margin-top:20px; '>
<div style='font-weight:300'>Download a prebuilt V package</div>
<div class='v-link'>
<a href='https://github.com/vlang/v/releases/download/0.1.21/v_linux.zip'>Linux</a>
<div>2.5 MB</div>
</div>
<div class='v-link'>
<a href='#'>macOS</a>
<div>soon</div>
</div>
<div class='v-link'>
<a href='#'>Windows</a>
<div>soon</div>
</div>
<!--
<div class='v-link'>
<a href='https://github.com/vlang/v/releases/download/v0.1.13/v.zip' >Download V alpha 0.1.13</a>
<div style='font-size:80%; font-weight: 300'>
%includes_binaries
</div>
<div>
<img src='/img/linux.png' width=31>
<img src='/img/mac.png' width=40>
<img src='/img/win.png' width=36>
</div>
<div> 1.3 MB </div>
</div>
-->
<div style='margin-top:20px'>
<!--
<pre>wget https://vlang.io/v.c && cc -std=gnu11 -w -o v v.c</pre>
-->
<a href='https://github.com/vlang/v#installing-v-from-source'>
%install_source</a>
<div style='font-size:80%; font-weight: 300'>
%couple_seconds
</div>
<!--
<pre style='text-align:center'>git clone https://github.com/vlang/v
cd v
make</pre>
-->
<div>
<img src='/img/linux.png' width=31 title='Linux'>
<img src='/img/mac.png' width=40 title='macOS'>
<img src='/img/win.png' width=36 title='Windows'>
<img src='/img/freebsd.png' width=36 title='FreeBSD, OpenBSD, NetBSD, DragonflyBSD'>
<img src='/img/solaris.png' width=36 title='Solaris'>
<!--
<img src='/img/android.png' width=36 style='position:relative;top:3px'>
-->
</div>
</div>
<div style='margin-top: 30px; font-weight: 300'>
<!--
Or build V from source with a C compiler:
<pre>wget https://vlang.io/v.c && clang -o v v.c</pre>
<pre>(coming on June 22)</pre>
-->
</div>
</div>
<div id='changelog'>
<a target=_blank href='https://github.com/vlang/v/blob/master/CHANGELOG.md'
>V 0.1.22 Changelog</a>
<br><br>
<a target=_blank href='https://fast.vlang.io'
>Is V still fast?</a>
</div>
<div class='sep' style='padding:0'></div>
<div id='editors'>
<div class='editor'>
<a target=_blank href='https://marketplace.visualstudio.com/items?itemName=0x9ef.vscode-vlang&ssr=false'
><img src='/img/vscode.png' width=25> <br>V for VS Code </a>
</div>
<div class='editor'>
<a target=_blank href='https://github.com/ollykel/v-vim'
><img src='/img/vim.png' width=25> <br>V for Vim </a>
</div>
<div class='editor'>
<a target=_blank href='https://github.com/vlang/vid'
><img src='/img/favicon.png' width=25> <br>Vid Editor</a>
</div>
</div>
<div id='home-examples'>
<div class='row' style='margin-top:30px'>
<div class='next' style='text-align:right'> <img onclick='prev()' src=/img/left.png width=30> </div>
<pre class='hello_devs' id=ex1>
<key>fn</key> main() {
areas := [<str>'game'</str>, <str>'web'</str>, <str>'tools'</str>, <str>'science'</str>, <str>'systems'</str>,
<str>'embedded'</str>, <str>'drivers'</str>, <str>'GUI'</str>, <str>'mobile'</str>]
<key>for</key> area <key>in</key> areas {
println(<str>'Hello, </str>$area <str>developers!'</str>)
}
} </pre>
<pre class='hello_devs' id=ex2 style='display:none'>
<key>import</key> os
<comment>// Print file lines that starth with "DEBUG:"</comment>
<key>fn</key> main() {
<comment>// `read_file` returns an optional (`?string`), it must be checked</comment>
text := os.read_file(<str>'app.log'</str>) <key>or</key> {
println(<str>'failed to read the file'</str>)
<key>return</key>
}
lines := text.split_into_lines()
<key>for</key> line <key>in</key> lines {
<key>if</key> line.starts_with(<str>'DEBUG:'</str>) {
println(line)
}
}
}
</pre>
<pre class='hello_devs' id=ex3 style='display:none'>
<key>import</key> time
<key>import</key> http
<key>fn</key> main() {
resp := http.get(<str>'https://vlang.io/utc_now'</str>) or {
println(<str>'failed to fetch data from the server'</str>)
return
}
t := time.unix(resp.text.int())
println(t.format()) <comment>// 2019-08-16 17:48</comment>
}
</pre>
<pre class='hello_devs' id=ex4 style='display:none'>
<key>import</key> json
<key>struct</key> User {
name string
age int
<key>mut</key>:
is_registered bool
}
<key>fn</key> main() {
s := <str>'[{"name":"Frodo", "age":25}, {"name":"Bobby", "age":10}]'</str>
users := json.decode([]User, s) <key>or</key> {
eprintln(<str>'Failed to parse json'</str>)
<key>return</key>
}
<key>for</key> user in users {
println(<str>'</str>$user.name<str>:</str> $user.age<str>'</str>)
}
println(<str>''</str>)
<key>for</key> i, user in users {
println(<str>'</str>$i<str>)</str> $user.name<str>'</str>)
if !user.can_register() {
println(<str>'Cannot register $user.name, they are too young'</str>)
continue
}
users[i].register() <comment>// `user` is immutable, we have to modify the array</comment>
}
<comment>// Let's encode users again just for fun</comment>
println(<str>''</str>)
println(json.encode(users))
}
<key>fn</key> (u User) can_register() bool {
<key>return</key> u.age >= 16
}
<key>fn</key> (u <key>mut</key> User) register() {
u.is_registered = true
}
</pre>
<pre class='hello_devs' id=ex5 style='display:none'>
struct Customer {
id int
name string
nr_orders int
country string
}
db := pg.connect(db_name, db_user)
nr_customers := db.select count from Customer
println('number of all customers: $nr_customers')
<comment>// V syntax can be used to build queries</comment>
uk_customers = db.select from Customer where
country == 'ukk' && nr_orders > 0
for customer in uk_customers {
println('$customer.id - $customer.name')
}
<comment>// by adding `limit 1` we tell V that there will be only one object</comment>
customer = db.select from Customer where id == 1 limit 1
println(customer.name)
<comment>// insert a new customer</comment>
new_customer := Customer{name: 'Bob', nr_orders: 10}
db.insert(new_customer)
</pre>
<pre class='hello_devs' id=ex20 style='display:none'>
struct Story {
title string
}
<comment>// Fetches top HN stories in 8 coroutines</comment>
fn main() {
resp := http.get('https://hacker-news.firebaseio.com/v0/topstories.json')?
ids := json.decode([]int, resp.body)?
mut cursor := 0
for _ in 0..8 {
go fn() {
for {
lock { <comment>// Without this lock the program will not compile</comment>
if cursor >= ids.len {
break
}
id := ids[cursor]
cursor++
}
resp := http.get('https://hacker-news.firebaseio.com/v0/item/$id.json')?
story := json.decode(Story, resp.body)?
println(story.title)
}
}()
}
runtime.wait() <comment>// Waits for all coroutines to finish</comment>
}
</pre>
<pre class='hello_devs' id=ex30 style='display:none'>
import ui // Native cross-platform ui toolkit (uses Cocoa, win32, GTK+)
// There are no globals, so we have to use a context struct
struct Context {
input ui.TextBox // this uses native conrols (NSTextView on macOS, edit HWND on Windows)
names []string // let's log the names to demonstrate how arrays work
}
fn main() {
wnd := ui.new_window(ui.WindowCfg{ // V has no default arguments and overloading.
width: 600 // All stdlib functions with many args use Cfg wrappers.
height: 300
title: 'hello world'
})
mut ctx := Context{
input: ui.new_textbox(wnd)
// we don't need to initialize the names array, it's done automatically
}
ctx.input.set_placeholder('Enter your name')
btn := ui.new_button(wnd, 'Click me', ctx.btn_click)
for {
ui.wait_events()
}
}
fn (ctx mut Context) btn_click() {
name := ctx.input.text()
println('current list of names: $ctx.names') // >> current list of names: [ "Bob", "Alex" ]
ui.alert('Hello, $name!')
if ctx.names.contains(name) {
ui.alert('I already greeted you ;)')
}
ctx.names << name
}
</pre>
<pre class='hello_devs' id=ex40 style='display:none'>
struct User { /* ... */ }
struct Post { /* ... */ }
struct DB { /* ... */ }
struct Repo <T> {
db DB
}
fn new_repo<T>(db DB) Repo {
return Repo<T>{db: db}
}
fn (r Repo) find_by_id(id int) T? { // `?` means the function returns an optional
table_name := T.name // in this example getting the name of the type gives us the table name
return r.db.query_one<T>('select * from $table_name where id = ?', id)
}
fn main() {
db := new_db()
users_repo := new_repo<User>(db)
posts_repo := new_repo<Post>(db)
user := users_repo.find_by_id(1) or {
eprintln('User not found')
return
}
post := posts_repo.find_by_id(1) or {
eprintln('Post not found')
return
}
}
</pre>
<div class='next' onclick='next()'> <img src=/img/right.png width=30></div>
</div>
<div class='center' style='text-align:center'>
<select id='select' onchange='change_ex()'>
<option value=1>Hello world</option>
<option value=2>Filter log file</option>
<option value=3>HTTP + time</option>
<option value=4>JSON encoding/decoding</option>
<option value=5>Built-in ORM</option>
<!--
<option value=2>Concurrent news fetcher</option>
<option value=3>Simple GUI app</option>
<option value=4>Generic SQL repository</option>
-->
</select>
<br>
<!--
<input type='button' style='margin-top:15px' onclick='window.location="/play"' value='Run'>
-->
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<br>
<i class='note'>
V is an actively developed language at an early stage.
It will stabilize by the time of the 0.2 release planned for November 2019.
</i>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>%simple_language_for_maintainable_programs</h2>
<p>
You can learn the entire language by going through the
<a target=_blank href='/docs'>documentation</a> in half an hour, and in most cases there's only one way to do something.
<p>
This results in simple, readable, and maintainable code.
<p>
Despite being simple, V gives a lot of power to the developer. Anything you can do in other languages, you can do in V.
</div>
<div class='feature'>
<h2>%safety</h2>
<li>No null
<li>No global variables
<li>No undefined values
<li>No undefined behavior
<li>No variable shadowing
<li>Bounds checking
<li><a target=_blank href='/docs#option'>Option/Result types</a>
<li> <a target=_blank href='/docs#generics'>Generics</a>
<li><a target=_blank href='/docs#vars'>Immutable variables by default</a>
<li><a target=_blank href='/docs#recvs'>Pure functions by default</a>
<li><a target=_blank href='/docs#mod'>Immutable structs by default</a>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>%performance</h2>
<li>As fast as C
<li>C interop without any costs
<li>Minimal amount of allocations
<li>Built-in serialization without runtime reflection
<li>Compiles to native binaries without any dependencies: a simple web server is only 65 KB
</div>
<div class='feature'>
<h2>%fast_compilation</h2>
%fast_comp1
<span style='font-size:70%'>(Intel i5-7500 @ 3.40GHz, SM0256L SSD, no optimization) </span>
<p>{{ raw (T "fast_comp2") }}</p>
<!--
<a href='/compilation_speed'>Compilation speed benchmark</a>
<p>%fast_comp3</p>
<p>%fast_comp4</p>
<p>
<i class='note'>Direct machine code generation is at a very early stage. Right now only x64/Mach-O is supported.
This means that for now emitting C has to be used. By the end of this year x64 generation should be stable enough.</i>
-->
</div>
</div>
</div>
<!--
Простой язык для создания читаемого и легко поддерживаемого ПО
-->
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>
Small and easy to build compiler
<!--
%zero_deps
-->
</h2>
<p>
The entire language and its standard library are less than 1 MB.
V is written in V, and can be built in 0.09 - 0.6 seconds.
<p>
For comparison:
</p>
<table>
<tr><td></td><td>Space required </td><td>Build time</td></tr>
<tr><td>Go</td><td>525 MB</td><td>1m 33s</td></tr>
<tr><td>Rust</td><td>30 GB</td><td>45m</td></tr>
<tr><td>GCC</td><td>8 GB</td><td>50m</td></tr>
<tr><td>Clang</td><td>90 GB
<a target=_blank class='sidenote' href='https://lists.llvm.org/pipermail/llvm-dev/2019-April/132028.html'>[0]</a>
</td><td>25m</td></tr>
<tr><td>Swift</td><td>70 GB
<a target=_blank class='sidenote' href='https://github.com/apple/swift#getting-started'>[1]</a>
</td><td>90m</td></tr>
<tr><td>V</td><td>< 1 MB</td><td>0.15s - 0.6s</td></tr>
</table>
<p>
<i class='note'>
V has only one dependency: a C compiler. If you are doing development, most
likely you already have a C compiler installed.
<p>
It's a small dependency, and it's not going to be needed once x64 generation is mature enough.</i>
</div>
<div class='feature'>
<p>
Building V in 0.4 seconds and then using the resulting binary to build itself again:
</p>
<video style='display:block; border: 1px solid #dfdfdf' muted autoplay src='/img/buildv.mp4'></video>
</div>
</div>
<!--
row {
feature height:360px {
h2 { 200 KB }
p { The entire V
-->
</div>
<div class='sep' ></div>
<div class='center'>
<div class='feature first'>
<h2 id=ctranslation>C translation</h2>
V can translate your entire C <span class='wip'>wip</span> project and offer you the safety, simplicity, and 10-25x compilation speed-up.
<br>
<pre style='float:left; font-size:80%;'>
std::vector<std::string> s;
s.push_back("V is ");
s.push_back("awesome");
std::cout << s.size(); </pre>
<pre style= 'font-size:80%;'>
mut s := []
s << 'V is '
s << 'awesome'
println(s.len)</pre>
<!--
Read about translating <a href='/doom' onclick='return soon()'>Doom & Doom 3</a>,
<a href='#'>LevelDB</a>, <a href='#'>SQLite</a>.
-->
<p>
<!--
<a href='#cppinfo'>How does it work?</a>
-->
<p>
A blog post about translating DOOM will be published soon. <!--, <u>Doom 3</u>, <u>LevelDB</u>, <u>SQLite</u> (coming soon). -->
<p>
<p>
<i class='note'>
C++ to V translation is at an early stage.
<!--
Almost the entire C standard is supported right now, but C++ translation is at an early stage. The example above works,
but more complicated code won't. C++ is a very complex language, hopefully the project will be finished by the end of this year.
-->
</i>
</div>
<div class='feature'>
<h2 style='height:1px'> </h2> <!-- i'll never understand css... -->
Translating DOOM from C to V and building it in 0.7 seconds (x25 speed-up): <span class='wip'>wip</span>
<img id='doompic' src='/img/doom.png'>
<p>
You can follow the progress and read translated code here:
<a target=_blank href='https://github.com/vlang/doom'>github.com/vlang/doom</a>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>Hot code reloading</h2>
<p>
Get your changes instantly without recompiling.
<p>
Since you also don't have to
get to the state you are working on after every compilation, this can save a lot of
precious minutes of your development time.
</p>
<p>
<a target=_blank href='https://github.com/vlang/v/tree/master/examples/hot_reload'
>github.com/.../examples/hot_reload</a>
</div>
<div class='feature'>
<h2 style='height:1px'> </h2> <!-- i'll never understand css... -->
<video style='display:block' loop muted autoplay src='/img/hot.webm'></video>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>Powerful graphics libraries</h2>
Cross-platform drawing library built on top of GDI+/Cocoa Drawing, and an OpenGL based graphics library
for more complex 2D/3D applications, that will also have the following features:
<br>
<br>
- Loading complex 3D objects with textures <span class='wip'>wip</span> <br>
- Camera (moving, looking around) <span class='wip'>wip</span><br>
- Skeletal animation <span class='wip'>wip</span> <br>
<p>
DirectX, Vulkan, and Metal support is planned.
<p>
A simple example of the graphics library in action is
<a target=_blank href='https://github.com/vlang/v/blob/master/examples/tetris'>tetris.v</a>.
</div>
<div class='feature'>
<h2 style='height:1px'> </h2> <!-- i'll never understand css... -->
<img src='/img/gg.png'>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2 id='ui'>Native cross-platform GUI library</h2>
Build native apps with native controls. You no longer need to embed a browser to
develop cross-platform apps quickly.
<p>
V has a <code>ui</code> module that uses native GUI toolkits: WinAPI/GDI+ on Windows, Cocoa on macOS.
On Linux custom drawing is used.
<p>
Coming soon: <br>
- a Delphi-like visual editor for building native GUI apps <br>
- iOS/Android support with native controls<br>
- a declarative API similar to SwiftUI and React Native.
<p>
</div>
<div class='feature'>
Volt, a 300 KB Slack client built with V and V ui : <br>
<a target=_blank href='https://volt-app.com'><img src='https://volt-app.com/img/screen3.png' width=500></a>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>Easy cross compilation</h2>
To cross compile your software simply run <code>v -os windows .</code> or
<code>v -os linux .</code> No extra steps required, even for GUI and graphical apps!
<p>
(Compiling macOS software only works on macOS for now.)
</div>
<div class='feature'>
<p>
Building V for Windows using V for macOS, and then testing resulting v.exe on a Windows VM:
</p>
<video style='display:block; border: 1px solid #dfdfdf' muted autoplay src='/img/vwin.mp4'></video>
</div>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='feature first'>
<h2>Painless deployments and dependency management</h2>
To build you project, no matter how big, all you need to do is run
<code>v .</code>
<p>
No more build environments, makefiles, headers, virtual environments, etc.
<p>
You get a single statically linked binary
that is guaranteed to work on all operating systems (provided you cross compile)
without any dependencies. <a href='#' onclick='alert("Of course, if you use C libraries, things get trickier.\n\nThis can be solved by translating C to V.")'>*</a>
<p>
Installing new libraries is as simple as <code>v install sqlite</code>.
</div>
<div class='feature'>
<h2>Run everywhere</h2>
V can emit (human readable) C, so you get the great platform support and
optimization of GCC and Clang.
<p>
Emitting C will always be an option, even after direct machine code generation matures.
<p>
V can call C code, and calling V code is possible in any language that has C interop.
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='feature first'>
<h2>REPL</h2>
<pre>
v
>>> import http
>>> data := http.get('https://vlang.io/utc_now')
or { panic(err) }
>>> data.text
1565977541
</pre>
</div>
<div class='feature'>
<h2>V Script</h2>
<pre>
for file in ls('build/') {
rm(file)
}
mv('v.exe', 'build/')
v run deploy.vsh
</pre>
<a target=_blank href='/docs#bash'>Read more about V script</a>
</div>
</div>
<div class='sep' ></div>
<div class='center'>
<div class='row'>
<div class='feature first'>
<h2>Powerful built-in web framework</h2>
<a target=_blank href='https://github.com/vlang/v/tree/master/vlib/vweb'
>github.com/vlang/v/tree/master/vlib/vweb</a>
<pre>
<comment>['/post/:id']</comment>
<key>fn</key> (b Blog) show_post(id int) vweb.Result {
post := b.posts_repo.retrieve(id) <key>or</key> {
<key>return</key> vweb.not_found()
}
<key>return</key> vweb.view(post)
}
</pre>
<p>
<a target=_blank href='//blog.vlang.io/forum'>V forum</a> and
<a target=_blank href='//blog.vlang.io'>V blog</a> are built with vweb/vtalk.
</div>
<div class='feature'>
<h2>Built-in ORM</h2>
<pre>
struct Customer {
id int
name string
nr_orders int
country string
}
db := pg.connect(db_name, db_user)
nr_customers := db.select count from Customer
println('number of all customers: $nr_customers')
<comment>// V syntax can be used to build queries</comment>
uk_customers = db.select from Customer where
country == 'uk' && nr_orders > 0
for customer in uk_customers {
println('$customer.id - $customer.name')
}
<comment>// by adding `limit 1` we tell V that there will be
// only one object</comment>
customer = db.select from Customer where id == 1 limit 1
println(customer.name)
<comment>// insert a new customer</comment>
new_customer := Customer{name: 'Bob', nr_orders: 10}
db.insert(new_customer)
</pre>
</div>
</div>
</div>
<div class='menu' ></div>
<div class='center'>
<h1 id='sponsors'>Sponsors</h1>
<!--
<a target=_blank href='https://offscale.io/'><img style='width:300px' src='/img/sponsor1.png'></a>
-->
<a target=_blank href='https://data.mx.com/'><img style='height:250px' src='/img/sponsor_mx.png'></a>
<br><br>
<center>
<a target=_blank href='https://patreon.com/vlang'>Become a sponsor</a>
</center>
</div>