r/AskComputerScience • • May 27 '21

Seemingly arbitrary tasks that are actually really hard.

I'm sure we're all familiar with this XKCD. In the spirit of it, I wanted to pose the question:

What's something that seems, to anyone not familiar with CS, like it should be simple, but is actually really hard or complicated. Fun stories relating to this are also appreciated.

41 Upvotes

35 comments sorted by

View all comments

Show parent comments

4

u/gokstudio May 27 '21

I'd really love to learn what's the best ways to do these tasks are. Any resources to learn the implementation details of these features that you recommend?

Just discussions of the data structures and algorithms should be fine

5

u/claytonkb May 27 '21

I think if you read any in-depth article that delves into the guts of Vim or Emacs, you're going to learn about these topics. You can start with Piece table Wiki and chase references. A brief web-search turned up this project but I've not reviewed it so I can't give any recommendation. Based on a brief glance, it looks like a great place to start if you're familiar with C -- you'll get a feel for the low-level problems involved with the naive solution which will give you an increased appreciation for more sophisticated solutions. Hope that helps!

2

u/gokstudio May 27 '21

Thanks! Will have a look

1

u/beeskness420 May 28 '21

Not that I know anything about text-editors, but I’ve heard of ropes used in that context.