Pretty.c - C के ऊपर Scripting
(github.com/aartaka)- Pretty C, C के साथ compatible एक नई scripting भाषा है, जो dynamic typing, generic iteration, resource tracking जैसी सुविधाएँ प्रदान करती है
- यह C और सभी libraries के साथ backward compatibility बनाए रखती है
- यह Lua, Python, JavaScript, Lisp से प्रेरित है
लक्ष्य
- C developers को भरपूर syntactic sugar देकर C को और आसान बनाना
- Lua, Python, JavaScript, Ruby जैसी कई भाषाओं की जगह लेने वाली अंतिम scripting भाषा के रूप में स्थापित होना
- सिर्फ एक header file शामिल करके किसी भी codebase को beginner-friendly बनाना
शुरू करना
- GitHub repository को clone करें या
pretty.hफ़ाइल को कॉपी करके उपयोग कर सकते हैं
दी जाने वाली सुविधाजनक विशेषताएँ
शामिल standard headers
stdbool.hके जरिएtrue,false,boolउपलब्धstdint.hके जरिए fixed-width integer types उपलब्धiso646.hके जरिए अधिक readable operator alternatives उपलब्ध
सरल macros
max,min,len,default,limit,between,divisibleजैसे macros उपलब्ध
नए types
string,byte,bytes,anyजैसे type aliases उपलब्धuchar,ushort,uint,ulongजैसे integer shorthands उपलब्ध
नए aliases
eq,is,bitnot,bitxorजैसे operator aliases उपलब्धbelow,above,upto,downtoजैसे comparison operators उपलब्धeven,odd,positive,negative,zero,emptyजैसे numeric/data predicates उपलब्धnil,until,elif,ifnt,repeat,done~/~finish,passजैसे aliases उपलब्ध
type inference (GCC, Clang, या C23+)
var,let,localkeywords का उपयोग करके type inference संभव
generic output (C11+)
print,printlnसे विभिन्न types का data output किया जा सकता है
generic equality (C11+)
equalसे विभिन्न types के data की तुलना की जा सकती है
सुंदर ternary operator
when,then,other,otherwise,only,otherwhenजैसे keywords के साथ अधिक readable ternary operator का उपयोग संभव
for macros
foreach,forthese,fortimes,forrange,forrangebyजैसे macros से विभिन्न iteration patterns उपलब्ध
assignment macros
new,vector,deleteजैसे macros से आसान memory allocation और deallocation संभव
block utilities
lambda,with,defer,try,catchजैसी block utilities उपलब्ध
GN⁺ का सार
Pretty C, C भाषा में विभिन्न syntactic sugar जोड़ने वाला एक project है, जो developers को कोड अधिक आसानी से लिखने में मदद करता है। खास तौर पर, यह C की backward compatibility बनाए रखते हुए Lua, Python, JavaScript जैसी भाषाओं से प्रेरित कई सुविधाएँ प्रदान करता है। ये सुविधाएँ C developers को अधिक संक्षिप्त और readable code लिखने में मदद कर सकती हैं। समान प्रकार की सुविधाएँ देने वाले projects में Zig, Nim शामिल हैं।
1 टिप्पणियां
Hacker News की राय