Programming Leftovers
-
Caleb Hearth ☛ Write cleaner, self-documented tests by defining methods in RSpec
When we write clean Ruby code, we try to pull out methods with descriptive names that do small amounts of work. It’s possible to do the same in RSpec, just as we would in a less “fluent” test framework like Ruby’s standard testing library Minitest.
-
[Old] Dr Jonathan Carroll ☛ Array Languages: R vs APL -
I’ve seen APL solutions pop up in codegolf and they’ve just looked like madness, which is probably fair. The linked video prompted me to look into some of their other videos and they do a great job explaining the glyphs in APL and how they compare to other languages. It turns out this madness is not nearly as hard to read as it looks. The above glyphs represent “maximum” (⌈), “reduce” (/), “GCD” (∨), and “minimum” (⌊) and those all correspond well to the problem statement. The function itself is “point-free” whereby the argument(s) aren’t specified at all; like saying mean rather than mean(x). For the truly adventurous: ‘The Hideous Beauty of Point-Free Programming; An exercise in combinators using Haskell’
I ended up diving deeper and deeper, and it all started to make more and more sense.
-
Python Speed ☛ The wrong way to speed up your code with Numba
If your NumPy-based code is too slow, you can sometimes use Numba to speed it up. Numba is a compiled language that uses the same syntax as Python, and it compiles at runtime, so it’s very easy to write. And because it re-implements a large part of the NumPy APIs, it can also easily be used with existing NumPy-based code.
-
Hackaday ☛ Video Poker Takes Your Money In 10 Lines Of BASIC
It wasn’t easy, but [D. Scott Williamson] succeeded in implementing Jacks or Better Video Poker in 10 lines of BASIC, complete with flashing light and sound! Each round, one places a bet then plays a hand of 5-card draw, hoping to end up with Jacks or better.
-
Rlang ☛ Mastering Replacement: Using the replace() Function in R
The replace() function is a handy tool in your R toolbox for modifying specific elements within vectors and data frames. It allows you to swap out unwanted values with new ones, making data cleaning and manipulation a breeze.
-
Python
-
Chloé Vulquin ☛ Raison d'être
In the mid-1980s, a language was created to replace BASIC. Built to be a teaching language, easy for beginners, it included a powerful collection of 5 data types, declaration-free strong typing, no limitations besides how much ram you had, and nesting by indentation. Guido van Rossum worked on it for a few years! No, no, it's not Python, it's called ABC, and it came out of academia.
Rossum was inspired by ABC, but didn't like some of its parts. For example, it was monolithic, and so could not gain support for things like… files, UI, and networking. Do you know that Python, to this day, bundles a separate programming language? Indeed, Python includes tkinter, its de-facto GUI. This GUI is implemented by wrapping over Tk, a windowing toolkit. This toolkit is exclusively usable in the Tcl language, and therefore, to wrap around it, Python also bundles Tcl itself. Python from the start was built to be highly extensible via modules, no doubt because of this formative experience. Python is often seen as a "batteries included" language, precisely because of the many modules it bundles, and how useful they are. Put a pin on that for now.
This gives us a general idea as to what Python is to its creator. What do the users of Python look like, though?
-
-
Rust
-
Diziet ☛ How to use Rust on Debian (and Ubuntu, etc.)
tl;dr: Don’t just apt install rustc cargo. Either do that and make sure to use only Rust libraries from your distro (with the tiresome config runes below); or, just use rustup.
-