Register
Handmade Hero»Forums»Code»Using pure C for eveything
16 posts
Using pure C for eveything
7 months ago Edited by Joystick on April 14, 2019, 8:18 p.m. Reason: Initial post
What's shakin' homies!
I've been wondering for a while now if I can use C to create things other than games/programs on PC. For instance, can I build a whole functional website just like this one, or make a game/application on android using nothing but plain C?
Can I do such a thing with nothing at my disposal but Emacs?
Build every tool that'd required for the task at hand from scratch just like Casey does it in his series?
Timothy Barnes
25 posts / 1 project
Using pure C for eveything
7 months ago Edited by Timothy Barnes on April 14, 2019, 9:09 p.m.
In general any possible app or web service can be written in C. However, I cannot guarantee that every device you may come across is programmable in C. In order to get a program in C running on a device, you need a C compiler for the device's instruction set, and a way to load that program into the device's memory.

There are cases in which you do not have direct access to the machine instructions, such as when the only interface to the module is a serial interface using some ASCII command representation such as the Hayes command set. Some semiconductor companies such as Silicon Labs use scripting languages that are directly sent to the module and processed internally such as their proprietary language BGScript.

If you have a specific project in mind that you would like to work on in C, feel free to let us know. If it is anything from a web server to a mobile game, I sure there is someone here that can give you some idea on how to get started.
16 posts
Using pure C for eveything
7 months ago
Thanks for your thorough input homie!

Let's say that I want to be able to follow Casey's series on Android. I'm well aware of the NDK which lets you implement parts of your app in native code using C/C++, but I'm still bound to Java and have to call all the native code I wrote in C using Java. What do I have to do in order to write apps on Android using nothing but C and Emacs?

P.S. Is it even advisable to do such a thing? Would that increase the performance of my apps or "reinventing the wheel" on Android is not a good idea?
19 posts
Using pure C for eveything
7 months ago Edited by SIMPalaxy on April 15, 2019, 3:28 a.m.
It's probably more trouble than it's worth. I believe there is a way to use a gcc cross-compiler from the NDK (native development kit) that generates java bytecode from a c source, but then you may have to learn an API to interface with it etc.

In short, if you make the Java part small, you shouldn't have significant performance penalty, and you can use the cross-compiler.

Google Dev has a good video explaining the whole situation. (The first portion anyway, which explains why C code can't run directly on the android OS)
16 posts
Using pure C for eveything
7 months ago
Thanks for the great source of information homie, I'll definitely check it out!

And what would you say about web development in C?
Where do I even start, and how efficient would this be (in terms of performance and time spent on creating all the necessary tools from scratch), in comparison to the regular approach using web languages?
475 posts
Using pure C for eveything
7 months ago
Joystick
Thanks for the great source of information homie, I'll definitely check it out!

And what would you say about web development in C?
Where do I even start, and how efficient would this be (in terms of performance and time spent on creating all the necessary tools from scratch), in comparison to the regular approach using web languages?


the networking itself isn't that hard once you find a good source on async IO

however all the protocols are a pain to deal with there are dozens of RFCs to comb through for all the details. The canonical libraries aren't necessarily that much better.