Hinglish

Om lang ek general purpose programming language hai. Ise sirf website, AI, apps ya server ke liye hi nahi balki isko kisi bhi type ke software banane ke liye use kar sakte hai. Isko is tarah design kiya gaya hai ki iska istmal karke programming easily seekh sakte hai. Om lang bohot simple programming language hai, bohot fast bhi hai aur isme aaj ki programming languages ke sare latest aur modern features hai.

OM Lang C, C++, Rust, Go etc. ki tarah ek statically type programming language Hai jo isko ek safe programming language banati hai. Javascript, PHP, Python type safe programming language nahi hai isliye OM Lang unse acchi hai. OM Lang ko C ka ek better version keh sakte hai kyunki ye C ki speed aur power deti hai per C ke mukable sikhne aur use karne me simple hai aur usi ke sath sahi tarike se code likhna bhi sikhati hai.

Install karne ka tarika

OM Lang ke do version hai ek PC ke liye aur ek smartphone ke liye.

OM Lang ka android app aap home page se ya google play store se download kar sakte hai.

OM Lang ko PC me download karne ke liye home page me jake PC version download kar sakte hai. Download file ke andar 4 folder honge, Mac, Linux, Windows aur ek example folder.

Data Types

int // 32bit int, -2,147,483,648 - 2,147,483,647
i16 // 16bit int, -32,768 - 32,767
i64 // 64bit int 
i8 // 8bit int, -128 - 127
f32 // 32bit floating point number
f64 // 64bit floating point number
string //
u16 // 16bit unsigned int, 0 - 65,535
u32 // 32bit unsigned int, 0 - 4,294,967,295
u64 // 64bit unsigned int
byte // 8 bit
bool // sahi, galat
array // [1,2,3,4]
map // {'ek': 1, 'do': 2}

Variable

Variable simply ek naam hai jisko kisi ek tarah ke data type ki value ko store karne ke liye use karte hai. Variables ki value ko by default badla nahi ja sakta, uski value ko badalne ke liye ‘bdl’ (Badal) keyword ka use karke declare karna padta hai. Variable ko ek code block ke andar hi declare kar sakte hai aur uska scope usi block tak limited rahega, matlab ki use us code block me bahar use nahi kar sakte hai.

do_sau := 200
bdl naam := 'mayank'
naam = 'mayank kumar'

Constant

Constant bhi ek naam hai jisko variable ki tarah ek data type ki value ko store karne ke liye use karte hai par constant ki value ko badal nahi sakte. Constant ko code block ke bahar declare karte hai aur isko kisi bhi aur koi bhi code block me access kar sakte hai. Constant ko declare karne ke liye ‘const’ keyword ka use karte hai.

const(
	pi = 3.14
	gravity = 9.8
)

Structures

Structure ek composite data type hai jisme hum alag-alag data type ke variable ki list ya group ko store karne ke liye use karte hai. Basically, structure ko ek object create karne ke liye use karte hai aur iska use OOP me hota hai. Structure ko declare karne ke liye ‘struct’ keyword ka use kare.

struct Gaadi {
	tyre int
	seat int
	color string
	name string
}

Structure ke andar bhi sare variable ko by default badla nahi jaa sakta, unko badalne ke liye ‘bdl’ keyword ka use kare.

struct Gaadi {
	tyre int
	seat int
	naam string
bdl:
	color string
}

bdl car := Gaadi{
	tyre : 4
	seat : 5
	naam : 'Wagon R'
	color : 'white'
}

car.color = 'red'
car.tyre = 3 // error

Interface

Interface ek aisa type hai jiske andar kuch tarah ki abstract properties define karte hai jaise ki data type ya function. Jo bhi data type en properties ko implement karega tab wo us interface ke type ko apna lega.

interface Polygon {
	sides int
	area() int
}

Enum

Enum ek aisa type hai jisme kuch naamo ki list hoti hai jinki koi value ya data type nahi hota. Enum ka use tab kar sakte hai jab hume kuch information ki list ko store karni ho par unki koi value na ho.

enum Phone {
	apple
	samsung
	oneplus
	xiaomi
	vivo
	oppo
}

Function

Function ek aisa instruction hai jisme kuch value bhejte hai aur function ek ya ek se jada value vaapis karta hai. Om Lang me function ek se jada value return kar sakta hai.

fnc area(width int, height int) int {
	vaapis width * height
}

fnc circle(radius int) (float, int) {
	area := 3.14 * radius * radius
	diameter := 2 * radius
	vaapis area, diameter
}

area(10, 20)
circle(5)

Method

Method function ki tarah hi hota hai bas iska use structure ke liye hota hai. Method hamesha ek kisi structure ke liye hi define kar sakte hai.

struct Gaadi {
	tyre int
	seat int
	naam string
bdl:
	color string
}

fnc (g Gaadi) color_badlo(color string) {
	g.color = color
}

bdl car := Gaadi{
	tyre : 4
	seat : 5
	naam : 'Wagon R'
	color : 'white'
}

car.color_badlo('black')

Conditional

color := 'red'

agar color == 'red' {
	println('color red hai')
} ya agar color == 'blue' {
	println('color blue hai')
} verna {
	println('alag color hai')
}

Loop

loop i := 0; i < 10; i++ ke liye {
	println(i)
}

phal_list := ['seb', 'anar', 'kela', 'naryal', 'angoor']

loop phal_list me ek_phal ke liye {
	println(ek_phal)
}

Match

mithai := 'laddoo'

match mithai {
	'petha' {println('Is mithai ka naam petha hai')}
	'laddoo' {println('Is mithai ka naam laddoo hai')}
	'barfi' {println('Is mithai ka naam barfi hai')}
	verna {println('Mithai match nahi hui')}
}

₹ Symbol

₹ Symbol ek string ek ander ek variable ki value ko string mai convert kerke automatically add ker deta hai.

naam := 'mayank'

intro := 'mera naam ₹naam hai'

// mera naam mayank hai

© 2022 🕉️  OM Lang. Made with 🧘  by Mayank Kumar in India. All Rights Reserved.