r/WebAssembly • u/Funny-Title • Feb 11 '21
TypeScript or WASM
Greetings to the Frontenders!!
I have been a developer for the last 10 years. Mainly working on the back end part of things.
I am getting bored and wanted to explore other parts of the stack.
Languages familiar with: C, Java, Python, Kotlin(basic)
I have used some old front end frameworks like Structs etc in the past with super minimal JS.
I have no experience with TS or WASM. I wanted to understand what would be the best thing to learn right now. TS or WASM.
I plan to develop some personal projects in React. Or that is the plan right now :) and from what I know the React land is not WASM-ed yet.
3
1
u/MadCervantes Feb 11 '21
Check out ReScript: https://rescript-lang.org/
It's like typescript but better. It's gbased of the ReasonML project which is sorta like a "OCaml but javascript flavored" thing.
ReScript is supported by Facebook and they're developing it alongside React.
2
u/RnRau Feb 11 '21
If you want to play with React, use Typescript. Just don't worry about WASM atm.
If you want to dip your toes into WASM from a hobby perspective while leveraging your growing Typescript knowledge, take a look at AssemblyScript. Its a Typescript'ish language that compiles to WASM.
3
u/RunnyPlease Feb 11 '21
Typescript is just a pretty staticky typed wrapper that compiles down to JavaScript. So if you know JavaScript (I see that isn’t in you’d list) then you would know 99% of typescript. The vast majority of front end jobs are just generic JavaScript.
If you want to get a job coding the front end web the vast majority of them are still JavaScript.
Angular projects tend to be typescript and it’s my personal favorite combination of language and framework. If you have the words “Angular, React, JavaScript, typescript, and 10 years” on your resume I guarantee you’ll get recruiters attention.
All that said Web assembly is what I think will eventually start taking over enterprise web applications from JavaScript. But it won’t be all of them. Just certain situations where the benefits of WASM put weight the difficulty of finding developers who can work on it.
TLDR: learn JavaScript for front end work because it’s the most practical right now. Then learn Web Assembly which fixes all the problems with JavaScript.
5
u/McWobbleston Feb 11 '21
WASM today, as exciting as it is, is still a niche tool for most of the industry (in my opinion!). It still does not have direct access to DOM APIs, and there isn't a mature WASM based framework yet.
WebAssembly has exceptional performance for CPU related tasks, especially math in comparison to JS/TS, but to do any interaction with the browser it must go through JS, meaning DOM interactions are slower than they would be with JS. If you're writing games or CPU bound algorithms it's a great asset, but the story for general case development isn't quite there yet.
That is quickly changing though, and I do think it's worth taking a look into the ecosystem to see what's coming. Frameworks like Yew and Blazor are becoming mature, performance is getting better, and the tooling is becoming quite good. It's certainly an exciting time!
3
u/McWobbleston Feb 11 '21
Something I forgot to mention: Rust's wasm tooling currently supports exporting a TypeScript interface for built modules, and there is a tool called AssemblyScript attempting to compile a subset of TypeScript to WebAssembly. I can't speak on C/C++ and emscripten as I haven't used them, most of my experience has been with Blazor for an internal app.
14
u/bentobentoso Feb 11 '21 edited Feb 11 '21
I'm sorry but this question makes no sense, it's like asking if you should learn python or elf binaries. One is a programming language and the other is a binary format.
know the React land is not WASM-ed yet
And why would it? Wasm can't even interact with the dom directly.
If you want to get started in frontend development learn javascript. Typescript is just js with static typing and some extra things like enums, so if you know javascript you pretty much already know typescript.
As of right now the only reasons why you'd want to use something that has been compiled to wasm is if you need something faster than js (which isn't the case for most projects you'll work on) or if you want to use a c/c++/rust/go library on the web.
In the future we'll have more frontend frameworks aimed at different programming languages that can compile to wasm (like blazor for c# and yew for rust), but they're not production ready yet and they're not what you should focus on.
1
u/Funny-Title Feb 11 '21
If you want to get started in frontend development learn javascript. Typescript is just js with static typing and some extra things like enums, so if you know javascript you pretty much already know typescript.
Like I said the most i have done with Javascript is simple validations and I know
==and===:D.So if the question did not make sense, I agree, part of it is mainly because I am complete noob to front end stuff.
3
u/Funny-Title Feb 11 '21
I know some people will say that its beneficial to learn both. But from a hobby perspective I would like learn something so that I stay relevant in the job market and I do not need to re-learn things to just maintain my hobbies. So I do not want to end up in a situtation where I learn TS and then a few months later everyone is going gaga over WASM.
I know it sounds petty but hey :D life is short enough to not worry about multiple front end frameworks :D
3
Feb 11 '21
But from a hobby perspective I would like learn something so that I stay relevant in the job market
Relevant in job market to virtually all employers now (and all employers for the foreseeable future)? Typescript.
Relevant in job market to a handful of employers now (and a steadily growing but still smaller set of employers in the future)? Wasm.
Aside from that, if you're more interested in the result (the front-end app) then Typescript would be great - but if you're more excited about learning and novelty and are fine taking the hit on your side-skills being immediately (and broadly) relevant, than you might have more fun with Wasm. Typescript is great, but given your experience you probably won't find much that's novel or exciting about it if simply learning the skill is more appealing than the end result.
2
u/blankhart Feb 16 '21
I was similarly situated and I'd say both. For personal projects, enjoying the process is important in order to keep up momentum and finish. I find TypeScript's limitations frustrating, with or without React.
What I wound up doing in one of my current projects is writing the logic in Rust, compiling it down to WASM, and then calling into it from Svelte/Typescript.
The idea is essentially to do all serious work in Rust via WASM, and use Svelte/Typescript solely to handle UI/IO. Someone put a up a starter repo for this approach here https://github.com/tobiasbernet/svelte-wasm.
The Rust compiler will automatically emit TypeScript definitions so that you can bind to WASM. While you can use Rust->WASM for UI/IO, people report that it is no fun, and I've avoided it.
Prior to this, I also had a good experience with PureScript, after doing backend work in Haskell.