Father of Redis: It is too difficult to find a reliable C programmer!

27e75f11c1eb888db3dab53d2ee4309f.png


Sicily is a sunny and quiet island located in southern Italy. As shown in the movie "The Beautiful Legend of Sicily", it has ancient history and architecture. It seems that it has nothing to do with IT, but it is the residence of Antriez, the author of Redis. land.

Redis is an infrastructure of the Internet, and a large number of websites in the world have the shadow of Redis behind them. Compared with the popularity of Redis, many programmers don't know the story of antriez. I have read almost all of his blog posts recently, and I would like to share with you the interesting things I learned and what we can learn from the previous generation of programmers born in the 70s.

Antriez is not a typical Italian programmer. Most locals like the boring-but-sure path. The IT industry is not a particularly high-paying job in the local area. Most people don’t like to do too much exploration, but Antriez likes new things and Create something new.

In an interview 10 years ago antriez said that living in Italy doesn't have much impact on programmers, because we can experience all interesting things on the Internet:

If your target is the world, being here is not a big limit for a programmer. The majority of interesting things are happening on the internet nowadays anyway.

At the beginning of his career, Antriez worked as a security researcher, and later did development in embedded, system, Web and other fields. In his early years, he also invented  idle scan [1] , a commonly used scanning technology in Nmap .

In 2009, when Antriez was doing real-time statistics on a website, he believed that existing databases such as MySQL could not meet the needs of intensive writing and checking statistics, so he set out to solve this problem.

Antriez used Tcl to quickly roll out a   module named  LLOOGG Memory DB [2]protocol , which only has 300 lines in total, but it solved the problem at hand and included the core design of Redis, with  and  list, and port 6379!

Then antriez re-implemented the new version in C language, put it into the production environment and ran well for a few weeks, and then published it on Hacker News and gained more attention. More and more companies began to run Redis in the production environment.

Let's talk a bit off topic here, Redis initially received attention in the Ruby community, and then Github, Instagram and other sites began to use Redis. The Ruby community used to be a trendsetter. For example, when Git was first released, Linus couldn't figure out why people in the Ruby community liked it so much. Later, there was Github written by Rails. Although Ruby is now in a bit of a decline, we should thank the good taste of the Ruby community for discovering and creating so many good things for the industry.

If it is only used for caching, we have had memcached since 2003. For example, when I first started working in 2011, memcached was a more mature and general-purpose component. I also carefully read the source code of memcached [3] , but why can Redis come from behind? ?

4829c17f40de1a2fbfda8ae735b9f643.png

Antriez talked about two main points:

  • For intensive write scenarios, especially cache-related requirements, Redis can save costs and perform well

  • Redis is not just a cache, but a different form of database, suitable for many scenarios that require higher performance than correctness

In the field of programming languages there is a motto: a programming language is worth learning if it is different enough from all you already know to change your mind, exposing you to new abstractions. Well I think Redis definitely is a really different database, and will change the way you think about your data.

Antriez treats Redis as a database from the very beginning, not just a cache component. In short, Redis can do what memcached can do, but memcached can't do what Redis can do.

Redis naturally supports various commonly used data structures , such as list, set, maps, etc. These data structures allow Redis to meet various business needs. It can be said that Redis has opened a new era of KV database.

This story and the origin of SQLite complement each other. The first version of SQLite is just a Tcl extension, and the first version of Git is only 1200 lines. This seems to confirm a truth in software design: complex systems that work well often evolve from simple designs. However, a complex system designed from the beginning often does not work, and usually cannot be solved by patching:

A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system." – John Gall

Both Redis and SQLite are heavily influenced by Tcl, a 35-year-old language invented in 1988. Tcl inherits the Unix design style of designing composable, compact components and maintaining a simple interface. Antriez believes that his program concept is deeply inspired by Tcl, especially the style of commands in Tcl continues to Redis  All data types can be manipulated as strings . And John Ousterhout invented Tcl to solve  a demand in EDA development [4] . In the 1980s and 1990s before the Internet wave, EDA was really a jewel in the technical field, and many technical branches were derived. .

The source code of Redis can be used as a model of C system programming , and it also includes the realization of many classic data structures. You can read this  Redis Design and Implementation [5]  to get a feel for it.

Subsequently, Redis was sponsored by VMWare, and later a special Redis Labs was established. Although Redis has been a popular open source project since the beginning, we can see from the ranking of the number of submissions that in the past 10 years, Antriez has mainly contributed and maintained it alone .

a8cd4503562f83acbaa142cd5fe8888b.png

This is a strange phenomenon. After all, Redis is such a general-purpose component, and the attention on Github is also very high. There will be many demands from various scenarios.

