Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FAT32 SHAMER
Aug 16, 2012



Volguus posted:

What does a loop have to do with "functional paradigm"? And "what about it?" It just looks a simple enough question, on par with the "initialized variable" questions java gets.
Trying to come and say: but the kotlin questions are so much better, doesn't really fly. Remember, most are the same developers asking both.

It’s not because iteration in kotlin is written very, very differently than in Java

Adbot
ADBOT LOVES YOU

FAT32 SHAMER
Aug 16, 2012



I would assume that everyone asking questions on SO has java experience, especially since they teach java in unis while they do not teach kotlin, so the average cute newbie question is going to be “yo how the gently caress does the .forEach() thing work and why do I have to use ‘it’ instead of ‘this’” instead of “HALO MY EXAM IS TOMORROW WHY MY CODE NO COMPILE PLEASE”

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

They're asking how to chain functions on a collection to return pairs of elements and their indices, while dropping the first n elements from the collection, without losing the original numbering

I mean yeah it's a fairly basic question in terms of understanding that paradigm (the answer is to flip the functions so you transform it into the indexed collection first and then drop elements from that collection) but it's something a lot of people will struggle with at first compared to the more imperative style they're used to

If you're doing Kotlin you should probably learn Java too, and I think most people have made that step - and you'll probably see that reflected in the kinds of questions that are asked. That was the point in comparing the number of questions - it's not like the amount of Java questions represents a mine of pure information gold or anything! But what you will get is a ton of stuff about the Java ecosystem, Android etc, just because that's the language everyone's been talking all these years. But it also means there's a lot of trash to sift through, pros and cons eh

Taffer
Oct 15, 2010


In addition to everything everyone else said, SO has been around for over a decade accumulating Java questions, while kotlin has only existed as a complete language for 3 years and has really only gotten heavy use in the last 1-2 years.

Also, Kotlin has incredibly good documentation that usually shows up as a first or second result in Google for any surface-level language questions. The same is not at all true for Java, it has poo poo documentation that is buried in random places on the internet. In reality SO and random medium posts are the Java documentation.

Kotlin is an awesome language, use it.

Volguus
Mar 3, 2009

baka kaba posted:

They're asking how to chain functions on a collection to return pairs of elements and their indices, while dropping the first n elements from the collection, without losing the original numbering
They just asked how to loop through a drat list, not chain crap together. Oh, the answer is to chain crap together, sure, that's fine, but it has nothing to do with the actual question.




There are really only two arguments that apply to both Kotlin on Android and Dart/Flutter against their usage:

- Both are relatively new languages, with relatively little knowledge base available on the internet. It's not zero, but certainly not at the 25 years level of Java.
- Both are Google projects and Google loves to kill things.

The difference between the two is that Kotlin as a language will survive outside of Android should Google decide to kill it (or more exactly, stop supporting it, kill its relationship with Jetbrains), while Dart/Flutter will not. If that is ok with you, by all means go for it.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

I mean it's literally the question they asked

Volguus
Mar 3, 2009

baka kaba posted:

I mean it's literally the question they asked

Jesus, here's the drat question :


That is all they asked. how to iterate a collection.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

And then they post the code that does that imperatively, and say they want to do it without tracking the index manually, and talk about how they attempted to do it declaratively but couldn't get it to work right, which is why they're posting

Cmon what's the point of this argument?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Volguus posted:

On the other hand, let's look at what help can we get when we're stuck:

https://stackoverflow.com/questions/tagged/kotlin - 23,106 questions
https://stackoverflow.com/questions/tagged/java - 1,550,652 questions

are you trolling or are you really this dumb

Taffer
Oct 15, 2010


Volguus posted:

There are really only two arguments that apply to both Kotlin on Android and Dart/Flutter against their usage:

- Both are relatively new languages, with relatively little knowledge base available on the internet. It's not zero, but certainly not at the 25 years level of Java.
- Both are Google projects and Google loves to kill things.

