Learn to code - the basics

Roadmap

Goals

  • Me and the 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.

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 in person & 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.

Screen%20Shot%202023-03-22%20at%204.18.13%20PM.png


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.

Screen%20Shot%202023-03-22%20at%205.10.06%20PM.png


However, it’s also important to further outline the aforementioned problems and hurdles. Here are some key points to consider.

  1. 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

 

  1. 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.

 

  1. 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.

 

  1. Building Blocks.

    Too often, we also tell people to “just try things out” without explaining basic concepts. Other skills aren’t taught this way…

 

  1. 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

Screen%20Shot%202023-03-22%20at%205.22.09%20PM.png

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)

  • IDEs (Integrated-development-environments)

You’ll probably be mostly familiar with GUIs, i.e. the “windows” a program provides functionality in (e.g. word, photoshop etc.). CLIs 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 GUIs with basic CLI work.

Screen%20Shot%202023-03-22%20at%205.25.11%20PM.png

Don’t be discouraged if you’ve never heard about CLIs 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 GUIs or switch to CLIs or IDEs. However, here’s already a quick summary.

Screen%20Shot%202023-03-22%20at%205.26.31%20PM.png

In the following lessons we will dive deeper into how to write code, specifically via the Python programming language.

IDEs

Screen%20Shot%202023-03-22%20at%205.29.22%20PM.png

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.

Screen%20Shot%202023-03-22%20at%205.28.48%20PM.png

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 and exploration,

  • 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