Live data from Hacker News

Ask HN: Best language to share code between an Android and iOS app?

news.ycombinator.com

121–123 of 123 posts

Re: Ask HN: Best language to share code between an Android and iOS app?

#121
post #27

So I'm sure lots of people will think that this definitely doesn't qualify as "Best language to share code...", but Haskell has stuff for getting web, desktop, iOS, and Android out of one code base. It's called Obelisk ( https://github.com/obsidiansystems/obelisk ) and it's actually getting to be a pretty good development experience.

I love hacker news. This is the comment I came here for. Just use this : A language that is (at best) fringe on the platform you are using. Here's a toolset nobody has ever heard of. Now build your mission critical bit of infrastructure on this house of cards, wait for the toolset maintainers to be outpaced and under-resourced by underlying OS/platform changes and then have to rewrite the whole thing which if it does…

"LINUX is obsolete", A.S. Tanenbaum, 1992.

A bit of nowadays tech scaled out from pet projects.

Re: Ask HN: Best language to share code between an Android and iOS app?

#122

Earlier quoted context omitted.

For example it is easier to avoid buffer overflows with std::string than with C-style strings.

It’s also easier to avoid buffer overflows in C by using the “n” variants of C string library functions.

Oh god no, because then you have to add string growth logic when you run out of space, and there's all sorts of opportunities to fuck that up.

Re: Ask HN: Best language to share code between an Android and iOS app?

#123

Earlier quoted context omitted.

strncpy notoriously doesn't necessarily 0-terminate. (It also always pads the full length with zeroes if necessary, so it's almost never what you actually want to do.) The C standard library is full of these footguns. I won't say C++ doesn't have its bad parts, and I certainly wouldn't say that it's impossible to avoid the bad parts of C (some would), but you probably aren't going to manage.

If all of your string manipulation is working with the knowledge of the maximum size, how is that any different than the standard Pascal or BSTR string handling where the size of the string can be found in the first two bytes of the string? The typical error case with C is something like char *a = “abcd”; //5 bytes char *b = “efgh”; char c[8]; strcpy(c,a); strcat(c,b); //buffer overflow by 1 byte. If you used the “n”…

It's not. But plenty of other standard C functions like to use 0-terminated strings without explicit lengths, including most of the system interfaces, and others make it awkward to pass in the length that you're actually tracking. You only need to call one of those with an unterminated string and it doesn't even matter whether your code knows the string's length.

You could say that just means you have to be very careful whenever you pass a pointer to a string around without also passing in its length, but that's a lot of places.

Post reply on HN