Last active
July 26, 2021 02:25
-
-
Save claforte/ea0a236ec932902dd29a28c65d72dbe4 to your computer and use it in GitHub Desktop.
Timeline of Package development in VSCode | Workshop | JuliaCon 2021
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code: on https://github.com/pfitzsebJuliaConWorkshop21 | |
In the outline below, lines that end in (*) include features I wasn't aware of or hadn't tried until now. I think many of them are newer features. | |
Outline: | |
4m35s: What's VSCode? Why use it? | |
9m10s: Setup VSCode | |
10m20s: Setup VSCode in the cloud (JuliaHub) | |
11m20s: VSCode Basics - install Julia extension | |
12m45s: Installing Julia locally | |
14m21s: VSCode Basic: Command Palette (F1/CTRL-SHIFT-P) | |
15m05s: VSCode settings | |
15m50s: VSCode Settings: julia environment path | |
16m50s: Terminal: Create New Integrated Terminal | |
- NOTE: CTRL-~ show/hides the default terminal | |
18m00s: Left toolbar panel | |
18m30s: Useful settings and extensions | |
- GitLens for better git integration | |
- vscode-pdf | |
- Remote - SSH | |
- Vim or `VsCode NeoVim` | |
- Set `julia.execution.resultType` to `inline, errors in REPL` (RECOMMENDED!), `inline` or `both` (*) | |
21m00s: JuliaMono font (*) | |
- Set `editor.fontFamily` to JuliaMono (https://juliamono.netlify.app/). You won't regret it! | |
- Add these 2 lines to settings.json: | |
- "editor.fontFamily": "JuliaMono", | |
- "editor.fontLigatures": true | |
21m43s: Search (CTRL-F) | |
22m10s: Git | |
22m40s: Debugger view (overview) | |
22m50s: Julia left panel: workspace, documentation, Plot navigator | |
24m10s: A glance at the JuliaHub interface | |
WAYS TO EFFICIENTLY EVALUATE CODE (1/2): | |
25m10s: Julia: Start REPL (Alt+J, Alt+O) | |
26m40s: Julia: Execute Code in REPL and Move (Alt+Enter on Windows/Linux, CTRL+Enter on Mac) (*) | |
- Executes the current line, shows result inline, moves cursor to next Julia expression | |
29m20s: Common trip-up: everything in the editor is relative to the current file, so beware of file/pwd mismatches! (*) | |
30m17s: Modules (*) | |
34m00s: Error stack trace | |
- Ctrl-Click on a line, to navigate to that file | |
- Hover on a red line to display stack trace, arrows to go up/down in stack (*) | |
37m40s: redefinition of struct within a module: re-evaluate the whole module (*) | |
39m30s: blue underline (errors) (*) | |
40m30s: Example: Editing JuliaCon.jl package (*) | |
43m24s: Navigate to function definition: hover on, or CTRL-click on function name | |
44m40s: Override now() method in JuliaCon module, override module selector (from main to JuliaCon) (*) | |
47m48s: Revise - allows live editing, a bit more powerful | |
Q&A: | |
50m53s: Is there a way to extend the REPL history? A: Settings→Terminal>Integrated:Scrollback (default 1000) | |
51m40s: Is there a convenient keybinding to switch from editor to terminal and back? A: My own answer (not Sebastian's): you can use CTRL-~ for that (although it hides the REPL when not in focus). ;-) | |
53m00s: Is there a setting to add a newline when executing the last line of the file? A: Not yet, but already open feature request for it | |
53m23s: Modules in the REPL will always evaluate to "Main" module | |
53m50s: Planning to share his example repo during the Break | |
54m05s: Color Theme he's using is "One Dark Pro" - check extensions | |
54m35s: Can move Terminal panel elsewhere, e.g. under the left panel | |
55m10s: There shouldn't be any difference in performance or memory footprint of vscode vs vscodium | |
55m58s: Julia 1.6.2 should work with vscode. If it doesn't: 1) make sure your version of the Julia extension is up-to-date (should happen automatically), 2) if still errors, ask on Julialang discourse or vscode+julia github | |
56m32s: Code autoformatters. Sebastian mostly disables current autoformatter, recommends instead JuliaFormatter.jl. Planning to integrate that within extension, hopefully soon. (*) | |
WAYS TO EFFICIENTLY EVALUATE CODE (2/2): | |
57m30s: Select only part of an expression, press Alt-Enter: only evaluate that sub-expression (*) | |
58m07s: Evaluate/run a whole file: click arrow in the upper-right, select "Julia: Execute file in REPL". Explains other options too. (*) | |
59m35s: People are asking for Alt-Enter equivalent for Mac. Answer: CTRL-Enter | |
1h01m50s: OhMyREPL! module should work fine ([https://github.com/KristofferC/OhMyREPL.jl](https://github.com/KristofferC/OhMyREPL.jl) (*) | |
1h02m00s: Q: Evaluate larger block of code? lines starting with ` ## ` defines "cells" that each get evaluated, shown separately. "Julia: Execute Code Cell in REPL": Shift-Enter (*) | |
~1h04m: answer minor questions | |
BREAK: | |
1h05m20s: start 5 mins break | |
1h10m15s: end break | |
Q&A: (I skipped a repeated question) | |
1h11m20s: Planning to eventually set default settings for first time users of the extension | |
DEVELOPING PACKAGES IN VSCODE | |
1h12m00s: Julia display system: overload Base.show() (*) | |
1h13m40s: display images, e.g.: `Base.show(io:: IO, ::MIME"image/png", ::BarPNG)` (*) | |
1h15m20s: also support GIF, SVG, and HTML - very powerful (*) | |
1h16m00s: with ` ::MIME"juliavscode/html" `you can even setup your own complete HTML/Javascript UI with bidirectional communication, inside vscode (*) | |
1h17m00s: left/right arrows in plot pane can show previous/next plot (*) | |
1h17m30s: Julia workspace panel, plot navigator lists plots, can switch between them (*) | |
1h18m20s: Also support VegaLite, PyPlot, etc. VegaLite Demo. (*) | |
1h19m15s: Julia workspace panel on the left shows all defined variables, imported modules and their submodules, defined functions, etc. (*) | |
1h20m30s: Inspect DataFrame through Julia workspace panel - "Open in VSCode button" (*) | |
1h23m10s: can drag-and-drop any of the tabs in a different area of vscode | |
1h23m45s: interactivity in the plot pane with WebIO or JSServe. Example: WGLMakie. Took ~5 mins... for me, it only worked the 2nd time around, maybe due to timeout (*) | |
1h26m00s: Progress bars (*) | |
1h30m20s: Julia Documentation panel. Can trigger through "Julia: Show Documentation" (Alt+j Alt+D) (*) | |
1h31m30s: Julia Docs search bar. Works for any module in your Julia environment. Don't even need to import them. (*) | |
Q&A | |
1h32m40s: WSL on Windows - recommended to use VSCode WSL extension (*) | |
1h33m23s: There's an indicator to show that vscode+julia is busy: "Julia: Evaluating...". Can click that message to see more details, cancel. | |
1h34m03s: Can interrupt Julia REPL through Cancel button or CTRL-C in REPL (even if the evaluation was triggered from an Editor window) (*) | |
DEBUGGING | |
1h35m20s: Debugger uses JuliaInterpreter.jl. Graphical debugger available in Juno, then vscode. Will explain the basics, then give tips for the debugger to run fast enough to be useful. | |
1h36m40s: in vscode, Sebastian always use @enter and @run to use the debugger. Automatically defined in the Julia REPL session. (*) | |
1h37m07s: @enter "steps" into the code, @run runs the code in the interpreter, which supports breakpoints. First show `@enter println(gcd(22, 10))` | |
~1h39m - ran into some issues - need to do an extra step for this to work. You need to press the - (minus) button in the "Julia: Compiled code" pane. (*) | |
Continue @enter example... | |
1h42m10s: @run example. Set/enable/disable breakpoints, @run... | |
1h43m21s: @run will by default break-on-exception. Can inspect local variables at any level of the stack. (*) | |
1h46m55s: can modify local variables inside debugger. Also Debug Console allows evaluating arbitrary code. (*) | |
1h49m00s: Restart Frame button, on the call stack. Very experimental feature. Didn't work. (*) | |
1h50m20s: Conditional breakpoints: right-click breakpoint, edit breakpoint, enter expression (*) | |
1h52m00s: Advanced tricks: right-click on any line, "run to cursor", "step into targets" (*) | |
1h52m20s: Debugger can be slow, due to constant overhead for each function call. Work-around: interpret only small fraction of the code, compile the rest (*) | |
1h59m00s: "Apply default compiled modules/functions". Still experimental, manually-entered list of modules/functions. Next release should work better. (*) | |
2h04m10s: Can also use Infiltrator.jl | |
2h05m27s: "Debug File in a new process" (*) | |
Q&A | |
2h07m10s: Best way to minimize precompilations: should not normally be a big overhead. Also Julia 1.7 has better caching for precompiled files. | |
2h08m13s: vscode debugger compared to Cthulhu.jl. Cthulhu.jl is focused on debugging compilation... ? | |
2h09m - reading questions silently for a while | |
2h10m00s: GitLens extension "Git blame" view | |
PROFILING CODE | |
2h10m40s: Traditional way is using Profile, @profile. ProfileView by default provides a GTK UI, not integrated in vscode, but still an interactive flamegraph. vscode-julialang also defines a @profview, which shows a table and can show a flamegraph. Ctrl-click to navigate to the code. (*) | |
Break | |
2h16m20s | |
Q&A | |
2h20m50s: explain the flame graph, more details on ProfileView | |
DEVELOPING YOUR OWN PACKAGE | |
2h22m20s: can use PkgTemplates to create a package "skeleton" - folders, files, etc. | |
2h28m00s: PkgTemplate by default sets the "git remote get-url origin" to your github | |
2h28m50s: Go to github.com, create a new repository | |
2h29m24s: Main thing you need to do after is "git push -u origin main" | |
2h30m40s: Let's implement a root finding algorithm... | |
2h32m40s: Test-driven development - Can write tests before implementing the function | |
2h33m20s: Show development without Revise.jl | |
UNFORTUNATELY SEBASTIAN DIND'T LINK TO THE NEWTON CODE USED IN THIS SECTION. | |
2h41m00s: Use ForwardDiff.derivative to automatically differentiate the function | |
2h43m00s: Run `] test` to run all tests | |
2h43m20s: Show vscode git features | |
2h44m15s: Register your package through JuliaHub Registrator | |
Q&A | |
2h45m00s: a few brief questions, e.g. Revise-based workflow | |
2h46m30s: switch to Shell mode in Julia REPL: type `;` (semicolon) | |
COOL VSCODE and/or JULIA FEATURES: | |
2h47m00s: `Markdown: Open Preview` | |
2h47m31s: Remote Editing (SSH, Docker, WSL) | |
2h51m26s: NEW FEATURE: Julia: Connect External REPL. Useful with multiple monitors - 1 monitor for Julia, 1 for vscode (*) | |
2h53m05s: Persistent Julia session: use tmux. Can automate through "Julia persistent session" vscode setting. (*) | |
2h55m00s: Use "Stop REPL". (Misnomer - actually disconnects from the REPL, without stopping it!) (*) | |
UPCOMING FEATURES | |
2h55m50s: Improved plot pane (pan/zoom and copy-paste/save), Jupyter-less notebook integration, JET integration (static checking of code) | |
Q&A | |
2h57m00s: If you have constants in your module, you don't need to export them (*) | |
2h57m10s: Documenter.jl | |
2h57m20s: Plots usually still work when you ssh to a machine. Might be some cases where an interactive javascript elements might not get forwarded through ssh. | |
2h58m10s: Write code, load it, run test is his usual workflow. | |
2h58m23s: You can have multiple modules in your package. The top-level module must have the same name as your package. | |
2h58m40s: bunch of quick questions, I didn't quite understand them | |
EXTENSION INTERNALS | |
3h00m50s: Language server protocol. | |
3h02m00s: If you double-click a struct name, hit F2, can rename it in a language-aware way, using a concrete syntax tree (*) | |
3h04m00s: Symbol server for a package, loads docstrings, etc. | |
3h05m00s: Search for "Microsoft Language Server protocol specification" for details | |
3h05m50s: Threads on Discourse about people successfully using the Julia Language Server using Vim, Sublime, other editors | |
3h06m00s: Very little documentation on the Julia Language Server, unfortunately | |
3h06m50s: Debug Server protocol - how debugging works with Julia |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment