11 ms·
The types are what give it structure. Types are the structure. When you create a type, you are saying in concrete terms "this is exactly how things happen and n
by WayneBro 10y ago
The types are what give it structure. Types are the structure. When you create a type, you are saying in concrete terms "this is exactly how things happen and nothing else".
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.
- rkwz 10y agoI don't understand. > 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".
- pixie_ 10y agoIt is pretty much impossible to have any sort of inferred structure from plain javascript. The reason you can use super powerful tools to refactor, rename, and find all references across files in typescript is because the IDE can build a 100% accurate data model of your code base when it's written in typescript.
- chc 10y agoYou can do that kind of stuff in dynamic languages like JavaScript, Python and Ruby. Check out JetBrains' editors.
- domlebo70 10y agoYeah, but at the end of the day it's a guess. Nothing more. The IDE cannot prove that it's change all instances of the "thing" being passed into a function, for it's just using names and heuristics to correlate them and derive meaning, not an actual mapping.
- lkitching 10y agoI use IntelliJ when writing Ruby, and the navigation and refactoring tools are much less reliable than those for Java. Finding symbol references can return a lot of false positives since it cannot use the type of the receiver, and a lot of the refactoring operations are not available.
- pyrale 10y agoJetbrains' editors for e.g. Python help me significantly less than their editors for e.g. java. 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.
- DCoder 10y agoTo do things like that in a dynamic language, you need to either infer types somehow, or rely on metadata like JSDoc, beyond the language itself, and that sucks – if another developer works on the project with a dumber IDE, their code will probably lack such metadata or it will not be entirely correct. 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).
- lloyd-christmas 10y agoI use Webstorm. When we switched to Typescript, it made navigating and error checking dramatically faster.
- caseymarquis 10y agoI agree with everyone else, I don't find Webstorm's js refactoring to be anywhere near Jetbrain's static offerings. And the js auto-completion is about the same as Atom's autocomplete-plus applied to generic text (which is really great, but nothing like static type tooling).
- smt88 10y agoWhen you use TypeScript, you don't have to organize your program any differently than you would in JavaScript. 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.
- deleted 10y ago[deleted]
- icholy 10y agoIt doesn't add structure, it just makes the existing structure obvious/explicit.
- ehnto 10y agohttp://www.spaceref.com/iss/ops/sm.life.support.book1.pdf http://www.spaceref.com/iss/ops/sm.life.support.book1.pdf A guide to the ISS personal hygiene facilities and operations. I couldn't help myself...
- deleted 10y ago[deleted]