André Staltz Profile picture
Feb 19, 2018 17 tweets 4 min read Read on X
Computer Science and why it's necessary even for web developers

I know that in some countries a degree in CS is expensive or unattainable, and that some companies do unnecessary algorithm interviews.

This thread is not about degrees or interviews, it's about CS itself.
CS is important because of general concepts and patterns that you will find everywhere when programming.

It's vital to have some knowledge which is *indirectly* applied.

E.g. trees, graphs, data structures, graph search (breadth-first, depth-first), languages
Data structures are ways of organizing data, e.g. in JavaScript:
- Array
- Object
- Set
- Map
Some data structures are "trees". 🌳 You can find them everywhere:

- Simple directories in the file system
- JSON is a tree
- HTML is a tree
- DOM is a tree

Some data structures are "graphs" 🔗:
- JS Objects (can have circular refs)
- GraphQL ( graphql.org/learn/thinking… )
It's not enough to just organize data, we also need to read and update data inside these structures:
- Array has push/pop
- Object has get/set through [ ] brackets
- DOM has appendChild etc
- GraphQL has mutations
Even though there are many data structures, certain read/update patterns are common because many of these can be classified as trees or graphs or lists.

It's great if you can learn strategies for trees so you once you know how handle JSON, you can handle the DOM, both are trees.
Hey, that's actually the Virtual DOM! A tree-structured JS object representing the desired tree-structured DOM
Sometimes you will need to do advanced search on these data structures.

npm install does an advanced graph search, while creating a *tree* (package-lock.json). Usually if some processing takes a lot of time (npm i), creating a temporary data structure (package-lock) helps.
Every tree is a simpler type of graph, so that's why processing package-lock.json is faster than processing the dependency graph from zero.

Computation can be light/heavy in two basic dimensions: time spent versus storage spent. There's a whole subfield dedicated to heaviness.
But graph search methods are usually simpler, and are one of these two:
- Depth-first (prioritize going deep)
- Breadth-first (prioritize going evenly through all children)

Maybe you've found a bug once where one of these modes was the wrong choice for the use case.
For instance, even if there are no explicit graph data structures in this #RxJS topic on schedulers, often people get a bug because the default scheduler is depth-first, and they could choose a breadth-first scheduler:

github.com/ReactiveX/rxjs…
Or maybe once you tried to parse some HTML with regex.

With some knowledge of formal languages, syntactical analysis, grammars, and compilers you could save hours of regex attempts by knowing that it's mathematically impossible to parse HTML with regex.
All of this is big picture knowledge that will be useful forever, no matter what's the hot framework or library of the year.

I don't want anyone to feel pressured to get a degree, I just want to encourage reading on Wikipedia basic CS concepts.

Have a nice week! 💾
Oh more juicy examples:

Ever built an array B based on another array A?

const B = []
for (let x of A)
B.push(`${x} €`)

That's a "map" operation:
B = A.map(x => `${x} €`)
Ever used an if inside a for loop?

const B = []
for (let x of A)
if (x < 100)
B.push(x)

That's a "filter" operation:
B = A.filter(x => x < 100)
What if you would create a DSL (a language) that allows you to pick data from a database using Map and Filter etc?

- SELECT == map
- WHERE == filter

Oh cool that's half way to recreating SQL

It's rooted in relational algebra.
Pretty much anywhere you look in programming, you'll find reusable patterns for information processing. Those patterns are Computer Science.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with André Staltz

André Staltz Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @andrestaltz

Aug 1, 2018
At #DWebSummit, @nicopace notes that "people in remote communities want to connect with each other, not necessarily to the internet".
@nicopace There is a unique value in keeping these communities "disconnected", to preserve their cultures against the monoculture on the internet.

This is the opposite strategy of what Zuckerberg wants to build in the Global South.
"There is no decentralized web without owning your infrastructure." @nicopace
Read 5 tweets
May 10, 2018
The business model of the Internet is intermediation.

Google Duplex (Google Assistant capable of making calls on your behalf) is branded as an "assistant" but it's in the long run a middleman: something that both consumer and producer will consider a necessary evil.
Consumers will consider the assistant necessary because they'll be dependent on it, either because they forgot how to research info on their own, or because they are time deprived.
Producers (small businesses) will consider the assistant necessary much like how Google-first SEO has become important for small business.

Google is migrating from Search to Suggest but they're not changing their middleman status: they'll influence small bizs to be "compliant".
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(