Hacker News new | past | comments | ask | show | jobs | submit | habibur's comments login

I get blocked anytime I share my github project.


Add, no way to determine size of Array, which is the primary data structure anyway.

No item.length propery.

You might decide to count with foreach(), but that will terminate when it encounters the first value in the array that is NULL.


Given the way that tables work, the concept of a 'length' is a fuzzy one. However, the '#' operator will give you the last index of a table, which for tables used as arrays is pretty much what you want. There's also the '__len' metamethod, which is what's invoked if it's present if you use the '#' operator. The operator's been in the language since at least 5.1.

It's a bad idea to think of Lua tables as arrays. They're maps/dictionaries with some extra semantics to allow them to be used similarly to arrays.


> You might decide to count with foreach(), but that will terminate when it encounters the first value in the array that is NULL.

True only if the programmer doesn’t take the effort to understand the difference between ipairs and pairs.


Less than 4k loc.

   457 android_native_app_glue.c
   360 audio.c
   802 game.c
   201 init.c
    93 main.c
    39 mouse.c
    38 shaders.c
   229 texture.c
  1377 upng.c
    27 utils.c
  3623 total


A student of mine had an assignment to write a game using SFML, they wrote a FlappyBird clone and it was like a few hundred lines of code. It's not a very complex program to write. To be honest, I think 4k is too much :)


3623 total - 1377 upng.c (3rd-party tiny PNG image decoding library) = 2246


To be fair, Android itself requires some level of fluff.

So does making the game work well in more than one device.


Are you including SFML loc in that total?


game.c is 800 odd lines. There are some optimizations you could do here and there (e.g load digit sprites in an array to avoid the switch case 1/2/3... stuff).

The bulk of the 3000 is fluff that you need because this is C on Android, not SFML.


A shame that 4k loc compiles to over 100k of binary size.


It compiles to 37kb of 32bit code and to 48kb of 64bit code.

  /lib/arm64-v8a/libflappybird.so    48kb
  /lib/armeabi-v7a/libflappybird.so  37kb
  assets:     29kb
  icon:        3kb
  signature:  12kb
Plus the manifest (2kb) and resources.arsc (0.5kb)


It doesn't. The total APK size is less than 100k, including images and sounds.


actually including both architectures: armeabi-v7a + arm64-v8a

to check:

- dependencies statically compiled-in

- debug symbols


"how many kilometers are there in 100 miles?"

Increase by 60%. That's how I do it.


RAII <-- best of both worlds.


If you are talking about C++, it’s nice when RAII works. But if it does work, then in some sense your problem was easy. Async code and concurrent code require different solutions


Smart camera. Attach a microphone and speaker with the camera. Any movement at odd times and you get a WhatsApp video call on your cell phone. You can watch the other person and can talk to him, "Hay! what are you doing at my home?"

I was wondering if that's already available or not.


Yes this is already available. Most major camera lines now offer 2-way audio (siren, voice) to do exactly that.


Reading the article I get a feeling that it's more like proof of concept, than a economically feasible project, as there's no mention of costs.


Cheapest solution is still LAMP on DigitalOcean box. But instead of MySQL use SQLite.

Add more performance? No framework, roll your own.


Get ready to through out your GC as soon as it works and build a better one or different one. And then again, and then again. It's more like art.


This is how I write my compilers. Indeed, it's how I write all my software.


For other that are wondering how C++ programmers memory managed till now -- check RAII.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: