Learn to code - the basics
Contents
Learn to code - the basics¶
Roadmap¶
Goals
me & machine
GUI
CLI
IDE
path structures
scripting: how to write a “programm”
how do i read/ work with online-tutorials
Goals¶
As already explained this course is designed to give you a comprehensive understanding of digital literacy and its various applications.
Specific goals of this first session will be to
Motivation: Why coding is necessary in modern research¶
This is obviously a very complex question but might nicely summarized by a quote from Marwick 2015
:
“The broad adoption of computers in experimental science has both enabled and obscured research.”
While (some form or level of) programming
is not only beneficial but also required in various parts of the research workflow, its utilization also introduces new challenges and hurdles. This especially refers to learning and handling these respective computational resources
, as the vast majority of researchers across levels is not trained in practical skills needed for sufficient and FAIR
computational work
during their study program.
Just think about the following example, depicting a very common research workflow and tasks therein.
create
/preprocess stimuli
collect data
inperson
&online
analyze
&visualize data
provide
executable
&reproducible publication
Within all of them, programming can be/is tremendously helpful. Considering the importance of open-source
resources and tools as a crucial pillar of digital literacy
, here are a few pointers how these steps can be implemented using python
, ie the respective python libraries
.
And that’s only a part of it…programming
is actually essential across all stages of a research project, specifically with regard to FAIR
-ness, reproducibility
and reliability
. Not to mention how much it will ease up your daily workflow and enable you to conduct certain projects in the first place. As outlined elsewhere in this course, every part of a research project should be shared, in the right way, and for all these parts programming
matters.
However, it’s also important to further outline the aforementioned problems and hurdles. Here are some key points to consider.
Intro Programming courses are often thought of as difficult and are courses with the highest dropout rates… .
Yet, the only thing that is slightly predictive of success in an intro programming course is … how successful the student thinks they will be.
Things that do NOT predict success:
gender
age
personality
math ability
There are many different level of expertise.
It’s generally accepted that it takes people 10 years to move from novice to expert programmer. But, there are lots of steps in between! We’re working to move further away from novice (& in the direction of expert) than where you are right now.
Mixed Messages.
Novice programmers get told learning to program will be tough and frustrating but that if you’re not having fun, you’re doing it wrong.
Building Blocks.
Too often, we also tell people to “just try things out” without explaining basic concepts. Other skills aren’t taught this way…
Be a mover: Make forward progress.
Strike a balance between just stopping and tinkering forever.
main areas of interest:
create your own experiment and stimuli
data exploration & statistics
automatization & reprodcuibility
You & your computer¶
How do you interact with your computer? In general, you, as a user, provide some input that contains a task that your computer should perform in order to obtain a desired outcome. However, there are different ways you can approach this, each with advantages and disadvantages. More precisely this refers to the distinction between
GUI
(Graphical-User-Interface
)CLI
(Command-Line-Interface
)IDE
s (Integrated-development-environments
)
You’ll probably be mostly familiar with GUI
s, i.e. the “windows” a program provides functionality in (e.g. word
, photoshop
etc.). CLI
s on the other hand are purely text-based methods of interacting with your computer, requiring the knowledge of some kind of programming language
and a bit of background knowledge on how to navigate the “paths
” of your device. An (IDE
) is a mixture of the two, helping people create software/code by putting all the tools they need in one place. Modern science relies on all of these approaches, often combining dedicated GUI
s with basic CLI
work.
Don’t be discouraged if you’ve never heard about CLI
s though. The main hurdles to utilize these for your work are mainly the inhibitory psychological barrier of not knowing where and how to start for most people and the need of an actual project to practice on.
We’ll try to deal with these hurdles as part of this session and also explore when and for what purposes you may want to rely on classical GUI
s or switch to CLI
s or IDE
s. However, here’s already a quick summary.
In the following lessons we will dive deeper into how to write code, specifically via the Python programming language
.
IDEs¶
IDEs allow for full flexibility and freedom in creating whatever functionality is necessary for your project, but as with the CLI they require knowledge of a programming language. They are industry standard and are essentially “agnostic”, in the sense that tey can be adapted to work with any programming language.
Jupyter notebooks: a special case¶
Jupyter notebooks
are a widely-used, open-source
tool for interactive computing
. They are not technically an IDE
but a web browser-based interactive computing platform
used to run code in Python
, R
and many other programming languages
for example. It’s important to note that web browser-based means that you installed an internet browser of choice is used to display the jupyter notebook
window but an internet connection is not necessary and none of your data will be transmitted, if your using a local installation.
The main benefits of Jupyter notebooks lies in the ability to combine live code, equations, visualizations, rich media presentations, and narrative text in a single document. This makes it easy to create engaging, interactive content to communicate complex concepts, such as a research workflow. Notebooks are further great for
data visualization
andexploration
,documentation
teaching
/learning
presentation of results
Due to this Jupyter Notebookss have become the community standard for communicating and performing interactive computing.
A Jupyter notebook file has the file-ending .ipynb and can either be opened and adapted using either the Jupyter Notebook application or IDEs like VScode.
You can try how this works here: Try Jupyter Notebooks
The following chapter “Introduction to Jupyter Notebooks” will provide a more in-depth explanation of the Jupyter interface and it’s capabilities.
JupyterLab: A Next-Generation Notebook Interface¶
The Jupyter Notebook has further been adapted to the needs of modern research workflows. The JupyterLab application is an IDE for notebooks, code, and data and provides most of the functionality as e.g. VScode.
You can try it here: Try Jupyter lab