Zachary W. Huang

Home Projects Blog Guides Resume

My notes on various programming languages/frameworks

Disclaimer: take everything I say on this page with a grain of salt. Note that “all programming languages suck, especially whichever one is your favorite.”

Also, I try to include language features/pitfalls I personally have some experience with - I’m not just copying the points on each language’s homepage.

Python

Pros

  • very easy to use & fast pace of development
  • large ecosystem (PyPI) and great tooling
    • Pandas, NumPy, MatPlotlib, IPython/Jupyter notebook

Potential Pros

Cons

  • dynamic/duck typing leads to frequent simple runtime errors, which can be very annoying
    • However, there are many static type checkers for Python (ex: Mypy, Pyre)
  • there is no standard for virtual environments - there is venv, virtualenv(wrapper), pipenv, poetry, conda, etc

Potential Cons

  • lambdas are clunky (honestly, I just like arrow notation for anonymous functions more)
  • potentially hard to bundle into an executable, though libraries like Nuitka and Mypyc exist
  • CPython is slow, but Cython, PyPy, Numba, etc are available if performance is important
    • Also, Python is often used as a glue language for C/C++ subroutines (e.g. PyTorch), so the actual performance of CPython isn’t too important
  • The Python global interpreter lock (GIL) can be a bottleneck for multi-threaded programs
  • Python has just enough functional features to pull you in, but not enough to really structure programs around it.
    • One annoying quirk is that certain functions “belong” to object instances while a small handful of useful builtin functions are instead in the global scope. This means I can’t do something like "Hello, world!".split(" ").map(String.upper). Instead, it’s map(lambda x: x.upper(), "Hello, world!".split(" ")), since map is a builtin function. Isn’t the former much easier to read and understand?
    • Also, I dislike magic functions - I feel like typeclasses would make Python more consistent and extensible.

Additional Notes

Julia

Pros

  • the Julia JIT compiler produces very fast/efficient code
  • since the language is dynamic, we get Python-like ease-of-use and speed of development
  • the underlying Julia AST is essentially a Lisp, which allows for code manipulation and powerful macros
  • Multiple dispatch allows for great interoperability between packages and a nice development experience
  • An extensive scientific computing ecosystem (see Research)
  • Easy interop with C, C++, R, Python, etc

Potential Pros

  • Julia is used at and sponsored by a variety of institutions, including universities, research labs, and more
  • The majority of the Julia standard library is written in pure Julia and is easily accessible on Github

Cons

  • slow initial compile times (see TTFP - “Time to First Plot”), which can force you into a REPL/notebook-based development environment (see Revise.jl)
  • hard to produce standalone binaries without packaging the entire Julia runtime (though work is being done on this - see “static compilation”)

Potential Cons

  • Functional language features are a little lacking, though packages like Chain.jl and Lazy.jl offer additional features through macros
  • 1-based indexing 1

Additional Notes

Javascript/Typescript

Pros

  • a huge package ecosystem
    • however, the split between npm and yarn is a little concerning
    • utilitie libraries like Lodash and fp-ts are very nice
  • “modern portability” - JS can run both in the browser (V8, SpiderMonkey) or locally (NodeJS, Deno)
  • TS allows for the benefits of strong typing while not being too restrictive (any as an escape hatch)

Potential Pros

  • arrow functions are very useful

Cons

Potential Cons

  • potentially unexpected type coersion
  • this can be confusing to those coming from “classic OOP” languages like Java or Python
  • JIT compilation means that performance can be nondeterministic - I think WASM aims to fix this
  • there are many different ECMA standards, and the CommonJS/ES6 split can be annoying
  • Various questionable design choices
    • Arrays are Objects but with integer keys (though it is implementation-dependent whether they are actually contiguous in memory or more like a hashmap)
    • also, no true integer type, only Number, which is a double-precision 64-bit IEEE-754 float

Additional Notes

C++

Pros

  • Allows for performant programs while also having effective (and ”zero cost”) abstractions
  • Pretty much everything that matters is written in C++

Potential Pros

Cons

  • C++ code can be very hard to read/understand, partly because of the huge number of language features available
    • just look at the standard library source code
    • Also, since the C preprocessor exists, it means that you essentially have to know two languages, not just one
    • Two and a half years after Scott Meyers retired from C++, he had “forgotten enough details of the language that [he was] no longer able to properly evaluate bug reports regarding the technical aspects of [his] books” - source
      • Yes, the Scott Meyers who has written 8 books on C++ which have been read by hundreds of thousands of people
      • What I’m trying to say is that C++ is a huge, complex language that no mortal can fully understand.
  • Building can be difficult…
    • There is Make, CMake, Autotools, Meson, Waf, etc
    • looking at existing C++ codebases, there are Makefiles and CMakeList.txts with more lines than most programs I have written
    • Also, packaging is fragmented - you have the system’s package manager (ex: apt, pacman), Vcpkg, Conan, NuGet, etc
    • Just in general, I think the #include <header> system is a little dated, especially compared to modern import systems in languages like Rust or Zig
  • can be hard to debug - Segmentation Fault

Potential Cons

  • It is very easy to write programs which have undefined behavior (footguns) and/or memory leaks if you don’t have years of experience with the language

Additional Notes

C

Pros

  • the de-facto standard for embedded systems, low-level programming, and performance-critical programs (along with C++)
  • the core language itself is very simple

Potential Pros

  • the macro system helps with code that could be otherwise very hard to write

Cons

  • same packaging/build issues I have with C++

Potential Cons

  • It is very easy to write programs which have undefined behavior (footguns) and/or memory leaks if you don’t have much experience with the language
  • the macro system has the potential to create unreadably and hard-to-debug code

Additional Notes

  • My opinion: I really like the simplicity of C. When you tell C to add two numbers together, you know that the cpu will run a single “add” instruction (assuming it isn’t optimized out). Sure, debugging can be a pain, and many high-level abstractions are missing, there is something satisfying about programming a computer at the lowest level that is still practical. Meanwhile, the abstractions that C provides are still powerful enough to do many, many things. Hmmm, so it turns out this is not exactly true… see articles such as this and this.

OCaml

Pros

  • Strongly typed with powerful type inference
  • Pattern-matching, algebraic data types, immutable data structures
  • Tail call optimization + currying by default
  • Decently fast by default
  • multi-paradigm: has both functional and imperative features, which work surprisingly well together

Potential Pros

  • Multicore OCaml coming in version 5.0 (projected release is end of 2021)
  • Core - Jane Street’s souped up standard library

Cons

  • the ecosystem/community is very small
  • the tooling is not all that impressive

Potential Cons

Additional Notes

  • some notable projects that use OCaml: FFTW, Haxe, ReasonML (now ReScript)

Footnotes

1. "Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." -Stan Kelly-Bootle
RSS icon github logo linkedin logo

Zachary W. Huang © 2021-2024