FAQ
Julia
Why are we using Julia?
Julia is open source. It has a great balance between intuitive syntax and speed. It was originally designed to share MATLAB’s mathematically-oriented syntax and Python’s readability. It can be used interactively, as more of a “scripting” language, but can be optimized to run code almost as quickly as C/C++. And it has a committed development base which is actively extending its capabilities: JuMP.jl
lets us program optimization problems in a syntax that’s very close to the mathematical expressions, and the Turing.jl
ecosystem has added some fantastic statistical and machine-learning libraries, among others. It’s becoming a common language among power systems modelers and environmental economists, among other applied communities.
Why not some common alternatives?
- R is fantastic for statistics, but it has a very unique syntax, and can be slow and struggles to scale to large-scale problems; while we won’t approach those limits in this class, there’s no need to go there for our purposes.
- Python is extremely readable, but also can be very slow unless you’re using libraries which are written in C++, and the syntax for these can be jarringly different than native Python.
- C/C++ are overkill for this class, and focusing on them would distract from our core engineering learning objectives.
- MATLAB is not free or open source. It also has some features which do not align with good broader coding and code maintainance practices (for example, having a single long function per file).
Ultimately, there are trade-offs with any language, and in this case, some specifics of Julia syntax and coding style may take an adjustment, but the pros outweigh the cons given the variety of programming tasks that we will be doing in this course.
Are there any resources I can use to learn Julia basics?
There are a few on the Julia Resources page; please suggest additional resources!
I have a Julia syntax question. Where should I look?
First, look at the Julia tutorials on the website to see if the relevant syntax is covered. If not, check the Julia Resources page to see if one of the provided cheatsheets lets you translate from another programming language to Julia. If those still don’t help, try Google; in particular, look for answers from https://stackoverflow.com or https://discourse.julialang.org.
If all of that fails, please post on Ed Discussion, and include what you’ve searched for and why they aren’t quite what you need. A stylized example of what you’d like to achieve is also helpful. As a last resort, come to office hours, but be aware you’ll have a low priority if you haven’t done the above steps, and the odds are that we’ll have to do those as well.
GitHub
Why are we using GitHub?
GitHub is an industry-standard version control platform. Anecdotally, adding GitHub to your skillset is a great resume booster for engineers who work in computing-heavy environments. For the purposes of our class, GitHub facilitates:
- Assignment management through GitHub Classroom;
- Sharing of code/notebooks for debugging and asking for help (otherwise, I end up with many files with the same name, and might not open the right one…);
- Using your repository as your submission in case something goes wrong and you can’t submit your completed assignment on time.
What level of GitHub familiarity will I need?
None from the start! And the following commands are all you will need for this course (you can also use GitHub Desktop or use the GitHub functionality in VS Code, which we will discuss in class):
git clone <github-repository-url>
: This is needed to “clone” your assignment repository (initialize your local repository).git commit -m <message>
: This is used to “lock in” changes that you’ve made to your files. You should make commits frequently as you make changes so you can revert to prior versions if something goes wrong (and make your messages meaningful so you know what changes you’ve made!)git push
: This syncs any committed changes to the remote GitHub repository. You must do this prior to using your repository to ask for help.
Assignments (Homework, Labs, and AEs)
How do I access assignments?
We will use GitHub Classroom to manage assessments. Links to accept the assignments and create your repository will be posted on Ed Discussion as they are released, and posts with the links for active assignments will be pinned. The class schedule will link to a page which has a preview of the assignment, but links are not provided from this page to accept the assignment.
For the first assignment you accept, you will need to link your GitHub account to your entry in the class roster. You will not need to do this again for the rest of the semester.
What if there’s an error in the assignment repository?
That’s certainly possible! If you believe I’ve made a mistake in writing the assignment, please document it in the Ed Discussion forum. I’ll describe steps for how to fix your files (unfortunately, I can’t do this remotely and push it to everyone’s repositories).
Help! My code isn’t working.
Here are some steps I would follow:
Search for the error message you’re seeing. Often, you can find posts in the r/Julia subreddit, the official Julia forum, or Stack Overflow for the same or similar issues. You should do this first: if you can find the answer this way, it will be faster than other options, and if you can rule out some approaches that you’ve already tried, it will make the following steps go more smoothly.
Post on Ed Discussion. For the most effective help, follow the following guidelines (adapted from Stack Overflow’s “How Do I Ask A Good Question?”):
Make your post subject specific and descriptive. “Problem with HW 1 Problem 3” makes it hard for other members of the class community to know if they’re having a similar issue or if they can help. Since the TA and I may not be checking Ed religiously, you’ll get faster responses if other students feel prepared to help.
Introduce the problem. What have you tried? What error message are you getting? Have you been able to identify a specific line of code or section of code that’s causing the problem?
Provide code. It’s very difficult to get a sense of what might be going wrong if you just say that you have a problem, even if you share the error message. If you have a small question (you can demonstrate the error with a brief snippet of code), you can directly put this into your Ed post, but otherwise, please provide a link to your GitHub repository and where to find the relevant codes.
Update Your Repository!You must commit and push your current files to GitHub prior to asking for help, or we won’t be able to see the code that you’re having trouble with.
Come to office hours. If you can identify the problem, but we’re having trouble solving it via Ed or more urgency is required, please come to office hours and we can try to work through the issue. This is most helpful if you’ve already done some problem-solving on your own.
Give Yourself Time To Problem-SolveWaiting until the last day or two to start an assignment can cause problems if you don’t have time to work through the following steps. If office hours are busy and you haven’t gone through the prior steps, you may be prioritized below than students who are have, and we may not have time to solve your problem. Running into coding challenges is not a valid reason to get an extension on an assignment!
Can you help me debug my code?
Your first task should be to identify what part of your code works as desired, to help narrow down where the bug could be. If your code is broken into functions or smaller blocks, set up simple tests to make find which block(s) are causing the problem. If your code is just one big script, try to divide it into logical sections, then conduct these tests. Once you identify the part of the code that is not working, go line by line to see what particular command is doing something unexpected. Once you’ve identified what line is doing something strange, try to search for how to solve the problem and/or post on Ed with your code snippet (actually copy the code into the post or provide a link to your GitHub repository, with the line number; do not paste a screenshot) and a description of what you’re trying to accomplish and what the specific problem is.
If you are not sure how to articulate what your code is trying to do (or are similarly unsure how to divide your code into logical units), that suggests that your problem is not debugging, but rather conceptual: step back and try to write out the logic of your code and how it aligns with the strategy you’ve developed to solve the problem. It might be that there is a conceptual problem rather than a bug, which we can definitely discuss!
If, however, you’ve tried the above steps and cannot figure out the bug, come to office hours, but if you have not done the above steps (and so cannot point to where exactly you’re running into a problem and cannot describe what that part of code is trying to accomplish), we will ask you to figure that out on your own first. Otherwise, we cannot fruitfully help — nobody is more familiar with your code and problem-solving strategy than you are.
How do I get a PDF of my notebook for submission?
There are two main options, depending on what you’ve already got set up on your computer.
Remember to “Run All” cells prior to conversion and submission, or else we won’t see your results!
If you have a Python installation, you can use a tool called
nbconvert
to convert to a PDF (if you also have LaTeX installed) or HTML (and then you can use your browser to print to a PDF).If you don’t have a Python installation, within VS Code, you can use
IJulia.jl
(which will be included in the environments provided with assignments in this class) as follows (enter these commands into the REPL) to open your notebook in your browser:using IJulia notebook()
This should open a Jupyter notebook interface in your browser. Navigate to and open the notebook, and once it has completed running, go to
File -> Print Preview
in the browser menu and Print to PDF.
How do I submit my PDF to Gradescope?
The instructions for submitting your assignment to Gradescope can be found here.
Make sure that you mark/tag the pages corresponding to each question! Otherwise, we will deduct 10%. If a problem spans multiple pages, tag them all; if a page includes multiple problems, tag it several times. You may lose points if part of your answer is untagged (these will not be returned through a regrade request).