Why would you post something purposely false and then make a incorrect contradictory retraction a sentence later? Kotlin is not Google and its functionality and development are not associated with them. They support it with their tools and documentation, but the usage of Kotlin doesn't depend at all on Google. Even if they decided one day to 100% drop all support for Kotlin it would still exist exactly like it does now, and could be used for Android development just like it is now. Kotlin is a JVM language and the JVM is the core of Android apps. Google couldn't disallow the use of Kotlin even if they wanted to, the worst they could do is make a little more of a hassle. Which would require a completely rebuild of their toolchain from scratch, because Kotlin support is never going away from Intellij, and Android studio is 95% Intellij.

As to your first point, almost all the Java "knowledge base" on the internet is applicable to Kotlin, unless it's very syntax specific. All the logic, methods, architecture, and API's that exist for Java are equally accessible to Kotlin. Because it's a JVM language, and that's how it works.

If you don't like kotlin you can just say so, nobody will be mad. But these reasons are either stupid or completely incorrect.

Volguus
Mar 3, 2009

baka kaba posted:

And then they post the code that does that imperatively, and say they want to do it without tracking the index manually, and talk about how they attempted to do it declaratively but couldn't get it to work right, which is why they're posting

Cmon what's the point of this argument?

It's a stupid argument. It's more about you declaring that something is true when it's false. That's all. But it is a stupid argument about the imperative-ness or functional-iness of the question nonetheless.

Taffer posted:

Why would you post something purposely false and then make a incorrect contradictory retraction a sentence later? Kotlin is not Google and its functionality and development are not associated with them. They support it with their tools and documentation, but the usage of Kotlin doesn't depend at all on Google. Even if they decided one day to 100% drop all support for Kotlin it would still exist exactly like it does now, and could be used for Android development just like it is now. Kotlin is a JVM language and the JVM is the core of Android apps. Google couldn't disallow the use of Kotlin even if they wanted to, the worst they could do is make a little more of a hassle. Which would require a completely rebuild of their toolchain from scratch, because Kotlin support is never going away from Intellij, and Android studio is 95% Intellij.

As to your first point, almost all the Java "knowledge base" on the internet is applicable to Kotlin, unless it's very syntax specific. All the logic, methods, architecture, and API's that exist for Java are equally accessible to Kotlin. Because it's a JVM language, and that's how it works.

If you don't like kotlin you can just say so, nobody will be mad. But these reasons are either stupid or completely incorrect.

Without google support kotlin on android will not go anywhere. Case in point: https://scala-android.org/ . Can it work ? Sure. How many people are actually working on it/with it? More than zero, less than 20. And what about what I posted was "purposely false"?

You all sound like Kotlin is the god's gift, the silver bullet, the thing, when is none of those things. Its a different language with its pluses and minuses. It will not make you an Android guru overnight, nor it will solve all your android development problems. Be honest with the guy here, not act like a zealot army.

And Dalvik is a JVM now? Come on, you know better.

Volguus fucked around with this message at 22:09 on May 21, 2019

Taffer
Oct 15, 2010


Volguus posted:

Without google support kotlin on android will not go anywhere. Case in point: https://scala-android.org/ . Can it work ? Sure. How many people are actually working on it/with it? More than zero, less than 20. And what about what I posted was "purposely false"?

Kotlin was growing fast as an Android language before Google ever even announced support for it, much less started championing it. I was one of the people using it before then, in fact. And I was telling everyone to use it, because it was a joy to work in. Scala didn't grow because it sucked, not just because it was a JVM language.

Volguus posted:

You all sound like Kotlin is the god's gift, the silver bullet, the thing, when is none of those things. Its a different language with its pluses and minuses. It will not make you an Android guru overnight, nor it will solve all your android development problems. Be honest with the guy here, not act like a zealot army.

Nobody ever said that, we all just said it's a good language that's fun to work in and will make things easier.

I'm a programmer, I enjoy solving problems in any language, but before I used Kotlin the language itself was just a means to an end, and I never found enjoyment in the language itself, just the problem solving. When I learned Kotlin I realized I could actually enjoy the act of working in a language, and that's the story for a lot of people. We know it's not magic, it's just really well made and an actual joy to work in. Given the choice I'd never go back to the other languages that I've spent a bunch of suffering on.

