Programming Leftovers
-
Lisp and Spreadsheets
What if you could use a Lisp inside a spreadsheet? Or another functional language? Or maybe even a general purpose language?
-
Help us test system trust stores in Python
If you're an IT or software team that uses Python along with corporate system certificates, an internal CA, or internal PyPI repository: please read on to help improve Python. If you know one or more teams that fits this description: forward them this article! We need lots of people to try the new pip feature to test our implementation of system trust stores in Python.
-
Posit – Why Rstudio is changing its name
For the past few years, Posit (formerly RStudio) has been shifting from R-exclusive tooling to a language agnostic ecosystem. Much to our enjoyment, we’ve seen the RStudio IDE grow to be more Python-friendly and the Posit data science ecosystem become “A Single Home for R & Python.”
-
RStudio is becoming Posit
So while you will see our name change in a bunch of places (including our main corporate website), we are still continuing on the same path. That path has widened as we have succeeded in the original mission, and we are excited at the chance to bring what we all love so much about the R community to everyone.
-
Fix bugs in Bash scripts by printing a stack trace
No one wants to write bad code, but inevitably bugs will be created. Most modern languages like Java, JavaScript, Python, etc., automatically print a stack trace when they encounter an unhandled exception, but not shell scripts. It would make it much easier to find and fix bugs in shell scripts if you could print a stack trace, and, with a little work, you can.
Shell scripts can span multiple files, and well-written code is further broken down into functions. Tracing issues when something goes wrong in a shell script can be difficult when these scripts get large enough. A stack trace that walks the code backward from the error to the beginning can show you where your code failed and give you a better understanding of why so you can fix it properly.
To implement the stack trace, I use the trap in the following manner at the beginning of my script:
This example accomplishes a few things, but I'll address the second one, trap 'ERRO_LINENO=$LINENO' ERR, first. This line ensures the script traps all commands that exit with a non-zero exit code (i.e., an error), and saves the line number of the command in the file where the error was signaled. This is not captured on exit.
-
Learn Rust by debugging Rust
In my previous article about rustup, I showed you how to install the Rust toolchain. Well, what good is the toolchain if you won’t be using it to get more hands-on with Rust? Learning any language involves reading existing code and writing a lot of sample programs. That's a good way to become proficient in a language. However, there's a third way: debugging code.
Learning through debugging involves trying to compile a pre-written (buggy) sample program, understanding the errors generated by the compiler, fixing the sample code, and then re-compiling it. Repeat that process until the code successfully compiles and runs.
Rustlings is an open source project by the Rust team that helps you learn Rust through the process of debugging. It also provides you with a lot of hints along the way. If you're a beginner to Rust and have either started or completed reading the Rust book, then rustlings is the ideal next step. Rustlings helps you apply what you've learned from the book, and move to working on bigger projects.