Anyone had any luck with using Typescript (compiles to JS) to develop plugins?

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
Because, frankly, "pure" JS scares me.


If so, can you give me few pointers?
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,440
First Language
French
Primarily Uses
RMMV
Typescript scare me ! loll
 

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
A bit, yeah, but it's still less scary than Javascript. Protip: If your language needs a "===" comparison operator in addition to "==", it sucks big time.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
You should learn JS before going to typescript. As for JS having an `===` operator(Should only ever use ===), hardly means it's a crappy language, and if you don't want to learn JavaScript because you heard that it "sucks" then you probably don't have the right mindset to learn JS anyways. JavaScript takes a special kind of mind, one that like new ideas and who can utilize the dynamics of JS.

Those who learn programming on other languages first tend to hate on JS because their minds are stuck on a specific way of programming and JavaScript totally annihilates that way of thinking. JavaScript is for those who can quickly adapt and change their way of thinking during whatever it is their developing.I mean the mere fact I can use both oop and functional programming to take control and solve any problem is epic in my eyes and many others.

Typescript on the other hand learn JS before Typescript, considering it compiles into it, it would be a good idea to learn it. I'm not saying Typescript is bad but it has its uses elsewhere, like really large applications or those who I talked about above and they just need types to satisfy their way of thinking.

And for a little video from my favorite Youtuber about his thoughts on Typescript

And another favorite of mine and he talks about the how overrated types are and how JavaScript can handle large applications no problem.

"Type Correctness does not guarantee program correctness" - Eric Elliot
 

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
Yes, static types are overrated.

I guess you want people breaking your software (or you yourself after months of not touching it) because someone accidentally put a string in a place a number should go to.

Static types exists for a reason. I mean, for the computer everything are numbers anyway, but data validation is important and that's why you should get an exception when you try to put round peg into a square hole (e.g. putting a bool where an object should go into). Otherwise you get stuff like in the video I've linked in the OP.

Another problem with dynamic variables is that you can break your stuff if you happen to misspell field. So e.g.

Code:
if Actor.hp<30 {
Actro.hp=30; //keeps actor health at 30 hp minimum
}
But what's that! It doesn't work and compiler/engine doesn't complain! Then after a weeks looking for a cause you see you've misspelled "Actor". Whoops.

And before you suggest something like hungarian notation... Ew.

As for ===... The mere existence of it is a problem. If == was broken, its behavior should have been changed instead of adding yet another equality operator. If === turns out to be broken in future as well, they'd probably add ====, then ===== and so on instead of just fixing operators they already have.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
The only problem I see with JavaScript is not the language itself but the programmer using it. If everyone would write unit tests first then the code, there wouldn't be any problems with types. In the test your write the result and what you expect from that result, if you do this for all your code and it's best practice do be doing it anyways, especially since JS is not a compiled language, then you should not have any problems with your code especially types.
Now with the latest ES6, It's an eslint rule for me to always use `const` or `let`(in rare cases) and never use `var` . const will stop you from switching types, you cant reassign a const variable to a new type it has to remain the same type. This helps a lot for those so attached to their precious types lol
Overall though, I'm not trying to debate weather or not a language sucks or what classify why a language sucks because frankly JavaScript does not suck, its actually amazing to use if you can get past those mental blocks. I'm just trying to show you that you are letting ideas from other people stop you from trying a language that many people love and enjoy and use on a daily basis, even for people who written in other languages most of their lives, like Eric Elliot.
 

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
Yes. And how can you know the unit test itself isn't buggy?

//edit: There's a very smart comment on Elliott's talk. Have you read it (emphasis mine)?
Michael Ahlers said:
There's a lot of good content here about best project and development practices in general. However, this talk is also full of advice that's either poor or impractical, all based on a straw man that type correctness guarantees program correctness. JavaScript is a language I use every day to build large, modular applications, and it's one of my favorites. Many of its features Elliott stresses in this talk are incredibly powerful. But dynamic typing is its greatest weakness, a weakness that allows incorrectness to easily and quietly slip in to large applications. Meanwhile, several modern languages (e.g., Dart, Scala) offer its benefits with all the safeguards of static typing. Developers aiming to achieve mythical 100% test code coverage—which this talk claims is necessary for confidence in type correctness with JavaScript—are effectively (and unproductively) reinventing compiler type checking.
 
Last edited:

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
Test runners are designed to help with that, the same way a compiler reports errors and warnings the test runner will handle everything for you. All you need to do is provide the code and a few unit tests, ie check for failing, truthy, falsy, deep equals, and all that fun jazz, obviously different for each piece of code. The best part is it all happens in real-time, using an editor like vscode gives me the built in terminal for watching my tests run while I write code,, I fail, refactor and repeat until it passes.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Code:
if Actor.hp<30 {
   Actro.hp=30; //keeps actor health at 30 hp minimum
}
But what's that! It doesn't work and compiler/engine doesn't complain! Then after a weeks looking for a cause you see you've misspelled "Actor". Whoops.
Not sure what you mean by the compiler/engine doesn't complain, because you would get an error that 'Actro' is not defined.

Unless of course, you defined both 'Actor' and 'Actro' which would produce the same risk of typos in any language.
 

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
Nope, in Javascript (as well as in other dynamic languages) the variable is defined the first time it's used. That's what so dangerous about them. You may misspell a thing and don't find it as the cause for the bug you're experiencing until much, much later, with a lot of frustration in between. I know it first hand from personal experience.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Nope, in Javascript (as well as in other dynamic languages) the variable is defined the first time it's used.
True, and I agree with your general principle. However, in JS you can't define an object property if the object isn't already defined.