FAT32 SHAMER
Aug 16, 2012



Volguus posted:

It's a stupid argument. It's more about you declaring that something is true when it's false. That's all. But it is a stupid argument about the imperative-ness or functional-iness of the question nonetheless.


Without google support kotlin on android will not go anywhere. Case in point: https://scala-android.org/ . Can it work ? Sure. How many people are actually working on it/with it? More than zero, less than 20. And what about what I posted was "purposely false"?

You all sound like Kotlin is the god's gift, the silver bullet, the thing, when is none of those things. Its a different language with its pluses and minuses. It will not make you an Android guru overnight, nor it will solve all your android development problems. Be honest with the guy here, not act like a zealot army.

And Dalvik is a JVM now? Come on, you know better.


On a scale of 1-10 how mad were you when COBOL fell out of favour

Volguus
Mar 3, 2009

Taffer posted:

Kotlin was growing fast as an Android language before Google ever even announced support for it, much less started championing it. I was one of the people using it before then, in fact. And I was telling everyone to use it, because it was a joy to work in. Scala didn't grow because it sucked, not just because it was a JVM language.

While I'm sure that you are a very popular and persuasive developer, you are underestimating the power of the google behemoth:

https://trends.google.com/trends/explore?date=today%205-y&q=kotlin

What happened in May 2017? Google I/O happened where they announced that Kotlin is the new language of choice for Android development. Your efforts before that, while commendable, only account for about 12% worldwide.

FAT32 SHAMER posted:

On a scale of 1-10 how mad were you when COBOL fell out of favour

It goes all the way up to 11.

FAT32 SHAMER
Aug 16, 2012



Do you have any idea how big of a deal 12% is when it’s such a new language or are you still trying to see if you can get to your tonsils via your rear end

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Volguus posted:

While I'm sure that you are a very popular and persuasive developer, you are underestimating the power of the google behemoth:

https://trends.google.com/trends/explore?date=today%205-y&q=kotlin

What happened in May 2017? Google I/O happened where they announced that Kotlin is the new language of choice for Android development. Your efforts before that, while commendable, only account for about 12% worldwide.


It goes all the way up to 11.


Lutha Mahtin posted:

are you trolling or are you really this dumb

Ola
Jul 19, 2004

I have question about choice of framework/platform, similar to a few pages back, but a bit different circumstances. I'll hopefully be spending the summer writing an app, the scope and specs aren't quite clear yet but I can choose the tools.

- For Android and iOS, maybe web as well.
- Nothing fancy, just registering some data, storage, visualization, sharing, maybe cloud storage.
- It should be easy to make it look nice.

Android dev experience: I know Java, I've done parts of a Head First Android course and got the demo apps there to run fine.
iOS dev experience: I have never owned anything made by Apple. If I help someone with a Mac and accidentally swipe off to a side desktop, I don't know how to get back.

I know Javascript.

Definitely React Native, yeah?

Taffer
Oct 15, 2010


If you just want a single app, make a website. Don't use React Native, it'll be a slower, more difficult, and less polished app on all platforms than compared to just doing things natively, and its tools suck so it will be an unpleasant experience.

If you're really set on a multiplatform solution, Xamarin would probably be your best bet, maybe Flutter. But both are going to have huge downsides and you'll once again probably just be making your life harder compared to either just making a website or making separate native apps.

Ola
Jul 19, 2004

Taffer posted:

If you just want a single app, make a website. Don't use React Native, it'll be a slower, more difficult, and less polished app on all platforms than compared to just doing things natively, and its tools suck so it will be an unpleasant experience.

If you're really set on a multiplatform solution, Xamarin would probably be your best bet, maybe Flutter. But both are going to have huge downsides and you'll once again probably just be making your life harder compared to either just making a website or making separate native apps.

Yeah, you're probably right. Part of it is the possible user/owner expectation of "it needs to be an app, not just a website". Part of it is me dreading the infrastructure and enjoying the comfortable idea of the walled garden phone storage, which is indistinguishable from cloud storage for the average user and has no self hosting or GDPR issues etc. But some form of online storage is probably desired sooner or later, so that requires hosting, authentication etc anyway. And HTML localStorage would probably be the same in practice as the app's phone storage.

