Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content for Development environments/Running code #3

Closed
wants to merge 7 commits into from
Closed

Content for Development environments/Running code #3

wants to merge 7 commits into from

Conversation

jacobusmmsmit
Copy link
Collaborator

This PR is mostly a test PR to

  1. See if I can write content using the right formatting such that it appears on the GH page,
  2. Lay out my plans for the structure of the "loading and running" section such that it can be taken into account when writing other sections,
  3. Throw out some comments about the structure of the content in general.

In particular here are some things to look at @gdalle (more detail in comments in file):

  • I think Revise should be moved to the next section on packages,
  • The VSCode part of this section should be written with/after the previous one on IDEs so there's no overlap in content and it flows better,
  • What should go in the startup.jl we provide? Should we provide one? It is my current opinion that it should be minimal. I'm always scared off by long vim configs (for example).

@jacobusmmsmit jacobusmmsmit marked this pull request as draft June 23, 2023 12:45
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated Show resolved Hide resolved
@jacobusmmsmit jacobusmmsmit changed the title First draft and comments. Content for Development environments/Running code Jul 8, 2023
@jacobusmmsmit jacobusmmsmit marked this pull request as ready for review July 8, 2023 16:12
@jacobusmmsmit
Copy link
Collaborator Author

Some parts are still a skeleton of the final content, but there's enough actual content for me to mark this as an actual PR so others writing can see what's already been written.

pages/writing.md Outdated Show resolved Hide resolved
pages/writing.md Outdated
### Help mode (`?`)
By entering a `?`, you can query information and metadata about Julia objects and unicode symbols simply by typing their name into the command line.
For functions, types, and variables, the query fetches things such as documentation, type fields and supertypes, and in which file the object is defined.
<!-- How do you do syntax highlighting for the Julia REPL? -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with triple backtick followed by julia-repl

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers.

pages/writing.md Outdated
For functions, types, and variables, the query fetches things such as documentation, type fields and supertypes, and in which file the object is defined.
<!-- How do you do syntax highlighting for the Julia REPL? -->
```
help?> Int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice for this to be run by Franklin itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages/writing.md Outdated
@@ -45,23 +45,131 @@ juliaup status

## Development environments

Depending on your experience and how you use Julia, some ways of writing code may be more familiar or useful to you than others.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add more details there

pages/writing.md Outdated
Data scientists commonly prefer notebook environments such as those provided by [Jupyter](https://jupyter.org/) through the [IJulia.jl](https://github.com/JuliaLang/IJulia.jl) package, or Julia's own reactive notebooks from [Pluto.jl](https://plutojl.org/).
On the other hand, package developers or those who write a lot of scripts will prefer the more traditional programming environment provided by a text editor or integrated development environment (IDE).

For some, the Julia REPL (Read Evaluate Print Loop) itself is all that's necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the REPL deserves its own section before dev envs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me

pages/writing.md Outdated
Shell mode: Functions as a terminal inside Julia, you can also execude shell commands from Julian mode.
Here's an example
```julia
an_example()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wtf ^^?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran out of energy

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the terminal niceties we might be interested in for this part? The one that comes to mind is git

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git is one, but what I meant to show in this example is calling bash commands from inside a non-interactive Julia session. Calling shell commands from inside Julia means anything Julia can't do but bash can, can be done without needing to worry about interop.

pages/writing.md Outdated

[^1]: Unless you're compiling binaries with [StaticTools.jl](https://github.com/brenhinkeller/StaticTools.jl).

<!-- The VSCode is important to write in tandem with or after the Development environments part is written to avoid overlap. -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm gonna reorder a bit once we merge this

