After 40 days of development, a new version of the statically typed programming language V (vlang) has been published. The main goals in creating V were ease of learning and use, high readability, fast compilation, improved security, efficient development, cross-platform use, improved interoperability with the C language, better error handling, modern capabilities, and more maintainable programs. The compiler code, libraries and related tools are open sourced under the MIT license.
In the new version:
- Language improvements:
- New module “encoding.xml with parser, validation, unit tests.
- Improved support for couroutines (IO, network).
- Reduce memory allocation operations in vweb applications by 80%.
- Implementation of "@VCURRENTHASH" to replace "C.V_CURRENT_COMMIT_HASH".
- The promotion of a new type int has begun, associated with the i64 type (previously, the int type was identified with the i32 type).
- Fixed type checking rules for the new int type and optimized code generation.
- API changes that break compatibility:
- The "Request.cookies" dictionary has been deprecated. Replaced by “Request.cookie()” and “Request.add_cookie()”.
- Stricter rules for C types, which must now always be declared.
- Type checking system changes:
- The warning about the option/result split has been moved to an error category.
- Fix calling "fn" with an optional argument in autofree mode.
- Naming check is back: pascal case for aliases.
- C.xx = C.yy aliases.
- Allow casting of integer types as ranges in math blocks.
- Warning about the deprecation of the byte type (in favor of the u8 type) when used as a fn parameter.
- Fix append method for generic arrays.
- Checking for an error in the implementation of the private interface of another module.
- Fixed checking for negative cap and len values when initializing an array.
- Turning the warning about duplicate var and param module names into an error.
- Allow reassignment of the entire shared variable (while maintaining the previous state of the mutex).
- Parser improvements:
- Fixed assigning a static method to anonymous functions.
- ast: Fixed formatting of struct declaration with nested structure.
- Added set_all + clear_all methods to the "[flag]" bitfields.
- Warn about unused imports, even if they are declared with "import math { sin, cos }".
- Compiler changes:
- checker, builder, pref: support the "-dump-defines" flag to view all available user and system definitions for a given program.
- maps: added maps.merge() and maps.merge_in_place() functions.
- Standard Library:
- builtin: added "unsafe { a.reset() }" method to quickly set all bytes in an array to 0.
- math.fractions: Use operator overloading and abandon old functions.
- gg: Fix draw_rounded_rect_empty bottom border alignment on macos and linux.
- crypto.bcrypt: fixed bug in bcrypt.
- sokol: updated to the latest version
- builtin: fixed sizeof(C.BOOL) (windows specific).
- math.big: Fix incorrect division with negative numbers.
- os: Added a convenient way to ignore some system signals.
- os: fix os.ls(folder) in windows when the protected directory cannot be opened.
- crypto.sha/md5/: Fixed calculation of the same hash values when calling .sum() multiple times for sha1/256/512.
- os: implemented os.fd_is_pending/1, os.Process.pipe_read/1, os.Process.is_pending/1.
- json2: added support for nested structures.
- Website
- vweb: added mime types for static .md files.
- net.conv: Added functions varinttou64 and u64tovarint for variable encoding of unsigned integers described in rfc-9000 (for QUIC).
- net.http: support specifying on_running, on_stopped, on_closed callback functions in http.Server{}, as well as show_startup_message: false.
- net.http: HTTP proxy passthrough supportServer in http.fetch.
- net.http: Add a retry mechanism to http.fetch() for unavoidable socket errors.
- wasm: implemented inline assembly.
- net.http: max_redirects value increased to 16.
- picoev: implementation of raw mode for direct work with file descriptors.
- net.http: added support for socks5 and http(s) proxies for unix-like systems.
- ORM:
- orm: added handling of null values and optional fields.
- orm: The is_null/is_not_null operations are made unary.
- Database Drivers:
- pg: C calls have been moved to .cv files.
- Native backend:
- native: support for -no-builtin flag (generating executables < 1 KB) Linux using "v -no-builtin -b native examples/hello_world.v").
- native: use i32 instead of int.
- C-backend:
- ast, native, cgen: added support for "$if native {}".
- vfmt:
- Now removes additional line breaks after call_expr and before structure arguments.
- Fixed value alignment when using keys with uft8 characters.
- Alignment of ternary expressions in const blocks.
- Tools:
- Added @LOCATION support to make debugging easier without having to combine @FILE and @LINE at runtime.
- benchmark: added new methods b.record_measure/1 and b.all_recorded_measures/0.
- ci: github workflow c2v updated.
- strings: added Bulder.write_decimal/1 method (for writing a decimal number, without additional allocations).
- Installation of an existing module using vpm (windows) has been fixed.
- tools.vpm: improved work with addresses ending in ".git".
- Added requirement for a v.mod file to install modules via external links using vpm.
Source: opennet.ru