I think the owner is open for web only, so I'll definitely keep this in mind.

Splinter
Jul 4, 2003
Cowabunga!
I'm writing code to sync my app data with a remote server, and vice versa. Data can be created from either a web app or various phone apps. I've decided it would be most reliable if the creator (whether mobile or web) was responsible for creating a unique ID used for sync purposes (as opposed to having the server create these IDs on POST then return them to the client for reconciliation). The IDs only need to be unique per user and per data type. What's a good way to generate this on an Android client? First thought is java.util.UUID.randomUUID(), but if anything that is overkill for this use case. At the same time, unless there is another tried and true option, just going with UUIDs is probably less headache in the long run than any attempt to roll my own.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Splinter posted:

I'm writing code to sync my app data with a remote server, and vice versa. Data can be created from either a web app or various phone apps. I've decided it would be most reliable if the creator (whether mobile or web) was responsible for creating a unique ID used for sync purposes (as opposed to having the server create these IDs on POST then return them to the client for reconciliation). The IDs only need to be unique per user and per data type. What's a good way to generate this on an Android client? First thought is java.util.UUID.randomUUID(), but if anything that is overkill for this use case. At the same time, unless there is another tried and true option, just going with UUIDs is probably less headache in the long run than any attempt to roll my own.

UUID unless you need to be able to recapture the user specifically if they uninstall and reinstall. You have a nice easy solution, don't overthink it.

Edit: see also: Best Practices for working with Android Identifiers

FAT32 SHAMER
Aug 16, 2012



When I did something like that I used firebase and the keys were great for that kind of thing

I’m not sure at what point it’s no longer free and if you don’t have experience with NoSQL it’ll make you sad since you have to double data in order to not murder your user’s data usage

My Rhythmic Crotch
Jan 13, 2011

Is there a preferred library out there for doing on-screen joysticks? I'm making a control app for a little bluetooth device (hobby, not work) and I really don't want to reinvent the wheel if there is something out there that doesn't suck, but so far have not seen much.

Taffer
Oct 15, 2010


Most of that is for games and will exist and add-ons for unity or unreal. You'll have a hard time finding such a specific lib for the native UI. On the plus-side, based on your description it sounds pretty simple. Have you ever built a custom view with canvas drawing?

My Rhythmic Crotch
Jan 13, 2011

No, I am still on the early part of the learning curve for android. Based on my research so far, it looks like that will probably be the way to go.

Taffer
Oct 15, 2010


yeah, doing some guessing at what you're describing you'll just be drawing a few primitive shapes and moving them around, maybe some resizing? Rings, circles, maybe some triangles are all straightforward to do, just look up a couple tutorials on custom view drawing and the canvas API and you'll be good to go.

New Coke
Nov 28, 2009

WILL AMOUNT TO NOTHING IN LIFE.

FAT32 SHAMER posted:

if you don’t have experience with NoSQL it’ll make you sad since you have to double data in order to not murder your user’s data usage

Noob here, what do you mean by this?

FAT32 SHAMER
Aug 16, 2012



New Coke posted:

Noob here, what do you mean by this?

if you organize your NoSQL database as you would an SQL database the user will redownload the entire database to the node that youre attempting to access every time you attempt to access that node, so instead of having a "deep" tree that has a singular entry point and that has lots of children, grandchildren, and great grandchildren, you should instead flatten your data as much as possible by having multiple root nodes, then if two root nodes need the same information somewhere along the line you have two or more copies of that information

https://firebase.google.com/docs/database/web/structure-data

ReverendCode
Nov 30, 2008

FAT32 SHAMER posted:

if you organize your NoSQL database as you would an SQL database the user will redownload the entire database to the node that youre attempting to access every time you attempt to access that node, so instead of having a "deep" tree that has a singular entry point and that has lots of children, grandchildren, and great grandchildren, you should instead flatten your data as much as possible by having multiple root nodes, then if two root nodes need the same information somewhere along the line you have two or more copies of that information

