Linked handout: 3. Your tools and environment

Your tools and environment

Your tools and environment

    Your environment

    (In descending order of restrictiveness)
  • Operating system / machine
  • Editor / IDEs
  • Development tools

    Categories of development tools

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Editor / IDEs

    NeoVim

  • Terminal editor - all platforms
  • Plugin/scripting in Lua
  • Customizable 10/10
  • Vim-motions
  • Steep learning curve

    Sublime Text

  • OpenGL GUI editor - all platforms
  • Plugin/scripting in Python
  • Customizable 7/10
  • Vim-mode possible
  • Semi-steep learning curve

    VsCode

  • Electron editor - all platforms
  • Plugin/scripting in TypeScript
  • Customizable 6/10
  • Vim-mode possible
  • Easy-moderate learning curve

    Spyder

  • Qt GUI editor - all platforms
  • Plugin/scripting in Python
  • Customizable 4/10
  • Vim-mode - maybe?
  • Easy learning curve

Your tools and environment

  • Editor / IDEs

    NeoVim

  • Plugin managers available
  • Many plugins available on git
  • Open source

    Sublime Text

  • Plugin manager: Package Control
  • Many plugins available at Package Control
  • Closed source - Free trial

    VsCode

  • Plugin manager: built-in
  • Many plugins available on Microsoft marketplace
  • Less plugins for Open source version
  • Half-open source - half not (kinda)

    Spyder

  • Plugin manager: python environment
  • A few plugins available
  • Open source

Your tools and environment

  • Editor / IDEs

Honorable mentions (that I have no experience in)

  • Textadept
    Open-source minimalist editor for all platforms
  • Geany
    Open-source lightweight editor for all platforms
  • Kate
    Open-source (KDE) advanced editor for all platforms
  • Emacs
    Open-source advanced editor for all platforms
  • Pycharm
    Closed-source Python IDE

Your tools and environment

  • Editor / IDEs

My recommendations

  • New to programming?
    VsCode / PyCharm / Spyder (Batteries included)
  • Experienced programmer but new to tooling?
    NeoVim / SublimeText / Emacs (Play around with plugins/configs galore)
  • Comfortable and efficient in your current setup?
    You are good to go! (maybe you get new ideas later)

Why I changed setup: inefficiencies i could not fix / friction

Your tools and environment

  • Editor / IDEs

Regardless of choice: master your editor!

If you know touch-typing and want to take it to the next level, maybe try vim-shortcuts in your editor

As long as the editor does not get in your way / slows you down

And YOU keep evolving / improving!

Your tools and environment

    Your environment

    (In descending order of restrictiveness)
  • Operating system / machine
  • Editor / IDEs
  • Development tools

    Categories of development tools

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Let's look at some examples of each tool type

Your tools and environment

  • Language Servers

Language Server Protocol (LSP) is an open protocol for communication between source code editors and language servers that provide "language intelligence tools".

So it is a Language Server that parses your code and sends the result to a Language Client (your editor)

This allows for things like:

Your tools and environment

  • Language Servers

This allows for things like:

Your tools and environment

  • Language Servers

This allows for things like:

Your tools and environment

  • Language Servers

This allows for things like:

  • Jumping to definition
  • Peeking at definition
  • Pulling in documentation of dependencies
  • Detecting syntax errors live
    • You forgot an import -> symbol not defined!
    • Wrong indentation level? It tells you!
    • Missing closing bracket? Red text everywhere
    • ...
  • And more...

Your tools and environment

  • Language Servers

Recommended Language Server setup

Your tools and environment

  • Language Servers

Example setup in handouts

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Linters and code analyzers

Static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. Language servers and Linters usually go hand in hand.

This allows for things like:

Your tools and environment

  • Linters and code analyzers

This allows for things like:

Your tools and environment

  • Linters and code analyzers

Recommended python linter: flake8

setup.cfg

or

.flake8
                    
                        [flake8]
                        ignore = D203,E251,E126,E226,W504,W503,W605
                        max-line-length = 100
                        exclude = src/pyant/__pycache__,src/pyant/__init__.py,src/pyant/**/__init__.py
                    
                

