What’s happening?
Same question
I like TypeScript for its types and type-checking, but I also want to write JavaScript to avoid having a local build step, and having to wait for things to transpile/compile/etc when running locally. I have a pretty large project where I’ve gotten both worlds by just using JSDoc and only using TS for type-checking. VSCode still offers built-in type-checking with JSDocs and ofc the type-checking can also be run separately if needed.
Fuck typescript.
(30,27): error TS7006: Parameter 'fuck' implicitly has an 'any' type.
Error: Cannot read properties of undefined (reading 'fuck')
My issue with typescript… and, correct me if I’m wrong… is it doesn’t exist without Javascript. Typescript needs to be compiled down into Javascript to be run. It has no stand alone interpreter (that I’m aware of) and definitely not one baked into web browsers or NodeJS (or adjacent) tools. In essence, Typescript is jank sitting on top of and trying to fix Javascript’s uber jank, simultaneously fracturing the webdev space while not offering itself as a true competitive and independent language for said space.
That’s my amateur two cents for what it’s worth.
Typescript doesn’t have strong typing but static typing still gets you really really far. It means you need to be more careful with your io and avoid dangerous type assertions, but I don’t think that’s a bad thing. Having used typescript an absolute ton, the only real jank I’ve encountered is from bad library typings that either use it lazily or incorrectly, but for code bases that use it through and through it has been smooth sailing, and having professionally used both traditional static typed languages and dynamically typed languages, I really enjoy typescript’s type inference and structural typing. I think you should give it an honest try before judging it. But that’s just my 2 cents as an industry professional who has used many languages and have been programming for decades for what it’s worth.
I agree.
I’m a hobbyist. I don’t work on really large or complex projects. I just want to get the most productivity for my spare-time-dabbling and having tried a few times to get into typescript it seemed to create more “extra steps” for me than it saved.
deleted by creator
I don’t think it really fractures anything considering you can call a ts package from js without knowing. The other way also works with third party typings in DefinitelyTyped.
It really just adds a bit of extra type info into js, looks like js, and transpiles into js that looks almost exactly like the input, including comments and spacing and such if you like, so there isn’t any lockin.
There isn’t any competition, it’s just an extra optional tool for the js ecosystem in my eyes.
The transpilation that typescript does doesn’t really have anything to do with typescript, it’s just there because typescript wants to support the latest ecmascript features, so transpilation is necessary for that, but technically you could simply strip out the type info and have another transpiler like babel handle the backwards compatibility. I think there are a few minor exceptions to that, like enums. There was even a proposal to add some typescript types to native JavaScript that would be ignored by the interpreter and just act as comments.
I mean, tsc without any of the backporting functionality is still a transpiler since it goes from a high level language(ts) to another high level language(js). Transpilation as a concept doesn’t imply that it is for backporting language features or that the source and destination languages are the same, just that it is a transformation from source code to a similar or higher abstraction level language source code
Yes, it’s still a transpiler, I’m not saying it isn’t, but what I mean is that it doesn’t add any functionally specific to the typescript language. There’s a transpiler for TS that doesn’t even do any type checking at all and just does the type stripping and back porting. But of course, that’s not why people use typescript. All the features that are actually important to typescript could be done through a linter instead. If type annotations were added to JavaScript you could get most of typescript’s features with linting rules and just handle back porting in a more standard way.
I think too many people ITT are conflating Typescript with Typescript frameworks like Angular.
As a professional with 25 years of experience I agree with you. The entire modern architecture was created by people who don’t like simple things that work. I’m pretty sure there are a couple of high ranking master developers sitting at the head of W3C competing to create the most convoluted system possible.
The fact that TypeScript doesn’t attempt to obfuscate JavaScript, and just fills in the gaps, is what makes it the best solution to the problem.
It’s not a separate language, it’s Javascript tooling
I’ve used JavaScript since its creation. I would describe typescript as JavaScript as it should have been. I’ve always actually liked JavaScript’s simplicity, but I’ve never liked its lack of type safety. At its core, JavaScript has a tiny conceptual footprint, and that’s actually pretty refreshing compared to other very complicated languages. But it was plagued with terrible implementations and the inherent messiness of dynamic typing. I’ve watched it evolve over the years and it’s improved beyond my greatest hopes. Between the advent of transpilation, tooling, and typescript, I’m very proud of where the language has gotten to. Having made websites in the 90s and 00s, I feel like people don’t realize how much work has gone into getting the ecosystem in a much better place.
You are correct.
That says I would never ever EVER start a project without TS.
It’s like coding with hands vs coding with your elbow.
I also don’t want to compile my C++ code myself. I’m pretty happy with letting a compiler do it’s job…
I really don’t get how people can feel more productive in JavaScript. With typescript the code practically writes itself. Sometimes when refactoring I’ll change a functions input and output signature and just fix compiler errors until it stops complaining, and the code just works without me having to really even think about what the code is doing.
Any time I’m forced to go back to js I feel like I’m going crazy trying to keep track of what’s in all the variables. With typescript I can use more powerful object structures without having to constantly double check where they came from.
Just fyi, while they don’t help with running TS in the browser, the Bun and Deno runtimes both natively run TS without any compilation.
That’s not true, deno compiles TypeScript to JavaScript, it just does it transparently. The code still runs on v8.
V8 also doesn’t run js, it does some byte code compilation stuff amongst other things, then interprets that. But that’s all a bit pedantic too, V8 runs js, deno runs ts.
fwiw https://deno.com even has as one of their first bullet points that they have “native support for TypeScript and JSX”
Sure, but part of the claim was “without any compilation”. But bun/deno do compile TS into JS.
Like 2023 CoffeeScript?
What we really need is a browser that runs something other than Javascript. Until then, stack of jank it is.
WASM?
Is that a standalone thing? This is obviously not my specialty but I thought it was part of Javascript.
I’ve never worked with it and don’t know in detail, but it lets you compile several languages into web based client/server code (basically, converting other languages into website code). Works with C, C++, C#, Go, Rust, Swift, etc)
I’m kind of a beginner… Can someone explain why you would make/use/have a dynamically and/or weak typed language? Is it just to not write some toInteger / as u64 / try_from()? I mean the drawbacks seem to outweigh the benefits…
They used to be more attractive around the 2000s, before type inference became commonplace and when IDEs/editors were still a lot less powerful.
As for making a dynamically typed language, to my knowledge, they are actually easier to create than statically typed languages…
If you are writing small and simple apps it will give you more velocity and much less boiler plate.
As apps grow it becomes harder to keep track of things and can quickly grow into a mess. You then start to need external tools to give you the features of a strong static type system.
Also from a web point of view you don’t want the website to crash and burn with every error. JS will power through things like invalid types. Imagine if any error caused the website to just stop.
But a statically typed language would catch those errors before it even compiles…
The fact it doesn’t need to be compiled is also a big reason why it’s used on the web.
But I absolutely agree. I’m not a fan of dynamic typing at all.
Si you say I should use python for websites?
Unsafe rust is your best bet.
There’s no real alternatives to JS “for websites” (meaning on the frontend, the part of your code that gets executed on your client’s browser). That’s what JS was invented for and what it does best.
I say “no real alternative” because technically we also have WebAssembly, which is a tool that allows you to run code written with any language on the web, but if you indeed are a beginner approaching to web development you should just forget about this for now and stick to JS as you learn.
Of course this doesn’t mean that you can’t use Python on your backend, your server.
Why should beginners approaching web development stay away from WASM? I’ve used it a few times to create online demos of software I made in Rust and it was a very simple and painless experience to get it working in a website. I consider myself a beginner and I have not run into any issues with it so far.
WASM is simply further down the rabbit hole for someone who is new to programming (but not someone who’s already a programmer and just doesn’t focus on web dev today). You are likely far less beginner than you think if you’re making decisions like “I’m going to compile my software written in Rust targeting WASM so I can demo it.”
I prefer using JS because I can see the errors, while having to figure out which part generated the problematic JS code with errors when using something else.
The typical arguments for a dynamic typed language are that it takes less time to write something in it.
The benefits of static typed languages are that your development environment can be a lot smarter (ironically enough leading to faster development speed) and several classes of bugs being unable to happen. In a statically typed language, the IDE can detect if you’re trying to call a function that takes a number but you’re actually providing a string. In this case the IDE will let you know and you can immediately fix silly mistakes like that.
Typescript is an abomination. Been writing JS just fine for 30 years without it.
Typescript is an abomination.
Why? (I’ve only used vanilla JS and jQuery.)
Not OP, but generally the arguments I’ve been told are:
Microsoft is an abomination (true).
“Don’t make me explicitly state types; it is too confusing!” Installs 20 libraries including fucking pad left to eek out basic functionality.
Strongly typed haters are right up there with curly brace haters.
Microsoft is an abomination (true).
Reflexive MS hatred is just as dumb as any other kind of reflexive hatred. TypeScript is free and open source, so what’s the danger?
javascript but more for philosophical reasons. when projects use typescript they always get focused on writing more scripts rather than optimizing HTML/CSS. Too many times I’ve seen overly complex scripts trying to solve what a properly arranged div and css tag have already solved.
I’ve been dealing with this at my job because a layout library was deprecated and is used throughout our codebase instead of proper css. Came to learn that my whole team doesn’t like/know css, so they used this library that used angular directives in the html instead. We had multiple giant scripts for arranging elements in a grid that changed based on screen width
I’m so sorry
There are some cases where this is a serious issue that can’t be solved through pure CSS. Once container units are finally approved though, that will solve quite a few problematic layout issues in CSS.
Aren’t these already supported in all major browsers? Also I agree, but in this case we did not even need a container query, just a media query
edit: https://caniuse.com/css-container-query-units about 85% of users have browser support for container query units
Yes but the support is very recent and hasn’t been fully accepted yet. Therefore, I can’t use it in enterprise. I have to wait for full adoption.
I learned typescript because so many authors are using it.
I think it’s like jQuery. Learn it because you’ll have to debug someone’s code one day.
All the stuff I write is personal tools anyways so I do the same. They’re small anyways.
Segment 0xA000 gang
I’ve been designing CPUs and writing machine code and assembly for the last month and it’s been a blast.
Truthy
!&&
I prefer JavaScript personally, but it’s time to acknowledge that TypeScript has won. If you want to contribute and succeed as a developer in the JS ecosystem, you need to learn TS, like it or not.
I wasn’t sure if this meme worked until I saw what he was eating
Me: 2024 is finally going to be the year of WASM, boys!
Unpopular opinion: I hope it’s going to be a flop (apart from the few use cases where it does make sense). The limitation of having just JavaScript ensures level of interoperability which is IMHO one of the big advantages of web as an application platform. If WASM becomes successful, it will fragment the web.
I definitely feel you. Not sure WASM is the answer, but it’s still neat.
And then there’s me, missing flash :(
Flash and AS3 was so much fun to work in. I completely understand why the industry moved away from it but even today we have yet to fully catch up to all the media animation and programmatic features it provided all in one. RIP.
Starfield has a bunch of AS3 and Flash files. I’ve been hacking it all week.
And, uh, I use vanilla JavaScript with Typescript checking via JSDocs.
I still have a hobby website with an AS flash animation on it that I don’t have the heart to get rid of. It was so cool.
Thanks, will check it out
That’s awesome.
But I’m picturing you keeping a retro computer to load it on and enjoy it.
Have you tried porting it to Haxe? It’s what I found whose selling point was “programming for those that know AS3”
Thanks, I will look into that
I just wish WASM could replace JS rather than merely augment it for non-DOM work.
You can have frameworks which fully generate the JS DOM code for you, allowing you to write complete single-page applications without writing a single line of JS.
I’m using the leptos framework (Rust) and really like it so far. Not a single line of JS, not even npm as a dependency in that project.
Yep, that’s the framework, I’m using, too. But most frameworks in the Rust ecosystem can do DOM interop, as the heavy lifting for that is provided by the
wasm-bindgen
library.
vanilla javascript? what are you, fucking Amish?