Polyglot Developer
Environments

Warsaw, 2023
Developer environment
- editor
- debugging tools
- version control system tools
- native libraries
- additional binaries
- remote resources
What this talk is about?
Unix philosophy
synergy between tools
tools
The regular approach
Pros:
- (tightly) integrated environment
- works out of the box
- great support for major languages & frameworks
- debugging tools
Cons:
- limited extendability
- does not play well with things that it wasn't integrated with
- lack of support for less popular languages
Reasons to use various languages
- right tool for the job
- personal preference
- willingness to learn & experiment
- legacy/existing project written in XY
Setting up the environment
- (if lucky) follow instructions in README.md
- run a provided shell script and pray for it not to fail with some obscure error
- how to make the editor aware of the environment?
- how to propagate updates across developer environments
- use docker?
$ cd workspace/projectA
$ code .Reasons to fail
- outdated/unclear instructions
- script does not support our system
- we have such an environment for X but it uses a different version of Y
- having to master rbenv, sdkman, nvm, ...
- inherent flaws
Meet Nix
- declarative package manager
- reproducible build tool
- functional language

Recipe
Binary
Linking
Example

{
inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
(sbt.override {
jre = temurin-jre-bin-17;
})
nodejs
yarn
];
};
}
);
}
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
(sbt.override {
jre = temurin-jre-bin-17;
})
nodejs
yarn
];
};How it works?

~ $ cd projectA
~ $ cd projectA
~/projectA $ which sbt
sbt not found
~ $ cd projectA
~/projectA $ which sbt
sbt not found
~/projectA $ which nodejs
nodejs not found
~ $ cd projectA
~/projectA $ which sbt
sbt not found
~/projectA $ which nodejs
nodejs not found
~/projectA $ nix develop
[15.1/0.0 MiB DL] downloading 'https://github.com/NixOS/nixpkgs/...'
~ $ cd projectA
~/projectA $ which sbt
sbt not found
~/projectA $ which nodejs
nodejs not found
~/projectA $ nix develop
[15.1/0.0 MiB DL] downloading 'https://github.com/NixOS/nixpkgs/...'
~/projectA $ which node 21:17:14
/nix/store/4bgg8j8275adawqbc5rkm4fv48dgg2i3-nodejs-18.18.2/bin/node
~/projectA $ which sbt 21:17:11
/nix/store/k9xwny18ihx78qh8pyxrnz7mrbqj962p-sbt-1.9.7/bin/sbt
~ $ cd projectA
~/projectA $ which sbt
sbt not found
~/projectA $ which nodejs
nodejs not found
~/projectA $ nix develop
[15.1/0.0 MiB DL] downloading 'https://github.com/NixOS/nixpkgs/...'
~/projectA $ which node 21:17:14
/nix/store/4bgg8j8275adawqbc5rkm4fv48dgg2i3-nodejs-18.18.2/bin/node
~/projectA $ which sbt 21:17:11
/nix/store/k9xwny18ihx78qh8pyxrnz7mrbqj962p-sbt-1.9.7/bin/sbt
~/projectA $ exit
~/projectA $ which sbt
sbt not found
How it works?

Nix store
/nix/store/zzpm91md3wqllaqpzm7whvcpa
/nix/store/zzpss56rnqxmhsg01v72762ha
/nix/store/zzqbcqjn05771v42fy9q97chk
/nix/store/zzqk32qc4imypcifq9jz1wif5
/nix/store/zzqnsgnpsfnrhwg8s4g9ci0dn
/nix/store/zzrajbcphf2f6spria8c7szwr
/nix/store/zzrgf0qw8vd3rd3fznzif1fh5
/nix/store/zzsgwdfagsw6xq6fvs7yycpvq
/nix/store/zzsm2ynsib3ddkjxw7g0j8v47
$ cd ~/workspace/projectA
# will use jdk11 and python2.7$ cd ~/workspace/projectB
# will use jdk19 and node16$ cd ~/workspace/projectC
# will use python3 and node17PATH:=
Use direnv to automatically enable nix shell when entering project directory


?
Nix
Direnv
Meet Neovim
- runs inside terminal
- build on top of years of experience from building vim
- easy to extend via lua scripts
- follows unix philosophy of modularity and simplicity
- builtin support for language server protocol

Language Server Protocol

LSP



Editors
Language servers
- completions
- diagnostics
- navigation
- code lenses
- code actions
- refactorings
- and many more...
is this enough to develop software?
Language Server Protocol
Treesitter

- General enough to parse any programming language
- Fast enough to parse on every keystroke in a text editor
- Robust enough to provide useful results even in the presence of syntax errors
- Dependency-free so that the runtime library (which is written in pure C) can be embedded in any application
Treesitter

language grammar
treesitter
parser.c
source code
AST + highlights

LSP
Nix
?





Direnv
What else?
?
- debugging
- quick feedback loop
- ai assistance
- git ops
- quality of life features
Debug Adapter Protocol

https://github.com/Tencent/LuaHelper/blob/master/docs/manual/debugPrinciple.md

LSP
Nix





DAP

?
Tmux

terminal multiplexer
- splits, windows, sessions
- plugins
- lightweight, stable and fast

Nix






Tmux

LSP
DAP
neogit

diffview

neotree


Nix






Tmux

LSP
DAP
neogit

diffview

neotree


Demo time



feedback: https://yavaconf.com/user.html#!/lecture/YAVA23-b121/rate
slides: https://slides.com/kasperkondzielski-1/polyglot-developer
config: https://github.com/ghostbuster91/dot-files
Thank you
@kkondzielski
Polyglot Developer
By Kasper Kondzielski
Polyglot Developer
- 126