https://firebase.google.com/docs/database/web/structure-data

Also good to note, Google adores naming their products in similar and confusing ways. That is docs for the Firebase Realtime Database, There is also Firebase Firestore, which is also a realtime NoSQL db that has, in my opinion a much better interface for the developer: https://firebase.google.com/products/firestore/

The official developer account on youtube even released a series of videos doing a decent look at how to structure your data effectively to minimize read/write calls to the repository:
https://www.youtube.com/watch?v=v_hR4K4auoQ

Anne Bonny
Feb 26, 2019
e

Anne Bonny fucked around with this message at 22:27 on Jun 6, 2019

brand engager
Mar 23, 2011

lmao

Telephones
Apr 28, 2013
android is loving poo poo

Telephones fucked around with this message at 09:26 on Nov 8, 2019

New Coke
Nov 28, 2009

WILL AMOUNT TO NOTHING IN LIFE.

FAT32 SHAMER posted:

if you organize your NoSQL database as you would an SQL database the user will redownload the entire database to the node that youre attempting to access every time you attempt to access that node, so instead of having a "deep" tree that has a singular entry point and that has lots of children, grandchildren, and great grandchildren, you should instead flatten your data as much as possible by having multiple root nodes, then if two root nodes need the same information somewhere along the line you have two or more copies of that information

https://firebase.google.com/docs/database/web/structure-data

Cool, thanks!

Splinter
Jul 4, 2003
Cowabunga!
If I'm reading an int from SharedPreferences in a BroadcastReceiver, do I need to worry about disk IO causing UI glitchiness (and therefore handle the work in a service, or perhaps call goAsync() in the receiver)? I believe shared prefs handling caching automatically, so most reads won't actually hit the disk, but lets say the data isn't cached for whatever reason. I'm thinking this isn't an issue, but wanna double check.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Splinter posted:

If I'm reading an int from SharedPreferences in a BroadcastReceiver, do I need to worry about disk IO causing UI glitchiness (and therefore handle the work in a service, or perhaps call goAsync() in the receiver)? I believe shared prefs handling caching automatically, so most reads won't actually hit the disk, but lets say the data isn't cached for whatever reason. I'm thinking this isn't an issue, but wanna double check.

Not unless you have some kind of profiling saying that this is an issue. You've got 16ms per frame, loading shared preferences won't take anywhere remotely close to that time.

Vim Fuego
Jun 1, 2000

I LITERALLY SLEEP IN A RACING CAR. DO YOU?
p.s. ask me about my subscription mattress
Ultra Carp
Is there an up to date "get started" guide for kotlin in android studio? I just want to follow directions and have hello world compile

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

You could do the Codelab

Shadow0
Jun 16, 2008


If to live in this style is to be eccentric, it must be confessed that there is something good in eccentricity.

Grimey Drawer
Does anyone know how to use Android's Room (API?)?
I've been doing a lot with it, but I can't figure out how to do things with files - specifically I want to be able to save a backup of the database or a subset of the database, or merge one into another (i.e. export and import).
I can't seem to find any info on it, and I'm not tremendously knowledgeable on how databases work - in case there's a more pure SQL solution.

smiling giraffe
Nov 12, 2015

Shadow0 posted:

Does anyone know how to use Android's Room (API?)?
I've been doing a lot with it, but I can't figure out how to do things with files - specifically I want to be able to save a backup of the database or a subset of the database, or merge one into another (i.e. export and import).
I can't seem to find any info on it, and I'm not tremendously knowledgeable on how databases work - in case there's a more pure SQL solution.

What are you trying to acheive by doing those things?

Adbot
ADBOT LOVES YOU

Shadow0
Jun 16, 2008


If to live in this style is to be eccentric, it must be confessed that there is something good in eccentricity.

Grimey Drawer

smiling giraffe posted:

What are you trying to acheive by doing those things?

I'm keeping track of my expenses with my app, and I want to be able to copy the database as a backup. But I also want the option to import a database for the opposite reason. Being able to do it for a particular month or other grouping would also be nice.
I suppose I could just export/import it as a CSV file or something.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply