Reflection

What is Reflection? Reflection enables a program to observe and modify its own structure and behavior. t bridges the gap between the base level (the application logic) and the meta level (objects representing the program itself). Core Concepts Introspection: The program can observe its own type information at run time. Intercession (Dynamic Manipulation): The program can modify its own structure and behavior (e.g., adding methods, changing fields). Reflective Code Generation: Creating executable code from data structures at run time. 8.1 Introspection Introspection is the ability to examine the runtime type of an object. The entry point for this in Java is the Class object. ...

December 6, 2025 · Reading Time: 4 minutes ·  By Xuanqiang Angelo Huang

Initialization in Programming Languages

\[...\] This has led to innumerable errors, vulnerabilities, and system crashes.” ~ Tony Hoare 1 The core problem addressed here is Null Safety and how to properly initialize objects to ensure type invariants (specifically non-nullness) hold true. Simple Non-Null Types The goal is to prevent null-dereferencing errors statically. Most of the variables are null, after initialization. Non-Null Types vs. Possibly-Null Types Non-null type T!: Consists of references to T-objects. It cannot hold null. Possibly-null type T?: Consists of references to T-objects plus null. This corresponds to the standard type T in languages like Java, and the most common case among most languages. Type Safety and Invariant Invariant: If the static type of an expression e is a non-null type, then e’s value at runtime must be different from null. Enforcement: We require non-null types for the receiver of each field access, array access, method call, and throw statement. Equivalent to message not understood cited in Typing and Subtyping. Subtyping and Casts The values of T! are a proper subset of T?. ...

December 2, 2025 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang

Bytecode Verification

Code in modern days is mobile in the sense that it gets downloaded and executed on the fly very often. In JVM they are usually shipped with: Platform independent code Organized into class files. Class Loaders The class loader is the part of the JVM that takes the bytecode and interprets all the class files to make the program runnable. Security Considerations Requirements for Security Mobile code cannot be trusted Code may not be type safe Code may destroy or modify data Code may expose personal information Code may crash the underlying VM Code may purposefully degrade performance (denial ofservice) This is somewhat similar to the trust relations we explored in Notions of Security. Anyways, since the code is not trusted, we need a way to prove some of its properties. ...

November 15, 2025 · Reading Time: 7 minutes ·  By Xuanqiang Angelo Huang

Typing and Subtyping

We first start with some design goals for the language Language Design Principles Simplicity Syntax and semantics can easily be understood by users and implementers of the language Expressiveness: Language can (easily) express complex processes and structures, conflicting with simplicity. Safety: Language discourages errors and allows errors to be discovered and reported, ideally at compile time Modularity: Language allows modules to be type-checked and compiled separately Performance: Programs written in the language can be executed efficiently Productivity: Language leads to low costs of writing programs like Python. Backwards Compatibility: Newer language versions work and interface with programs in older versions (dependency injection for examples helps for this.) ...

November 11, 2025 · Reading Time: 12 minutes ·  By Xuanqiang Angelo Huang

Object Orientation

Il Tipo di Dato Astratto Introduzione Per questi tipi di dato non ci interessa di sapere cosa ci sia sotto (storato come bit? storato come sabbia boh), ci interessa solamente che abbia quei metodi, che possiamo in un certo senso identificare come la sua capsula, opaca in questo caso. Quando si può andare a modificare solamente attraverso questo metodo potrei dire che sia safe collegato alla Algebra dei tipi, nel senso che vengono soddisfatte sempre le proprietà del tipo. ...

August 28, 2024 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang

Polimorfismo

Introduzione Tipi Monomorfici Quando non posso utilizzare un tipo come parametro. Ossia non possiamo definire una funzione generica. Polimorfismo Polimorfismo, come dice il nome, significa avere tante forme, in questo caso tanti tipi. Ma avere tanti tipi non è una cosa ambigua? Questa cosa si risolve solitamente a compile time (facendo checks di sottotipo, oppure dispatch della funzione corretta). A program part is polymorphic if it can be used for objects of several classes ...

August 28, 2024 · Reading Time: 13 minutes ·  By Xuanqiang Angelo Huang

Variational Inference

$$ p(\theta \mid x_{1:n}, y_{1:n}) = \frac{1}{z} p(y_{1:n} \mid \theta, x_{1:n}) p(\theta \mid x_{1:n}) \approx q(\theta \mid \lambda) $$For Bayesian Linear Regression we had high dimensional Gaussians which made the inference closed form, in general this is not true, so we need some kinds of approximation. Laplace approximation Introduction to the Idea $$ \psi(\theta) \approx \hat{\psi}(\theta) = \psi(\hat{\theta}) + (\theta-\hat{\theta} ) ^{T} \nabla \psi(\hat{\theta}) + \frac{1}{2} (\theta-\hat{\theta} ) ^{T} H_{\psi}(\hat{\theta})(\theta-\hat{\theta} ) = \psi(\hat{\theta}) + \frac{1}{2} (\theta-\hat{\theta} ) ^{T} H_{\psi}(\hat{\theta})(\theta-\hat{\theta} ) $$ We simplified the term on the first order because we are considering the mode, so the gradient should be zero for the stationary point. ...

January 15, 2025 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang

OTP and Stream Ciphers

XOR operation È una operazione binaria abbastanza semplice però ci sarà importante per andare ad analizzare dei cifrari di un certo genere. Come il ONE TIME PAD che faremo fra poco in OTP and Stream Ciphers. Teorema cifratura con XOR Prendiamo $X$ una variabile aleatoria in $\left\{ 0,1 \right\}^{n}$ uniforme, sia $Y$ una variabile aleatoria su uno stesso dominio come vogliamo. Tali per cui $X, Y$ siano indipendenti Allora avremo che $C = X \oplus Y$ è una variabile aleatoria uniforme. ...

June 2, 2024 · Reading Time: 15 minutes ·  By Xuanqiang Angelo Huang

Sulla Stocasticità

Introduzione alla Randomicità Questo è principalmente basato su (Li & Vit{'a}nyi 2019) Capito 1.9 Sembra che la nozione di random sia alla fine una cosa molto profonda. Per esempio, un caso lampante che le definizioni non funzionano nel caso di numeri trascendenti è che catalogano i numeri di $\pi$ come se fossero casuali, mentre in realtà possono essere trovati mediante procedimenti precisi. È una distinzione filosoficamente molto interessante. Alla fine sembra ci sia un link molto diretto con la crittografia, si può vedere (Stinson 2005). ...

February 29, 2024 · Reading Time: 4 minutes ·  By Xuanqiang Angelo Huang

Inheritance

Introduction to Inheritance Difference between Inheritance and Subtyping We say that a subclass is inheritance and subtyping. We have studied subtyping in Typing and Subtyping and it entails mainly two things: Liskov Substitution Polymorphism of the types While inheritance is just the code reuse and specialization. Another example of code reuse can be the “has-a” relation composition, which couples two objects together. With aggregations, we can also see delegation calls, when you have a class, and call a method of that class. ...

October 9, 2025 · Reading Time: 12 minutes ·  By Xuanqiang Angelo Huang