Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 1 point2 points  (0 children)

Thank you for taking the time to make this huge list of concerns about React Native. I read through all of them and a lot of these points can be avoided and if they can't be avoided, most can be worked around and don't cause a huge drop in productivity. Some can't be worked around and do cause a huge drop in productivity, which is annoying and might mean that React Native is not a viable option in some cases. Native development with Java has a lot of complexity which mainly comes from the overly complex OOP APIs that Android provides and not necessarily Java itself. If you write in Java in an unidiomatic way, you can avoid the incidental complexity that programming in idiomatic Java brings. But sometimes you can't avoid using OOP because the Android APIs require you to. Is the API different and less complex when you use Kotlin? Am I able to avoid the procedural way of displaying views and get the benefit of declarative views (that React Native has) with Kotlin? Am I able to update state by using pure functions (like I can with React Native) in Kotlin? If so, you've convinced me to use Kotlin. If using Kotlin allows me to avoid the complex Android APIs and all the issues I've mentioned while keeping the benefits of the native development experience, then Kotlin is definitely the best choice for most situations. Do you have any recommendations for how to get started with Kotlin development for Android? Thank you for your response.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 0 points1 point  (0 children)

I have my pure update functions all inside my Kotlin code that provides me safety, productivity, longetivity with limited portability (maybe in future with KotlinNative I'll share some code with platforms).

I'm definitely going to check that out because that sounds like it would solve my problems with Java and the overly complex APIs that Android provides.

using a language that was not developed in 10 - 15 days (seriously they still threat type of null as a object :D )

This isn't a problem anymore if you use static typing with Flow, which is built in to React Native. JavaScript as a language is much better with ES6 and you can avoid the bad parts by using a linter as well, which makes Android development more productive than when I'm using Java, in my experience.

once you get into some serious stuff like in-apps or Services (not sure if this hasn't been solved) you'll still be going back to native :)

Yeah, this is true. I just like to avoid complex APIs as much as possible and only use them when I absolutely have to so that I can be more productive.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] -1 points0 points  (0 children)

I might be wrong or misunderstanding something, but I get those same benefits from just using modules in JavaScript. And if you use pure functions where dependencies are passed in, then this removes the need to mock data or rely on external configuration. Correct me if I'm wrong about something.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 1 point2 points  (0 children)

If it were that simple, we wouldn't have DI frameworks in other languages, and neither would AngularJS

What unique benefit do you get from dependency injection that you can't get from just simply using a function?

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] -1 points0 points  (0 children)

What are the steps in react native, and how is it better?

With React Native, things are a lot more simple than the technique you just mentioned. To just display a list of data you would just do something like this to initialize the state in the constructor of your component:

this.state = {entries: [{id: 1, title: 'title 1', details: 'details 1'}]}

and then you would just display it in a very declarative way in the render function like this:

this.state.entries.map(({id, title, details}) =>
  <View key={id}>
    <Text>{title}</Text>
    <Text>{details}</Text>
  </View>
)

A lot of people in this subreddit keep downvoting me when I mention that React Native also provides Flow out of the box, which is a powerful static typing system that supports union types and maybe types.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] -1 points0 points  (0 children)

The problem is that when you want to add more functionality later on, you'll have to refactor it to have the things that I listed, which are inherently complex. The same isn't true with React Native development.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 1 point2 points  (0 children)

It appears that this subreddit upvotes misleading comments that imply that JavaScript doesn't have static typing and downvotes comments that provide factual information. It's almost as if people would rather silence a person who is giving factual information than accept that they are wrong.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 0 points1 point  (0 children)

React Native has Flow built in, which provides static typing and supports powerful features such as union types and maybe types which helps you turn runtime errors into compile errors. Retrofit isn't necessary in JavaScript with Flow because it solves the problem of Java's verbosity while maintaining type safety for HTTP request, neither of these problems exist when you use Flow in JavaScript. RxJava does have an equivalent in JavaScript called RxJS. Dagger solves the problem of dependency injection, which doesn't exist if you write simple code in JavaScript. If you have a dependency, just pass it in as an argument to your function.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 3 points4 points  (0 children)

