V (programming language)

V, also known as vlang, is a compiled programming language created to be easier for using, reading, maintaining, and making safer programs. It was created by Alexander Medvednikov in 2019.

Some technical details

V is also general-purpose, which means that it can be used for different purposes, to include creating different kinds of applications that can be cross-platform. V applications can be created to run on many different operating systems. The language also has various rules and features for greater program safety. 

Users don't have to care about managing memory themselves, unless they want to, because V gives different options. Users can use a garbage-collector (GC), which is 1 of 4 other choices. Advanced users can choose to turn the GC off and manage memory themselves, using the other options from V.

V works well with C. Functions in C can be called for use in V. It can translate C code into V. Code in V can also be compiled to human readable C, JavaScript, and other languages.

 Examples 

Here is a hello world program in V.
println("Hello world!")

Here is an example of using a variable:
 Define by using  and a value.
 Variables that don't have , have values that can't be changed.
 Variables that have  before them can change values using .

a := 1 // value can not be changed
mut b := 2 // value can be changed
b = 3

Here is an example of using `if`, `else if` and `else` conditionals in V. 

// Define entry point.
fn main() {
	a := 10
	b := 20
	if a < b {
		println("${a} < ${b}")
	} else if a > b {
		println("${a} > ${b}")
	} else {
		println("${a} == ${b}")
	}
	// Output: 10 < 20
}

Here are examples of how to use the for loop in V.
 In V, all types of loops use the same `for` keyword.
 This helps to make it easier to learn and separate them from other kinds of code.
// Define entry point.
fn main() {
    // Here is a condition `for` loop (also known as a `while` loop).
	mut count := 0
    for count < 5 {
        // some code
        count++
        println(count) // Prints numbers from 1 up to 5.
    }

    // Here is a range `for` loop.
    for i in 1..10 {
        println("Number: ${i}") // Prints numbers from 1 up to 9.
    }

    // Here is a map `for` loop.
	m := {
		"one": 1
		"two": 2
	}
	for key, value in m {
		println("${key} -> ${value}")
		// Output: one -> 1
		//         two -> 2
	}

	// Here is a bare `for` loop.
	mut num := 0
	for {
		num += 2
		if num >= 10 {
			break
		}
	}
	println(num) // Prints "10".

	// Here is a C style `for` loop.
	for i := 0; i < 8; i += 2 {
		// Don't print 4
		if i == 4 {
			continue
		}
		println(i) // Prints the numbers "0", "2", and "6".
	}
}

References

 Further reading 









 Other websites 

 Official website
 Vlang on GitHub
 Documentation
 Modules
Review Videos:
 How To Maintain And Iterate With V (Sydney Computing Society)
 A small presentation of V's features at IBM

Category:Programming languages
Category:Cross-platform software
Category:Functional languages
Category:Multi-paradigm programming languages