Skip to content

Instantly share code, notes, and snippets.

View CJSmith-0141's full-sized avatar

CJ Smith CJSmith-0141

View GitHub Profile
// Import the WebAssembly memory at the top of the file.
import { memory } from "wasm-game-of-life/wasm_game_of_life_bg";
// . . .

Rust

Rust has been touted as the most loved programming language many years in a row according to respondents in the Stack Overflow Annual Developer Survey , and if you write a blog post without mentioning this you are potentially commiting a crime. But . . . why? What productive things are being done with Rust, right now? Where, exactly, does rust shine? Having tinkered with the language on-again and off-again, I think it clearly shines where its killer application of garbage-collection-less memory safety can shine. That brings us to . . .

WebAssembly (wasm)

WebAssembly. wasm. You've probably heard murmerings of it, things like "it's faster!" or "adoption is coming!". Wasm evangelists haven't won me over, but I am curious about it. Since rust can compile with wasm as a target, rust and wasm feel tied together in my brain. How unfortunate for them both.

Svelte

Svelte is a JavaScript framework without a virtual DOM. But it's actually not that at all, it's

// This is how I passed the state of the game to JS
#[wasm_bindgen]
impl Universe {
// . . .
pub fn cells_copy(&self) -> Uint8Array {
let data : Vec<u8> = self.cells.clone().into_iter().map(|x| x as u8).collect();
let ret = Uint8Array::new_with_length(data.len().try_into().unwrap());
ret.copy_from(data.as_slice());
ret
}
// Import the WebAssembly memory at the top of the file.
import { memory } from "wasm-game-of-life/wasm_game_of_life_bg";
// . . .

Rust

Rust has been touted as the most loved programming language many years in a row according to respondents in the Stack Overflow Annual Developer Survey , and if you write a blog post without mentioning this you are potentially commiting a crime. But . . . why? What productive things are being done with Rust, right now? Where, exactly, does rust shine? Having tinkered with the language on-again and off-again, I think it clearly shines where its killer application of garbage-collection-less memory safety can shine. That brings us to . . .

WebAssembly (wasm)

WebAssembly. wasm. You've probably heard murmerings of it, things like "it's faster!" or "adoption is coming!". Wasm evangelists haven't won me over, but I am curious about it. Since rust can compile with wasm as a target, rust and wasm feel tied together in my brain. How unfortunate for them both.

Svelte

Svelte is a JavaScript framework without a virtual DOM. But it's actually not that at all, it's

package com.example.routes
import cats.Applicative
import cats.effect.Concurrent
import cats.syntax.all.*
import org.http4s.*
import org.http4s.circe.{jsonEncoderOf, jsonOf}
import org.http4s.dsl.Http4sDsl
import org.typelevel.ci.CIString
import io.circe.generic.semiauto.*
@CJSmith-0141
CJSmith-0141 / Day1.scala
Last active December 1, 2023 18:42
AoC 2023 Day 1
package net.tazato
import cats.effect.*
object Day1 extends IOApp.Simple {
private def eat(s: String): String = {
s.replaceAll("one", "o1e")
.replaceAll("two", "t2o")
.replaceAll("three", "t3e")
.replaceAll("four", "f4r")
.replaceAll("five", "f5e")
@CJSmith-0141
CJSmith-0141 / Day2.scala
Last active December 2, 2023 15:55
AoC 2023 Day 2
package net.tazato
import cats.*
import cats.data.NonEmptyList
import cats.effect.*
import cats.syntax.all.*
import cats.parse.*
import cats.derived.*
import cats.parse.Rfc5234.{alpha, digit, wsp}
import scala.io.BufferedSource
@CJSmith-0141
CJSmith-0141 / Day3.scala
Created December 4, 2023 01:29
AoC 2023 Day 3
package net.tazato
import cats.*
import cats.effect.*
import cats.syntax.all.*
object Day3 extends IOApp.Simple {
case class PartNumberCoordinate(xMin: Int, xMax: Int, y: Int)
case class PartNumber(partNumber: Int, coordinate: PartNumberCoordinate)
@CJSmith-0141
CJSmith-0141 / Day4.scala
Created December 4, 2023 16:25
AoC 2023 Day 4
package net.tazato
import cats.*
import cats.effect.*
import cats.syntax.all.*
import cats.parse.Parser as P
import cats.parse.Rfc5234.{digit, wsp}
import scala.collection.mutable