Comments (8)
Read https://ziglang.org/documentation/master/.
from postmortem.
https://news.ycombinator.com/item?id=17184729
Zig is memory-safe if you keep runtime checks enabled (e.g. with debug or release-safe optimization levels) but it does not have the compile-time guarantees of Rust.
Is it also true today?
from postmortem.
const std = @import("std");
pub fn main() !void {
var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
const ptr = &array[20];
ptr.* += 1;
}
$ zig build-exe test.zig
./test.zig:5:23: error: index 20 outside array of size 10
const ptr = &array[20];
^
from postmortem.
const std = @import("std");
pub fn main() !void {
var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
const slice = array[2..20];
slice[1] += 1;
}
$ zig build-exe test.zig
$ ./test
index out of bounds
/home/kiwamu/tmp/zig/test.zig:5:24: 0x22a934 in main (test)
const slice = array[2..20];
^
It causes a run-time error.
from postmortem.
https://ziglang.org/documentation/master/#Integer-Overflow
If we capture compile time error, we need comptime
keyword.
from postmortem.
https://ziglang.org/documentation/master/#Division-by-Zero
Or use const
variable to causes compile error.
from postmortem.
https://ziglang.org/documentation/master/#Lifetime-and-Ownership
Above means the Zig doesn't have lifetime such as Rust's.
from postmortem.
Umm... Finally we think that the Zig language is not suitable for this postmortem.
from postmortem.
Related Issues (20)
- Avoid FreeBSD-SA-20:05.if_oce_ioctl HOT 2
- Avoid FreeBSD-SA-20:06.if_ixl_ioctl HOT 2
- Avoid FreeBSD-SA-20:14.sctp HOT 3
- Avoid FreeBSD-SA-19:22.mbuf
- Avoid FreeBSD-SA-20:13.libalias
- Avoid FreeBSD-SA-20:02.ipsec
- Write postmortem for 50 of FreeBSD Kernel Security Advisory HOT 5
- Avoid FreeBSD-SA-20:24.ipv6 HOT 1
- Avoid FreeBSD-SA-19:14.freebsd32 HOT 1
- Avoid FreeBSD-SA-19:02.fd HOT 2
- Avoid FreeBSD-SA-18:04.vt
- Avoid FreeBSD-SA-17:10.kldstat HOT 1
- Define array of char in typedef HOT 3
- Write SPARK code to avoid some of bugs HOT 2
- Write KreMLin code to avoid some of bugs HOT 13
- Write Idris code to avoid some of bugs HOT 1
- Write Checked C code to avoid some of bugs HOT 14
- Write Frama-C code to avoid some of bugs HOT 1
- Write postmortem for FreeBSD PR with ATS2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postmortem.