adonisjs / rfcs

💬 Sharing big changes with community to add them to the AdonisJs eco-system
52 stars 6 forks source link

Collect.js - Add Laravel Collections (Illuminate/Collections) to Adonis #27

Closed zhorton34 closed 3 years ago

zhorton34 commented 4 years ago

Brief history

Laravel has a support library dubbed illuminate. Illuminate has several Php components, one of the most popular among them being Collections. Although no big deal to install, adding Collect.js in as a core provider or as a sub-service of a AdonisSupport provider (similar to illuminate) would provide Laravel Collections within adonis.js for those who are not already aware of collect.js

More Information about collect.js

Very clear documentation that matches Laravel's collection API all but perfectly. The small differences between collect.js and illuminate/collections are very clearly documented. This package is also highly tested and has zero other non-dev dependencies.

What problem does it solve?

This doesn't solve a specific problem, but rather helps push adonisjs and encourages those already familiar and in love with Laravel and Laravel Collections to also fall in love with adonis and collect.js. Enhancement more than anything.

Proposal

collect.js docs laravel collection docs collect.js repo laravel collections repo (Illuminate) collect.js non-implemented methods vs. laravel

Are you willing to work on it?

Maybe, either way this issue wouldn't take very long to implement.

RomainLanz commented 4 years ago

Hey @zhorton34! 👋

Thanks for your contribution. Since this topic has already been discussed, I have a few questions.

  1. Why this library should be built-in the core of the framework?
  2. Which methods are you missing from default JavaScript Array methods?
  3. What issues this library will solve?
zhorton34 commented 4 years ago

Hey @RomainLanz, great questions!

1. Why should collect.js be built-in to the core of adoinsjs?

2. Which methods are we missing from default JavaScript Array Methods?

3. What other issues will collect.js solve?

The Most Worth While Reason For Adding Collect.js to Adonis

The most important value added by collect.js to Adonis in my opinion is the love of collections within the Laravel community. Adonis JS is based off of Laravel and does an amazing job replicating many of Laravel's concepts (Seriously Great Work On Your Part). Personally, I almost selected express over Adonis and decided on Adonis because of the dependency injection container via Typescript. I'm very, very happy adonis was my choice, it's phenomenal! By adding in collect.js you're offering another point of interest for Laravel developers to adopt adonisJS.

Pushing the adoption of Adonis to Laravel developers, in my opinion, is huge - especially with Service Providers. By adding a core illuminate like library that is provided to the core, you're offering experienced Laravel developers an easy access point to start contributing to the Adonis "Core Supported" codebase.

I personally have a few packages that are js packages based on Laravel Illuminate/Components (Check out laravel-js-str). That package supports Laravel's Str and fluent Stringable Illuminate Components, not because they're necessary to the core of any project but rather because they are very enjoyable to work with pretty immediately.

Collect.js is also fully tested and has zero non-dev dependencies - very explicitly pointing out the few methods it does not support that Laravel Collections do.

Ultimately, collect.js pushes the adoption rate of adonis js as a whole forward while offering an optional but ultimately very useful package that has no negative impact as far as I can figure.

thetutlage commented 4 years ago

All the points you shared are very subjective and its hard to debate on subjective opinions.

I appreciate your intentions on improving AdonisJS or making it more accessible to Laravel and PHP developers. But I would rather ask folks making a move to embrace Javascript wherever possible. For example: Collections are required in PHP, coz PHP doesn't have a rich API for dealing with arrays or objects. On the other handl, JavaScript is pretty much self equipped.

For now, I will resist to add it to the core set of packages and others can continue using it in their apps directly.

ashokgelal commented 4 years ago

Coming from Laravel (and Kotlin, where many of the collection functions are built-in), I sympathize with @zhorton34. For a beginner who is trying to test the water with Adonis, it might become a gap too wide to make the jump. However, I do agree with @thetutlage, JavaScript is self equipped and where it is not, there are great libraries built on/for it, such as Collect.js or my personal favorite, lazy-collections, that users can use. This allows the core members to focus on the core rather than maintaining yet another dependency, which adds not much value by integrating it in the core.

However, the one problem still remains - how to ease the new comers to increase the wide adoption of Adonis, when they are searching for an official package like Laravel Collections? I think this could be achieved by having a dedicated page that links to alternatives for things like Collections, Laravel Mix, Queues, Laravel Echo etc. maybe even with some explanation behind the rationale of not having it in the core. It could be in the official docs or even a separate repo.

An argument could be made that it's not Adonis's job to maintain the list of alternatives but if it helps the new comers and helps adoption of Adonis then why not? If there was an official repo, I'm sure community will help to build the list, myself included.

(Sorry for slightly being off topic at the end, please feel free to delete this comment)

thetutlage commented 4 years ago

Yeah we can collect helpful links and share them with new comers along with some context. I have some plans to have a community website similar to https://vue-community.org and all this can be part of that website

thetutlage commented 3 years ago

Closing since not actionable