Introduction (Table of contents)
-
Code Snippets (Useful code snippets for rust and python)
-
Good Rust Libraries (My Favorite/Most used rust libraries)
-
Learning Plan (Important concepts to learn in python)
-
Things Learned (Lessons learned from projects)
-
Rust Tooling (Useful cargo tooling)
Code Snippets
Rust:
[profile.release]
lto = true
strip = true
opt-level = 3
panic = "abort"
codegen-units = 1
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), Box<dyn Error>> {}
use clap::{Parser, value_parser};
#[derive(Parser, Debug, Clone)]
pub enum CliArguments {}
#![warn(
clippy::all,
clippy::restriction,
clippy::pedantic,
clippy::nursery,
clippy::cargo
)]
#![allow(
clippy::missing_docs_in_private_items,
clippy::question_mark_used,
clippy::std_instead_of_core,
clippy::cargo_common_metadata,
clippy::blanket_clippy_restriction_lints,
clippy::print_stdout,
clippy::implicit_return,
clippy::unwrap_used,
clippy::arbitrary_source_item_ordering,
clippy::single_call_fn,
clippy::allow_attributes_without_reason,
clippy::missing_const_for_fn,
clippy::shadow_reuse,
)]
max_width = 56
use_field_init_shorthand = true
use_small_heuristics = "Max"
Python
from polars import Config
Config.set_engine_affinity(engine="streaming")
Config.set_tbl_cols(-1)
Config.set_tbl_rows(-1)
Config.set_tbl_width_chars(-1)
Config.set_tbl_formatting("UTF8_FULL", rounded_corners=True)
Config.set_tbl_cell_alignment("CENTER")
Config.set_tbl_column_data_type_inline(True)
from fastapi import FastAPI
DESCRIPTION = """
# A API
"""
app = FastAPI(
swagger_ui_parameters = {"tryItOutEnabled": True},
title = "API",
debug = True,
version = "0",
description = DESCRIPTION.strip(),
)
@app.get("/")
def home() -> dict[str, str]:
return {
"title" : "A API",
"description" : DESCRIPTION,
"description_type" : "markdown"
}
A list of useful, fundamental, popular and ergonomic rust libraries
Essential Features
Macros
-
Derive Builder (Derive macros to implement the builder pattern)
-
Strum (Enum and String macros)
-
Validator (Struct field validation)
-
Variantly (Derive useful
Option
-like methods for enums) -
Derive More (More derive macros)
-
Fake (Alternative to Fakeit with derive macros)
Popular
-
Clap (Comprehensive CLI argument parsing)
-
Reqwest (Async/Sync HTTP client)
-
SQLx (Simple async database library)
-
Serde JSON (JSON support for serde)
-
Serde (Derive macros for struct serialization)
-
Tokio (Popular async runtime for rust)
-
Tracing Subscriber (Logging Utilities integrating with Tracing)
-
Tracing (Comprehensive Logging)
Utilities
-
Better Panic (Makes panics more readable)
-
Fakeit (Fake data generation for testing)
-
Itertools (Iterator utilities)
-
Pretty Assertions (Make assertion look better)
Text snippets
-
Describe or solve an algorithm in a formal manner. That is, write a proof, justify why it works, or its time complexity. This is rarely, needed, but having the ability to be able to read, understand, and sometimes derive these is important
-
There is a lot of cool techniques in papers, or tiny blogs, or GDC slides describing the applications from industry / academia
-
Multiple languages (including ones you would not think relevant). (C, Lisp, Prolog, Python, assembler, C++, and Smalltalk)
-
Multiple AI concepts
-
Deep explanation of the electrical part of computer (how the processor, the ram, the buses works with diagrams)
-
How to write a compiler (C) and an interpreter (Lisp)
-
Parallelism (not only multithreading but work on multiple machines in a network)
-
Networking concepts thoroughly
-
All the rather boring parts you would not spend too much time on your own but are actually useful (Data Structures, Big O notation)
-
Algorithms: Backtracking, width vs depth search and A*-style stuff, ordering algorithms, etc
-
Algorithm complexity (O(1), O(n), and the like), to understand why your stuff goes SO slowly
-
Design Patterns: They’re a must in OOP
-
Graph Theory may be handy in very specific situations. Also a decent knowledge in maths doesn’t hurt
-
Cryptography: The most obvious. Also it doesn’t hurt to know what a hashing function is, specially because you may use hash tables
-
Machine code and how everything works underneath the surface, the stack, local variables, dynamic memory allocation, etc
-
Graduate level statistics, machine learning algorithms, deep learning and a lot more. Theory heavy stuff
Key Points
-
Embedded Systems
-
Networking
-
Big Data
-
Debugging
-
Mobile Application Development
-
Game Development
-
Web Development
-
Reading Research Papers
-
Good Math (linear algebra, vectors, calculus, graph theory)
-
Cryptography
-
Low Level Mechanics (stack, local variables, dynamic memory allocation)
-
Design Patterns/Design AntiPatterns
-
Data Engineering
-
Scientific computing
-
Low level networking
Roadmap Website
A list of things learned from doing
Use ORMs not raw SQL:
-
SQL is hard to maintaining and makes messy code when constructing dynamic queries
-
The key is to use a ORM
-
query builders are acceptable but often a ORM is better
-
This only applies to python, in rust SQLx is better
Avoid many files and folders in python:
-
Python imports are messy and hard to deal with
-
so just minimize files
-
Folders are even worse and are the main problem with python imports
-
This does not apply to rust
APIs are not easy to make in rust:
-
In rust api are challenging to make
-
Databases are difficult but somewhat easier
-
Instead of APIs make CLIs
Useful Cargo subcommands
Basic Checking:
-
cargo check (Code Compiles)
-
cargo test (Tests Pass)
-
cargo clippy (Code Style is Good/Idiomatic)
-
cargo fmt (Code is well Formatted)
-
cargo audit (Code dependencies don’t have security vulnerabilities )
-
cargo update (Code dependencies are up to date)
-
cargo udeps (Code uses dependencies)