joplin-notes/joplin notion extension/Web Development/Extras/cli commands for different programming languages.md
2026-11-04 00:33:23 +05:30

91 lines
No EOL
2.2 KiB
Markdown

cli commands for different programming languages
- C
Requiments : gcc in linux and mingw in windows
For build system : meson, cmake,pkg-config
configuration file : Makefile
```c
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
```
- Compiling and running
`gcc hello.c -o hello`
Additionally to link packages use
```
gcc `pkg-config --cflags gtk+-3.0` -o main1 main.c `pkg-config --libs gtk+-3.0`
```
this will compile and create a binary file named `hello`
Running it
`./hello`
&nbsp;
- C++
```cpp
// Your First C++ Program
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}
```
- compiling and running
`g++ hello.cpp -o hello` and `./hello` to run
Additionally to link packages
`g++ main.cpp -Ifltk-1.3.9 -Lfltk-1.3.9/lib -lfltk -lX11 -lXfixes -lXext -lXft -lXrender -lfontconfig -lXcursor -lXinerama -ldl -o main`
&nbsp;
- Java
Requirements : openjdk installed
Build systems : maven/gradle(optional) for extra packages
Config files : pom.xml for maven and build.gradle for gradle
```java
// Your First Program
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
Compiling and running it
`javac hello` this will create a bytecode named `HelloWorld.class`
to execute the bytecode `java HelloWorld`
Theory
bytecode is the low level, platform independent code and when we use java command for bytecode it executes in JVM(Java Virtual Machine). This JVM converts bytecode into machine language and then executes it
&nbsp;
Compiling and running with maven
`mvn package` to build it
`mvn spring-boot:run` to run the sprint boot app
&nbsp;
- Javascript
Requirements : node installed
Build systems : npm/yarn for managing packages
Config files : package.json
```js
console.log('Hello World!')
```
Running
`node hello.js`
for packages
`npm i`
`npm start`
&nbsp;
- python
Requirements : python 3.x installed
Build system : pip for managing packages
Config file : requirements.txt
```py
print("Hello World!")
```
Running
`python hello.py`
for packages
`pip install requiremnts.txt`
`python main.py`