pages/writing.md Outdated
<!-- The VSCode is important to write in tandem with or after the Development environments part is written to avoid overlap. -->
Most people develop Julia using a tool that allows for [interactive development](https://en.wikipedia.org/wiki/Interactive_programming).
In VScode, you can [run code](https://www.julia-vscode.org/docs/stable/userguide/runningcode/) in the following useful ways:
* For interactive development, the standard way to use Julia, you can use hotkeys to run selections, lines, sections, or whole files in the currently open REPL.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear to a beginner what a hotkey is. Mention the universal shortcut Ctrl + Shift + P for the command pane?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hotkey is a common enough term that I feel comfortable using it. 3rd opinion?

That said, this part's not written yet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the Julia VSCode docs use the term "keyboard shortcuts".

pages/writing.md Outdated
This allows you to, among other things, load packages that improves your development experience or contain functionality that you use very often.

It's tempting to put a lot of code in your `startup.jl` file for convenience's sake, but this convenience comes at a cost of increasing your startup time as it is executed.
To balance convenience and time, we can use AST transformations to conditionally load functionality from packages only when necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too scary for the first page

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a hard dilemma. Conditional loading makes using Julia way better so I want to put it in, but I also hate introducing "magic code" in tutorials. I think conditional loading itself isn't that advanced, it's just not so common because the code itself isn't something most people can write themselves. The concept of "AST transformations" is advanced, I just put it in there to "remove the magic" for those who can understand it. That said, there's probably a better wording (or it can be a footnote) or we can just remove the conditional package loading part entirely.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly with 1.9 / 1.10 it's no longer that expensive to pre-load small packages like BenchmarkTools, is it?

pages/writing.md Outdated
using Revise
using OhMyREPL

colorscheme!("GruvboxDark")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this from OhMyREPL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? Not sure lol

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages/writing.md Outdated
colorscheme!("GruvboxDark")
OhMyREPL.enable_pass!("RainbowBrackets", false)

if Base.isinteractive() &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this belongs on the first page, maybe as a footnote or linked file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an effort to give a nearby example of everything but also not repeating myself too much I just put an actual config here. I think it's probably fine if we end up not putting the conditional loading part, then it's just a short code snippet that's also a genuinely useful startup.jl file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a folder in _assets with such typical files. I also wanna do one for runtests.jl

pages/writing.md Outdated
ENV["JULIA_EDITOR"] = "code"

using Revise
using OhMyREPL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revise and OhMyREPL both recommend loading the packages in a try-catch statement:

https://timholy.github.io/Revise.jl/stable/config/#Using-Revise-by-default-1

try
    using Revise
catch e
    @warn "Error initializing Revise" exception=(e, catch_backtrace())
end

https://kristofferc.github.io/OhMyREPL.jl/latest/installation/#Automatically-start-with-Julia.

atreplinit() do repl
    try
        @eval using OhMyREPL
    catch e
        @warn "error while importing OhMyREPL" e
    end
end

pages/writing.md Outdated
```

For unicode symbols, the query will return how to type the symbol in the REPL, which is useful when you copy-paste a symbol in without knowing its name, and fetch information about the object the symbol is bound to, just as above.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also mention that using help-mode with a string will call apropos and look for the string in all available docstrings:

help?> "determinant"
LinearAlgebra.logabsdet
LinearAlgebra.det
LinearAlgebra.logdet
LinearAlgebra.det_bareiss!
LinearAlgebra.det_bareiss

This is quite useful to find / remember function names.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know this...

pages/writing.md Outdated
For unicode symbols, the query will return how to type the symbol in the REPL, which is useful when you copy-paste a symbol in without knowing its name, and fetch information about the object the symbol is bound to, just as above.

### Pkg mode (`]`)
Pkg mode is for managing environments and packages that is based on the Rust package manager "cargo".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence is missing a word.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm also not sure the comparison to Rust's cargo is crucial enough to belong in the first sentence. This might confuse people who have no experience with Rust.)

@gdalle
Copy link
Collaborator

gdalle commented Jul 10, 2023

Just a word on reviewing: it's cool to spend time at the beginning to make sure that our general orientations and styles are aligned, but I don't expect this level of detail on all PRs :) Let's not discourage each other either, we can always re-modify after the fact

@gdalle gdalle mentioned this pull request Jul 11, 2023
Merged
@gdalle
Copy link
Collaborator

gdalle commented Jul 11, 2023

@jacobusmmsmit I took your REPL content and merged it in #23 with the brand new Franklin REPL code blocks. Feel free to merge gdalle:main into your branch, remove duplicates and continue from there :)

gdalle added 2 commits July 11, 2023 19:33
* Test new REPL blocks

* Re-test blocks

* Fix CSS

* Style help mode and more tests

* Working and properly styled REPL section
@jacobusmmsmit
Copy link
Collaborator Author

Crap I just nuked my content.

@jacobusmmsmit jacobusmmsmit deleted the loading-and-running-draft branch July 11, 2023 17:45
@jacobusmmsmit
Copy link
Collaborator Author

made new branch RIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants