Live data from Hacker News

Rawdrawandroid – Build Android apps without any Java, in C and Make

github.com

141–150 of 157 posts

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#141
post #15
post #13

Now we only need to embed Lua into this to write the high-level logic, and we may have a winner for stuff that does not need a lot of accessibility support. Like, say, games, or media players. Easy to link C libraries that do performance-critical stuff, or writhe your own C code. (Then gradually rewrite the core in Zig.)

...I of course would rather embed Janet [1], but I realize what is going to have an easier time gaining popularity %) Also, Lua has Löve [2] which could be immediately usable, among other things. [1]: https://janet-lang.org/ [2]: https://www.love2d.org/

Defold is another great open source Lua-based cross-platform game engine, and has a healthy ecosystem.

https://defold.com/

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#142
post #97

Earlier quoted context omitted.

> Unfortunately you can't just ship a PWA with no wrapper. You can… but it won’t be in the Play Store. Disqualifying for many, but not all.

this is what I do. are you really any more discoverable there? I don't think so.

I got a significant number of installs and I didn't do any promotion. People also directly requested an "app" and this satisfies them a lot more than a lecture on the steps to install a PWA.

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#143
post #50

Earlier quoted context omitted.

No, it doesn't. Java is a piece of crap with JVMs imposing an 8-24 byte overhead per object, which destroys caching, memory footprint, and any chance of low-level optimization. Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable. That, along with lacking SIMD, imposing stupid decisions like bounds checks on all array accesses, making arrays boxed (int[] is not an array of ints, sorry), or…

> JVMs imposing an 8-24 byte overhead per object You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects. > Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable…

I appreciate your response. My original post was a rant for sure, but let me reply to your comments.

> You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects.

SoA requires unboxed arrays, otherwise it defeats the purpose. I may have been wrong about int[] being boxed (it seems to be unboxed in most implementations), but the fact that ints still auto-promote to Integer in certain circumstances is just ridiculous for any kind of low-level programming.

It's also hilarious that Value Objects are still in preview. Even C# has had structs (value semantics) since forever.

> This is silly. This happens with all other languages, and Java will give you better results on average. Use a different compiler or runtime for your C code, or run it on a different processor architecture, and have fun tuning your code.

This is false. structs in C or C++ don't have a language-imposed overhead. They may have different sizes depending on the alignment requirements of the platform.

> The Vector API [1] is available in preview.

Also hilarious. It's 2024.

> It's widely understood that doing the opposite has been perhaps one of the largest mistakes in the history of the industry.

Checking every single array access in a tight loop, for example, is stupid. It's the naive, dumb, and inefficient way of doing it (i.e., the Java way.) The right way to do it is to enforce up front that the index may never be out of bounds. Ada helps with this by having user-defined ranges and integer types, for example.

> What does this even mean? An int[] is a linear array of 32-bit int values in memory.

Yes, I think I botched that one, but see also my comment above.

> Are we now just talking about a small slice of people who write bad code?

No, I am talking about Java.

> Ah, ok. Have a fine day.

Oh, and how does Java do low-level systems programming without unsigned integer types, lol? Oh, yeah, you need to cast to/from the next largest integer representation so that you can encode all of the positive values. And you better hope you don't need more than the native size, because then you get fuck-boxed into Integer (see my comment above.) Fucking hilarious, y'all.

Also, you don't even have a guarantee that a variable is allocated on the stack even when the dumbest compiler can tell it's bound by function scope. You need to hope that the JIT will do it, and from my past experience in Android (which this post is about), it doesn't. This is why, for example, if you look at the math library of LWJGL [1], all functions are defined to mutate one of the arguments, they never allocate a new vector to return. This is just completely stupid because mathematical vectors should have value semantics and the compiler optimize the fuck out of them. (Don't get me wrong, I love LWJGL and the guys. This is a criticism of the language, not the library; they are doing the best they can given the language's stupid decisions.)

[1] https://github.com/JOML-CI/JOML/blob/main/src/main/java/org/...

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#144
post #50

Earlier quoted context omitted.

No, it doesn't. Java is a piece of crap with JVMs imposing an 8-24 byte overhead per object, which destroys caching, memory footprint, and any chance of low-level optimization. Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable. That, along with lacking SIMD, imposing stupid decisions like bounds checks on all array accesses, making arrays boxed (int[] is not an array of ints, sorry), or…

I feel so out of place when interviewing for firmware/embedded roles and the interviewers turn out to be java snobs. I honestly still have a hard time comprehending the situation; how does it come to this? Thanks for your insight

It's really sad. I think Java is a rather ill-designed and boring language, not even worth learning for intellectual purposes, but it does have a mature ecosystem around databases, web services and stuff, and it has its use cases. Beyond that, it really beats me where this attitude comes from. I attribute it to living in your bubble and not exploring what the guys over on the other side of the fence are doing. This is why one should learn as many programming languages (and paradigms) as possible, even if you don't end up using half of them. It's like when those guys come out with a new "minimalist" CSS framework, and the bitch downloads a 2MB payload just to bootstrap your "hello world".

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#145
post #133
post #132

Earlier quoted context omitted.

Maven is more as capable for anyone that doesn't suffer from XML allergy, and doesn't require a background daemon to actually make it run at reasonable speed.

Correctness is the number 1 priority, and maven is simply not always doing what it should, unless you do a clean build. I am absolutely not bothered by XML and alia (btw, there are maven frontends in json/yaml, etc for those who are), and throwing out valid criticism over some straw man is not really productive.

I’m still learning about the tools and their pros and cons. Can you provide an example of a case where Maven would not do what it should? Are there particular bug reports or bug reproduction repos that you’ve seen?

Context: I worked on a Spring app many years ago and am picking Java back up.

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#146
post #143

Earlier quoted context omitted.

> JVMs imposing an 8-24 byte overhead per object You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects. > Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable…

I appreciate your response. My original post was a rant for sure, but let me reply to your comments. > You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects. SoA requires unboxed arrays…

> Vector API

In all fairness, simd in C++ and portable-simd in Rust are both in preview. Not that there is a lack of alternate options there but still.

The languages that do have these APIs stable are Swift, C#, Mojo, Zig and Julia if I’m not mistaken. Stability means different things for some of these as Mojo and Zig are young languages.

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#147
post #143

Earlier quoted context omitted.

> JVMs imposing an 8-24 byte overhead per object You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects. > Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable…

I appreciate your response. My original post was a rant for sure, but let me reply to your comments. > You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects. SoA requires unboxed arrays…

FWIW, I spend a lot of my time writing low-level code, but more for desktop/server machines and less-so for mobile.

> SoA requires unboxed arrays, otherwise it defeats the purpose. I may have been wrong about int[] being boxed

Yeah, that's wrong. Primitive arrays aren't "boxed". An int[] is not an Integer[], and no boxing is performed unless you ask for it. SoA is fine in Java.

> the fact that ints still auto-promote to Integer in certain circumstances

It's pretty easy to avoid boxing if you don't want it. They are separate types after all. Even so, Android lint has an inspection for it, and Intellij (presumably Android Studio too?) has an inspection you can turn on to detect it [1]. If you're running afoul of autoboxing, it's probably mostly in collections-based code and you'll want something like fastutil [2].

> It's also hilarious that Value Objects are still in preview.

Agreed, it's been a long time coming, but they've been doing a good job of releasing features that don't need deprecating five years later.

> This is false. structs in C or C++ don't have a language-imposed overhead. They may have different sizes depending on the alignment requirements of the platform.

Sorry, I misunderstood your comment. You were talking about different overheads on different platforms, and I read that as general overhead. (For example, if you run the exact same x86_64 binary on an Intel and AMD processor from the same generation, you can get drastically different results. Heck, you can get drastically different results within the same family from the same manufacturer for a half-dozen reasons). In any case, I wouldn't lose sleep over the varying size of object headers on different platforms. In the cases it matters, you should be avoiding them altogether.

> Also hilarious. It's 2024.

I don't know when Valhalla will land, but the Vector API is far smaller in scope. It's on its 8th incubator, and seems likely to land soon. You could give it a try.

> Checking every single array access in a tight loop, for example, is stupid.

This is a red herring in most situations. Your array accesses did get elided, you need to rewrite your code so it's easier for them to get elided, or the checks didn't have a performance impact. Also, you dev for mobile in Ada?

> No, I am talking about Java.

You must not be, because there are no exceptions used for control flow in code I write or review.

> Oh, and how does Java do low-level systems programming without unsigned integer types, lol?

It's annoying. You don't cast, you promote through a mask, e.g. val & 0xFF; That said, jOOU [3] looks interesting.

> And you better hope you don't need more than the native size, because then you get fuck-boxed into Integer

I don't understand this. You aren't using more than "native size" on any platform in any language without some sort of emulated Big* type.

> Also, you don't even have a guarantee that a variable is allocated on the stack even when the dumbest compiler can tell it's bound by function scope.

Implementations typically have both escape analysis and a nursery generation for this. This works well in a desktop/server environment. I can't speak to ART. Ultimately, Valhalla will solve this for constrained implementations.

> I love LWJGL

I'm knee-deep in GDX and LWJGL, right now, but again not in a mobile context. I used to hang out in the Java gaming forums with the folks who originated LWJGL (e.g. cas).

> This is a criticism of the language, not the library

I think your criticisms are mostly with ART. I agree there are a handful of language changes that would make things easier for ART.

1) https://www.jetbrains.com/help/inspectopedia/boxing.html#loc... 2) https://github.com/vigna/fastutil 3) https://github.com/jOOQ/jOOU

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#148
post #45

Earlier quoted context omitted.

> I've stopped counting how many times I came back to an Android project after only a few months, only to have Android Studio force me to update Gradle and dependencies and whatnot, and break everything. This used to be 5-6 years back. These days it is very stable.

No, it's not. This year I still had to upgrade all my projects (I do this yearly) and they still broke in a myriad of different ways. Most of them fortunately and perhaps ironically the solution was one Google search away. I actually _like_ Java, so it's not that I hate Android, but frankly, I have no idea what it is even doing downloading and generating gigabytes of crap with inscrutable huge log files. Most of my a…

> The Android tooling is basically a textbook definition of oversized enterprisey software. I really wish there was just a frigging (resource) compiler, linker and maybe packer that I could invoke from the command line in simple steps.

Yeah, I feel the same. There are CLI approaches that I have encapsulated into Makefile ( https://ashishb.net/all/use-makefile-for-android) and GitHub Actions (https://github.com/ashishb/gabo/blob/master/src/gabo/interna...) but they do require time to set up.

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#149
post #133

Earlier quoted context omitted.

Correctness is the number 1 priority, and maven is simply not always doing what it should, unless you do a clean build. I am absolutely not bothered by XML and alia (btw, there are maven frontends in json/yaml, etc for those who are), and throwing out valid criticism over some straw man is not really productive.

I’m still learning about the tools and their pros and cons. Can you provide an example of a case where Maven would not do what it should? Are there particular bug reports or bug reproduction repos that you’ve seen? Context: I worked on a Spring app many years ago and am picking Java back up.

Here is a case: https://stackoverflow.com/a/4662537

But I have run into issues with multi-module projects and the like, and it can be very frustrating to realize that you are trying out some corrupt version. Nonetheless, maven is also a cool and stable tool, but you are better off adding a clean step from time to time.

Re: Rawdrawandroid – Build Android apps without any Java, in C and Make

#150
post #133
post #132

Earlier quoted context omitted.

Maven is more as capable for anyone that doesn't suffer from XML allergy, and doesn't require a background daemon to actually make it run at reasonable speed.

Correctness is the number 1 priority, and maven is simply not always doing what it should, unless you do a clean build. I am absolutely not bothered by XML and alia (btw, there are maven frontends in json/yaml, etc for those who are), and throwing out valid criticism over some straw man is not really productive.

As if Gradle was any better in "correctness" given without its daemon, it is a slower Ant for folks with XML allergy.
Post reply on HN