But if you look closely at Antriez's style, it makes sense. He believes that for Redis, avoiding complexity and maintaining stability are the most important things , so when he faces many demands and PRs every day, he will say "No" most of the time, otherwise a  Less stable code base, more problems vicious circle will appear.

The bugs you write in the first implementation are extremely hard to fix later. They don’t go away easily. Basically there’s this process where you say, okay, I want to change something, but I want the software to remain stable. So you start to think about it for weeks, the way you want to do it, without writing any code.

The introduction of each new function must be very careful. The core code of Redis has been kept at the level of 10,000 lines, and it was run in a single thread before version 4.0.

Design is what matters, and coding and implementation is easy because it just happens .

Instead, there’s this huge design process. But because of this design, sometimes we can write a new feature using half as many lines of code in a much more simple way, a much more stable way. You think and think and think and find that a couple of days ago, what sounded like the best design — it starts to sound pretty lame, actually, and you find another and another. At the end, you understand that probably that specific one was the best, and then you start doing the implementation.

This means, in turn, that people say, don’t worry, I can help you implement this. And you say, no. If you want to help me, you have to put more time into the design effort. Writing the code is the easy task. The hard task is understanding what to do and in what way to do it.

I think this is also an aspect that we as programmers must be aware of if we want to advance to a higher level. Don't spend too much time on coding, but spend time thinking about requirements and problems, and finding good designs. on .

Maintaining a project for a long time will also feel boring. In order to keep himself interested, antriez will try to switch between different fields , such as doing data structure for a while, and switching to cluster after a few weeks. And in addition to Redis, he is doing more  side projects [6] :

1) Load81, children programming environment. 2) Dump1090, software defined radio ADS-B decoder. 3) A Javascript ray tracer. 4) lua-cmsgpack, C implementation of msgpack for Lua. 5) linenoise line editing library. Used in Redis, but well, was not our top priority. 6) lamernews, Redis-based HN clone. 7) Gitan, a small Git web interface. 8) shapeme, images evolver using simulated annealing. 9) Disque, a distributed queue (work in progress right now).

As a programmer side project is a way of exploration and a way of mental rest, and programmers usually appear more creative in side projects:

Like a writer will do her best when writing that novel that, maybe, nobody will pay a single cent for, and not when doing copywriting work for a well known company, programmers are likely to spend more energies in their open source side projects than during office hours, while writing another piece of a project they feel stupid, boring, pointless.

I took a rough look at these projects, and they are all implemented in C and have a unified style. The README will write some of my own thinking and design choices.

Antriez likes to write small programs, not only because the complexity can be controlled, but because short programs have their own beauty.  Fascinating little programs [7] , the older generation of programmers like to challenge their skills under strict restrictions, such as  Writing an editor in less than 1000 lines of code, just for fun [8] .

Independently maintaining an open source project with such a large impact will have huge psychological pressure . Although users do not pay directly, maintainers have the responsibility to fix problems that arise. This kind of pressure is not necessarily technical, but also social. For example, people continue to accuse him of not replacing the master/slaver in the code and API.

Antriez once mentioned in an interview that he wanted to form a small team at home to maintain Redis. Later, he lamented that it is too difficult to find reliable C programmers , and fewer and fewer are willing to do system programming.

In this article, Antriez   explained the difficulties of maintaining open source projects in The struggles of an open source maintainer [9] . It mentioned that after the Redis project has more users, he needs to be online all the time. And the way he is used to working is to work for a period of time and then completely empty out. He has never been used to the regular work system of 9 to 5, and even mentioned that he cannot keep programming for more than 40 minutes. He likes to code for a while and then go to take care of the children or exercise for a while before return.

In addition to programming, Antriez is also very interested in red wine and sports, and what he pursues more is writing. He can give up programming for writing, which reminds me of Wang Xiaobo.

Three years ago, he posted a blog post declaring that he had stepped back from Redis because he thought that what he wanted to do was creative work like an artist, and programming was also a way of expressing himself, and Redis has developed to this level of creativity. There are fewer things and more transactional work, which is not what I expected:

I write code in order to express myself, and I consider what I code an artifact, rather than just something useful to get things done. I would say that what I write is useful just as a side effect, but my first goal is to make something that is, in some way, beautiful. In essence, I would rather be remembered as a bad artist than a good programmer.

Redis handed over several core maintainers who have worked with him in the open source community for many years, so it was a natural choice for the community.

In the past few years when he stopped programming, he quietly completed  a science fiction novel named Wohpe [10] . This novel is about artificial intelligence and climate change. The original text is written in Italian, but now there is also an English translation version.

I now know for sure: it is no coincidence that for hundreds of years writing has been considered the highest art in which to try one's hand. By writing you look for things, and if you insist enough you end up really finding them.

After finishing the novel, Antriez still hesitated whether to return to programming or continue to engage in other writing, or to do some technology while writing. Until some time ago, after a two-year farewell, Antriez finally   found the fun of programming through Advent of Code [11] . He solved 18 problems and created a stack-based programming language in the process. Judging from Twitter, he has been working on some small projects on LoRa devices recently, and he is also tossing geek devices such as Flipper Zero.

In short, antriez's blog is very worth reading. One of them is  English is my 15 pain [12],  which resonates with me very much. As a non-native English developer, it takes a lot of extra effort to integrate into the English environment, and This is something that most native English speakers in the technical circle will not care about and talk about at all.

There are also some good articles on his blog:

  • Maintain flow in programming. If you find new ideas and problems in programming, you can record them first and then review them later. This is called  Log driven programming [13] .

  • For me other people making money out of something I wrote is not something that I lost, it is something that I gained. Redis 使用 BSD[14]

  • Arts are one of the few things worth life's best efforts. Programming is art, if done in certain ways.

  • Life is too short to work like crazy for most of its part.

  • The mythical 10x programmer[15]

  • Programming and Writing[16]

After reading so many antriez-related articles, what impresses me the most is curiosity, and driven by curiosity, I continue to do interesting things .

Keeping interested, not only technically, but also in life is very important, red wine, CrossFit, writing, and ice cream, antriez and the first user of Redis (an old colleague) have been jointly opening an ice cream shop !

reference:

[1]

 idle scan: https://en.wikipedia.org/wiki/Idle_scan

[2]

 LLOOGG Memory DB: https://gist.github.com/antirez/6ca04dd191bdb82aad9fb241013e88a8

[3]

 Read the source code of memcached:  https://catcoding.me/p/memcached/

[4]

 EDA development:  https://catcoding.me/p/3-years-in-eda/

[5]

 Redis design and implementation:  http://redisbook.com/index.html

[6]

 side project: http://antirez.com/news/86

[7]

 Fascinating little programs: http://antirez.com/news/74

[8]

 Writing an editor in less than 1000 lines of code, just for fun: http://antirez.com/news/108

[9]

 The struggles of an open source maintainer: http://antirez.com/news/129

[10]

 Wohpe: http://antirez.com/news/136

[11]

 Advent of Code: https://github.com/antirez/adventofcode2022

[12]

 English is my 15 pain:  http://antirez.com/news/61

[13]

 Log driven programming: http://antirez.com/news/51

[14]

 Redis uses BSD:  http://antirez.com/news/48

[15]

 The mythical 10x programmer: http://antirez.com/news/112

[16]

 Programming and Writing: http://antirez.com/news/135

(over)

ChatGPT has been very hot recently, and it may completely revolutionize the way programmers program. Shanke and I have recently established a knowledge planet " ChatGPT Base " dedicated to programmers.

1. Help programmers to master ChatGPT as an excellent tool as soon as possible, find the best way to use it, and the best way to improve work efficiency.

If you don't know how to use ChatGPT, you can't be a programmer who is proficient in using ChatGPT. Others use natural language to generate code, you are still typing line by line, the efficiency is ten times or a hundred times worse. This will directly affect a person's job performance, job opportunities, salary, bonuses. 

A junior programmer who uses ChatGPT well may be able to compete with intermediate or even senior programmers.

2. Explore the opportunities that ChatGPT brings to programmers. If the appearance of the iPhone brings app development, turn the sideline business into the main business.

ChatGPT will definitely restructure many industries, such as various trainings. If ChatGPT is packaged as a "Socratic tutor", it is entirely possible to achieve 24-hour company with high-quality tutors, completely covering various subjects in primary and secondary schools, and For adult IT training, there must be many opportunities here.

Of course, these are the two main purposes. Join the planet, and you can also view ChatGPT’s cutting-edge information, high-quality resources and projects, ChatGPT’s geek gameplay, etc. 

The planet now has these events:

Join the planet to get a ChatGPT account (only for the top 100 who entered the planet today, contact information: add WeChat onlyliuxin97 )

Export high-quality content and send a 100 yuan red envelope

Participate in the check-in challenge and have the opportunity to refund the star fee

When I chatted with Shanke, I said: "This planet may become a planet where we pay back money! But it doesn't matter. If we can really use ChatGPT well and make ourselves more competitive, it will be worth it. "

Now the planet is in the trial operation period, the original price is 199 yuan, now there is a coupon of 100 yuan , which is equivalent to 99 yuan , you can join, embrace ChatGPT early, become the first batch of people who can use ChatGPT and use ChatGPT well, and take the lead , get bonus.

859a4383bac46f1a8046c95b974214ce.png

Guess you like

Origin blog.csdn.net/coderising/article/details/130234357