Skip to content

Instantly share code, notes, and snippets.

View Verdagon's full-sized avatar

Evan Ovadia Verdagon

View GitHub Profile
struct Account {
name: String,
money: i64,
labelView: i32
}
struct Button {
onclick: Box<dyn FnMut()>
}
let accounts = [];
accounts.push({ name: "Bob", money: 100, labelView: null });
accounts.push({ name: "Cindy", money: 100, labelView: null });
accounts.push({ name: "Reginald", money: 100, labelView: null });
accounts.push({ name: "Jim Argalax", money: 100, labelView: null });
accounts.push({ name: "Valerian Vast", money: 100, labelView: null });
accounts.push({ name: "Archonicus Auriarch", money: 100, labelView: null });
accounts.forEach(account => {
let row = document.body.appendChild(document.createElement("div"));
// Make some accounts.
let accounts = [];
accounts.push({ name: "Bob", money: 100, labelView: null });
accounts.push({ name: "Cindy", money: 100, labelView: null });
accounts.push({ name: "Reginald", money: 100, labelView: null });
accounts.push({ name: "Jim Argalax", money: 100, labelView: null });
accounts.push({ name: "Valerian Vast", money: 100, labelView: null });
accounts.push({ name: "Archonicus Auriarch", money: 100, labelView: null });
// Add each account to the document. It will look like:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <setjmp.h>
_Thread_local void* current_coroutine_args = NULL;
size_t rotate_left(size_t x, int bits) {
return (x << bits) | (x >> ((sizeof(size_t) * 8) - bits));
}

Prototyping and Iterating

The borrow checker can be [slower](https://news.ycombinator.com/item?id=31063493 .anecdote) to prototype [with](https://news.ycombinator.com/item?id=26419670 .anecdote) when we just want to [solve](https://news.ycombinator.com/item?id=28804477 .anecdote) [the problem](https://news.ycombinator.com/item?id=23744577 .anecdote) rather than being [distracted by the language](https://blogs.dust3d.org/2019/03/13/why-i-rewrote-the-mesh-generator-of-dust3d-from-rust-to-cplusplus/ .anecdote), even for [more](https://lobste.rs/s/veinkw/comparison_rust_zig#c_nmf8jz .anecdote) [experienced](https://news.ycombinator.com/item?id=31568497 .anecdote) [rustaceans](https://www.reddit.com/r/rust/comments/iwij5i/blog_post_why_not_rust/g627nwx/ .anecdote).

[One user says,](https://www.reddit.com/r/rust/comments/iwij5i/comment/g62ytxa/?utm_source=share&amp;utm_medium=web2x&amp;context=3 .anecdote) "Rust’s complexity regularly slows things down when you’re work

valerian@ubuntu:~/core/build$ cmake -DOPTION_BUILD_LOADERS_C=ON -DOPTION_BUILD_LOADERS_RS=ON ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
valerian@ubuntu:~/core$ tools/metacall-environment.sh
++ pwd
+ ROOT_DIR=/home/valerian/core
+ APT_CACHE=0
+ APT_CACHE_CMD=
+ INSTALL_APT=1
+ INSTALL_PYTHON=0
+ INSTALL_RUBY=0
+ INSTALL_RUST=0
+ INSTALL_RAPIDJSON=0
valerian@ubuntu:~/core/build$ sudo make install
[sudo] password for valerian:
[ 1%] Built target version
[ 1%] Built target preprocessor
[ 2%] Built target environment
[ 2%] Built target format
[ 3%] Built target threading
[ 10%] Built target log
[ 12%] Built target memory
[ 13%] Built target portability
func MakeBoard(rand_seed int) [][]bool {
rows = [][]bool(20);
foreach row_i in 0..20 {
row = []bool(20);
foreach col_i in 0..20 {
random_bool = true;
// Implicit & causes a gen check in push. Inlining will fix.
row.push(random_bool);
}