passabilities / crypto-exchange

Pulls together list of crypto exchanges to interact with their API's in a uniform fashion.
MIT License
261 stars 78 forks source link

Why the promises? #18

Closed thisismydesign closed 6 years ago

thisismydesign commented 6 years ago

Thanks for this, it's a great project.

My only concern is with the use of promises. It'd be easy to use this lib asynchronously if the API would be synchronous but the other way around is not possible unfortunately. In other words using promises forces a style that some might want to avoid while it would be trivial to introduce it by the user if needed.

Would it be possible for you to release a synchronous API?

passabilities commented 6 years ago

How would there be a synchronous version? Each exchange requires a request to be made with a callback function. Instead of using callback functions, I made every request follow the promise structure. If you use ES6 then you can use the async / await feature to make the requests synchronous.

thisismydesign commented 6 years ago

Coming from a different background I didn't realize this is standard practice in JS. Sorry to bother you with this.

passabilities commented 6 years ago

No problem. I would like to make this in Python as well but that's a big rewrite for the time being. I would take a look at the async / await ES6 feature tho

thisismydesign commented 6 years ago

Will definitely do so, thanks. In the meanwhile I got comfortable with this style but I still think it has some overhead - at least code-wise.

Regarding the choice of language: I actually think JS is a great choice as nowadays it's very popular for creating simple webservices. Along these lines Ruby would be another good choice IMO. Python is great for scientific stuff (say creating a trading bot) but it's probably a good idea to decouple that from the service providing the data. Is the reason for porting simply to make it more accessible or do you have some specific use case in mind?