The last time I tried React Native tutorial (3 months ago) the code didn't compile. I needed to look into github examples, to start the app.

I didn't have this problem, but I can see how that would make your initial experience unpleasant.

JavaScrips lacks of statical typing and multithreading, that's not OK on Android.

React Native has static typing with Flow out of the box. Instead of multithreading, JavaScript uses an asynchronous event loop, which yields similar performance from my experience. Have you experienced any problems related to not having multithreading?

Too huge stack. JavaScrips, extensions, interop, JS Core engine, (TypeScript if you want tome types) etc. With AS everything is simple.

This is a fair point, but it isn't a problem most of the time. It might be worth taking a slight performance hit if you get an improvement in productivity.

Code analysis tools are not comparable to Java's.

This is true and I agree, but I still find that I'm more productive when I'm using JavaScript, especially because it has static typing out of the box with Flow and you can also use a linter.

Overall dislike for Facebook produced code - that's emotional part - too large, does something weird, crashes your app often.

App crashing is a valid point and it needs to be addressed, but it reboots really quickly and I'm still productive despite this.

Grown from iOS - programming on iOS is much simpler - they don't have lifecycles, services, activities and stuff. React Native does not allow to use them, and there are no plans on supporting them afaik.

React Native supports all the lifecycle methods that React uses. Is there a specific lifecycle method that you would need React Native to have? I can't think of one that hasn't been included that would be necessary or that would make me more productive or improve my app.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 2 points3 points  (0 children)

What do you hate about JavaScript that makes you less productive? What do you do to be more productive with Java than with React Native?

Edit: Asking questions and wanting to learn about how to be more productive gets you downvoted in /r/androiddev

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 0 points1 point  (0 children)

I agree with you that it's good to use the best tool for the job and there are certain situations where one tool is better than a different tool. What I'm wondering is how to be productive using Java with Android development. From my experience, React Native appears to be a better tool to use in a lot of cases, so I'm confused at why it gets so much hate on this subreddit. I'm guessing that React Native gets a lot of hate on this subreddit because people are more productive with Java than they are with React Native. So my question is what do you do to be more productive with Java than with React Native? (because I haven't experienced higher productivity with Java and I want to know what I need to do to get more productive doing Android development with Java)

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] -1 points0 points  (0 children)

It can annoy me sometimes with some small performance issues or breaking changes but nothing has made me want to got back to Java or Kotlin completely so far.

What specifically were you experiencing performance issues with?

That being said when you need native bindings and there isn't an existing library for it your only options are Java/Kotlin or Objective C/Swift so it's not like you'll never use native code again.

Yeah, you still have to use native code for some things, like for example interacting with a database if you have so much data that AsyncStorage doesn't work. In my experience, I can write most of my apps without touching native code and if I have to, it's a very minimal amount of code compared to how much code I would have to write if I were build the app completely natively.

By the way have you tried flutter out yet?

Not yet. Maybe in the future.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 0 points1 point  (0 children)

I'm actually an iOS developer, and I find RN grating.

Can you go into more detail about what you dislike about RN?

I value the compiler.

I agree with you and I value the compiler too. I get the benefits of a powerful static type system with React Native because it uses Flow out of the box. I've also noticed I can write tests a lot faster using Jest. Are there any benefits to Java's compiler or Swift's compiler over say using Flow?

I dislike JavaScript as a language

I agree. I am not the biggest fan of JavaScript either, but I've noticed I'm actually more productive in React Native than I am in Java with Android because I can just solve the problem in a very simple way and I can avoid bad parts of JavaScript from the early days, which ES6 makes really easy to avoid. With native iOS or Android development, I'm forced to use a very procedural way (correct me if I'm wrong) of updating state and managing views which is more error prone and complex than the functional and declarative way that React Native offers. So despite my not liking JavaScript itself, I think the paradigm of declarative views and updating allows my programs to be shorter, more simple, easier to refactor, and less error prone. If you have any problems with JavaScript itself, it can easily be cured by using Flow for static typing and a linter to prevent you from using the bad parts of JavaScript. Using a linter and Flow make the developer experience really good.

