-
Notifications
You must be signed in to change notification settings - Fork 99
/
preview.html
1093 lines (965 loc) · 57 KB
/
preview.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="/img/v-logo.png">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:400,300,100,200,500,700|Roboto+Mono:400,300,100,200,500" media="none" onload="if(media!='all')media='all'"><noscript><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:400,300,100,200,500,700|Roboto+Mono:400,300,100,200,500"></noscript>
<link rel="stylesheet" href="./app.css">
<!--
<script src="tokenizer.js"></script>
-->
<title>The V Programming Language</title>
</head>
<body>
<div id='app'>
<div class='header'>
<div class='flex'></div>
<a href='/'><img src='/img/v-logo.png' class='logo' /></a>
<div class='nav'>
<a target=_blank href='https://github.com/vlang/V/tree/master/examples' class='item'>%examples</a>
<a target=_blank href='https://github.com/vlang/v/blob/master/doc/docs.md' class='item'>%documentation</a>
<a target=_blank href='https://github.com/vlang/v/blob/master/tutorials' class='item'>Tutorials</a>
<a target=_blank href='https://modules.vlang.io' class='item'>Standard Library Docs</a>
<a target=_blank href='https://vpm.vlang.io/' class='item'>vpm</a>
<a target=_blank href='https://github.com/vlang/v/discussions' class='item'>Forum</a>
<a target=_blank href='https://blog.vlang.io' class='item'>Blog</a>
<!--
<a target=_blank href='https://v-wasm.now.sh' class='item'>Playground</a>
<a target=_blank href='https://play.vlang.io' class='item'>Playground</a>
<a href='/#builtinv' class='item'>Built in V</a>
-->
<!--
<a target=_blank href='https://github.com/vlang/v/wiki/FAQ' class='item'>%faq</a>
<a target=_blank href='https://github.com/vlang/v/wiki/Backers' class='item'>Backers</a>
-->
</div>
<div class="donate-button">
<a target=_blank href='https://patreon.com/vlang' class='patreon'><img src='/img/patreon.png' /></a>
<a target=_blank href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HRGVJ2LA2LKJ8&item_name=Support+V+development¤cy_code=USD&source=url&lc=US" class="paypal">PayPal</a>
<a target=_blank href='https://github.com/sponsors/medvednikov' class="paypal">GitHub $</a>
<!--
<a target=_blank href='#' class="paypal" id='btc' onclick="document.getElementById('btcaddr').style.display='inline'; document.getElementById('btc').style.display='none'; return false;">BTC</a>
<span id='btcaddr' style='display:none'>
1HZiH6MXkVpaWFwiGVCLAr8WQDBQCMnW3v
</span>
-->
<!--
<a target=_blank href='https://github.com/sponsors/medvednikov'><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="93" height="20"><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="93" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="72" height="20" fill="#555"/><rect x="72" width="21" height="20" fill="#9f9f9f"/><rect width="93" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJ3aGl0ZXNtb2tlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+R2l0SHViIGljb248L3RpdGxlPjxwYXRoIGQ9Ik0xMiAuMjk3Yy02LjYzIDAtMTIgNS4zNzMtMTIgMTIgMCA1LjMwMyAzLjQzOCA5LjggOC4yMDUgMTEuMzg1LjYuMTEzLjgyLS4yNTguODItLjU3NyAwLS4yODUtLjAxLTEuMDQtLjAxNS0yLjA0LTMuMzM4LjcyNC00LjA0Mi0xLjYxLTQuMDQyLTEuNjFDNC40MjIgMTguMDcgMy42MzMgMTcuNyAzLjYzMyAxNy43Yy0xLjA4Ny0uNzQ0LjA4NC0uNzI5LjA4NC0uNzI5IDEuMjA1LjA4NCAxLjgzOCAxLjIzNiAxLjgzOCAxLjIzNiAxLjA3IDEuODM1IDIuODA5IDEuMzA1IDMuNDk1Ljk5OC4xMDgtLjc3Ni40MTctMS4zMDUuNzYtMS42MDUtMi42NjUtLjMtNS40NjYtMS4zMzItNS40NjYtNS45MyAwLTEuMzEuNDY1LTIuMzggMS4yMzUtMy4yMi0uMTM1LS4zMDMtLjU0LTEuNTIzLjEwNS0zLjE3NiAwIDAgMS4wMDUtLjMyMiAzLjMgMS4yMy45Ni0uMjY3IDEuOTgtLjM5OSAzLS40MDUgMS4wMi4wMDYgMi4wNC4xMzggMyAuNDA1IDIuMjgtMS41NTIgMy4yODUtMS4yMyAzLjI4NS0xLjIzLjY0NSAxLjY1My4yNCAyLjg3My4xMiAzLjE3Ni43NjUuODQgMS4yMyAxLjkxIDEuMjMgMy4yMiAwIDQuNjEtMi44MDUgNS42MjUtNS40NzUgNS45Mi40Mi4zNi44MSAxLjA5Ni44MSAyLjIyIDAgMS42MDYtLjAxNSAyLjg5Ni0uMDE1IDMuMjg2IDAgLjMxNS4yMS42OS44MjUuNTdDMjAuNTY1IDIyLjA5MiAyNCAxNy41OTIgMjQgMTIuMjk3YzAtNi42MjctNS4zNzMtMTItMTItMTIiLz48L3N2Zz4="/><text x="455" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">Sponsor</text><text x="455" y="140" transform="scale(.1)" textLength="450">Sponsor</text><text x="815" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="110">❤</text><text x="815" y="140" transform="scale(.1)" textLength="110">❤</text></g></svg></a>
-->
</div>
<div class='flex'></div>
</div>
<!--
BUILTIN TESTING
V LANGUAGE SERVER
-->
<div class='content landing'>
<div class='hero'>
<div class='info'>
<h1>The V Programming Language 0.3</h1>
<p>Simple, fast, safe, compiled. For developing maintainable software.</p>
<a class='button' target=_blank href="https://github.com/vlang/v">
<svg class="svg-inline--fa fa-github fa-w-16" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" data-fa-i2svg=""><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg>
<div class='text'>
<span class='link'>github.com/vlang/v</span>
<span class='details'><svg viewBox='0 0 14 16' version='1.1' width='12' height='14' aria-hidden='true'><path fill-rule='evenodd' d='M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z' /></svg>30k</span>
</div>
</a>
<div class='button' style="background: #4a607e">
<a id="dl-a" href="https://github.com/vlang/v/releases/latest/download/v_linux.zip" style="display: flex; color: #eee">
<svg class="svg-inline--fa fa-windows fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="windows" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z"></path></svg>
<div class='text'>
<span class='link' id='dl-name'>Download for Linux</span>
<span class='details' id='dl-size'>v0.3.x - 1.7MB</span>
</div>
</a>
<div class='options-container' tabindex="0">
<img class='right-icon' src='/img/down.png' />
<div class='options'>
<a href="https://github.com/vlang/v/releases/latest/download/v_linux.zip" class='dl-option' id='dl_linux'>
<svg class="svg-inline--fa fa-linux fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="linux" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M220.8 123.3c1 .5 1.8 1.7 3 1.7 1.1 0 2.8-.4 2.9-1.5.2-1.4-1.9-2.3-3.2-2.9-1.7-.7-3.9-1-5.5-.1-.4.2-.8.7-.6 1.1.3 1.3 2.3 1.1 3.4 1.7zm-21.9 1.7c1.2 0 2-1.2 3-1.7 1.1-.6 3.1-.4 3.5-1.6.2-.4-.2-.9-.6-1.1-1.6-.9-3.8-.6-5.5.1-1.3.6-3.4 1.5-3.2 2.9.1 1 1.8 1.5 2.8 1.4zM420 403.8c-3.6-4-5.3-11.6-7.2-19.7-1.8-8.1-3.9-16.8-10.5-22.4-1.3-1.1-2.6-2.1-4-2.9-1.3-.8-2.7-1.5-4.1-2 9.2-27.3 5.6-54.5-3.7-79.1-11.4-30.1-31.3-56.4-46.5-74.4-17.1-21.5-33.7-41.9-33.4-72C311.1 85.4 315.7.1 234.8 0 132.4-.2 158 103.4 156.9 135.2c-1.7 23.4-6.4 41.8-22.5 64.7-18.9 22.5-45.5 58.8-58.1 96.7-6 17.9-8.8 36.1-6.2 53.3-6.5 5.8-11.4 14.7-16.6 20.2-4.2 4.3-10.3 5.9-17 8.3s-14 6-18.5 14.5c-2.1 3.9-2.8 8.1-2.8 12.4 0 3.9.6 7.9 1.2 11.8 1.2 8.1 2.5 15.7.8 20.8-5.2 14.4-5.9 24.4-2.2 31.7 3.8 7.3 11.4 10.5 20.1 12.3 17.3 3.6 40.8 2.7 59.3 12.5 19.8 10.4 39.9 14.1 55.9 10.4 11.6-2.6 21.1-9.6 25.9-20.2 12.5-.1 26.3-5.4 48.3-6.6 14.9-1.2 33.6 5.3 55.1 4.1.6 2.3 1.4 4.6 2.5 6.7v.1c8.3 16.7 23.8 24.3 40.3 23 16.6-1.3 34.1-11 48.3-27.9 13.6-16.4 36-23.2 50.9-32.2 7.4-4.5 13.4-10.1 13.9-18.3.4-8.2-4.4-17.3-15.5-29.7zM223.7 87.3c9.8-22.2 34.2-21.8 44-.4 6.5 14.2 3.6 30.9-4.3 40.4-1.6-.8-5.9-2.6-12.6-4.9 1.1-1.2 3.1-2.7 3.9-4.6 4.8-11.8-.2-27-9.1-27.3-7.3-.5-13.9 10.8-11.8 23-4.1-2-9.4-3.5-13-4.4-1-6.9-.3-14.6 2.9-21.8zM183 75.8c10.1 0 20.8 14.2 19.1 33.5-3.5 1-7.1 2.5-10.2 4.6 1.2-8.9-3.3-20.1-9.6-19.6-8.4.7-9.8 21.2-1.8 28.1 1 .8 1.9-.2-5.9 5.5-15.6-14.6-10.5-52.1 8.4-52.1zm-13.6 60.7c6.2-4.6 13.6-10 14.1-10.5 4.7-4.4 13.5-14.2 27.9-14.2 7.1 0 15.6 2.3 25.9 8.9 6.3 4.1 11.3 4.4 22.6 9.3 8.4 3.5 13.7 9.7 10.5 18.2-2.6 7.1-11 14.4-22.7 18.1-11.1 3.6-19.8 16-38.2 14.9-3.9-.2-7-1-9.6-2.1-8-3.5-12.2-10.4-20-15-8.6-4.8-13.2-10.4-14.7-15.3-1.4-4.9 0-9 4.2-12.3zm3.3 334c-2.7 35.1-43.9 34.4-75.3 18-29.9-15.8-68.6-6.5-76.5-21.9-2.4-4.7-2.4-12.7 2.6-26.4v-.2c2.4-7.6.6-16-.6-23.9-1.2-7.8-1.8-15 .9-20 3.5-6.7 8.5-9.1 14.8-11.3 10.3-3.7 11.8-3.4 19.6-9.9 5.5-5.7 9.5-12.9 14.3-18 5.1-5.5 10-8.1 17.7-6.9 8.1 1.2 15.1 6.8 21.9 16l19.6 35.6c9.5 19.9 43.1 48.4 41 68.9zm-1.4-25.9c-4.1-6.6-9.6-13.6-14.4-19.6 7.1 0 14.2-2.2 16.7-8.9 2.3-6.2 0-14.9-7.4-24.9-13.5-18.2-38.3-32.5-38.3-32.5-13.5-8.4-21.1-18.7-24.6-29.9s-3-23.3-.3-35.2c5.2-22.9 18.6-45.2 27.2-59.2 2.3-1.7.8 3.2-8.7 20.8-8.5 16.1-24.4 53.3-2.6 82.4.6-20.7 5.5-41.8 13.8-61.5 12-27.4 37.3-74.9 39.3-112.7 1.1.8 4.6 3.2 6.2 4.1 4.6 2.7 8.1 6.7 12.6 10.3 12.4 10 28.5 9.2 42.4 1.2 6.2-3.5 11.2-7.5 15.9-9 9.9-3.1 17.8-8.6 22.3-15 7.7 30.4 25.7 74.3 37.2 95.7 6.1 11.4 18.3 35.5 23.6 64.6 3.3-.1 7 .4 10.9 1.4 13.8-35.7-11.7-74.2-23.3-84.9-4.7-4.6-4.9-6.6-2.6-6.5 12.6 11.2 29.2 33.7 35.2 59 2.8 11.6 3.3 23.7.4 35.7 16.4 6.8 35.9 17.9 30.7 34.8-2.2-.1-3.2 0-4.2 0 3.2-10.1-3.9-17.6-22.8-26.1-19.6-8.6-36-8.6-38.3 12.5-12.1 4.2-18.3 14.7-21.4 27.3-2.8 11.2-3.6 24.7-4.4 39.9-.5 7.7-3.6 18-6.8 29-32.1 22.9-76.7 32.9-114.3 7.2zm257.4-11.5c-.9 16.8-41.2 19.9-63.2 46.5-13.2 15.7-29.4 24.4-43.6 25.5s-26.5-4.8-33.7-19.3c-4.7-11.1-2.4-23.1 1.1-36.3 3.7-14.2 9.2-28.8 9.9-40.6.8-15.2 1.7-28.5 4.2-38.7 2.6-10.3 6.6-17.2 13.7-21.1.3-.2.7-.3 1-.5.8 13.2 7.3 26.6 18.8 29.5 12.6 3.3 30.7-7.5 38.4-16.3 9-.3 15.7-.9 22.6 5.1 9.9 8.5 7.1 30.3 17.1 41.6 10.6 11.6 14 19.5 13.7 24.6zM173.3 148.7c2 1.9 4.7 4.5 8 7.1 6.6 5.2 15.8 10.6 27.3 10.6 11.6 0 22.5-5.9 31.8-10.8 4.9-2.6 10.9-7 14.8-10.4s5.9-6.3 3.1-6.6-2.6 2.6-6 5.1c-4.4 3.2-9.7 7.4-13.9 9.8-7.4 4.2-19.5 10.2-29.9 10.2s-18.7-4.8-24.9-9.7c-3.1-2.5-5.7-5-7.7-6.9-1.5-1.4-1.9-4.6-4.3-4.9-1.4-.1-1.8 3.7 1.7 6.5z"></path></svg>
<span class='name'>Linux</span>
<span class='size'>6.6MB</span>
</a>
<a href="https://github.com/vlang/v/releases/latest/download/v_macos.zip" class='dl-option' id='dl_macos'>
<svg class="svg-inline--fa fa-apple fa-w-12" id="dl-icon" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="apple" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" data-fa-i2svg=""><path fill="currentColor" d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"></path></svg>
<span class='name'>macOS</span>
<span class='size'>6.0MB</span>
</a>
<a href="https://github.com/vlang/v/releases/latest/download/v_windows.zip" class='dl-option' id='dl_windows'>
<svg class="svg-inline--fa fa-windows fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="windows" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z"></path></svg>
<span class='name'>Windows</span>
<span class='size'>5.9MB</span>
</a>
<a href="https://github.com/vlang/v/blob/master/doc/docs.md#install-from-source" class='dl-option'>
<svg class="svg-inline--fa fa-windows fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="windows" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""></svg>
<span class='name'>Build from source</span>
</a>
</div>
</div>
</div>
<script>
var dlname = document.getElementById('dl-name')
var dlicon = dlname.parentElement.parentElement.children[0]
var dlsize = document.getElementById('dl-size')
var dla = document.getElementById('dl-a')
var ua = window.navigator.userAgent,
platform = window.navigator.platform,
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
iosPlatforms = ['iPhone', 'iPad', 'iPod'],
os = null;
//console.log(platform + '!!');
if (macosPlatforms.indexOf(platform) !== -1 || iosPlatforms.indexOf(platform) !== -1) {
document.getElementById('dl_macos').style.display = 'none'
dlname.innerText = 'Download for macOS'
dlsize.innerText = 'v0.3.x - 6.0MB'
console.log('hello', dlicon)
dlicon.outerHTML = '<svg class="svg-inline--fa fa-apple fa-w-12" id="dl-icon" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="apple" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" data-fa-i2svg=""><path fill="currentColor" d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"></path></svg>'
dla.href = "https://github.com/vlang/v/releases/latest/download/v_macos.zip"
} else if (windowsPlatforms.indexOf(platform) !== -1 || /Android/.test(ua)) {
document.getElementById('dl_windows').style.display = 'none'
dlname.innerText = 'Download for Windows'
dlsize.innerText = 'v0.3.x - 5.9MB'
dlicon.outerHTML = '<svg class="svg-inline--fa fa-windows fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="windows" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z"></path></svg>'
dla.href = "https://github.com/vlang/v/releases/latest/download/v_windows.zip"
} else if (!os && /Linux/.test(platform)) {
document.getElementById('dl_linux').style.display = 'none'
dlname.innerText = 'Download for Linux'
dlsize.innerText = 'v0.3.x - 6.6MB'
dlicon.outerHTML = '<svg class="svg-inline--fa fa-linux fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="linux" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M220.8 123.3c1 .5 1.8 1.7 3 1.7 1.1 0 2.8-.4 2.9-1.5.2-1.4-1.9-2.3-3.2-2.9-1.7-.7-3.9-1-5.5-.1-.4.2-.8.7-.6 1.1.3 1.3 2.3 1.1 3.4 1.7zm-21.9 1.7c1.2 0 2-1.2 3-1.7 1.1-.6 3.1-.4 3.5-1.6.2-.4-.2-.9-.6-1.1-1.6-.9-3.8-.6-5.5.1-1.3.6-3.4 1.5-3.2 2.9.1 1 1.8 1.5 2.8 1.4zM420 403.8c-3.6-4-5.3-11.6-7.2-19.7-1.8-8.1-3.9-16.8-10.5-22.4-1.3-1.1-2.6-2.1-4-2.9-1.3-.8-2.7-1.5-4.1-2 9.2-27.3 5.6-54.5-3.7-79.1-11.4-30.1-31.3-56.4-46.5-74.4-17.1-21.5-33.7-41.9-33.4-72C311.1 85.4 315.7.1 234.8 0 132.4-.2 158 103.4 156.9 135.2c-1.7 23.4-6.4 41.8-22.5 64.7-18.9 22.5-45.5 58.8-58.1 96.7-6 17.9-8.8 36.1-6.2 53.3-6.5 5.8-11.4 14.7-16.6 20.2-4.2 4.3-10.3 5.9-17 8.3s-14 6-18.5 14.5c-2.1 3.9-2.8 8.1-2.8 12.4 0 3.9.6 7.9 1.2 11.8 1.2 8.1 2.5 15.7.8 20.8-5.2 14.4-5.9 24.4-2.2 31.7 3.8 7.3 11.4 10.5 20.1 12.3 17.3 3.6 40.8 2.7 59.3 12.5 19.8 10.4 39.9 14.1 55.9 10.4 11.6-2.6 21.1-9.6 25.9-20.2 12.5-.1 26.3-5.4 48.3-6.6 14.9-1.2 33.6 5.3 55.1 4.1.6 2.3 1.4 4.6 2.5 6.7v.1c8.3 16.7 23.8 24.3 40.3 23 16.6-1.3 34.1-11 48.3-27.9 13.6-16.4 36-23.2 50.9-32.2 7.4-4.5 13.4-10.1 13.9-18.3.4-8.2-4.4-17.3-15.5-29.7zM223.7 87.3c9.8-22.2 34.2-21.8 44-.4 6.5 14.2 3.6 30.9-4.3 40.4-1.6-.8-5.9-2.6-12.6-4.9 1.1-1.2 3.1-2.7 3.9-4.6 4.8-11.8-.2-27-9.1-27.3-7.3-.5-13.9 10.8-11.8 23-4.1-2-9.4-3.5-13-4.4-1-6.9-.3-14.6 2.9-21.8zM183 75.8c10.1 0 20.8 14.2 19.1 33.5-3.5 1-7.1 2.5-10.2 4.6 1.2-8.9-3.3-20.1-9.6-19.6-8.4.7-9.8 21.2-1.8 28.1 1 .8 1.9-.2-5.9 5.5-15.6-14.6-10.5-52.1 8.4-52.1zm-13.6 60.7c6.2-4.6 13.6-10 14.1-10.5 4.7-4.4 13.5-14.2 27.9-14.2 7.1 0 15.6 2.3 25.9 8.9 6.3 4.1 11.3 4.4 22.6 9.3 8.4 3.5 13.7 9.7 10.5 18.2-2.6 7.1-11 14.4-22.7 18.1-11.1 3.6-19.8 16-38.2 14.9-3.9-.2-7-1-9.6-2.1-8-3.5-12.2-10.4-20-15-8.6-4.8-13.2-10.4-14.7-15.3-1.4-4.9 0-9 4.2-12.3zm3.3 334c-2.7 35.1-43.9 34.4-75.3 18-29.9-15.8-68.6-6.5-76.5-21.9-2.4-4.7-2.4-12.7 2.6-26.4v-.2c2.4-7.6.6-16-.6-23.9-1.2-7.8-1.8-15 .9-20 3.5-6.7 8.5-9.1 14.8-11.3 10.3-3.7 11.8-3.4 19.6-9.9 5.5-5.7 9.5-12.9 14.3-18 5.1-5.5 10-8.1 17.7-6.9 8.1 1.2 15.1 6.8 21.9 16l19.6 35.6c9.5 19.9 43.1 48.4 41 68.9zm-1.4-25.9c-4.1-6.6-9.6-13.6-14.4-19.6 7.1 0 14.2-2.2 16.7-8.9 2.3-6.2 0-14.9-7.4-24.9-13.5-18.2-38.3-32.5-38.3-32.5-13.5-8.4-21.1-18.7-24.6-29.9s-3-23.3-.3-35.2c5.2-22.9 18.6-45.2 27.2-59.2 2.3-1.7.8 3.2-8.7 20.8-8.5 16.1-24.4 53.3-2.6 82.4.6-20.7 5.5-41.8 13.8-61.5 12-27.4 37.3-74.9 39.3-112.7 1.1.8 4.6 3.2 6.2 4.1 4.6 2.7 8.1 6.7 12.6 10.3 12.4 10 28.5 9.2 42.4 1.2 6.2-3.5 11.2-7.5 15.9-9 9.9-3.1 17.8-8.6 22.3-15 7.7 30.4 25.7 74.3 37.2 95.7 6.1 11.4 18.3 35.5 23.6 64.6 3.3-.1 7 .4 10.9 1.4 13.8-35.7-11.7-74.2-23.3-84.9-4.7-4.6-4.9-6.6-2.6-6.5 12.6 11.2 29.2 33.7 35.2 59 2.8 11.6 3.3 23.7.4 35.7 16.4 6.8 35.9 17.9 30.7 34.8-2.2-.1-3.2 0-4.2 0 3.2-10.1-3.9-17.6-22.8-26.1-19.6-8.6-36-8.6-38.3 12.5-12.1 4.2-18.3 14.7-21.4 27.3-2.8 11.2-3.6 24.7-4.4 39.9-.5 7.7-3.6 18-6.8 29-32.1 22.9-76.7 32.9-114.3 7.2zm257.4-11.5c-.9 16.8-41.2 19.9-63.2 46.5-13.2 15.7-29.4 24.4-43.6 25.5s-26.5-4.8-33.7-19.3c-4.7-11.1-2.4-23.1 1.1-36.3 3.7-14.2 9.2-28.8 9.9-40.6.8-15.2 1.7-28.5 4.2-38.7 2.6-10.3 6.6-17.2 13.7-21.1.3-.2.7-.3 1-.5.8 13.2 7.3 26.6 18.8 29.5 12.6 3.3 30.7-7.5 38.4-16.3 9-.3 15.7-.9 22.6 5.1 9.9 8.5 7.1 30.3 17.1 41.6 10.6 11.6 14 19.5 13.7 24.6zM173.3 148.7c2 1.9 4.7 4.5 8 7.1 6.6 5.2 15.8 10.6 27.3 10.6 11.6 0 22.5-5.9 31.8-10.8 4.9-2.6 10.9-7 14.8-10.4s5.9-6.3 3.1-6.6-2.6 2.6-6 5.1c-4.4 3.2-9.7 7.4-13.9 9.8-7.4 4.2-19.5 10.2-29.9 10.2s-18.7-4.8-24.9-9.7c-3.1-2.5-5.7-5-7.7-6.9-1.5-1.4-1.9-4.6-4.3-4.9-1.4-.1-1.8 3.7 1.7 6.5z"></path></svg>'
dla.href = "https://github.com/vlang/v/releases/latest/download/v_linux.zip"
}
</script>
<div class='links'>
<a target=_blank href="https://fast.vlang.io/">Is V still fast?</a>
<a target=_blank href="https://github.com/vlang/v/wiki/FAQ">FAQ</a>
<a target=_blank href="https://github.com/vlang/v/blob/master/CHANGELOG.md">Changelog</a>
<a href='/#builtinv'>Built in V</a>
<a target=_blank href='https://github.com/vlang/rfcs'>RFCs</a>
</div>
<div class='social'>
<a target=_blank href='https://twitter.com/v_language'><svg class="svg-inline--fa fa-twitter fa-w-16" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg></a>
<a target=_blank href='https://discord.gg/vlang'><svg class="svg-inline--fa fa-discord fa-w-14" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="discord" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M297.216 243.2c0 15.616-11.52 28.416-26.112 28.416-14.336 0-26.112-12.8-26.112-28.416s11.52-28.416 26.112-28.416c14.592 0 26.112 12.8 26.112 28.416zm-119.552-28.416c-14.592 0-26.112 12.8-26.112 28.416s11.776 28.416 26.112 28.416c14.592 0 26.112-12.8 26.112-28.416.256-15.616-11.52-28.416-26.112-28.416zM448 52.736V512c-64.494-56.994-43.868-38.128-118.784-107.776l13.568 47.36H52.48C23.552 451.584 0 428.032 0 398.848V52.736C0 23.552 23.552 0 52.48 0h343.04C424.448 0 448 23.552 448 52.736zm-72.96 242.688c0-82.432-36.864-149.248-36.864-149.248-36.864-27.648-71.936-26.88-71.936-26.88l-3.584 4.096c43.52 13.312 63.744 32.512 63.744 32.512-60.811-33.329-132.244-33.335-191.232-7.424-9.472 4.352-15.104 7.424-15.104 7.424s21.248-20.224 67.328-33.536l-2.56-3.072s-35.072-.768-71.936 26.88c0 0-36.864 66.816-36.864 149.248 0 0 21.504 37.12 78.08 38.912 0 0 9.472-11.52 17.152-21.248-32.512-9.728-44.8-30.208-44.8-30.208 3.766 2.636 9.976 6.053 10.496 6.4 43.21 24.198 104.588 32.126 159.744 8.96 8.96-3.328 18.944-8.192 29.44-15.104 0 0-12.8 20.992-46.336 30.464 7.68 9.728 16.896 20.736 16.896 20.736 56.576-1.792 78.336-38.912 78.336-38.912z"></path></svg></a>
<a target=_blank href='https://github.com/vlang/v/discussions'><svg class="svg-inline--fa fa-comments fa-w-18" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="comments" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg=""><path fill="currentColor" d="M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160zm122 220c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z"></path></svg></a>
<a target=_blank href='https://www.youtube.com/channel/UCLZIElNyubHOvbfudT7KS1A'><svg class="svg-inline--fa fa-youtube fa-w-18" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg=""><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z"></path></svg></a>
<a href='https://t.me/vlang_en'><svg class="svg-inline--fa fa-telegram fa-w-16 telegram" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="telegram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" data-fa-i2svg=""><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"></path></svg></a>
<a target=_blank href='https://twitch.tv/v_language'>
<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="twitch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-twitch fa-w-16 fa-2x"><path fill="currentColor" d="M391.17,103.47H352.54v109.7h38.63ZM285,103H246.37V212.75H285ZM120.83,0,24.31,91.42V420.58H140.14V512l96.53-91.42h77.25L487.69,256V0ZM449.07,237.75l-77.22,73.12H294.61l-67.6,64v-64H140.14V36.58H449.07Z" class=""></path></svg>
</a>
<a target=_blank href='https://marketplace.visualstudio.com/items?itemName=vlanguage.vscode-vlang'><img width=27 src='/img/vscode.png'></a>
<a target=_blank href='https://github.com/ollykel/v-vim'><img width=27 src='/img/vim.png'></a>
<a target=_blank href='https://github.com/damon-kwok/v-mode'><img width=27 src='/img/emacs.png'></a>
<!--
<a target=_blank href='https://github.com/oversoul/vlang-sublime'><img width=27 src='/img/sublime.png'></a>
-->
<a target=_blank href='https://github.com/elliotchance/vlang-sublime'><img width=27 src='/img/sublime.png'></a>
</div>
<div style='margin:12px'>
<a target=_blank href='https://twitter.com/v_language'>
<img src='https://camo.githubusercontent.com/711d2ed47f8b819c9ca3832eba4272a1eac09ba376febac3b965cdb8c891611f/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f765f6c616e67756167652e7376673f7374796c653d666c61746c266c6162656c3d466f6c6c6f77266c6f676f3d74776974746572266c6f676f436f6c6f723d776869746526636f6c6f723d316461316632'>
</a>
<a target=_blank href='https://discord.gg/vlang'>
<img src='https://camo.githubusercontent.com/6c33b3fd882c28b844cc7970053244660b857100/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3539323130333634353833353832313036383f6c6162656c3d446973636f7264266c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465'>
</a>
</div>
</div>
<a class='book' href='https://www.amazon.com/gp/product/1839213434' target='_blank'>
<img style='width:155px' src='/img/book.jpg'> <br>
The first printed book on V!
</a>
<div class='examples'>
<div style="width: 100%; overflow-x: hidden; margin-bottom: -22px;">
<a target=_blank href='https://my-store-7564322.creator-spring.com/'><img style="width: 200px; margin:0; padding: 0; float: right; right: -20px; z-index: 2; position: relative" src="/img/veasel.png"></a>
</div>
<div class='codeblock' id="codeblock_99404097">
<div class='titlebar separator'>
<div class='flex'></div>
</div>
<pre class="hello_devs" id=ex1>fn main() {
areas := ['game', 'web', 'tools', 'science', 'systems',
'embedded', 'drivers', 'GUI', 'mobile']
for area in areas {
println('Hello, $area developers!')
}
}</pre>
<pre class="hello_devs" id=ex2 style='display:none'>
// Print file lines that start with "DEBUG:"
import os
// `read_file` returns an optional (`?string`), it must be checked
text := os.read_file('app.log') or {
// `err` is a special variable that contains the error
// in `or {}` blocks
eprintln('failed to read the file: $err')
return
}
lines := text.split_into_lines()
for line in lines {
if line.starts_with('DEBUG:') {
println(line)
}
}
</pre>
<pre class="hello_devs" id=ex3 style='display:none'>
import time
import net.http
resp := http.get('https://vlang.io/utc_now') or {
println('failed to fetch data from the server')
return
}
t := time.unix(resp.text.int())
println(t.format()) // 2019-08-16 17:48
</pre>
<pre class="hello_devs" id=ex4 style='display:none'>
import json
struct User {
name string
age int
mut:
is_registered bool
}
fn main() {
s := '[{"name":"Frodo", "age":25}, {"name":"Bobby", "age":10}]'
mut users := json.decode([]User, s) or {
eprintln('Failed to parse json')
return
}
for user in users {
println('$user.name: $user.age')
}
println('')
for i, mut user in users {
println('$i) $user.name')
if !user.can_register() {
println('Cannot register $user.name, they are too young')
continue
}
// `user` is declared as `mut` in the for loop,
// modifying it will modify the array
user.register()
}
// Let's encode users again just for fun
println('')
println(json.encode(users))
}
fn (u User) can_register() bool {
return u.age >= 16
}
fn (mut u User) register() {
u.is_registered = true
}
</pre>
</div>
<select id="select" onchange="change_ex()" style="margin-top:5px">
<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>
-->
</select>
<script>
var ex_id = 1;
const nr_exs = 5;
function prev() {
ex_id--;
if (ex_id < 1) ex_id = nr_exs;
update_ex()
}
function next() {
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++) {
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;
next();
}
function tokenize_codeblock_99404097 (e) {
Tokenizer(e.target.value).then(function(tokens) {
document.getElementById("codeblock_hl_04227451").innerHTML = tokens
.map(function(token) { return `<span class='${token.type}'>${token.value}</span>` })
.join('')
})
}
document.getElementById("codeblock_ta_39322469").oninput = tokenize_codeblock_99404097
tokenize_codeblock_99404097({target:{value: document.getElementById("codeblock_ta_39322469").value}})
document.getElementById("codeblock_rb_13318017").onauxclick = function(e) {
localStorage.setItem('sandbox-code', document.getElementById("codeblock_ta_39322469").value)
}
document.getElementById("codeblock_rb_13318017").onclick = function(e) {
if (location.pathname === 'https://v-wasm.vercel.app') e.preventDefault()
var codeblock_value = document.getElementById("codeblock_ta_39322469").value
localStorage.setItem('sandbox-code', codeblock_value)
}
</script>
</div>
</div>
<div>
<div class="section news">
<div class='news_header'>
<b>Latest news</b><br>
</div>
<div class="block">
<div class='news_date'>
June 30, 2022
</div>
<div>
<a target=_blank href='https://github.com/vlang/v/discussions/14895'>V 0.3 is out!</a>
</div>
</div>
<div class="block">
<div class='news_date'>
June 22, 2022
</div>
<div>
C2V is out! Demo video:
<a target=_blank href='https://www.youtube.com/watch?v=6oXrz3oRoEg'>
translating DOOM from C to V, building it under a second and running it!</a>
</div>
</div>
<div class="block">
<div class='news_date'>
June 10, 2022
</div>
<div>
V has appeared on
<a target=_blank href="https://twitter.com/v_language/status/1535291800717500416">RedMonk Q122 Programming Language Rankings</a>.
</div>
</div>
<div class="block">
<div class='news_date'>
June 9, 2022
</div>
<div>
As of today, programs built with the V compiler no longer leak memory by default.
</div>
</div>
<div class="block">
<div class='news_date'>
May 29, 2022
</div>
<div>
7000 pull requests have been merged!
</div>
</div>
</div>
<div class="section">
<div class="block">
<h2>%simple_language_for_maintainable_programs</h2>
<p>
You can learn the entire language by going through the
<a target=_blank href='https://github.com/vlang/v/blob/master/doc/docs.md'>documentation</a> over a weekend, 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 and can be used in pretty much every field, including systems programming, webdev, gamedev, GUI, mobile, science, embedded, tooling, etc.
</p>
<p>
V is very similar to Go. If you know Go, you already know ≈80% of V.
Things V improves on Go: <a target=_blank href='https://vlang.io/compare#go'>vlang.io/compare#go</a>.
</p>
</div>
<div class="block">
<h2>Safety</h2>
<ul>
<li>Bounds checking</li>
<li>No undefined values</li>
<li>No undefined behavior</li>
<li>No variable shadowing</li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#variables">Immutable variables by default</a></li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#access-modifiers">Immutable structs by default</a></li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#optionresult-types-and-error-handling">Option/Result and mandatory error checks</a></li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#sum-types">Sum types</a></li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#generics">Generics</a></li>
<li><a href="https://github.com/vlang/v/blob/master/doc/docs.md#immutable-function-args-by-default">Immutable function args by default, mutable args have to be marked on call</a></li>
<li>No null <i>(allowed in unsafe code)</i></li>
<li>No global variables <i>(can be enabled for low level applications like kernels via a command line flag)</i></li>
</ul>
</div>
</div>
<div class="section" style="flex-direction: column">
<div class="block">
<h1>Sponsors</h1>
<div style="margin-top: 16px">
<a target=_blank href="https://threefold.io/">
<img style="height: 200px" src="/img/sponsor_threefold.svg" />
</a>
<a target=_blank href="https://data.mx.com/">
<img style="height: 200px" src="/img/sponsor_mx.png" />
</a>
<a target=_blank href="https://syndica.io/">
<img style="height:200px; margin-left: 20px;" src="/img/sponsor_syndica.jpg?1" />
</a>
<a target=_blank href="https://chipnetics.com/">
<img style="height: 200px" src="/img/sponsor_chipnetics.svg" />
</a>
</div>
</div>
<a href="https://github.com/sponsors/medvednikov" target=_blank style="margin: 0 0px 32px 0px; text-align: center">
Become a sponsor via GitHub Sponsors
</a>
</div>
<div class="section">
<div class="block">
<h2>Performance</h2>
<ul>
<li>As fast as C <i>(V's main backend compiles to human readable C)</i></li>
<li>C interop without any costs</li>
<li>Minimal amount of allocations</li>
<li>Built-in serialization without runtime reflection</li>
<li>Compiles to native binaries without any dependencies: a simple web server is only 65 KB</li>
</ul>
</div>
<div class="block">
<h2>Fast compilation</h2>
<p>
V compiles ≈110k (Clang backend) and ≈500k (x64 and tcc backends) lines of code per second. <br><i>(Intel i5-7500, SM0256L SSD, no optimization)</i><br/><br/>
V is written in V and compiles itself in under a second.
</p>
<p>
Most of the compiler is still single threaded, so it's going to be 2-3x faster in the future!
</p>
</div>
</div>
<div class="section">
<div class="block">
<h2>Small and easy to build compiler</h2>
<p>
V can be bootstrapped in under a second by compiling its code translated to C with a simple <pre>cc v.c</pre>No libraries or dependencies needed.
<br /><br />
For comparison, space and time required to build each compiler:
</p>
<table>
<tbody><tr><td></td><td>Space </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>60m</td></tr>
<tr><td>Swift</td><td>70 GB
<a target="_blank" class="sidenote" href="https://github.com/apple/swift/blob/1f9da381dcdef98df2a7313d8729750cbac54f45/README.md#getting-started">[1]</a>
</td><td>90m</td></tr>
<tr><td>V</td><td>< 10 MB
<a target="_blank" class="sidenote" href="https://github.com/vlang/vc/blob/master/v.c">[2]</a>
</td><td><1s</td></tr>
</tbody></table>
</div>
<div class="block">
<p>Building V in 0.3 seconds and then using the resulting binary to build itself again:</p>
<a href='https://www.youtube.com/watch?v=pvP6wmcl_Sc' target=_blank>
<img style="width: 90%; margin-left: 0" src='/img/youtube_comp_speed.png'>
</a>
<!--
<iframe width="448" height="252" src="https://www.youtube.com/embed/pvP6wmcl_Sc" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
-->
<!--
<video looping="true" autoPlay muted src="/img/buildv.mp4" style="width: 80%; margin-left: 10%"></video>
-->
</div>
</div>
<div class="section" id="memory">
<div class="block">
<h2>Innovative and flexible memory management</h2>
<p>
V avoids doing unnecessary allocations in the first place
by using value types, string buffers, promoting a simple abstraction-free code style.
</p>
<p>
Right now allocations are handled by a minimal and well performing GC until V's autofree engine is production ready.
<p>
Autofree can be enabled with <code>-autofree</code>. It takes care of most objects (~90-100%):
the compiler inserts necessary free calls automatically during compilation.
Remaining small percentage of objects is freed via GC.
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.
</p>
<p>
For developers willing to have more low level control, memory can be managed manually
<!--
autofree can be disabled
-->
with <code>-gc none</code>.
</p>
<!--
<p>
There's also an option to use GC for everything via <code>v -gc boehm</code>.
</p>
-->
<p>
Arena allocation is available via <code>v -prealloc</code>.
</p>
</div>
<div class="block">
<p>
V's autofree demo. All objects are freed during compilation. Running the Ved editor on an 8 MB file with 0 leaks:
</p>
<a href='https://www.youtube.com/watch?v=gmB8ea8uLsM' target=_blank>
<img style="width: 90%; margin-left: 0" src='/img/youtube_compile_speed.png'>
</a>
<!--
<iframe width="448" height="252" src="https://www.youtube.com/embed/gmB8ea8uLsM" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
-->
</div>
</div>
<div class="section">
<div class="block">
<h2>C translation</h2>
<p>V can translate your entire C project and offer you the safety, simplicity, and compilation speed-up (via modules). </p>
<div style="display: flex">
<pre style="margin-right: 36px">v translate file.c
std::vector<std::string> s;
s.push_back("V is ");
s.push_back("awesome");
std::cout << s.size();</pre>
<pre>mut s := []
s << 'V is '
s << 'awesome'
println(s.len)</pre>
</div>
<p>
A blog post about translating DOOM will be published.<br/><br/>
<i>C++ to V translation is at an early stage.</i>
</p>
</div>
<div class="block">
<p>
Translating DOOM from C to V and building it in under a second:
</p>
<a target=_blank href='https://www.youtube.com/watch?v=6oXrz3oRoEg'><img src="/img/doom.png" style="width: 80%; margin-left: 0"></a>
<p>
You can read translated code here:
<a target=_blank href='https://github.com/vlang/doom'>github.com/vlang/doom</a>
</p>
</div>
</div>
<div class="section">
<div class="block">
<h2>Hot code reloading</h2>
<p>
Get your changes instantly without recompiling.
<br /><br />
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>
<a href="https://github.com/vlang/v/tree/master/examples/hot_reload">github.com/.../examples/hot_reload</a>
</div>
<div class="block">
<video looping="true" autoPlay muted src="/img/hot.mp4" style="width: 80%; margin-left: 10%"></video>
</div>
</div>
<div class="section">
<div class="block">
<h2>Powerful graphics libraries</h2>
<p>
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:
</p>
<ul>
<li>Loading complex 3D objects with textures</li>
<li>Camera (moving, looking around)</li>
<li>Skeletal animation</li>
</ul>
<p>DirectX, Vulkan, and Metal support is planned.</p>
<p>A simple example of the graphics library in action is <a href="https://github.com/vlang/v/blob/master/examples/tetris">tetris.v</a>.</p>
</div>
<div class="block">
<img src="/img/gg.png" style="width: 60%; margin-left: 20%"></img>
</div>
</div>
<div class="section">
<div class="block">
<h2>Native cross-platform GUI library</h2>
<p>
Build native apps with native controls. You no longer need to embed a browser to develop cross-platform apps quickly.<br /><br />
V has a ui module that uses native GUI toolkits: WinAPI/GDI+ on Windows, Cocoa on macOS. On Linux custom drawing is used.<br /><br />
Coming soon:
</p>
<ul>
<li>a Delphi-like visual editor for building native GUI apps</li>
<li>iOS/Android support with native controls</li>
<li>a declarative API similar to SwiftUI and React Native</li>
</ul>
<p><a href="https://github.com/vlang/ui">github.com/vlang/ui</a></p>
</div>
<div class="block">
<p>
Volt, a 300 KB Slack client built with V and V ui:
</p>
<img src="https://volt-app.com/img/screen3.png" style="width: 100%"></img>
</div>
</div>
<div class="section">
<div class="block">
<h2>Easy cross compilation</h2>
<p>
To cross compile your software simply run v -os windows. or v -os linux. No extra steps required, even for GUI and graphical apps!<br/><br/>
(Compiling macOS software only works on macOS for now.)
</p>
</div>
<div class="block">
<p>
Building V for Windows using V for macOS, and then testing resulting v.exe on a Windows VM:
</p>
<video looping="true" autoPlay muted src="/img/vwin.mp4" style="width: 100%"></img>
</div>
</div>
<div class="section">
<div class="block">
<h2>Painless deployments and dependency management</h2>
<p>
To build your project, no matter how big, all you need to do is run
<pre>
v .
</pre><br/>
No build environments, makefiles, headers, virtual environments, etc.<br/>
You get a single statically linked binary that is guaranteed to work on all operating systems (provided you cross compile) without any dependencies.<br/><br/>
Installing new libraries via vpm, a centralized package manager written in V, is as simple as
<pre>
v install ui
</pre>
</p>
</div>
<div class="block">
<h2>Run everywhere</h2>
<p>
V can emit (human readable) C, so you get the great platform support and optimization of GCC and Clang. (Use <code>v -prod .</code> to make optimized builds.)<br/><br/>
Emitting C will always be an option, even after direct machine code generation matures.<br/><br/>
V can call C code, and calling V code is possible in any language that has C interop.
</p>
</div>
</div>
<div class="section">
<div class="block">
<h2>REPL</h2>
<pre style="margin-right: 36px">v
>>> import net.http
>>> data := http.get('https://vlang.io/utc_now')?
>>> data.text
1565977541</pre>
</div>
<div class="block">
<h2>Cross-platform shell scripts in V</h2>
<p>
V can be used as an alternative to Bash to write deployment scripts, build scripts, etc.
The advantage of using V for this is the simplicity and predictability of the language, and cross-platform support. "V scripts" run on Unix-like systems as well as on Windows.
</p>
<pre style="margin-right: 36px">for file in ls('build/') {
rm(file)
}
mv('v.exe', 'build/')
v run deploy.vsh</pre>
<p><a href="https://github.com/vlang/v/blob/master/doc/docs.md#cross-platform-shell-scripts-in-v">Read more about V script</a></p>
</div>
</div>
<div class="section">
<div class="block">
<h2>Code formatting with vfmt for consistent style</h2>
<p>
No more arguments about coding styles. There's one official coding style
enforced by the vfmt formatter.
</p>
<p>
All V code bases are guaranteed to use
the same style, making it easier to read and change code written by
other developers.
</p>
<pre>v fmt -w hello.v</pre>
</div>
<div class="block">
<h2>A built-in code profiler</h2>
<p>
Build and run your program with <pre>v -profile profile.txt x.v && ./x</pre> and
you'll get a detailed list for all function calls: number of calls, average time per
call, total time per call.
</p>
</div>
</div>
<div class="section">
<div class="block">
<h2>JavaScript and WASM backends</h2>
<p>
V programs can be translated to JavaScript:
</p>
<pre>v -o hello.js hello.v</pre>
<p>
They can also be compiled to WASM (for now with Emscripten).
V compiler compiled to WASM and running V programs by translating them to JavaScript:
</p>
<p>
<a target=_blank href='https://v-wasm.vercel.app/'>v-wasm.vercel.app</a>
</p>
<p>A game written using V's graphical backend and compiled to WASM:</p>
<a target=_blank href='https://v2048.vercel.app/'>v2048</a>
</div>
<div class="block">
<h2>Automatic documentation</h2>
<p>
Use vdoc to get instant documentation generated directly from
the module's source code. No need to keep and update separate documentation.
</p>
<pre>v doc os</pre>
</div>
</div>
<div class="section">
<div class="block">
<h2>Built-in testing framework</h2>
<p>
Writing tests is very easy: just start your test function with <code>test_</code>
<pre>
fn get_string() string { return 'hello' }
fn test_get_string() {
assert get_string() == 'hello'
}
<p>
</div>
<div class="block">
<h2>Friendly error messages</h2>
<p>
Helpful error messages make learning the language and fixing errors simpler:
</p>
<pre>
user.v:8:14: error: `update_user` parameter `user` is mutable, you need to provide `mut`: `update_user(mut user)`
7 | mut user := User{}
8 | update_user(user)
| ~~~~
9 | }
</pre>
</div>
</div>
<div class="section">
<div class="block">
<h2>Powerful built-in web framework</h2>
<p><a href="https://github.com/vlang/v/tree/master/vlib/vweb">github.com/vlang/v/tree/master/vlib/vweb</a></p>
<div class='codeblock' id="codeblock_12828032">
<div class='titlebar separator'>
<div class='flex'></div>
<a href="https://v-wasm.vercel.app" class='play-btn' id='codeblock_rb_06463216'><svg class="svg-inline--fa fa-play fa-w-14" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="play" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg> Run</a>
</div>
<pre><div id="codeblock_hl_93987704">['/post/:id']
fn (b Blog) show_post(id int) vweb.Result {
post := b.posts_repo.retrieve(id) or {
return vweb.not_found()
}
return vweb.view(post)
}</div><textarea spellCheck="false" id="codeblock_ta_15447927" class="">['/post/:id']
fn (b Blog) show_post(id int) vweb.Result {
post := b.posts_repo.retrieve(id) or {
return vweb.not_found()
}
return vweb.view(post)
}</textarea></pre>
</div>
<script>
function tokenize_codeblock_12828032 (e) {
Tokenizer(e.target.value).then(function(tokens) {
document.getElementById("codeblock_hl_93987704").innerHTML = tokens
.map(function(token) { return `<span class='${token.type}'>${token.value}</span>` })
.join('')
})
}
document.getElementById("codeblock_ta_15447927").oninput = tokenize_codeblock_12828032
tokenize_codeblock_12828032({target:{value: document.getElementById("codeblock_ta_15447927").value}})
document.getElementById("codeblock_rb_06463216").onauxclick = function(e) {
localStorage.setItem('sandbox-code', document.getElementById("codeblock_ta_15447927").value)
}
document.getElementById("codeblock_rb_06463216").onclick = function(e) {
if (location.pathname === 'https://v-wasm.vercel.app') e.preventDefault()
var codeblock_value = document.getElementById("codeblock_ta_15447927").value
localStorage.setItem('sandbox-code', codeblock_value)
}
</script>
<p><a href="https://github.com/vlang/gitly">Gitly</a>, a light and fast alternative to GitHub/GitLab is built in V and vweb.</p>
</div>
<div class="block">
<h2>Built-in ORM</h2>
<p>
<div class='codeblock' id="codeblock_63253338">
<div class='titlebar separator'>
<div class='flex'></div>
<a href="https://v-wasm.vercel.app" class='play-btn' id='codeblock_rb_61993869'><svg class="svg-inline--fa fa-play fa-w-14" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="play" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg> Run</a>
</div>
<pre><div id="codeblock_hl_69524066">import sqlite
struct Customer {
id int
name string
nr_orders int
country string
}
fn main() {
db := sqlite.connect('example.sqlite') or {
panic('could not create/find example.sqlite')
}
nr_customers := sql db {
select count from Customer
}
println('number of all customers: $nr_customers')
// V syntax can be used to build queries
uk_customers := sql db {
select from Customer where country == 'uk' && nr_orders > 0
}
for customer in uk_customers {
println('$customer.id - $customer.name')
}
// by adding `limit 1` we tell V that there will be
// only one object
customer := sql db {
select from Customer where id == 1 limit 1
}
println(customer.name)
// insert a new customer
new_customer := Customer{name: 'Bob', nr_orders: 10}
sql db {
insert new_customer into Customer
}
}
</div><textarea spellCheck="false" id="codeblock_ta_60982598" class="">import sqlite
struct Customer {
id int
name string
nr_orders int
country string
}
fn main() {
db := sqlite.connect('example.sqlite') or {
panic('could not create/find example.sqlite')
}
nr_customers := sql db {
select count from Customer
}
println('number of all customers: $nr_customers')
// V syntax can be used to build queries
uk_customers := sql db {
select from Customer where country == 'uk' && nr_orders > 0
}
for customer in uk_customers {
println('$customer.id - $customer.name')
}
// by adding `limit 1` we tell V that there will be
// only one object
customer := sql db {
select from Customer where id == 1 limit 1
}
println(customer.name)
// insert a new customer
new_customer := Customer{name: 'Bob', nr_orders: 10}
sql db {
insert new_customer into Customer
}
}
</textarea></pre>
</div>
<script>
function tokenize_codeblock_63253338 (e) {
Tokenizer(e.target.value).then(function(tokens) {
document.getElementById("codeblock_hl_69524066").innerHTML = tokens
.map(function(token) { return `<span class='${token.type}'>${token.value}</span>` })
.join('')
})
}
document.getElementById("codeblock_ta_60982598").oninput = tokenize_codeblock_63253338