Reference
Built-in Functions Reference BanglaCode provides 135+ built-in functions for I/O, type conversion, string manipulation, array operations, math, file handling, HTTP, JSON, environment variables, networking (TCP/UDP/WebSocket), database connectivity (PostgreSQL/MySQL/MongoDB/Redis), and complete OS-level system access.
Input/Output Function Parameters Returns Description dekhoargs...khaliPrint values to console nao[prompt]stringRead user input from console
1 // Print output 2 dekho ("Hello" );3 dekho ("Name:" , "Rahim" , "Age:" , 25 );4 5 // Read input 6 dhoro naam = nao ("Enter your name: " );7 dekho ("Hello," , naam);
Type Functions Function Parameters Returns Description dhoronvaluestringGet type of value lipivaluestringConvert to string sonkhavaluenumberConvert to number
1 // Type checking 2 dekho (dhoron (42 )); // "int" 3 dekho (dhoron (3.14 )); // "float" 4 dekho (dhoron ("hello" )); // "string" 5 dekho (dhoron (sotti )); // "boolean" 6 dekho (dhoron ([1 ,2 ,3 ])); // "array" 7 dekho (dhoron ({x:1 })); // "map" 8 9 // Convert to string 10 dekho (lipi (42 )); // "42" 11 dekho (lipi (sotti )); // "true" 12 13 // Convert to number 14 dekho (sonkha ("123" )); // 123 15 dekho (sonkha ("3.14" )); // 3.14
String Functions Function Parameters Returns Description dorghyostrintGet string length boroHaterstrstringConvert to uppercase chotoHaterstrstringConvert to lowercase bhagstr, separraySplit string by separator joroarr, sepstringJoin array elements chhantostrstringTrim whitespace khojostr, substrintFind index of substring (-1 if not found) angshostr, start, [end]stringGet substring bodlostr, old, newstringReplace all occurrences
1 dhoro str = " Hello World " ;2 3 dekho (dorghyo (str)); // 15 4 dekho (chhanto (str)); // "Hello World" 5 dekho (boroHater ("hello" )); // "HELLO" 6 dekho (chotoHater ("HELLO" )); // "hello" 7 dekho (bhag ("a,b,c" , "," )); // ["a", "b", "c"] 8 dekho (joro (["a" ,"b" ,"c" ], "-" ));// "a-b-c" 9 dekho (khojo ("hello" , "ll" )); // 2 10 dekho (angsho ("hello" , 1 , 4 )); // "ell" 11 dekho (bodlo ("aaa" , "a" , "b" )); // "bbb"
Array Functions Function Parameters Returns Description dorghyoarrintGet array length dhokaoarr, itemarrayPush item to end berKoroarranyPop item from end katoarr, start, [end]arraySlice array ultoarrarrayReverse array achearr, itembooleanCheck if item exists sajaarrarraySort array
1 dhoro arr = [3 , 1 , 4 , 1 , 5 ];2 3 dekho (dorghyo (arr)); // 5 4 dhokao (arr, 9 ); // Push 9 5 dekho (berKoro (arr)); // 9 (and removes it) 6 dekho (kato (arr, 1 , 3 )); // [1, 4] 7 dekho (ulto (arr)); // [5, 1, 4, 1, 3] 8 dekho (ache (arr, 4 )); // sotti 9 dekho (saja ([3 ,1 ,2 ])); // [1, 2, 3]
Math Functions Function Parameters Returns Description borgomulnfloatSquare root ghatbase, expnumberPower (base^exp) nichenintFloor (round down) uporenintCeiling (round up) kachenintRound to nearest nirateknnumberAbsolute value choto...numsnumberMinimum value boro...numsnumberMaximum value lotto(none)floatRandom number [0, 1)
1 dekho (borgomul (16 )); // 4 2 dekho (ghat (2 , 10 )); // 1024 3 dekho (niche (3.7 )); // 3 4 dekho (upore (3.2 )); // 4 5 dekho (kache (3.5 )); // 4 6 dekho (niratek (- 5 )); // 5 7 dekho (choto (5 , 2 , 8 , 1 )); // 1 8 dekho (boro (5 , 2 , 8 , 1 )); // 8 9 dekho (lotto ()); // 0.xxxxx (random)
Map Functions Function Parameters Returns Description chabimaparrayGet all keys as array
1 dhoro obj = {naam: "Rahim" , boyosh: 25 };2 dekho (chabi (obj)); // ["naam", "boyosh"]
File I/O Functions Function Parameters Returns Description poropathstringRead file content lekhopath, contentbooleanWrite content to file file_jogpath, contentbooleanAppend content to file (জোগ = add) file_mochhopathbooleanDelete file (মোছো = erase) file_nokolsource, destinationbooleanCopy file (নকল = duplicate) folder_mochhopath, [recursive]booleanDelete folder (recursive if sotti/true) file_dekhunpath, callbackwatcherWatch file for changes (দেখুন = watch) file_dekhun_bondhowatcherbooleanStop watching file (বন্ধ = stop)
1 // Read file 2 dhoro content = poro ("data.txt" );3 dekho (content);4 5 // Write file 6 lekho ("output.txt" , "Hello World" );7 8 // Append to file 9 file_jog("log.txt" , "New log entry\n" ); 10 11 // Copy file 12 file_nokol("source.txt" , "backup.txt" ); 13 14 // Delete file 15 file_mochho("temp.txt" ); 16 17 // Delete folder (recursive) 18 folder_mochho("old_data" , sotti ); 19 20 // Watch file for changes 21 dhoro watcher = file_dekhun("config.json" , kaj (event, filename) {22 dekho ("File changed:" , event, filename); 23 // Reload configuration 24 }); 25 26 // Stop watching after 10 seconds 27 ghumaao(10000 ).tarpor(kaj () { 28 file_dekhun_bondho(watcher); 29 dekho ("Stopped watching" ); 30 });
JSON Functions Function Parameters Returns Description json_porostranyParse JSON string json_banaovaluestringConvert to JSON string
1 // Parse JSON 2 dhoro obj = json_poro ('{"name":"Rahim","age":25}' );3 dekho (obj.name); // "Rahim" 4 5 // Create JSON 6 dhoro json = json_banao ({x: 1 , y: 2 });7 dekho (json); // {"x":1,"y":2}
Environment Variables See the Environment Variables Documentation for detailed examples and multi-environment setup.
Function Parameters Returns Description env_loadfilenamebooleanLoad environment variables from .env file env_load_autoenvironmentstringAuto-load .env.{environment} or fallback to .env env_getkeystringGet environment variable (error if not found) env_get_defaultkey, defaultstringGet environment variable with default fallback env_setkey, valuebooleanSet environment variable at runtime env_all(none)mapGet all environment variables as map env_clear(none)booleanClear all loaded environment variables
1 // Load .env file 2 env_load(".env" ); 3 4 // Get environment variables 5 dhoro api_key = env_get("API_KEY" );6 dhoro api_url = env_get_default("API_URL" , "http://localhost:3000" );7 8 dekho ("API URL:" , api_url);9 10 // Multi-environment support 11 env_load_auto("prod" ); // Loads .env.prod or falls back to .env 12 dhoro db_host = env_get("DB_HOST" );13 dekho ("Database Host:" , db_host);14 15 // Set runtime variable 16 env_set("SESSION_ID" , "abc123" ); 17 18 // Get all variables 19 dhoro all = env_all();20 dekho ("All env vars:" , all);
Utility Functions Function Parameters Returns Description somoy(none)intCurrent time in milliseconds ghummskhaliSleep/delay for milliseconds bondho[code](exit)Exit program
1 // Current time 2 dhoro now = somoy ();3 dekho ("Timestamp:" , now);4 5 // Sleep 1 second 6 dekho ("Waiting..." );7 ghum (1000 );8 dekho ("Done!" );9 10 // Exit program 11 bondho (0 ); // Exit with code 0
HTTP Functions Function Parameters Returns Description server_chaluport, handlerkhaliStart HTTP server anunurlmapHTTP GET request uttorres, body, [status], [type]mapSend HTTP response json_uttorres, data, [status]mapSend JSON response
1 // Start server 2 server_chalu (8080 , kaj (req, res) {3 json_uttor (res, {message: "Hello!" }); 4 }); 5 6 // Make HTTP request 7 dhoro response = anun ("https://api.example.com/data" );8 dekho (response.body);
Async/Promise Functions Asynchronous functions that return promises. Use with proyash/opekha keywords. See the Async/Await documentation for detailed examples.
Function Parameters Returns Description ghumaaomillisecondsPromiseSleep for specified time (async) sob_proyasharrayPromiseWait for all promises concurrently (Promise.all) poro_asyncpathPromiseRead file asynchronously lekho_asyncpath, contentPromiseWrite file asynchronously anun_asyncurlPromiseHTTP GET request asynchronously
1 // Sleep for 1 second 2 proyash kaj timer() { 3 dekho ("Start" ); 4 opekha ghumaao(1000 ); 5 dekho ("1 second later" ); 6 } 7 8 // Run multiple operations concurrently 9 proyash kaj parallel() { 10 dhoro results = opekha sob_proyash([ 11 ghumaao(500 ), 12 poro_async("file.txt" ), 13 anun_async("https://api.example.com" ) 14 ]); 15 dekho ("All operations complete!" ); 16 } 17 18 timer(); 19 parallel();
Networking Functions BanglaCode provides comprehensive networking capabilities for TCP, UDP, and WebSocket protocols, making network programming as easy as JavaScript/Node.js.
TCP Functions (6 functions) Function Parameters Returns Description tcp_server_chaluport, handlerkhaliStart TCP server with callback tcp_juktohost, portPromiseConnect to TCP server (async) tcp_pathaoconnection, datakhaliSend data on TCP connection tcp_lekhoconnection, datakhaliWrite data to TCP connection (alias) tcp_shunoconnectionPromiseRead data from TCP connection (async) tcp_bondhoconnectionkhaliClose TCP connection
1 // TCP Server 2 tcp_server_chalu(8080 , kaj (conn) { 3 dekho ("Client:" , conn["remote_addr" ]); 4 dekho ("Data:" , conn["data" ]); 5 tcp_pathao(conn, "Echo: " + conn["data" ]); 6 }); 7 8 // TCP Client 9 proyash kaj client() { 10 dhoro conn = opekha tcp_jukto("localhost" , 8080 ); 11 tcp_lekho(conn, "Hello!" ); 12 dhoro response = opekha tcp_shuno(conn); 13 dekho (response); 14 tcp_bondho(conn); 15 } 16 client();
UDP Functions (5 functions) Function Parameters Returns Description udp_server_chaluport, handlerkhaliStart UDP server with callback udp_pathaohost, port, dataPromiseSend UDP packet (async) udp_uttorpacket, datakhaliSend UDP response to client udp_shunoport, handlerkhaliListen for UDP packets (alias) udp_bondhoconnectionkhaliClose UDP connection
1 // UDP Server 2 udp_server_chalu(9000 , kaj (packet) { 3 dekho ("From:" , packet["remote_addr" ]); 4 dekho ("Data:" , packet["data" ]); 5 udp_uttor(packet, "Got it!" ); 6 }); 7 8 // UDP Client 9 proyash kaj send() { 10 opekha udp_pathao("localhost" , 9000 , "Hello UDP!" ); 11 } 12 send();
WebSocket Functions (4 functions) Function Parameters Returns Description websocket_server_chaluport, handlerkhaliStart WebSocket server websocket_juktourlPromiseConnect to WebSocket server (async) websocket_pathaoconnection, messagekhaliSend WebSocket message websocket_bondhoconnectionkhaliClose WebSocket connection
1 // WebSocket Chat Server 2 websocket_server_chalu(3000 , kaj (conn) { 3 dekho ("Message:" , conn["message" ]); 4 websocket_pathao(conn, "Reply: " + conn["message" ]); 5 }); 6 7 // WebSocket Client 8 proyash kaj chat() { 9 dhoro ws = opekha websocket_jukto("ws://localhost:3000" ); 10 websocket_pathao(ws, "Hello WebSocket!" ); 11 ghumaao(1000 ); 12 websocket_bondho(ws); 13 } 14 chat();
Function Name Meanings All built-in functions use Bengali words:
Function Bengali Meaning dekhoদেখো look/see (print) naoনাও take (input) dhoronধরন type/kind lipiলিপি script/writing (string) sonkhaসংখ্যা number dorghyoদৈর্ঘ্য length dhokaoঢোকাও insert/push berKoroবের করো take out/pop boroHaterবড় হাতের uppercase chotoHaterছোট হাতের lowercase borgomulবর্গমূল square root somoyসময় time poroপড়ো read lekhoলেখো write
System Operations BanglaCode provides 53 system-level functions for file operations, process management, network information, system statistics, environment variables, and temporary file handling.
File Metadata Function Parameters Returns Description file_akarpathnumberGet file size in bytes file_permissionpathstringGet file permissions (e.g., "0644") file_permission_setpath, permskhaliChange file permissions file_malikanpathmapGet file owner (uid, gid, naam) file_shomoy_poribortitopathnumberGet file modified time (Unix) file_dhoronpathstringGet file type (file/directory/symlink) file_renameold, newkhaliRename or move file
Directory Operations Function Parameters Returns Description directory_taliikapatharrayList directory contents directory_ghumaopatharrayRecursive directory traversal directory_khali_kipathbooleanCheck if directory is empty directory_akarpathnumberGet total directory size in bytes
1 // File metadata example 2 dhoro size = file_akar("/path/to/file.txt" );3 dekho ("Size:" , size, "bytes" );4 5 dhoro perms = file_permission("/path/to/file.txt" );6 dekho ("Permissions:" , perms);7 8 // Directory operations 9 dhoro files = directory_taliika("/home/user" );10 ghuriye (dhoro i = 0 ; i < dorghyo (files); i = i + 1 ) {11 dekho (files[i]); 12 }
Process Management Function Parameters Returns Description chalancmd, [args]mapExecute system command process_ghummskhaliSleep for milliseconds process_maropidkhaliKill process by PID process_chalucmd, [args]mapStart process in background process_opekhapidmapWait for process completion
Network Information Function Parameters Returns Description network_interface- arrayGet all network interfaces ip_addressifacearrayGet IP addresses for interface ip_shokal- arrayGet all IP addresses mac_addressifacestringGet MAC address for interface
System Statistics Function Parameters Returns Description memory_total- numberTotal system memory in bytes memory_bebohrito- numberUsed memory in bytes disk_akar[path]numberTotal disk size in bytes disk_mukt[path]numberFree disk space in bytes
Time Operations Function Parameters Returns Description shomoy_ekhon- numberCurrent Unix timestamp shomoy_formattimestamp, [format]stringFormat timestamp to string shomoy_parsestr, [format]numberParse time string to timestamp timezone- stringGet current timezone
Temporary Files Function Parameters Returns Description temp_directory- stringGet system temp directory temp_file[prefix]stringCreate temporary file temp_folder[prefix]stringCreate temporary directory
Symbolic Links Function Parameters Returns Description symlink_banaotarget, linkkhaliCreate symbolic link symlink_porolinkstringRead symlink target symlink_kipathbooleanCheck if path is symlink
Database Functions Production-grade database connectors for PostgreSQL, MySQL, MongoDB, and Redis with connection pooling and async support. See the Database Documentation for detailed examples.
Universal Database Functions Function Parameters Returns Description db_juktotype, configconnectionConnect to database (postgres/mysql/mongodb/redis) db_jukto_asynctype, configpromiseConnect to database (async) db_bandhoconnkhaliClose database connection db_queryconn, sqlresultExecute SELECT query (SQL databases) db_execconn, sqlresultExecute INSERT/UPDATE/DELETE db_proshnoconn, sql, paramsresultPrepared statement (SQL injection safe)
Connection Pool Functions Function Parameters Returns Description db_pool_banaotype, config, maxConnspoolCreate connection pool (50-100x faster) db_pool_naopoolconnectionGet connection from pool db_pool_ferotpool, connkhaliReturn connection to pool db_pool_bondhopoolkhaliClose connection pool db_pool_tothyopoolmapGet pool statistics
PostgreSQL Functions Function Parameters Description db_jukto_postgresconfigConnect to PostgreSQL db_query_postgresconn, sqlExecute SELECT query db_exec_postgresconn, sqlExecute INSERT/UPDATE/DELETE db_proshno_postgresconn, sql, paramsPrepared statement db_transaction_shuru_postgresconnBegin transaction db_commit_postgrestxCommit transaction db_rollback_postgrestxRollback transaction
MySQL Functions Function Parameters Description db_jukto_mysqlconfigConnect to MySQL db_query_mysqlconn, sqlExecute SELECT query db_exec_mysqlconn, sqlExecute INSERT/UPDATE/DELETE db_proshno_mysqlconn, sql, paramsPrepared statement db_transaction_shuru_mysqlconnBegin transaction db_commit_mysqltxCommit transaction db_rollback_mysqltxRollback transaction
MongoDB Functions Function Parameters Description db_jukto_mongodbconfigConnect to MongoDB db_khojo_mongodbconn, collection, filterFind documents db_dhokao_mongodbconn, collection, docInsert document db_update_mongodbconn, collection, filter, updateUpdate documents db_mujhe_mongodbconn, collection, filterDelete documents
Redis Functions Function Parameters Description db_jukto_redisconfigConnect to Redis db_set_redisconn, key, value, ttl?Set key-value (optional TTL) db_get_redisconn, keyGet value by key db_del_redisconn, keyDelete key db_expire_redisconn, key, secondsSet expiration time db_lpush_redisconn, key, valuePush to list (left/front) db_rpush_redisconn, key, valuePush to list (right/back) db_lpop_redisconn, keyPop from list (left/front) db_hset_redisconn, key, field, valueSet hash field db_hget_redisconn, key, fieldGet hash field db_hgetall_redisconn, keyGet all hash fields