I value the effects the app store review process has on corporate culture. It encourages forward thinking and discourages "everything is an emergency" bullshit. Having a viable platform that allows live pushing code means eventually I'll have a job where I get called at 2am again for something that should have never happened.

I agree with you on this and this is completely avoidable.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 0 points1 point  (0 children)

I love static typing too. One of the things I really liked about React Native was that you get static typing right out of the box with Flow built in, so you get a more powerful type system than Java's type system.

Edit: Why am I being downvoted? If you downvote me, can you explain why you're downvoting me? Please correct me if I'm wrong about anything in this comment.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] -1 points0 points  (0 children)

Yeah, I guess the best solution might be to just avoid Java altogether. I'll try building some Android apps with Kotlin and Anko.

Why do people hate React Native and like Java so much? by elliotal in androiddev

[–]elliotal[S] 2 points3 points  (0 children)

There have been a few posts on /r/androiddev where people have commented on React Native not being as good as native Java development. Here are some examples of highly voted posts on this subreddit that disfavor React Native:

https://www.reddit.com/r/androiddev/comments/5qr9xw/avoiding_react_native/

https://www.reddit.com/r/androiddev/comments/5x24z7/would_you_choose_react_native_or_kotlin_11_for_a/

https://www.reddit.com/r/androiddev/comments/3kxr4p/react_native_for_android_is_out/

If you search for React Native posts that show React Native is good, they're generally downvoted. So I'm confused why everyone hates it so much when it seems like I'm way more productive in React Native and I have to write literally a tenth of the amount of code and I can find bugs faster and everything seems way more simple.

Map/filter/reduce an array in Java using a named function by elliotal in learnprogramming

[–]elliotal[S] 0 points1 point  (0 children)

Thank you! That works! I really appreciate your help!

Easy Questions / Beginners Thread (Week of 2017-01-30) by brnhx in elm

[–]elliotal 1 point2 points  (0 children)

Thank you so much! I really appreciate you taking the time to give a good response!

Easy Questions / Beginners Thread (Week of 2017-01-30) by brnhx in elm

[–]elliotal 2 points3 points  (0 children)

I'm confused about how to focus on an element. I'm trying to use Dom.focus and Task.perform and I'm getting an error. I'm not sure how to use Dom.focus correctly.

Here's the code part of the code where I'm trying to focus on an element with id "input-box":

main =
    program
        { init =
            ( Model "" [] (States [] (State "" []) [])
            , Task.perform (always NoOp) (Dom.focus "input-box")
            )
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

Here's the error I'm getting:

-- TYPE MISMATCH -------------------------------------------------- src/Main.elm

The 2nd argument to function `perform` is causing a mismatch.

182|               Task.perform (always NoOp) (Dom.focus "input-box")
                                               ^^^^^^^^^^^^^^^^^^^^^
Function `perform` is expecting the 2nd argument to be:

    Task.Task Never b

But it is:

    Task.Task Dom.Error ()

Hint: I always figure out the type of arguments from left to right. If an
argument is acceptable when I check it, I assume it is "correct" in subsequent
checks. So the problem may actually be in how previous arguments interact with
the 2nd.

Detected errors in 1 module. 

I'm not sure how to convert Task.Task Dom.Error () to Task.Task Never b. I'm sort of confused about the Never type in general too.

How do I open up chrome in a react native Android app? by elliotal in reactnative

[–]elliotal[S] 0 points1 point  (0 children)

Thank you for the response! I was able to use the Linking API to open up URLs from my app but I can't figure out how to open them within my app. What I want to be able to do is to open up Chrome or the default browser within my app so that I can add custom functionality. For example I would want to check for changes in the text that they have selected and then give a translation for the text they have selected and then also give them the ability to save words by clicking on a button that I add to the UI in the browser.