issue | c | zig (release-safe) | rust (release) | Nim (release) | Nim (danger) | D (@safe) | Swift | modern C++ |
---|---|---|---|---|---|---|---|---|
out-of-bounds heap read/write | none | runtime | runtime | runtime | none | runtime | runtime | none³ |
null pointer dereference | none | runtime | runtime | runtime | none | runtime¹ | runtime | none⁴ |
type confusion | none | runtime, partial | runtime | compile time | compile time | compile time | compile time | partial⁵ |
integer overflow | none | runtime | runtime | runtime | none | wraps | runtime (checked) | undefined behavior |
use after free | none | none |
- How to Design Programs: https://htdp.org/
- Structure and Interpretation of Computer Programs: https://sarabander.github.io/sicp/
- Programming Language Foundations in Agda: https://plfa.github.io/
- Think Julia - How to Think Like a Computer Scientist: https://benlauwens.github.io/ThinkJulia.jl/latest/book.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Tested on Zig v0.10 (stage 1) | |
const std = @import("std"); | |
test "forwarding a value" { | |
const result = forth("value", .{ | |
.value = @as(u32, 42), | |
}); | |
std.testing.expectEqual(@as(u32, 42), result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Copyright © 2020-2022 Robin Voetter | |
/// | |
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
/// files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
/// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the | |
/// Software is furnished to do so, subject to the following conditions: | |
/// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
/// Software. | |
/// | |
/// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
Logging functionality that supports:
- If a log message should be printed is determined at comptime, meaning zero overhead for unprinted messages (so just leave the code peppered with debug logs, but when it makes sense scope them; so downstream users can filter them out)
- Scoped log messages
- Different log levels per scope
- Overrideable log output (write to file, database, etc.)
- All the standard
std.fmt
formatting magic
Este texto é inspirado em A Half Hour to Learn Rust.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
cd /tmp | |
echo "=================================================" | |
echo "Downloading new Zig version:" | |
curl -s https://ziglang.org/download/index.json \ | |
| jq ".master.\"$(uname -m)-$(uname | awk '{ print tolower($0) }')\"" \ | |
| jq -r .tarball \ | |
| wget -q --show-progress -i - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace std; | |
#include <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <numeric> | |
#include <sstream> | |
#include <fstream> | |
#include <cassert> | |
#include <climits> | |
#include <cstdlib> |
NewerOlder