V - Best Programming Language to Learn in 2023?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
thanks to everyone who recommended that I check out the V programming language so what does the V programming language get us that we can't get from all the other languages that we have to choose from these days we're going to address that and also take a tour of some of its syntax the V language like rust aims to provide modern safety features including memory safety while still having c-like performance but at the same time V is more high level than rust so it occupies an interesting Niche you can even translate an entire C project to V automatically and there's an example of this using the game Doom John Carmack if you're watching this go ahead and comment below on what you think of V Ultra fast compilation speed is also a nice icing on the cake apparently it's very syntactically similar to go which is a language I'm not very familiar with who has a better mascot though come on seriously there's also a bit of drama and controversy around the V language but we'll get to that a bit later first let's take a look at the language syntax itself then we'll look at what might be its killer feature which is Auto free memory management first of all V programs are currently transpiled to C prior to being compiled to machine code you can actually view the C code for your program by running this command there's a lot of V compiler boilerplate in there but it could come in handy if you ever need to see what the V compiler is doing under the hood personally I prefer never looking at this but that's just me V has an official object relational mapping module for interacting with databases Yes you heard that right a programming language has an official orm module V also has an official desktop UI framework these official UI and orm modules yield a level of batteries included that I didn't know was possible also there's a Tetris example project if Auto free doesn't get you excited you can always fall back on that okay let's dive into the highlights of these syntax like go variables are declared and initialized using the colon equals operator initialization is required when a variable is declared if they are marked as mutable with the mute keyword they can be reassigned after declaration using the equals operator V is statically typed but has the type inference you'd expect in a modern language when you do need to specify types like in function parameters and return types there's no colon necessary like there is in many languages an identifier and its type are separated only by a space character V mostly has parity with the rust primitive type types Boolean i32 u32 and so on strings are immutable like string slices and rust they are just a read-only array of bytes arrays can be mutable and have both capacity and length Fields capacity is automatically increased as necessary similar to something like an arraylist in Java functions can return multiple values by using a comma delimited list of types surrounded by parentheses as a return type in the function signature structs are defined using a simple syntax no commas are necessary between Fields just identifiers for each field and their respective types annotate Fields with required to make sure that particular field is assigned when creating an instance of the struct to Define methods on a type such as a struct you actually put a special receiver argument prior to the function name that makes the function a callable method on the receiver type there's an interesting feature called struct embedding which is sort of like inheritance without polymorphism let me explain I can have a struck person that has an age field and a method called is adult then I can have another struct programmer that has a lines of code per day field I can specify that the person struct is embedded in the programmer struct and the programmer struct will inherit the fields and methods of person but again there's no polymorphism here you can't pass a programmer to a function that has a person parameter but V does have an interface construct which does allow for polymorphism and there are some things about it that are pretty unique compared to the equivalent construct in other languages first of all it can specify fields that implementers must have that can be handy because it can free you to create more methods on the interface that might otherwise have to be in the implementing structs functions are first class citizens in that they can be created anonymously assigned to a variable and use as function parameters closures are supported too so an anonymous function can inherit variables from the scope they were created in the somewhat unique thing about these closures is that you need to explicitly list all the variables that you'd like the anonymous function to inherit put a comma delimited list of identifiers Embraces immediately after the FN keyword V does have a concept of references if I'm defining a function that takes a struct as a parameter I can force it to be passed by reference by prefixing the type with an ampersand similar to how it would be in C plus but if I omit the Ampersand on an immutable type it won't necessarily be passed by value the compiler will make the optimal choice for you depending on what the parameter is and what you're doing with it in the function okay that's a quick tour of some of the syntax of V we haven't covered nearly all of its features but those are just a few to give you a feel for what the language is all about to define a module create a directory with the name of that module then include the module keyword followed by module name at the top of each file any identifiers like a struct or a function with a public access modifier can be accessed from a different module by using import followed by the module name as for writing tests V definitely Embraces convention over configuration all files with names that end in underscore test are assumed to contain tests all functions in those files that begin with test underscore are run as tests there is a built-in assert keyword which feels more like a core language construct than a function call no need to use parentheses just follow it with the Boolean expression that you'd like to test to run your tests run the v test command having the entire V tool chain in a binary that is only one character long is actually pretty nice the V command contains most of the operations you'll need like compiling running and selling module Jewels running tests hot reloading and so on like you'd expect from any modern build tool you can prefix many commands with watch to have it automatically re-execute each time a file is changed we install and then the module name will install the V module called markdown to a global.v modules directory on your system it reminds me a bit of how pip works in the python ecosystem the speed of the V compiler is one of the main selling points on the website and I didn't really expect to care much about it but it did feel extremely nice to have my build finish before I could even switch back to the terminal for my IDE now let's look at safety in the infamous Auto free V doesn't have a borrow Checker which some might be relieved to hear V is also a bit unique in that you're able to select from a few different memory management strategies the only other language I've used that allows for this is Nim at the time this video is being made the default memory management strategy is garbage collection but supposedly that's temporary fully manual memory management can be enabled as Kenwood aims to eventually be the default memory management strategy which is Auto free Auto free claims to quote insert necessary free calls automatically during compilation and to quote fall back to reference County everywhere that isn't possible ostensibly this should negate the need for a garbage collector or manual memory management I did have some issues trying to figure out how this is supposed to work but here's what I've gathered in Rust if you create an instance of something in a scope that thing is automatically deallocated when the instance goes out of scope in this simple situation something like reference counting is not needed when something needs to be deallocated somewhere other than the end of the scope it was defined in and rust the situation can be addressed using a change in ownership which might be able to do what you need to do while still guaranteeing memory safety in C plus plus you can address the scenario using dynamic memory management via the new and delete keywords but this puts memory safety in the hands of the developer and is the root cause of an unfathomable number of software bugs if you can tolerate a little extra memory and performance overhead you can use automatic reference counting in these scenarios in Rust you can do that using the RC smart pointer okay so back to Auto free my understanding is that V's Auto free aims to automatically detect whether something should be deallocated at the end of the scope it was defined in or whether it requires reference counting this is supposed to to happen without any developer input every other language I've used including rust requires this decision to be made by the developer having the compiler make this decision for you sounds pretty ideal in most cases but there's currently no documentation on how this is ultimately supposed to work and there is some skepticism in the community as to whether it's even possible if the promise of Auto free memory management is the reason you'd like to learn or use V I'd exercise a little bit of caution if the robot for Auto free does become a bit clearer after this video is released I'll explain the latest developments in a pin comment below now let's talk about some of the controversy surrounding the V language after researching a bit the language seems to have a reputation for over-promising and under delivering at least in the past some claim that there have been many times where features have been advertised before they're implemented or before they're in a state that can be considered complete now I haven't looked into the validity of any of these claims but I did notice a lack of information around the vision for Auto free memory management here's a Reddit thread where someone was asking about how autofree is supposed to work I'm not sure if the person responding is a v developer but in reading through the thread it felt like they were avoiding the Poster's Quest question basically telling them that they have no business asking such a question until they've tried the language I felt like that's pretty short-sighted since I think it's natural to want to know about a language's features prior to investing time into learning it the original poster didn't have the best tone in his question but the tone of the responses he got was pretty much the opposite of what you'd want as your first impression of the community surrounding a technology of course this is just one anecdote and ultimately I don't think it should discourage anyone from trying the language that's a quick tour of the V programming language and what sets it apart from other modern languages it's not something I'd put all my eggs into quite yet but it's worth keeping tabs on especially if Auto free winds up fulfilling its promise if you like interesting programming languages that you might not have heard of check out this video for some other programming languages that you might not have tried thanks for watching and we'll see you in the next one
Info
Channel: Code to the Moon
Views: 133,865
Rating: undefined out of 5
Keywords: vlang, esoteric, programming languages, memory safety, no gc, autofree
Id: jr1EBaLkjfc
Channel Id: undefined
Length: 8min 44sec (524 seconds)
Published: Sat Feb 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.