英文:
is dartz Either Nesisty or just matter of taste?
问题
I'll provide translations for the text you provided:
所以在我开始之前,我是Flutter的初学者,也是编程的新手。
我过去只是跟随视频教程并考虑它们的最佳实践,我早期的一个教程介绍了Dartz库,它在从API获取数据时使用。
final Either<ServerException, answer> result = await repository.get(...);
result.fold(
(exception) => handle,
(answer) => yaay
);
它被介绍为唯一的方式,所以我以为是这样的,然而现在我更了解future类型及其所有功能,我也学到了我可以使用OnError或尝试和捕获来处理异常。
更多的搜索让我了解到,由于Dart是一种面向对象的语言,Dartz确实为Dart提供了函数式编程风格。
鉴于这一切
1- 这是更好的方法还是只是一些人偏好它?
2- 为什么我感觉有些人那么讨厌面向对象编程(OOP)?
3- 对于像我这样还在学习的人来说,使用一个库来改变语言风格并避免使用本地代码行为是否有好处?
英文:
So before I start I,m a beginner in Flutter and in programming all together.
I used to just follow video tutorials and consider their best practices, one of my earliest tutorials introduced me to the Dartz library and it was used when getting data from an API.
final Either<ServerException, answer> result = await repository.get(...);
result.fold(
(exception) => handle,
(answer) => yaay
);
it was introduced as the only way so I thought that, however now I know more about the future type and all its features, I also learned that I can handle exceptions with OnError or try and catch.
more search lead me to that Dartz really offers the style of Functional programming to Dart because of its OOP language.
given all of that
1- is it better or just some people prefer it that way?
2- why I felt that people hate OOP that much?
3- is it any good at all for someone still learning like me to use a library to change language style and avoid using native code behavior?
答案1
得分: 2
I prefer fpdart, and am using it in production for a number of clients.
https://pub.dev/packages/fpdart has this to say about dartz:
与dartz的比较
dartz的一个主要问题一直是缺乏文档。这对于尝试使用该软件包的新手来说是一个巨大的问题。
dartz于2016年发布,最初面向Dart 1。
dartz还缺少一些功能和类型(Reader、TaskEither等)。
Fpdart是基于fp-ts和cats的重写。主要区别包括:
Fpdart已完全文档化。
Fpdart使用defunctionalization实现了高种类类型。
Fpdart基于Dart 3。
Fpdart从一开始就是完全空安全的。
Fpdart具有更丰富的API。
Fpdart实现了dartz中的一些缺失类型。
? Fpdart(目前)不提供不可变集合(ISet、IMap、IHashMap、AVLTree)的实现。
英文:
I prefer fpdart, and am using it in production for a number of clients.
https://pub.dev/packages/fpdart has this to say about dartz:
> Comparison with dartz
> One of the major pain points of dartz has always been is lack of
documentation. This is a huge issue for people new to functional programming to attempt using the package.
> dartz was released in 2016, initially targeting Dart 1.
> dartz is also missing some features and types (Reader, TaskEither, and others).
> Fpdart is a rewrite based on fp-ts and cats. The main differences are:
> Fpdart is fully documented.
> Fpdart implements higher-kinded types using defunctionalization.
> Fpdart is based on Dart 3.
> Fpdart is completely null-safe from the beginning.
> Fpdart has a richer API.
> Fpdart implements some missing types in dartz.
? Fpdart (currently) does not provide implementation for immutable collections (ISet, IMap, IHashMap, AVLTree).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论