
Why I made Wyvern, and why I chose C++ over Rust, Zig or Golang
No, it’s not another language war post, and nor is it another “I can do it better than others” propaganda!
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
No, it’s not another language war post, and nor is it another “I can do it better than others” propaganda!
Disclaimer: Wyvern is still a kid! It still needs to learn a lot, and it still needs a lot of nourishment from my side to become what I want it to be. Also, this is not a beef against any of the frontier model providers; it’s just me thinking out loud!
The whole story began 20 years ago, when I enrolled at university for a bachelor’s in computer science back in Iran. In a machine learning class, our teacher gave us some examples of how ML is used, and her last example lit the fire in me to enter this arena.
What was the example? Well, she brought up many examples, but the most interesting one for me was Google!
She said: “Okay, Kaveh! We all know that you love PHP, and that you use it a lot for your customers since you’re a freelancer as well, right? Let’s open two different browser windows. We both search for ‘pear’, and let’s see how the results differ when Kaveh searches for pear while he’s logged in with the account he uses every day, compared to me, since I don’t like PHP at all!” (And yes, I still love PHP!)
Well, Google’s response was what sparked my curiosity and pushed me in this direction. My first Google result was PHP PEAR, while for her it showed pictures of pears and other links about pears and such!
She continued the lecture, but instead of listening to her, I was thinking the whole time about the questions floating around my head; questions like “How? And more importantly, why did Google do it this way? What are they trying to achieve? How do they store all this data?! And how does it work so fast while keeping my interests in mind?” And you see? That was almost 20 years ago! Anthropic, OpenAI and the others like them didn’t even exist back then. Google was pretty much a hero, right?!
My research continued. I started ordering books and asking in forums, and yeah, I was sometimes mocked for my questions, but very, very slowly I started to understand why and how Google does it. Google was my tech god! Not a single day passed without me checking their documents, blogs and so on.
Then a rapid competition started in Iran to build a native, Iranian search engine. The government encouraged people to build one, promising financial support for the most appealing one, although I have no clue whether that promise was ever kept.
In the end, two projects were introduced. Well, they had nothing to offer compared to Google or Bing, but, well, they were working.
The point was, they were fast in development and I wasn’t, since I was alone. Their language of choice was mostly C# and Java; mine was a combination of PHP and a couple of PHP extensions I wrote myself in C++!
Anyway, I made my own search engine and called it “Metaora”!! Perhaps you ask what it means? Well, since I was a hardcore fan of Linkin Park (and still am!), I wanted a domain name after their album “Meteora”! But I made a typo, and I didn’t have the money to buy another domain name, so… yeah!
Mine was working fine, actually very fine! Back then PHP was at version 5.x, which was very slow, and I saw that tech people didn’t like it. But it was working, though not the way it was supposed to, and as you can guess, it was never even close to Google; but it was better than its Iranian competitors! Why? Let me explain:
I was relying only on the keywords and tags defined by the pages, and… I had it connected to the Bing API and Yahoo! BOSS, which were available back then. Whenever I failed to show results to users, I asked them for results and recorded the websites they returned for later consideration. After a couple of months it barely needed to ask Bing or Yahoo! BOSS anymore, since it had most keywords covered. I had a lot of traffic on my tiny website! That really fueled my soul, and I was working on it day and night! But the most important piece was still missing: machine learning! I ran a lot of experiments, but I kept failing every time! So later it was mostly about tuning my database queries (on early versions of MySQL) and working harder on my PHP extensions for fetching websites, recording images and such, to make them faster. But my feedback form said people were satisfied! And that was what kept me motivated.
But it eventually failed, not merely for technical reasons, but mostly for political and social ones! After the protests in 2009, my website got blocked by the government! I went to the authorities and asked why?! They said it was because I covered news agencies abroad that were covering the protests. Their reasoning was actually ridiculous! All those websites were already blocked by the government, so me showing their links in my results wouldn’t have changed much! And since I hated censoring myself, I said “screw it!”…
Five years later, I was told I could get my domain back, but I wasn’t the same person anymore. The young Kaveh had grown up and wanted to build something not just for the sake of building it, but to make a difference. I kept studying and worked at different companies in Iran, the last of which was the strongest software company I’ve worked at so far! E-Sahra (not sure if non-Iranian IP addresses can open it) had at least 100 developers back then and was responsible for stock market infrastructure. There, I learned A LOT from projects and people. My colleagues introduced me to even more resources, and I started to get a better idea of what I had always wanted to build.
Then, in 2023, I came to Austria. After two years, I realized it was time to build my idea! Here the internet is open, people are free to build their ideas as long as they don’t harm others, and the guidelines and rules are clear and understandable for everyone! I took the chance. I named my project “Wyvern” because I’ve been drawn to this creature since early childhood, and building it felt good! And I picked a .at domain for it, because this country generously helped me grow, even though I’m just a migrant!
But what was different technically this time? First of all, technology has improved a lot! There are dozens of libraries and frameworks that make things easier, and hardware has improved a lot too. This time, I decided to fully engage AI in my system.
Now, in a nutshell, AI is the heart of this system. The crawler finds pages on the internet, another part of the software splits them into small pieces, about a paragraph each, and a local embedding model turns every piece into a vector: a list of numbers that captures its meaning. On top of that, Wyvern trains a small extra layer, a “head”, on its own crawled pages, so its idea of “similar” slowly fits my index instead of the whole internet. The big model itself is never retrained. When you search, your query goes through the same model, and Wyvern returns the pages whose meaning sits closest to what you asked. It gives you links, not written answers, and none of it leaves my own server in the EU!
By now I more or less know how AI works, and I’m doing my best to get it to run on a limited server and give users reasonable results. I really don’t care about monetizing it, as it’s a laboratory for me more than anything.
But why a different approach than Google, Bing or even Baidu? Well, by no means do I believe they chose the wrong approach! Actually, what they did and still do is technically hard and brilliant! The core foundation here is me asking myself: “How well is my system aware of the data floating across the internet, and how capable is it of understanding what the user is looking for?!”
Fundamentally, extending this question and helping the system blossom to the next stage will question the usefulness of the chatbots provided by tech giants! I’m asking you: “Would you still need those chatbots if you were using a search engine that knew what you wanted?”
Let’s sit with it for a moment. The problem is, our brains are bombarded with needs and norms defined by corporations rather than with solutions to the real, day-to-day problems we have! You might have heard it before: define a need for people and earn money from it! Partly they had no choice: Google was the first one to rock it and had to introduce a norm to you, which is completely understandable.
Let me ask it another way: Would you ever have needed any of those chatbots to answer your questions if you were using a search engine that didn’t force you to refine your keywords or work hard on them to get what you want? A search engine where you could just start typing and ask for whatever you had in mind? This is not a simple question! If we had one, none of the effort websites put into useful content would go to waste, and webmasters wouldn’t be as demotivated as they are today, with frontier models trained on their content without properly crediting them!
Perhaps you ask how that’s even possible, which is indeed a valid question, and math is here to answer you! Simply put, in Wyvern every paragraph found on a website is converted to a vector, a list of numbers that represents its meaning. Texts that mean similar things get similar numbers, so they sit close to each other on a kind of map of meaning. When you search, your query is converted to a vector as well, and then the system does the following:
Perhaps the biggest obstacle is what a search engine means to people. We’ve been taught that we should search for keywords, and refine our keywords until the engine gives us results. As every webmaster has learned from experience, if you pick a keyword, let’s say “auto” instead of “car”, and your page has lots of useful information, but the user searches for “car”, the whole page gets skipped by the search engine. In my humble opinion, that’s why webmasters are given tools like Google Search Console to tune their websites. In our example, the webmaster finds out they are missing traffic because they lack the right keywords, so they need to shift their content strategy. Do you see where the problem starts now?
With meaning search, that huge effort could be avoided, and you as a user could get better results. For example:
Let’s say you love dogs and want to know which breed is right for you to adopt. You do your best refining your keywords, but you’re not satisfied with the results and don’t feel confident even after reading them, so you go to a chatbot to talk it through. In Wyvern it can be different! You can just type your question the way you’d ask a friend, and Wyvern can show you an animal shelter or a vet whose page talks about adopting and caring for dogs, even if it never uses the words you typed. They might not have a “which breed should I pick” article, but they’re exactly who you’d want to ask! See the difference now?
I gave both Golang and Rust a real shot. Rust is a great language, and I understand why so many people love it, but it isn’t for me. Its compiler is built not to trust me, and that’s exactly its strength! For this project, though, I wanted a language that trusts me and lets me experiment, break things, and learn from them.
With C++, I’d rather do my homework: know the language well, choose the right approach, and take responsibility for memory myself. To me that’s not a weak point of C++, it’s flexibility. And since Wyvern reads HTML from thousands of websites I don’t control, I don’t trust them either! Every download has a time limit and a size cap, checked both on the wire and after unpacking, so one page can’t flood the memory. Every piece of incoming text is cleaned to valid UTF-8 before it’s stored, and a test suite of more than a hundred files keeps me honest.
For Golang, the situation was much, much better than with Rust. Actually, it’s good! But Wyvern keeps a big index of vectors in memory and compares your query against it on every search. With a garbage collector, a search could randomly pause while the GC cleans up, and I want every search to take about the same time. In C++, I decide when memory is allocated and freed.
Zig’s story was
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。