5333 private links
I really like using (and making!) programming playgrounds, and I got thinking the other day about how I didn’t have a great list of playgrounds to refer to. So I asked on Mastodon for links to cool playgrounds.
Here’s what I came up with. I’d love to know what I missed.
AnechoicMedia @AnechoicMedia_
What an incredible rabbit hole. Margaret Hamilton, awarded the Presidential Medal of Freedom for "[leading] the team that created the on-board flight software" for the Apollo missions, wasn't even hired until after the completed software had already flown to the moon in Apollo 8!
For decades, coders wrote critical systems in C and C++. Now they turn to Rust. //
Many software projects emerge because—somewhere out there—a programmer had a personal problem to solve.
That’s more or less what happened to Graydon Hoare. In 2006, Hoare was a 29-year-old computer programmer working for Mozilla, the open-source browser company. Returning home to his apartment in Vancouver, he found that the elevator was out of order; its software had crashed. This wasn’t the first time it had happened, either.
Hoare lived on the 21st floor, and as he climbed the stairs, he got annoyed. “It’s ridiculous,” he thought, “that we computer people couldn’t even make an elevator that works without crashing!” Many such crashes, Hoare knew, are due to problems with how a program uses memory. The software inside devices like elevators is often written in languages like C++ or C, which are famous for allowing programmers to write code that runs very quickly and is quite compact. The problem is those languages also make it easy to accidentally introduce memory bugs—errors that will cause a crash. Microsoft estimates that 70% of the vulnerabilities in its code are due to memory errors from code written in these languages.
Most of us, if we found ourselves trudging up 21 flights of stairs, would just get pissed off and leave it there. But Hoare decided to do something about it. He opened his laptop and began designing a new computer language, one that he hoped would make it possible to write small, fast code without memory bugs. He named it Rust, after a group of remarkably hardy fungi that are, he says, “over-engineered for survival.”
Seventeen years later, Rust has become one of the hottest new languages on the planet—maybe the hottest.
The original Mac was written in Pascal and assembly, though not natively. They had to use a cross-platform development system called the Macintosh Development System, compiling on one machine and transmitting the binary to the target (via a serial connection) for execution and testing. Very similar in concept to hardware-testing software on iOS. //
The Lisa/Lisa 2 supported this kind of cross-platform development, but it was too expensive for most developers. The environment sold to developers comprised two Mac 128s. When the 512 came out, it became possible to code natively. Two or three applications were available by late 1984 that allowed users to write and run simple interpretive code: Microsoft Basic, Turbo Pascal, and a Mac version of Apple Pascal that didn't seem to materialize past the demo stage.
The lack of a good, cheap development system probably contributed to the exodus of developers--especially game developers--from the Mac to the PC. It wasn't until the Mac Plus came out in 1986 that it was a truly comfortable environment to code in. Two years wasted. Oh, well.
This is an FAQ about El Al’s recently introduced in-flight zmanim system that uses the KosherJava zmanim code. This FAQ is almost identical to what you will see on El Al flights, but it is slightly expanded and includes links to articles that are not available on the in-flight system.
Manage all your software, all in one place
Backstage makes it easy for one team to manage 10 services — and makes it possible for your company to manage thousands of them
A uniform overview
Every team can see all the services they own and related resources (deployments, data pipelines, pull request status, etc.)
Metadata on tap
All that information can be shared with plugins inside Backstage to enable other management features, like resource monitoring and testing
The object oriented toaster
Once upon a time, in a kingdom not far from here, a king summoned two of his advisors for a test. He showed them both a shiny metal box with two slots in the top, a control knob, and a lever. "What do you think this is?"
One advisor, an Electrical Engineer, answered first. "It is a toaster," he said. The king asked, "How would you design an embedded computer for it?" The advisor: "Using a four-bit microcontroller, I would write a simple program that reads the darkness knob and quantifies its position to one of 16 shades of darkness, from snow white to coal black. The program would use that darkness level as the index to a 16-element table of initial timer values. Then it would turn on the heating elements and start the timer with the initial value selected from the table. At the end of the time delay, it would turn off the heat and pop up the toast. Come back next week, and I'll show you a working prototype."
The second advisor, a software developer, immediately recognized the danger of such short-sighted thinking. He said, "Toasters don't just turn bread into toast, they are also used to warm frozen waffles. What you see before you is really a breakfast food cooker. As the subjects of your kingdom become more sophisticated, they will demand more capabilities. They will need a breakfast food cooker that can also cook sausage, fry bacon, and make scrambled eggs. A toaster that only makes toast will soon be obsolete. If we don't look to the future, we will have to completely redesign the toaster in just a few years."
"With this in mind, we can formulate a more intelligent solution to the problem. First, create a class of breakfast foods. Specialize this class into subclasses: grains, pork, and poultry. The specialization process should be repeated with grains divided into toast, muffins, pancakes, and waffles; pork divided into sausage, links, and bacon; and poultry divided into scrambled eggs, hard- boiled eggs, poached eggs, fried eggs, and various omelette classes."
"The ham and cheese omelette class is worth special attention because it must inherit characteristics from the pork, dairy, and poultry classes. Thus, we see that the problem cannot be properly solved without multiple inheritance. At run time, the program must create the proper object and send a message to the object that says, 'Cook yourself.' The semantics of this message depend, of course, on the kind of object, so they have a different meaning to a piece of toast than to scrambled eggs."
"Reviewing the process so far, we see that the analysis phase has revealed that the primary requirement is to cook any kind of breakfast food. In the design phase, we have discovered some derived requirements. Specifically, we need an object-oriented language with multiple inheritance. Of course, users don't want the eggs to get cold while the bacon is frying, so concurrent processing is required, too."
"We must not forget the user interface. The lever that lowers the food lacks versatility, and the darkness knob is confusing. Users won't buy the product unless it has a user-friendly, graphical interface. When the breakfast cooker is plugged in, users should see a cowboy boot on the screen. Users click on it, and the message 'Booting UNIX v.8.3' appears on the screen. (UNIX 8.3 should be out by the time the product gets to the market.) Users can pull down a menu and click on the foods they want to cook."
"Having made the wise decision of specifying the software first in the design phase, all that remains is to pick an adequate hardware platform for the implementation phase. An Intel Pentium with 48MB of memory, a 1.2GB hard disk, and a SVGA monitor should be sufficient. If you select a multitasking, object oriented language that supports multiple inheritance and has a built-in GUI, writing the program will be a snap."
The king wisely had the software developer beheaded, and they all lived happily ever after.
This project is a continuation of Stack Overflow Documentation, which ended in August 2017.
The intent is to preserve that work and improve upon it.
This project is collaborative. All documentation is released under Creative Commons BY-SA license and hosted on GitHub. Please do contribute!
Guiding principles behind Essential Books
- driven by examples
- not limited in size like a traditinal book
- articles are cross-linked
- search friendly
Driven by examples
Show, don't tell.
Not limited in size
A traditional book is limited by physical size, number of pages. This limits how much information it can have.
We don't have such constraints so there's no limit to how much useful information we can add.
Documenting popular libraries, adding step-by-step tutorials for specific tasks. Everything is in scope.
Search friendly
A search bar at the top allows quick navigation to a topic of interest.
Instead of scanning table of contents, you can type the topic you're interested in.
Graybeards know compiler technology is much more complex than simple go/no-go code parsing. In the 70-odd years since Grace Hopper brought compilers into existence, every milestone in processor design has been blessed or cursed by compiler advances or the lack of them. Itanium died because Intel couldn't make the compiler fly. Arm prospered because its compilers made its performance available.
Only compilers can unify the market: C wouldn't be more than a footnote if its compiler technology wasn't easy to port to multiple platforms. Conversely, compilers can divide the market. Think of the 1980s with multiple monolithic C compilers trying to lock products into platforms by making porting painful. They weren't very good, they weren't very compatible, life was slower and harder than it needed to be.
It is hard to overstate the difference that GCC made to that environment. Compilers can be split into three components: a front end, an optimizer, and a back end. The front end takes your code and digests it into a form the optimizer can then arrange according to rules, and the back end translates that output into the right object format for the target system. GCC liberated this structure, so if you wanted to write a new language, you just had to worry about the front end. A new target instruction set, just the back end. A particular cache structure, hit the optimizer. The benefits are shared with everyone.
That's where the true magic of compilerdom lies. You can have the world's most thoughtfully designed language, but if your compiler makes slow code, nobody will care. With GCC, you got the same kit of parts as everyone else and you could concentrate on what makes your language or processor special. When GCC stopped being the GNU C Compiler and became the GNU Compiler Collection, the economics and scope of compilers skyrocketed, and systems innovation followed them into orbit.
Then LLVM went a step further, and broke compiler technology into a set of libraries, meaning that some of the things compilers do very well, as in optimally managing data structures and parsing complex commands, can be added into databases and browsers and all manner of applications. Sure, languages are cool, but a complete architectural component model is cooler. Do you want magic in a bottle or to badly reinvent the wheel?
Code with Mu: a simple Python editor for beginner programmers.
Why not just use C and C++? The reason is security and memory-related bugs, said Lerche, quoting research that “70 per cent of all high severity security vulnerabilities in software in C and C++ are due to [lack of] memory safety.”
Rust is revolutionary, he said, because “Rust is the first mainstream programming language that is efficient while maintaining memory safety.” Lerche explained how Rust achieves memory safety by using the idea of ownership, based on a concept called Affine logic, where each object has one and only one owner at a time.
Ownership rules are checked at compile time, so there is no runtime overhead. Concurrency too is easier and safer in Rust than in C or C++, leading to further performance and efficiency gains. //
The problem is that coding in Rust is hard. One reason why languages like Java, JavaScript, and Python have seen such wide adoption is that programmers can become productive more quickly.
This then is the elephant in the room, “the famous learning curve,” said Miller. In a recent survey, “of the engineers who said they were no longer using the language, 55 per cent cited learning and productivity as their reason for abandoning it. Experienced engineers require three to six months of study supported by a subject matter expert before they are productive with the language.”
If-else statement takes a specific condition and checks whether the condition is truthy or falsy. If the condition is true, then the if statement executes a specific code block. If the condition is false, then the else statement executes a different code block. //
The switch statement is a multiple-choice selection statement. Once you have given the choices and relevant expressions for each choice, It looks through the choices until it finds the choice that matches the expression and executes it. //
Choosing one over the other is not that straightforward. Here are some tips when choosing one over the other;
You can use if-else when:
- The condition result is a boolean.
- The conditions are complex. For example, you have conditions with multiple logical operators.
You can use a switch-case when:
- There are multiple choices for an expression.
- The condition is based on a predefined set of values such as enums, constants, known types. For example, error codes, statuses, states, object types, etc.
Understanding Projects
Understanding of project like how folders are arranged? how files are linked? which tech stack is used? is the most important thing before raising an issue or making a pull request in any project on GitHub. //
Making Pull Request
Your PR should do one thing. Always make a pull request for one part or section so that it would be easier for reviewers and maintainers to merge your pull request. If you are solving multiple issues in a project then open multiple PRs.
Wolfram argued that, early on, the language saved its adopters from their darkest fear: “That they would always delegate the process of computation to somebody who would be down in the dungeon somewhere actually dealing with the computer.
“The big transformative thing that happened as a result of the release of Mathematica — and it happened rather quickly — was that people like theoretical physicists, mathematicians, things like this … Those kinds of people, were able to go from thinking of a computation to actually doing a computation directly, and were able to, therefore, get much further in lots and lots of different areas.
“And it’s been wonderful over the last third of a century to see all the inventions and discoveries that have been made using the technology that we built.”
karalabe commented May 2, 2017
TL;DR https://play.golang.org/p/LPkPTRF7fC
The above code looks quite plain and obvious, except it does something completely different than you'd expect (feel free to run it). The obvious thing that should happen is that it counts the number of bits set in the given string. The non-obvious thing that happens is that the mask is actually 0, not 0x01.
So, what happened there? The abuse in the above code is around the invisible Unicode characters that mark following text to be right-to-left or left-to-right. Since Go permits arbitrary Unicode characters to be present in string literals, it also allows me to have a string of the form "bla bla blaabc". Since we're dealing with valid Unicode sequences here, any modern editor/website will actually interpret those special characters, causing the content in between the two special marks to be reversed to the end of the line (alas still part of the string literal).
In my playground code this is abused by having the following source code:
str, mask := "Hello, World!<rtl>10x<ltr>", 0
Which will be displayed by all modern editors/websites as:
str, mask := "Hello, World!", 0x01
The security aspect of this issue is social engineering attacks. The "display" line of my sample code is obvious beyond doubt, so noone will ever inspect such a thing; however it managed to flip one bit in a mask (imagine doing this for file permission umasks). The issue is that such code could easily get past reviews and into a final product.
At issue is a component of the digital text encoding standard Unicode, which allows computers to exchange information regardless of the language used. Unicode currently defines more than 143,000 characters across 154 different language scripts (in addition to many non-script character sets, such as emojis).
Specifically, the weakness involves Unicode’s bi-directional or “Bidi” algorithm, which handles displaying text that includes mixed scripts with different display orders, such as Arabic — which is read right to left — and English (left to right).
But computer systems need to have a deterministic way of resolving conflicting directionality in text. Enter the “Bidi override,” which can be used to make left-to-right text read right-to-left, and vice versa.
“In some scenarios, the default ordering set by the Bidi Algorithm may not be sufficient,” the Cambridge researchers wrote. “For these cases, Bidi override control characters enable switching the display ordering of groups of characters.”
Bidi overrides enable even single-script characters to be displayed in an order different from their logical encoding. As the researchers point out, this fact has previously been exploited to disguise the file extensions of malware disseminated via email.
Here’s the problem: Most programming languages let you put these Bidi overrides in comments and strings. This is bad because most programming languages allow comments within which all text — including control characters — is ignored by compilers and interpreters. Also, it’s bad because most programming languages allow string literals that may contain arbitrary characters, including control characters. //
“Therefore, by placing Bidi override characters exclusively within comments and strings, we can smuggle them into source code in a manner that most compilers will accept. Our key insight is that we can reorder source code characters in such a way that the resulting display order also represents syntactically valid source code.”
“Bringing all this together, we arrive at a novel supply-chain attack on source code. By injecting Unicode Bidi override characters into comments and strings, an adversary can produce syntactically-valid source code in most modern languages for which the display order of characters presents logic that diverges from the real logic. In effect, we anagram program A into program B.”
Are you just getting started with PowerShell? Use this guide to create and run your first script file on Windows 10.
“I’m very proud of the fact that there’s actually a fair number of people still involved with the kernel that came in in 1991 — I mean, literally 30 years ago.” (Hohndel is one of them.)
The longevity of the Linux community is especially impressive in light of how few contributors there were back in 1991, Torvalds said: “I think that’s a testament to how good the community, on the whole, has been, and how much fun it’s been.”
Yes, fun — and Torvalds still considers that one of the building blocks of the Linux community; “just for fun,” he said, is part of what he still strives for.
It comes up when people talk about the possibility of writing some Linux kernel modules using Rust. “From a technical angle, does that make sense?” Torvalds asked. “Who knows. That’s not the point. The point is for a project to stay interesting — and to stay fun — you have to play with it.” //
The keynote conversation closed with Hohndel asking what they should do for the 50th anniversary of Linux, in the year 2041, when both of them will be in their 70s.
Characteristically Torvalds answered that, just like with the Linux kernel, he doesn’t make plans more than six months out. But the question did draw some reflection. “I’ve been very happy doing the kernel for 30 years,” Torvalds began thoughtfully.
“Somehow I don’t see myself doing kernel programming when I’m 70. But on the other hand, I didn’t see myself doing kernel programming when I was 50 either, a few years back. So… we’ll see.”
Within modern software development practices, you are expected to build software from a two- or three-sentence business feature. The name of the game is to not go too deep and to constantly iterate. This is far different from the traditional waterfall method, where you would spend six months figuring out the requirements analysis before you wrote a single line of code. With a waterfall approach, this is fine because you will know the end state in order to create your database objects. However, you simply can’t do this if you’re following agile methods because there is no way to build a data model from a three-sentence business requirement, and you’re constantly having to rework your database. //
RDBMS Growth at Travelers
YEAR Tables in production
2013 40
2015 70
2017 100
//
We taught every team how to data model in JSON, as opposed to the rigid tables and rows of a relational database. This was an eye-opening experience for many people, who now understood how this affected the speed at which our teams could deliver software into production. //
At the end of the day, if you’re doing it right in relational, you have a lot of tables, and if you’re modeling your data properly, you will have a lot of objects even for the simplest use cases. Once we determined that our database was slowing us down, we knew it was time for a change.
Perl is a high-level programming language that’s easier to learn when compared with Python. Python is more robust, scalable, and stable when compared to Perl. While Perl code can be messy, featuring many paths to accomplish the same goal, Python is clean and streamlined. //
Ask someone who’s worked with both Perl and Python what the most noticeable difference between the two is, and they will most likely reply “readability.” Perl, although designed for beginners to master, is consistently reported to look unreadable, especially compared to the sleek interface brought by Python. Editing code can be difficult enough. Having to decipher the code you’re trying to edit at the same time? That may be pushing it.