-
Notifications
You must be signed in to change notification settings - Fork 482
Moving LokiJS To TypeScript? #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Typescript does look interesting... I expect I will be looking into it more over the next few months or so. I am not sure yet of the major benefits inside the lokijs project itself. Without the benefit of much research into typescript, I would expect that higer level abstractions of lokijs like resultset and dynamic view would be easier to port, while the low level core methods and plumbing are more functional style and may be less able to concretely express? Externally and across api surfaces, the value is obvious and your definitions probably already help for that. We have been very careful to keep loki as pure native javascript solution not only for deployment purposes, but for development purposes as well. Having said that, this 'common feature set' will likely be fine tuned and tested enough soon that domain specific solutions / forks can pivot that source base into more specific environments like a full typescript rewrite. I would offer to include your definitions in this project but I assume DefinitelyTyped is the preferred central location for these? |
Thanks for your input obeliskos, TypeScript isn't pure javascript, that's true, but it is a superset of javascript, which means LokiJS core level methods could remain unchanged and higher level methods like resultset and dynamic view could have types added to their function parameters and return types. Yes, the central repository for definitions is DefinitelyTyped. I was thinking I might not always be available or remember to keep the definition over there updated as LokiJS continues to evolve, which was one of the reasons I asked this question. |
Yes i'm looking over it a bit and looks pretty impressive. Once I learn more I would be willing to help maintain the typescript definitions. Maybe once i get comfortable enough to work with the definitions you created (thanks :) we can coordinate via messaging here or elsewhere. |
DefinitelyTyped is open to any contributors, the LokiJS definition hasn't been updated in 5 months, so it could use an update. |
Since ES6 (and in a few more months ES7) is already available in all major browsers, there isn't any benefit at all (except type checking) at using TypeScript over plain JS (ES6). Furthermore, you'll notice that the entire community is 👎 TypeScript as it just makes things harder to debug without any reason. Also, developers just don't seem to want to learn/deal with TypeScript syntax. Just look at the biggest JS project (that I'm aware of): Atom. They started doing it in CoffeeScript and now they are moving to plain ES6. Just my 2 cents |
I think it would be a huge win to include the updates to the definition file. We are looking to use in an Angular 2 project and we are Typescript all the way oh and my 2 cents |
I'm not saying to not support TS. Supporting TS would be totally fine, if it were possible with some minor effort. My point is that right now, being ES6 already available in all browsers, there are no reasons to switch over to TS (except type checking, which imho is a solution to a non-existing problem). Type checking is a good thing, but be honest with yourself, how many times you actually screwed something because of bad variable assignment? Just a simple example, Python doesn't have type checking, and Python apps are cool, they work fine. About Angular 2, Ionic, Aurelia, etc... They all chose what they chose based on what was available at the time they started those projects. On the other hand, TS adds yet another point of failure, as browsers don't run TS, but JS. So you're forced to transpile the code to JS, meaning you're actually tied to yet another component. Let a single bug in the transpiler happen, and you'll be debugging something for hours before realizing you're hunting ghosts. There is also the fact that just a small subset of the developers that code in JS understand/code TS too. Such a change will scare the vast majority of possible contributors. Last, but not least important. Your issue is the opposite of the very first rule of coding: Don't touch it if it works. This is not some 300 lines Angular directive. We're talking about 7k lines of code. Odds are rewriting such a big code base will (listen my words, this is not the first time I see such a thing) cause bugs, failures and other odd situations. My final point, and with that I'll probably stop replying to this issue as I don't want a flame war, TS doesn't offer that much pros compared to all the cons it has, after analyzing the amount of work required to do what you're requesting. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey, @alexandernst, your arguments doesn't hold (anymore).
It's just your personal view. Not the view of community.
And, what would you say with that statement? Assembler works fine too. And cobol. And TypeScript.
Python community was interested in type checking for many years (since 2012?). But AFAIK it was hard to support types in not invasive way. Well, finally, https://docs.python.org/3/library/typing.html
That's not true. Angular 2 startet with own script language and then switch to TypeScript.
That is the best of two worlds. But it's not whole true. You can create just type definitions.
There are bugs in browsers, OS and in between. Should we stop developing at all? Anyway, you can just looking at compiled code.
Not hold anymore.
It's just your personal rule.
https://trends.google.de/trends/explore?date=today%205-y&q=%2Fm%2F0n50hxv,%2Fm%2F0hjc5m0
Yeah, it's like not to write tests, because in meantime you can implement new features... I totally agree, that rewrite whole code base is a huge deal. I even understand, that there is no time for improvements like this. And it can't be expected for open source projects. But I think there is a room to look at this feature request again. Fortunately, there are at least tree way to support TypeScript:
Personally, I can't imagine to developing with JS instead of TS anymore. |
My very first statement was: “I’m not saying to not support TS”. From there on everything is just my POV. I’m sure the dev team will be more than happy to review your patch and merge it. 👍 |
I see @techfort mixed things up by adding stale bot ;) Guys we have already embraced Typescript within the (next gen loki) LokiDB. @Viatorus put in a lot of work to make that happen. As it stands now we are refactoring critical code paths and adding new ones. Hopefully that should be in a (non-beta) supported upgrade path from lokijs soon. Packages are currently being emitted to es6, so if you prefer javascript you should be able to utilize that along with full type definitions for your editor. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Title makes this sound extreme, but there are some solid reasons to switch.
My viewpoint after writing the definition file for LokiJS (see #167) is that there's no obvious downsides to TypeScript for an OOP JS library like LokiJS, the code doesn't doing anything crazy with prototypes or function argument and makes an excellent target for TypeScript.
Since all javascript code is valid typescript, file extensions can be changed to .ts to move a project to TypeScript. Types can be added when contributer's have the time/desire. There's a dozen tools and IDEs to compile .ts to .js when you save a file or as part of a build process, keeping side-by-side .ts and .js files in the LokiJS /src directory wouldn't take much effort.
TypeScript has the obvious advantage of providing compile time error checking, it has great refactoring support (VS2015's TS tooling is pretty awesome! Check it out if you haven't) and the TS module syntax, shorthand lambdas, classes, etc. (which can all be compiled away into standard JS) merges very cleanly with ES6 making the upgrade easy in future.
What are your, the major contributors to LokiJS, thoughts on upgrading Loki to typescript and pros/cons from your viewpoint?
(based on my experience over the last 6 months working on a large business web app using VS2015 + TypeScript + LokiJS + lokijs.d.ts file linked in #167)
The text was updated successfully, but these errors were encountered: