August 13, 2020

Typed APIs in Python with dataclasses and NamedTuples

Why would Python programmers ever care about types? While Python doesn’t check any types statically (before running the program), it does perform extensive run-time type checking. Checking types at run-time without any implicit casts makes the language strongly-typed and dynamically-typed, as opposed to a language like C which is weakly-typed and statically-typed. This is an important distinction, but I won’t go over the differences between strong and weak typing in this post. Read more

March 11, 2020

Three Completely Different Approaches to the FizzBuzz Problem

Here’s a solution to the classic infamous FizzBuzz problem in Python: for i in range(1, 31): if i % 15 == 0: print("FizzBuzz") elif i % 3 == 0: print("Fizz") elif i % 5 == 0: print("Buzz") else: print(i) 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz This program is really simple and is probably the most common approach. Read more

March 9, 2020

Remote Linux Process Hacking through SSH

There’s this really cool process hacking series on YouTube by Keist Zenon. He uses the programming language Common Lisp to interact with processes on his Linux machine. I tried following the tutorial on my Mac, but macOS does not have the same ptrace commands and system call interfaces as Linux so this did not work out. However, I have VirtualBox set up on my Mac with a Debian VM which I use whenever I need Linux. Read more

March 8, 2020

Interactive OCaml Development

Interactive development features are mostly found in dynamically-typed interpreted programming languages like Python or JavaScript. While OCaml is a statically-typed compiled language, it is still possible to program in an interactive style using a REPL. However, OCaml will never be quite as flexible and interactive as something like Lisp because of its greatest feature: the strong static type system. Testing functions using the REPL One of the nicest features of OCaml is that is has both a byte-code compiler (ocamlc) and a native-code compiler (ocamlopt). Read more

© Samarth Kishor 2020

Powered by Hugo & Kiss.