by monkmartinez · 8y ago · 0 comments
I am super frustrated with lack of screens for python. I don't want to pigeon hole into an ecosystem where I am limited to a certain platform like Java/Kotlin or even (dare I say) Swift (no real web, still need JS). As a single developer, mostly hobby, I want options for all the things!!!
I have been migrating my Python scraping to JavaScript with node, puppeteer, and it has been quite illuminating, and the speed is ridiculously better. Furthermore, I can easily turn my scrape into a desktop app with electron with an api that is consumed by a mobile app with react-native. Long story short, I can now think about making some of my Python ideas into cross platform desktop apps with mobile versions as well. Not super easy with Python.
The question is would TypeScript be even better for a long term bet?
If your goal is to grow as a developer, you should absolutely try it out and at least learn the basics. There are valid gripes, like some find it cumbersome for smaller/prototype projects (though I still prefer it over untyped JS even for small things), but it's probably best to try out both worlds (and maybe try out Flow as well) and make an informed choice from experience.
It doesn't make JS strongly typed though. It's still possible to compare different types, it still allows type coercion,truthiness and what not. It add type definitions, but it does not turn Javascript into a strongly typed language.
https://www.typescriptlang.org/play/index.html#src=const%20x...
So while there are still things like truthy/falsy values, the type system is stronger (not just static) in some sense compared with JS.
* stick with JS,
* learn a language that's a superset of JS (like TypeScript), or
* learn another language which compiles to JS.
If you're looking for a language that can also replace Python for you, then maybe the 3rd option above is a good bet. Something which has its own VM (or other native target), but which also can be compiled to JS. For example, Haxe, Kotlin, Nim, Go, or Dart.
1. TypeScript is just a modern expressive strutural typing system on top of JavaScript, not a full new language.
2. Modern JavaScript (es2017) is not our old JavaScript, the language matured very well. Not perfect, no language it, but as good as it get for a scripting language, and TypeScript has a lot of structure while keeping its flexiblity.
3. JS/TS really enable a Functional First, OO as needed programming style, which can greatly reduce boilerplate code and API code complexity, which in turn makes the code scale better.
Note: I have been doing Java for the last 20 years, building big enterprise Java app for a living for the last 10 years, and right now, I would say that Modern JS / TypeScript and all of its benefit, offer a better productivity environment for big app development, that traditional Java. We just ported one of our client's Java backend, 40% less code, better typed, and better scale (as most node libs are nio/async in nature)
Typescript has some advantages that are appealing to people coming from Java/c#, and it integrates sort of well into a codebase that’s a mix of JS and typescript. So you don’t really lose that much from using it. We found it relatively burdensome compared to plain JS, simply put, it made us less productive. You fix some of JSs problems, mainly typesafety, but the trade off is that you’ll need to keep updated on both typescript and JS as well as getting a more complicated approach to prototypes and testing that isn’t as smooth (at least not for us, and that may be us not typescript but it’s still something you have to account for).
If we were doing angular on the front end we might do typescript, but I honestly think we would’ve picked angularDart and flutter instead of typescript.
I don’t think you go wrong either way though, typescript has just been unnecessary for us.
With VsCode and a jsconfig.json file you can get much of the benefits of typechecking anyway.
I'm still a fan of static typing, but Typescript ain't it. I need something much simpler that isn't dragging our productivity down.
It's worth using. like flow it can validate plain js files and even supports a subset of JS doc (on that aspect I wish it didn't, I wish Microsoft established a more powerful format for type comments as an alternative to JS doc which is not well defined, but it does its job). So you don't even have to use ts files. In VSCode IDE, you can just had
// @ts-check
to benefit from typescript compiler.At the end of the day, yes, JS today is a safe bet. You can develop native apps with react-native, desktop apps with electron even attempt to include 3rd party language libraries through WASM.
Is it faster than Python? I don't think so, but it's a trade-off. Javascript is ubiquitous now. I say it as someone who still kind of despise the language yet it's productive.
The other route to take is to try to follow the cutting edge of webassembly, so you can continue to use a lot of python. Python is probably going to be first in it's class of languages for support at each step, but it's class is not as ideal for webassembly as non-gc strongly typed languages which are ironically less like Python than JS!