Perhaps you could try your example yourself, press F12 on your browser and paste this into the console, and tell me if you get an error.

Code:
const Actor = {};
Actor.hp = 29;
if (Actor.hp < 30) {
   Actro.hp=30; //keeps actor health at 30 hp minimum
}
 
Last edited:

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
Your lack of JavaScript knowledge is showing. Again probably because many people can't get past the mental block, they talk and talk about the downsides without actually ever learning it. I promise you will love JavaScript if you give It time and take the time to learn it, if you take anything from what I said in this thread I hope it's that . You can never truly see JavaScript for what it is until you try it.

Use strict is probably the most important step and is enforced with eslint rules. This prevents your actro typo issue with normal variables. Also as Aloe Gunver says, you can't add a property to an udefined object.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
484
Reaction score
288
First Language
Portuguese(BR)
Primarily Uses
RMMV
May I ask which one is easier to start learning?
 

Clock Out

Veteran
Veteran
Joined
Jun 14, 2016
Messages
92
Reaction score
45
First Language
English
Primarily Uses
RMMV
Yeah that's a funny video and all but people looking to get work done don't write JS in plain text editors anymore. There are tools to prevent that stuff now. Download Visual Studio Code, turn on the type checker for JS, install the ESLint extension, customize to your liking or use the default linting configuration until you know what you like. Download the TypeScript definition files for RPG Maker MV so you get type checking and intellisense.

If all I knew about planes were a video of plane crashes then I might not want to fly either.

Resources
 
Last edited:

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
No VS Code on Linux, no. And even if it is (last time I've checked it wasn't), I don't trust anything Microsoft had direct involvement with. As far as comparison to planes goes, it's BS (like any analogy) and totally unfair towards the planes (they're not as utterly broken as JS is).

As far as learning JS goes, thanks but no thanks. I want my code to never be a subject to CodeSOD entry on TDWTF and with JS I just know I'll have to write some ugly hack to get around JS's limitations sooner or later, which would make me a prime target for being featured on TDWTF. And I'm too good of a programmer for that.

Bonus fact: You want a dynamically typed language that's actually good? Ever heard of Lua? Yes, Lua is far better than JS both in syntax (no ugly hacks around brainfarts of original JS designers that made things like === necessary to implement) and in error handling (if you try to add two incompatible types it will just throw an error instead of doing stuff like in the WAT presentation and returning garbage).
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
As far as learning JS goes, thanks but no thanks.
It's interesting then, that you posted this thread in the "Learning Javascript" forum if you have no interest in learning Javascript. Did you come here just to tell us that?

I have no loyalty to Javascript and I'm not offended when people bash it. I'm well aware of it's limitations and concede that you're making some accurate points, however, you are being extreme (for example I would strongly disagree that JS is "utterly broken", as you described it). However, I'm a bit confused as to the point of this thread. I think the first video that you posted and the subsequent replies knocked the discussion off-track.

Going back to Typescript, I've never used it personally, but if it compiles into Javascript then I don't see a reason why you couldn't use that to write plugins.
 

Rave

Veteran
Veteran
Joined
May 10, 2013
Messages
99
Reaction score
29
First Language
Polish
Primarily Uses
The point of this thread was to find a way to use Typescript for RMMV plugin development. You can thank @LTN Games for derailing it.

And yes, while TS compiles into JS, I'm not sure if it would be then recognized as a proper plugin by RMMV. So I need help to get it to work.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
You can thank @LTN Games for derailing it.
Perhaps he did derail it, or perhaps he was just responding to your previous statements that JS "sucks big time" and "JS scares me" by trying to give you help/resources so that it would scare you less. Either way, doesn't really matter.

I hope that someone has successfully used Typescript to write a RPG Maker MV plugin, and that they see this thread and can give you some advice/tutorials. Until then, it may be prudent to give it a try and see what issues come up. Unfortunately, since I haven't used Typescript, and you are not willing to learn Javascript (which I could help teach you), I can't help anymore here - I'm "unwatching" the thread.

Good luck and hope it works out!
 

chaucer

Veteran
Veteran
Joined
Aug 6, 2014
Messages
328
Reaction score
552
First Language
English
Primarily Uses
RMMV
@Rave A few things...

Rave said:
I don't trust anything Microsoft had direct involvement with.
"Microsoft developed typescript, it was made to have first class citizen support in Visual Studio including Intelligence and on-the-fly compiler errors."

Rave said:
As far as learning JS goes
"TypeScript is just a complete superset of JavaScript. All JavaScript code is totally valid TypeScript code."
So even if you don't want to learn javascript you'll essentially be using & learning it as you write typescript. :D

That aside, I'm quite positive it's possible to use typescript instead of javascript in MV, however I've never tried it myself, but anythings possible as long as you have the will power and effort to put into it brother :) If I get a chance, I'll see if I can get typescript to run in MV( unless someone beats me to it lol ), might take me some time though, super busy T__T
 
Last edited:

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
I had no intentions on "derailing" a topic, you asked if typescript was possible while at the same time saying your scared of JS.
The actual OP has no detail as to what you you really want other than "If so, can you give me few pointers?". I gave you a few tips, the first one being to learn JavaScript first, considering it's what Typescript compiles into, in fact if you google "Should I learn JavaScript before Typescript" the general consensus is yes you should. The rest of my replies were simply answering and giving you new ideas to all the concerns you had.

If anything my intentions were to get you to at least try JavaScript before judging a book by its cover. I may have come off strong because I enjoy introducing people to JavaScript and do anything to change their minds on their preconceived ideas about it, especially when most of those ideas are either false, opinionated or just lack knowledge and experience.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top