flake8 does not support pyproject.toml yet :(

Your tools and environment

  • Linters and code analyzers

Static code analyzers: Clang or mypy

Python type annotation
                    
                        def fib(n):
                            a, b = 0, 1
                            while a < n:
                                yield a
                                a, b = b, a+b
                    
                
                    
                        def fib(n: int) -> Iterator[int]:
                            a, b = 0, 1
                            while a < n:
                                yield a
                                a, b = b, a+b
                    
                

mypy then checks everything is typed correctly

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Formatters

Automatically format code according to a standard
(usually the same standard that the Linter is using)

This allows for things like:

Your tools and environment

This allows for things like:

Your tools and environment

  • Formatters

Recommended python formatter: black or ruff

Note: Black cannot be configured

Consistent but slightly ugly formatting can be better than no formatting at all

Compare:

Your tools and environment

  • Formatters

Compare:

                        

                        
                    

Your tools and environment

  • Formatters

Compare:

                        

                        
                    

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Highlighters

Highlights your code with color and font styling for faster parsing by humans!

Compare:

Your tools and environment

  • Highlighters
                    
                        def true_to_mean(nu, e, degrees=False):
                            '''Transforms true anomaly to mean anomaly.

                            Parameters
                            ----------
                            nu : numpy.ndarray or float
                                True anomaly.
                            e : numpy.ndarray or float
                                Eccentricity of ellipse (e<1), parabola (e==1) or hyperbola (e>1).
                            degrees : bool
                                If true degrees are used, else all angles are given in radians

                            Returns
                            -------
                            numpy.ndarray or float
                                Mean anomaly.
                            '''
                            if degrees:
                                _nu = np.radians(nu)
                            else:
                                _nu = nu

                            E = true_to_eccentric(_nu, e, degrees=False)
                            M = eccentric_to_mean(E, e, degrees=False)

                            if degrees:
                                M = np.degrees(M)
                            return M
                    
                

Your tools and environment

  • Highlighters
                    
                        def true_to_mean(nu, e, degrees=False):
                            '''Transforms true anomaly to mean anomaly.

                            Parameters
                            ----------
                            nu : numpy.ndarray or float
                                True anomaly.
                            e : numpy.ndarray or float
                                Eccentricity of ellipse (e<1), parabola (e==1) or hyperbola (e>1).
                            degrees : bool
                                If true degrees are used, else all angles are given in radians

                            Returns
                            -------
                            numpy.ndarray or float
                                Mean anomaly.
                            '''
                            if degrees:
                                _nu = np.radians(nu)
                            else:
                                _nu = nu

                            E = true_to_eccentric(_nu, e, degrees=False)
                            M = eccentric_to_mean(E, e, degrees=False)

                            if degrees:
                                M = np.degrees(M)
                            return M
                    
                

Your tools and environment

  • Highlighters

Recommended NeoVim highlighter: treesitter

Most editors have highlighting built-in (picking a color theme is fun!)

    It is not just fun: sometimes its vital!

  • too high/low contrast, small fonts, etc. for 8h/day = headaches, eye strain, ...
  • accessibility = choose plot schemes that your color blind collogues can see

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Snippet generators

These allow for inserting pre-defined code quickly.

Sources for snippets can be: The LSP (code hints), a spell-checker/buffer (for plain text), a snippet library (for common boiler-plate), etc.

This allows for things like:

Your tools and environment

This allows for things like:

Your tools and environment

This allows for things like:

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Debuggers

A Debug Adapter Protocol allows debuggers to talk to the editor or debugger interface.

This allows for things like:

Your tools and environment

This allows for things like:

Your tools and environment

This allows for things like:

Your tools and environment

  • Debuggers

Your tools and environment

  • Language Servers
  • Linters and code analyzers
  • Formatters
  • Highlighters
  • Snippet generators
  • Debuggers
  • Compilers

Your tools and environment

  • Compilers

We can deep dive later into things like JIT / GIL / LLVM / etc.

    Python

  • cython (transpiles Python/Cython to C)
  • numba (LLVM Python/Numba compiler)
  • pypy (CPython replacement)
  • C

  • gcc (The GNU toolchain for C/C++)
  • clang (The LLVM toolchain for C/C++)
  • And of course a bunch others for other languages...

Your tools and environment

Jerod Santo on Changelog & Friends - Episode #81 podcast, 2025-02-18

I think we waste way too much time customizing, tweaking, filling, changing our programming environments [more] than we need to. I think you can get 80% of the way there with 20% of the effort, and then knock it off and get some work done. ... And I used to customize to the hilt.

    I personally think that by customizing you

  • Learn how to be efficient
  • Learn what tools you need / don't need
  • Learn how the systems work
    (LSP, DAP, compiler, editor, etc.)
  • Get to a point where you only think about doing - not how you do it
  • But when you learned enough: stop and just code

Your tools and environment

Example setups and homework

Let's check out the handout above!