Programming Leftovers
-
Is local a bad part in Perl?
Q. What should be used instead of local?
Using my in all Perl programs is recommended strongly.
my $foo;
This is called a lexical variable. This is strange name we don't usually hear in daily life.
-
AI is About to Feel Like AGI, and You Need to Get Ready
I’ve been doing this for months already using GPT-3, and I’m completely stunned by what it can do with, say, a security news story. I can give it the body of an article and it can tell me who the attacker was, who the defender was, what technique they used in their attack, and tons of other important analysis. It’s insane. And to the point of my previous article, it’s precisely what we thought could only come from an AGI.
-
Find bugs with the git bisect command
Have you ever found a bug in code and needed to know when it was first introduced? Chances are, whoever committed the bug didn't declare it in their Git commit message. In some cases, it might have been present for weeks, months, or even years, meaning you would need to search through hundreds or thousands of commits to find when the problem was introduced. This is the problem that git bisect was built to solve!
The git bisect command is a powerful tool that quickly checks out a commit halfway between a known good state and a known bad state and then asks you to identify the commit as either good or bad. Then it repeats until you find the exact commit where the code in question was first introduced.
This "mathmagical" tool works by leveraging the power of halving. No matter how many steps you need to get through, by looking at the halfway point and deciding if it is the new top or bottom of the list of commits, you can find any desired commit in a handful of steps. Even if you have 10,000 commits to hunt through, it only takes a maximum of 13 steps to find the first offending commit.
-
Introducing Rust calls to C library functions
Why call C functions from Rust? The short answer is software libraries. A longer answer touches on where C stands among programming languages in general and towards Rust in particular. C, C++, and Rust are systems languages, which give programmers access to machine-level data types and operations. Among these three systems languages, C remains the dominant one. The kernels of modern operating systems are written mainly in C, with assembly language accounting for the rest. The standard system libraries for input and output, number crunching, cryptography, security, networking, internationalization, string processing, memory management, and more, are likewise written mostly in C. These libraries represent a vast infrastructure for applications written in any other language. Rust is well along the way to providing fine libraries of its own, but C libraries—around since the 1970s and still growing—are a resource not to be ignored. Finally, C is still the lingua franca among programming languages: most languages can talk to C and, through C, to any other language that does so.