News for hackers. Stuff that matters.
Re:Challenging projects every programmer should try by bobsomers on Tuesday December 26, 2023 @02:10AM (#38769515)
I don't understand why you think a search engine requires the use of "real engineering skills" like picking and choosing libraries and identifying which opportunities will yield fruitful optimization.

Literally all of the listed projects, text editors, compilers, operating systems, and ray tracers, can exercise the exact same activities.

I'm more inclined to think that your comment is really more revealing about what kind of knowledge is in your own personal wheelhouse. Having worked on a ray tracer that was subsequently used on many feature films, I can assure you that all of your bullet points apply to that project, too.

It's much more a matter of whether you want to do something small scale and fun, or whether you want to suck all the joy out of it by applying the same soul crushing constraints we already get paid to do in our day jobs. Bleh.

Re:Challenging projects every programmer should try by p-e-w on Tuesday December 26, 2023 @02:20AM (#38769557)
> Literally all of the listed projects, text editors, compilers, operating systems, and ray tracers, can exercise the exact same activities.

In the linked article, these projects are all explicitly described as opportunities to learn about low-level stuff like how to efficiently store editable text. The difference with a web search engine is that nobody today can build such a thing completely from scratch, therefore it forces you to give up the toxic NIH mentality, which in my experience is usually driven by elitism and ego (on full display in this comment thread), not by some lofty desire to learn something new.

Re:Challenging projects every programmer should try by 59nadir on Tuesday December 26, 2023 @03:19AM (#38769836)
> The difference with a web search engine is that nobody today can build such a thing completely from scratch

I'm sorry, but can you substantiate this claim? I've seen no indication that a search engine is not buildable from scratch at all.

Re:Challenging projects every programmer should try by fho on Tuesday December 26, 2023 @03:36AM (#38769936)
Sigh ... Of to the silicone mines it is then ... again /s
Re:Challenging projects every programmer should try by isoprophlex on Tuesday December 26, 2023 @04:03AM (#38770081)
You mean, the beach?
Re:Challenging projects every programmer should try by sethammons on Tuesday December 26, 2023 @04:21AM (#38770167)
It is a joke based on needing to define "from scratch". Similar to, "how do you bake a cake from scratch? First you must create the universe." Op is gathering the raw ingredients to start fabricating his chips.
Re:Challenging projects every programmer should try by enneff on Tuesday December 26, 2023 @04:39AM (#38770254)
Yeah, that’s sand. :)
Re:Challenging projects every programmer should try by fho on Tuesday January 02, 2024 @02:51PM (#38846201)
Fair enough :-)
Re:Challenging projects every programmer should try by crazygringo on Tuesday December 26, 2023 @09:01AM (#38771796)
Assuming you get the TCP/IP stack for free, you still need to build fully-featured HTTPS and a "webscale" multi-server database for document storage from scratch. The crawler is easy and so is something like PageRank, but then building the sharded keyword text search engine itself that operates at webscale is a whole other project...

The point is that it's too much work for a single person to build all the parts themselves. It's only feasible if you rely on pre-existing HTTPS libraries and database and text search technologies.

Re:Challenging projects every programmer should try by YetAnotherNick on Tuesday December 26, 2023 @09:25AM (#38772002)
Simple methods of search like exact matching are very fast using textbook algorithms. There are well known algorithm like suffix tree which could search in millions of documents in milliseconds.
Re:Challenging projects every programmer should try by crazygringo on Tuesday December 26, 2023 @06:35PM (#38777264)
That's not enough. It needs to be sharded and handle things like 10 search terms, each of which match a million documents and you're trying to find the intersection. Across shared results from 20 servers. Quickly.

That's not a textbook algorithm.

Re:Challenging projects every programmer should try by marginalia_nu on Tuesday December 26, 2023 @07:20PM (#38777582)
Intersecting postingslists is a solved problem. You can do it in sublinear time with standard search engine algorithms.

The problem space is embarassingly parallel, so sharding is no problem. Although, realistically, you probably only need 1 server to cope with the load and storage needs. This isn't 2004. Servers are big and fast now, as long as you don't try to use cloud compute.

Re:Challenging projects every programmer should try by crazygringo on Wednesday December 27, 2023 @08:54AM (#38781911)
1 server to index the whole internet? I don't care how big your server is -- that's going not to happen.

And of course all of this is based on "standard" algorithms. But it doesn't change the fact that implementing them all to build a functional performant web crawler+database+search is a project that is larger than any one person could build from scratch.

It would only be feasible to build on top of existing libraries, which is the whole point here.

Re:Challenging projects every programmer should try by 59nadir on Wednesday December 27, 2023 @12:10PM (#38784022)
> It would only be feasible to build on top of existing libraries, which is the whole point here.

I don't think you've made a single point that substantiates that claim and neither has anyone else, really. The person you're arguing with has built (as per their own estimation) more from scratch when it comes to the actual search engine core than anything else in their own project (https://marginalia.nu/).

Honestly, it seems more like the people arguing a search engine is somehow "off limits" from scratch are doing so because they imagine it's less feasible, probably because they simply don't know or are in general pretty bad at implementing things from scratch, period.

To a large degree there is also a wide difference in actual project scope. Remember that we are comparing this to implementing Space Invaders, one of the simplest games you can make, and one that is doable in an evening even if you write your own renderer.

To talk about "webscale" (a term that is so deliciously dissonant with most of the web world which runs at a scale several 100 times slower and less efficient than things should be) is like suddenly talking about implementing deferred shading for the Space Invaders game. Even if this was something you'd want to explore later, it's just not something you're doing right now because this is something you're using to learn as you go.

Re:Challenging projects every programmer should try by marginalia_nu on Wednesday December 27, 2023 @10:11AM (#38782712)
> 1 server to index the whole internet? I don't care how big your server is -- that's going not to happen.

Well let's do the math!

1 billion bytes is 1 GB. The average text-size of a document is ~5 KB, that is the HTML, uncompressed. 1 billion documents is thus about 5 TB raw HTML. In practice the index would be smaller, say 1 TB, because you're not indexing the raw HTML, but a fixed width representation of the words therein, typically with some form of compression as well. (In general, the index is significantly smaller than the raw data unless you're doing something strange)

You could buy a thumbdrive that would a search index for 1 billion documents. A real server uses enterprise SSDs for this stuff, but even so, you don't even have to dip into storage server specs to outfit a single server with hundreds of terabytes of SSD storage.

> And of course all of this is based on "standard" algorithms. But it doesn't change the fact that implementing them all to build a functional performant web crawler+database+search is a project that is larger than any one person could build from scratch.

I'm still not seeing why this is impossible.

> It would only be feasible to build on top of existing libraries, which is the whole point here.

I don't think there are existing libraries for most of this stuff. Most off-the-shelf stuff in the search space is for indexing smaller corpuses, they generally aren't built to scale up to corpus sizes in the billions (e.g. using 32 bit keys etc.)

Re:Challenging projects every programmer should try by YetAnotherNick on Wednesday December 27, 2023 @11:39AM (#38783667)
No, it doesn't require. If you take all public web text it is just something like 40 trillion characters, which could fit in a single hard disk uncompressed including suffix tree structure.

[1]: https://arxiv.org/pdf/2306.01116.pdf

Re:Challenging projects every programmer should try by vidarh on Thursday December 28, 2023 @07:58PM (#38800620)
Yeah, it is textbook. It was textbook a decade and a half ago already.

Add docids to sorted update lists. Zipper merge and arithmetic coding once lists get large, is the textbook baseline from back then.

Tack on a skip list, and you have fast intersections.

This is well trodden ground.

Re:Challenging projects every programmer should try by yu3zhou4 on Tuesday December 26, 2023 @03:46AM (#38769990)
I enjoy reading your discussion and just wanted to add that some people write a big scale software from scratch nowadays - for instance Marginalia for web search and Andreas Kling and team for operating system and web browser
Re:Challenging projects every programmer should try by cinntaile on Tuesday December 26, 2023 @04:30AM (#38770204)
I guess the first step in writing large scale software is to become Swedish!
Re:Challenging projects every programmer should try by marginalia_nu on Tuesday December 26, 2023 @09:11AM (#38771878)
Long cold winters dimly lit by a flickering CRT.
Re:Challenging projects every programmer should try by p-e-w on Tuesday December 26, 2023 @04:50AM (#38770309)
Marginalia, which I'm a big fan of, is not "written from scratch" (it would be stupid to do so). Check the project on GitHub, it has lots of third-party dependencies.
Re:Challenging projects every programmer should try by marginalia_nu on Tuesday December 26, 2023 @07:50AM (#38771338)
I definitely lean more toward NIH than what's conventionally considered wise, but most of the time it's not NIH for the sake of NIH.

I do pull a lot of libraries, but an enormous amount of what the search engine does is very much built from scratch. The libraries generally deal with parsing common formats, compression, serialization, and various service glue like dependency injection. I think the number of explicit dependencies is a bit inflated by the choice to not use a framework like springboot, which pulls many of the same (or equivalent ones) implicitly.

What makes the search engine a search engine, the indexing software (all the way down to database primitives like btrees etc.), a large chunk of the language processing, and so forth; that's all bespoke. I think it needs to be. A lot of existing code just doesn't scale, or has too many customizations that would add unnecessary glue and complexity to my own code.

I'm going to echo SerenityOS Andreas and suggest that it's a skill like any other. If you shy away from building custom solutions to hard problems, you will never be good at it; and it will become a self-fulfilling prophecy that these NIH solutions are too hard to build.

At the same time, there's a time and a place and you should indeed be judicious as to when to roll your own solutions, but maybe that time and place is exactly in a hobby project like the ones suggested in this thread (and is how my search engine started out; a place to dick around with difficult problems).

I'd also add that being able to tackle problems yourself, rather than needing a library to do all the heavy lifting at all times, is a great enabler. Sometimes there is no adequate library, but that doesn't mean the conclusion has to be "welp, I guess we can't do that yet..."

Re:Challenging projects every programmer should try by indigo945 on Tuesday December 26, 2023 @04:35AM (#38770233)
Back when online learn-to-code courses like Codecadamy and Udemy were a fad, I remember that one of them (and unfortunately I don't remember which, and Google, ironically, turns up nothing) taught how to build a search engine in Python from scratch as a first project for complete beginners. I thought it had a reasonable level of complexity for this task.

You can still find search-engine-from-scratch courses on Udemy, complete with all the necessary algorithms [1].

[1]: https://www.udemy.com/course/build-a-search-engine-with-pyth...

Re:Challenging projects every programmer should try by universse on Tuesday December 26, 2023 @05:22AM (#38770457)
was it udacity's cs101?
Re:Challenging projects every programmer should try by indigo945 on Tuesday December 26, 2023 @05:55AM (#38770659)
Yes! Thank you.
Re:Challenging projects every programmer should try by dmoy on Tuesday December 26, 2023 @11:24AM (#38773117)
Incidentally, the first Google search result for

"introduction online cs course that uses Python the build a search engine from scratch"

is udemy CS 101

Even through my smartphone autocorrect mistakes of 'introductory -> introduction' and 'the -> to'

Re:Challenging projects every programmer should try by benj111 on Tuesday December 26, 2023 @04:44AM (#38770281)
>elitism and ego

You know those car guys who will rebuild their engine, just because? Or those retro computer guys that will recap an ancient board rather than buying a modern pc?

For you it is a job, for me it is a hobby. I have no interest in making something 'professional' I want to take it apart to understand how it works. Want to understand how a text editor works? Write one.

What component of that is ego?

It seems to me you're the elitist, you're not far off saying mere users shouldn't be allowed to modify their own software, shouldn't be allowed to install software that hasn't been okayed by the people who know what they're doing.

Re:Challenging projects every programmer should try by finnthehuman on Tuesday December 26, 2023 @09:09AM (#38771863)
> What component of that is ego?

Your lack of constraints on personal exploration in software is interpreted as hubris by people who came to software seeking high paying regimented recipe-following.

Re:Challenging projects every programmer should try by vkazanov on Tuesday December 26, 2023 @05:07AM (#38770373)
A simple search engine is certainly doable from scratch in a matter of weeks, complete with most things expected from a search engine.

Similar to compilers or tiny OSes, one can go as hardcore as necessary, or just stick to basic stuff.

Of all the typical personal challenge style projects, databases are probable the hardest to build, and even that is not impossible.

Re:Challenging projects every programmer should try by fragmede on Tuesday December 26, 2023 @06:41AM (#38770913)
making a database is easy. making a fast database is what's hard.
Re:Challenging projects every programmer should try by kragen on Tuesday December 26, 2023 @08:01AM (#38771403)
even implementing all of sql92 or datalog without concern for efficiency is fairly complex
Re:Challenging projects every programmer should try by convolvatron on Tuesday December 26, 2023 @12:07PM (#38773550)
implementing a toy datalog should take no more than a week.
Re:Challenging projects every programmer should try by kragen on Tuesday December 26, 2023 @12:25PM (#38773744)
maybe less
Re:Challenging projects every programmer should try by kragen on Tuesday December 26, 2023 @09:34PM (#38778473)
but a text editor, a space invaders clone, a tiny basic compiler, or a mini operating system is an afternoon project. a spreadsheet or a video game console emulator is maybe comparable to implementing datalog
Re:Challenging projects every programmer should try by pointy_hat on Wednesday December 27, 2023 @07:07AM (#38781202)
Also, making a correct one is not an easy fit.
Re:Challenging projects every programmer should try by AeroNotix on Tuesday December 26, 2023 @05:30AM (#38770503)
Please can you define "from scratch"?
Re:Challenging projects every programmer should try by gushogg-blake on Tuesday December 26, 2023 @09:13AM (#38771892)
I encountered some push back on this in my "code editor from the ground up" post[1]. I think the only reasonable definition of from scratch is:

Does not have domain-specific dependencies.

So a code editor based on ACE or CodeMirror would not be from scratch, obviously, but one that involves writing all of the domain-specific logic would be. Using generic libraries doesn't stop something being from scratch. (In my case Tree-sitter is arguably domain-specific, but an early version did use a hand-coded JavaScript tokeniser in its place.)

[1] https://news.ycombinator.com/item?id=34577246

Re:Challenging projects every programmer should try by jvanderbot on Tuesday December 26, 2023 @08:18AM (#38771510)
If you want to build a compiler from scratch, you must first invent the universe. Peeling back abstractions to see how things could or should work is perfectly fine, even for professionals.

Case in point, I've spent a year excising bloated frameworks from my stack at work and replacing the few corners we needed from those frameworks with, e.g. 50 lines of curl calls. The C compiles instantly and is tailored for our tiny use case, produced much quicker delivery on our one related feature we wanted, and removed chains of dependencies.

Being reliant on far-too-abstract libraries and frameworks to do simple jobs is also a curse. But nobody at work has the experience to know that curl was sitting right there on our image available for our use. And nobody has that experience because nobody took the time to build something from low level libraries. Now we know how and can make an intelligent decision without defaulting in either direction because we were afraid to try.

Re:Challenging projects every programmer should try by pipes on Tuesday December 26, 2023 @02:35PM (#38775194)
Genuine question: what value was added by getting rid of the frameworks?
Re:Challenging projects every programmer should try by jvanderbot on Tuesday December 26, 2023 @02:46PM (#38775319)
20,000 fewer lines of code, faster compile / deploy times, significantly less interfacing / translation between "their" types and "their" apis, and a much better control over types and structure across our codebase b/c we didn't need "their" types and structure anywhere. It had crept everywhere.

It's just faster, cleaner, and easier in a few cases to do precisely what you need right now, rather than anticipate a million things you might need and refactor your code to adopt a given "solution".

Re:Challenging projects every programmer should try by cellularmitosis on Wednesday December 27, 2023 @11:04AM (#38783271)
Yeah, the problem / benefit is never the one framework you added / removed, it is the mindset of reaching for another dependency as a default which leads to a behemoth which no one enjoys working with.
Re:Challenging projects every programmer should try by thomaslord on Friday December 29, 2023 @11:44AM (#38806973)
I also think a person who has had to strip out or replace dependencies is more likely to be careful when choosing them in the future. This is definitely the case for me, at least.
Re:Challenging projects every programmer should try by deterministic on Wednesday December 27, 2023 @05:48PM (#38787807)
My experience as well. The more dependencies I remove, the fewer problems I have. It is a massive productivity boost.

Having said that, there are libraries there are high value/cost. So I keep those. But the dirty reality is that most libraries are pretty bad.

Re:Challenging projects every programmer should try by phkahler on Tuesday December 26, 2023 @08:32AM (#38771599)
>> The difference with a web search engine is that nobody today can build such a thing completely from scratch

Really? I think there are a couple out there. The main issue today is scale, but you could constrain that by limiting your crawler to a fixed set of sites.

Re:Challenging projects every programmer should try by HumblyTossed on Tuesday December 26, 2023 @08:49AM (#38771706)
Well, if I’m going to build a web search engine from scratch don’t I first need to write a compiler from scratch? Which means I first need to write an editor from scratch…
Re:Challenging projects every programmer should try by Xeamek on Tuesday December 26, 2023 @09:48AM (#38772195)
While nih is ultimately dependent on multiple different aspects, I would argue that, ironically, it's more likely to create nih-qualifying product with your aproach.

Because when you write things from scratch, you actually have the space to innovate. But when building product with preexisting puzzles, there is much less space to actually make any usefull changes that would make your product actually standout from existing alternatives (which nih is all about)

Re:Challenging projects every programmer should try by datadeft on Tuesday December 26, 2023 @06:04PM (#38777048)
I think searx was largely built by a single person.

https://github.com/searx/searx

Re:Challenging projects every programmer should try by PH95VuimJjqBqy on Tuesday December 26, 2023 @02:19AM (#38769555)
> I'm more inclined to think that your comment is really more revealing about what kind of knowledge is in your own personal wheelhouse.

That's my read as well.

Re:Challenging projects every programmer should try by mattarm on Tuesday December 26, 2023 @11:44AM (#38773314)
> It's much more a matter of whether you want to do something small scale and fun, or whether you want to suck all the joy out of it by applying the same soul crushing constraints we already get paid to do in our day jobs. Bleh.

Amen. And further, what better prepares a programmer to assess the relative costs of implementing a thing vs using a library providing that thing than having attempted an implementation?

Learning by doing is a valid approach, and this can even be called fun.

Re:Challenging projects every programmer should try by tamrix on Tuesday December 26, 2023 @05:40PM (#38776876)
How about the ultimate programming challenge. Make a project that makes real money.