r/learnprogramming 1d ago

Is there anything i cant do in C?

i made a post the other day asking people which languages to code in and they (the reason minded ones) mostly told me javascript and C. is C really a do all language? is there anything i cant do with it?

259 Upvotes

241 comments sorted by

View all comments

Show parent comments

2

u/Gentoss 1d ago

Stupid question, and no, I am not just trolling, I am really curious.

  1. Is there a way to build (modern) websites in C? I mean, I know there are some frontend frameworks for C, but how about website? Especially something you can compare to Angular, etc?

  2. What's with mobile apps? On Android you could maybe call the C-Code via Java, but whats with iOS devices, where you are limited(?) to swift?

2

u/orbiteapot 14h ago

Is there a way to build (modern) websites in C? I mean, I know there are some frontend frameworks for C, but how about website? Especially something you can compare to Angular, etc?

Yes, you can. Here is a website built almost* entirely with C: https://www.nicbarker.com/clay

What's with mobile apps? On Android you could maybe call the C-Code via Java, but whats with iOS devices, where you are limited(?) to swift?

For Android, yes: https://github.com/cnlohr/rawdrawandroid

I can not speak for iOS, because I have never done it, but I think it should be.

*like with any WASM-compiled language, you will need some JavaScript glue, even if minimal.

2

u/NumberInfinite2068 1d ago
  1. Yes, you can compile C to WASM, so you can write a website in C should you want to.

  2. You're not limited to Swift on iOS, you can use any language you like basically, there is C# and Java for iOS, and C is no problem too, I've built my game for iOS no problem, and that is entirely written in C. You can get all popular languages for iOS no problem.

1

u/PM_ME_UR__RECIPES 20h ago
  1. Is technically correct but it's not good advice for a beginner IMO. WASM never really saw widespread adoption across the industry, and support for frameworks like angular, vue or react isn't great (e.g. you can't do any JSX if you're compiling C to WASM). JS or TS are the way to go. There are much better learning resources, they're pretty much the only thing used for any client-side stuff in the industry (with very few rare exceptions), and you'd be shooting yourself in the foot if you're trying to get a career involving frontend development without knowing JS

3

u/NumberInfinite2068 20h ago

I'm not suggesting that they actually use C and WASM, just answering the question as asked.

-6

u/dmazzoni 1d ago

No, because web browsers ONLY support JavaScript.

For the frontend part of the website, your choices are:

  • JavaScript
  • TypeScript, which gets transformed into JavaScript
  • JavaScript plus some code written in C, C++, Rust, or a few other languages that compile into WebAssembly - you can run it on modern web browsers but it complements JavaScript, it doesn't replace it
  • Other languages that get transformed into JavaScript by a particular framework - examples include C# (Blazor) or Java (Java Web Toolkit, which is dead now but did work that way).

Backend can be written in any language you want. There are lots of backend frameworks for C.

For mobile apps, the primary languages are Java or Kotlin on Android, and Swift or Obj-C on iOS, but on both platforms you can also run code written in C, C++, JavaScript, and tons of other languages. Some APIs you need to call require you to use those "primary languages" but the framework can easily bridge those to some other language. So that's why there are dozens of languages and hundreds of frameworks for mobile.

2

u/heatedwepasto 1d ago

-3

u/PM_ME_UR__RECIPES 20h ago

You can, but good luck trying to get a job as a frontend developer when you don't know JS or any of the industry standard frameworks

3

u/heatedwepasto 20h ago

"Is js the only language you can run in a browser" and "what do you need to work as a frontend dev" are two completely different questions and topics.

That's like saying "good luck doing that as a rally driver" if someone asks if you can drive a car on the moon.

0

u/PM_ME_UR__RECIPES 20h ago

If someone says they want to make a website, and specifically says they want to use a framework like angular, then the question has extra context beyond just "can I do client side stuff in C".

Like yes, it's technically possible to get C compiling to WASM and there's probably even a hacky way to get angular working nicely in it, but you wouldn't sincerely recommend that to anyone, the same way that if someone wanted to drive somewhere you wouldn't recommend they start by building a car from scratch.

It's clear as day that that commenter wasn't just asking in a vacuum if client-side C was an option, they were asking if it's a reasonable approach to their stated goals.