0

Is C and C++ are universal coding language?

I mean can I write the code in C and run it on any platform like windows android mac and linux? Is every OS and kernels are developed in C and C++? Please explain about compiler... I have just started learning to code,so I am looking for basic explanation.

14th May 2018, 3:10 AM
Arth Doshi
11 ответов
+ 1
a compiler is a program that reads the source code (In your case, the c/c++ files) and create a binary file that the machine can execute. A program written in c/c++ can run on any platform if there is a compiler for that platform. Often you develop and compile on the platform that will execute the binary, but not necessarily. For example: you can develop on Linux using a compiler for something else (say, windows), in which case the resulting binary will run on the target platform (windows) but not Linux.
14th May 2018, 5:29 AM
ifl
ifl - avatar
+ 1
ifl Are compilers pre installed on the OS? Or Do I need to install something ro run the program?
14th May 2018, 6:19 AM
Arth Doshi
+ 1
c++ compilers are usually not installed on the OS . well it is on some Linux distributions but even then you want to get yourself a recent version. What platform are you developing on?
14th May 2018, 12:36 PM
ifl
ifl - avatar
+ 1
nothing is natively supported by Windows, except PowerShell. If you are a beginner, you may want to download and install python. it installs with the interpreter and an editor and you are all set up. for java, you need to install the java SDK, then on top of that an editor, for example eclipse. a bit harder than python but once you are set, you can do a lot. For c++ you need to install the compiler and an editor. on windows, visual studio combines both. c++ is probably the harder to start with as a beginner.
14th May 2018, 4:13 PM
ifl
ifl - avatar
0
ifl I am just a beginner, I learnt to develop website on sololearn myself, I am looking forward to develop apps for windows, But I was wondering does user needs anything pre installed to run apps written in C,C++,C#,java etc.. As far as I know java needs to be installed to run java apps. Is it the case with other or the rest are natively supported by windows?
14th May 2018, 12:59 PM
Arth Doshi
0
ifl Thank you very much for the support. I still have one doubt. If I wrote the code in C,C++,C# or python and compile it on one PC. Will that exe work for other PC with different architecture?if no,then can I recompile the same code for different platforms?will it work same?
14th May 2018, 4:23 PM
Arth Doshi
0
python is not compiled. if you install python on your target system it should run the same as on your dev system. java is not compiled to an exe, but to java classes and libraries(jar files) You don't need to install the jdk on the target machine, but the java environment (JRE ) need to be installed on the target system to run your java classes or jar. C++ programs need to be compiled with a compiler compatible with the target architecture. Then the exe will work on the target pc with no need for anything else.
14th May 2018, 4:34 PM
ifl
ifl - avatar
0
ifl That means java and python runs in a same way i.e. on a runtime or virtual machine that needs to be separately installed in order to run the code. Then C++ is the only option to develop app that can run on every windows similarly. Am I right? Is C,C++ and C# are similar to each other?Are they derived and developed on the top of same language? And sorry in advance if my question are too silly...
14th May 2018, 4:48 PM
Arth Doshi
0
C is the oldest C++ syntax is derived from C and introduces classes and object orientedness. C# is the most recent, syntax evolved from c++ . Was created as a competition to java. and is very Windows centric.
14th May 2018, 4:52 PM
ifl
ifl - avatar
0
thefact that you need to install python or java environment on the target machine should not stop you. It is very easy to download and is free, and could even have been already installed for other programs to run. just pick up something you enjoy and start coding!
14th May 2018, 4:55 PM
ifl
ifl - avatar
0
ifl Can you give some examples of popular apps on windows coded with java or python? microsoft also suggests development in C++ and C# for beginners. https://developer.microsoft.com/en-us/windows/desktop/getstarted
14th May 2018, 4:59 PM
Arth Doshi