Fireship · @fireship
Nim in 100 Seconds
Uploaded November 3, 2022 · Length 2:35
Summary
Nim language basics, performance, and features in 100 seconds.
- nim language
- systems programming
- statically typed language
- meta programming
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
Nim a general purpose systems
- 0:02
programming language that can deliver
- 0:03
high performance native apps with
- 0:05
concise elegant code it was created by
- 0:08
Andreas rump in Germany in 2005 who
- 0:10
wanted a language with the performance
- 0:12
of C the productivity of Python and the
- 0:14
extensibility of lisp like other systems
- 0:16
languages Nim is statically typed and
- 0:19
compiled however it's Unique because its
- 0:21
source code is first translated to a
- 0:23
different language usually C then uses a
- 0:25
compiler like clang to convert it to
- 0:27
machine code and it can also transpile
- 0:29
to C plus plus Objective C and even
- 0:31
JavaScript by default it uses a
- 0:34
deterministic memory management strategy
- 0:36
based on reference counting but this
- 0:38
Behavior can be customized or removed
- 0:40
altogether allowing low-level control
- 0:42
over memory with pointers syntactically
- 0:44
it feels like a statically typed python
- 0:46
but it also provides extensive support
- 0:48
for meta programming with a macro system
- 0:51
that allows direct access to the
- 0:53
abstract syntax tree allowing you to
- 0:55
mold the language to your exact needs
- 0:56
much like the list family of languages
- 0:58
to get started install an on your
- 1:00
machine then create a new file ending in
- 1:02
dot Nim unlike C no main function is
- 1:04
necessary use Echo to print to the
- 1:06
standard output or create a variable
- 1:08
with the VAR keyword and follow it with
- 1:10
an optional type annotation variables
- 1:12
can be reassigned but we can make them
- 1:14
single assignment with let or use cons
- 1:16
to make the assigned value immutable
- 1:18
when writing a complex statement like an
- 1:21
if condition indentation matters like
- 1:23
python this keeps the code nice and
- 1:24
readable like when declaring multiple
- 1:26
variables for Loops it has a variety of
- 1:29
built-in iterators like count up and
- 1:31
countdown or you can use the iterator
- 1:33
keyword along with yield to build your
- 1:35
own from scratch to Define functions or
- 1:37
methods we use procedures which can take
- 1:39
input arguments and return a value it
- 1:42
also supports closures and using
- 1:43
procedures as arguments or return values
- 1:46
for functional programming patterns
- 1:48
however it's also possible to use object
- 1:50
oriented patterns by first creating a
- 1:52
complex type which can then be
- 1:54
instantiated like a class and it also
- 1:56
supports generics allowing you to use
- 1:58
types as parameters what makes Nim


