Note that while this all is not necessarily about types, this is about documenting the data structures - and good type systems enable you to do so in an unambiguous and even machine-checkable way.
1975: There's a famous quote in "The Mythical Man-Month" by Frederick Brooks:
Show me your flowcharts and conceal your tables,
and I shall continue to be mystified.
Show me your tables,
and I won’t usually need your flowcharts;
they’ll be obvious.
Note that this is old language from the 1970s, where "tables" roughly means "types definitions" (or comments describing the structure of input and output values, think of database table definitions) and flowcharts roughly means "function definitions" (think of hand-written flowcharts written next to low-level code to make all its GOTOs understandable).1989: You can find a similar statement in "Notes on Programming in C" by Rob Pike:
Data dominates.
If you've chosen the right data structures and organized things well,
the algorithms will almost always be selfevident.
Data structures, not algorithms, are central to programming.
Note that Rob Pike refers directly to Frederick Brooks.1995: Frederick Brooks reiterates this statement in the second edition of "The Mythical Man-Month" (20 years later).
2003: The same idea is also stated as one of the basic design rules in "The Art of Unix Programming" by Eric Raymond:
Rule of Representation:
Fold knowledge into data, so program logic can be stupid and robust.
Note that Eric Raymond refers directly to Rob Pike.2006: Another quite famous quote from the Git mailing list by Linus Torvalds:
Bad programmers worry about the code.
Good programmers worry about data structures and their relationships.
And so on.(BTW, does anyone know about a similar quote before 1975? Or a popular reformulation after 2006?)
I have found a lot of bang for the buck in software development comes from "the schema". I can use them to automatically enforce the runtime contracts between my code and my consumers'. As a communication mechanism between myself and other developers, the well-annotated schema builds an unambiguous picture for everyone of the entities, relationships w/ restrictions, and cardinalities in our systems.
At the boundaries of our microservices, we JSON Schema validate messages before they are sent on the service and upon receipt by the client (at least in the non-production environments.) We use the schema to guarantee the services and clients are always "speaking the same language" even when teams are releasing versions of their code at different times.
Just take a look at the data division of COBOL. This has been very clear for a long time.
In a related note. Databases schemas usually outlast applications. I highly recommend taking a look at database refactoring.
Type and reference checking creates the walls your code must stay inside of otherwise there are compile errors. The compiler enforces a certain structure on your code that you must adhere to in order for the compilation to succeed.
Think of it like a coloring book where TypeScript keeps you inside the lines. Ever see a three year old's coloring book? :p
This is very useful information for a large project. Think of it like a map. You don't need one for your house, but you need one to walk cross country. Or like NASA procedural manuals for something normal people don't need a guide for...like an astronaut taking a shower or something.
> Types are the structure. When you create a type, you are saying in concrete terms "this is exactly how things happen and nothing else".
Types make the interface concrete - which is better for compiler/interpreter (catch bugs) and better for developers (easy to understand instead of guesswork)
But when I think about "structure", It is usually about how the codebase is organized. How different modules interact with each other and is the flow of the code easily understandable. This could be easily achieved without Types.
Maybe it's just my interpretation of the term "structure".
I have been using IntelliJ daily for the last five years for PHP, JS and TS development. For PHP, I write typehints and PHPDoc wherever possible to help the IDE make sense of things. For JS, I tried doing the same with jsdoc but it didn't work out, and I have decided to avoid any automated refactoring or even autocomplete, it's far too fragile. For TS, using the types in my code makes the IDE smart and reliable, although IntelliJ's support for type inference in TS is still far behind VSCode.
Special mention here goes to Magento developers, whose PHPDoc, 98% of the time, is either lacking or outright incorrect (referencing classes that don't exist – incredibly frustrating).
Not that it's a bad thing, but basically Pycharm is an editor with some nice-to-have Python env integration, linter, etc. IntelliJ has significantly better refactoring tools.
If "structure" means how the directories and files are organized, then TypeScript makes no difference. I personally use the outDir setting in my tsconfig.json file to separate my JS from my TS, but not everyone does that.
If "structure" means "paradigm" (such as OOP), TypeScript might make a difference. You might find, for example, that functional programming makes more sense than object orientation to you once you have types. It really depends on you. Again, there's no real reason you'd change your preferred paradigm.
If "structure" means the types themselves (the structure of your data), then TypeScript isn't changing anything. It's just documenting your intentions in a way that other people and the compiler can understand.
A guide to the ISS personal hygiene facilities and operations.
I couldn't help myself...
Typescript just gives you static types and classes. I can understand "classes" make the code more modular and thereby more structured, but can't you already do that using ES5 "class"? Types help in catching errors early and can help in documenting the interface of the methods etc.
Also, if the other problem was isolating the scope of modules and dependency injection, it could be easily done using Requirejs and all the modules could be concatenated during build time. Webpack is a cool tool, but given the nature of its documentation, the maintenance would be really costly in the long run. Requirejs is just more established and satisfies all the author's requirements.
It would've been really helpful if the author had included additional reasoning behind the choices made.