Why Use a Dynamic Language over a Statically Typed One?

Correctness and Catching Bugs

The Strength of the Type System Matters Even at Runtime

#include <stdio.h>void multiply(int count, int input) {
int result = 0;
int i = 1;
while (count) {
result += input;
i += 1;
}
printf("%d times %d equals %d", input, count, result);
}
int main(int argc, char **argv) {
multiply(9, 8);
}
using Printffunction multiply(count, input)
result = 0
i = 1
while count
result += input
i += 1
end
@printf("%d times %d equals %d", input, count, result);
end
multiply(9, 8)
ERROR: LoadError: TypeError: non-boolean (Int64) used in boolean context
Stacktrace:
[1] multiply(::Int64, ::Int64) at boolean.jl:6
[2] top-level scope at none:0
[3] include at ./boot.jl:326 [inlined]
[4] include_relative(::Module, ::String) at ./loading.jl:1038
[5] include(::Module, ::String) at ./sysimg.jl:29
[6] exec_options(::Base.JLOptions) at ./client.jl:267
[7] _start() at ./client.jl:436
in boolean.jl:13

A strong dynamic type system trumps a weaker static type system

Problems Not Caught by The Type System But Frequently Caught in Dynamic Languages

  • Null pointers you forget to check for
  • Getting static initialization and de-initialization order wrong.
  • Using dangling pointers
  • Using uninitialized objects.
  • Broken copy constructors. Releasing memory used by other objects.

Ability to Handle Errors Gracefully in Dynamic Languages

Roundtrip Times and Productivity

  • Render lots of graphics fast
  • Do collision detection between multiple objects quickly

Tests vs Compile Time Type Checking

Meta Programming and Productivity

When to Use Statically and Dynamically Typed Languages

Personal Reasons for Preferring Dynamic Languages

  • writing code
  • compiling
  • running

--

--

--

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Erik Engheim

Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

More from Medium

Quarantine experience in New Taipei !

Dealing With My Past and Present Insecurities

Sound & Healing Tools…