Lua, ikani chilankhulo champhamvu ichi pa Ubuntu

Pafupi ndi lua

M'nkhani yotsatira tiwona za Lua. Ichi ndi chilankhulo chaulere komanso chotsegula. Ndi yamphamvu, yamphamvu, yochepa komanso yophatikizika. Lua ndi chilankhulo cholembera chomwe chimathandizira mapulogalamu, njira zoyendetsera zinthu, mapulogalamu ogwira ntchito, mapulogalamu oyendetsedwa ndi deta ndi kufotokozera izi.

Lua imaphatikiza syntax yosavuta yolongosoka ndi kufotokozera kwamphamvu kwamapangidwe kutengera magulu ophatikizika ndi ma semantics owonjezera. Chilankhulochi chimayimbidwa mwamphamvu, amathamanga akamamasulira chikhomo ndi makina olembetsa olembetsa ndipo imakhala ndi kasamalidwe kake kodzidzimutsa komwe kamakhala ndi zochulukirapo zinyalala. Ndizofunikira pakukonzekera, kulemba, komanso kutengera mwachangu.

Chilankhulochi chakhala chikugwiritsidwa ntchito m'mafakitale ambiri, monga Adobe Photoshop Lightroom. Amagwiritsidwanso ntchito pamasewera monga World of Warcraft ndi Angry Birds. Malinga ndi tsamba lawo lawebusayiti, ichi ndiye chilankhulo chotsogola pamasewera. Mitundu yambiri ya Lua yamasulidwa ndikugwiritsidwa ntchito ngati momwe idayambira kuyambira mu 1993.

Lua ali ndi mbiri yoyenera kuchita. Nenani kukhala 'mwachangu ngati lua', ndichilakolako cha zinenero zina zolembedwa. Zizindikiro zosiyanasiyana zikuwonetsa Lua monga chilankhulo chothamanga kwambiri pamasulidwe azilankhulo.

Tidzatha kuyendetsa zonse, ngati si machitidwe ambiri, Gnu / Linux ndi Windows pakati pa ena. Imayendanso pamakina ogwiritsa ntchito mafoni monga Android, iOS, BREW kapena Windows Phone. Tipezanso ikugwira ntchito yama microprocessors ophatikizika, ARM ndi Kalulu kapena pamafayilo a IBM ndi ena ambiri.

Kuti tiphunzire kugwiritsa ntchito chinenerochi tidzakhala ndi Kutalika Buku lothandizira komanso kuchokera m'mabuku angapo onena za izi. Ngati tikufuna tione momwe mapulogalamu a Lua amagwirira ntchito tisanayike mu Ubuntu wathu, titha kugwiritsa ntchito chiwonetsero chamoyo zomwe opanga ake amapanga kuti azigwiritsa ntchito.

Makhalidwe ambiri a Lua

Zina mwazomwe zilankhulo za Lua ndi izi:

  • Ndi chilankhulo cha malembedwe ochiritsira Yosavuta kugwiritsa ntchito.
  • Ndizodabwitsa kuwala, kudya ndi kothandiza.
  • Ali ndi kuphunzira pamapindikira. Ndizosavuta kuphunzira ndikugwiritsa ntchito.
  • Chilankhulochi ndi kusintha kwa ntchito zosiyanasiyana.
  • API yake ndiyosavuta ndipo zalembedwa bwino.
  • Imathandizira mitundu yosiyanasiyana yamapulogalamu. Monga njira zamachitidwe, zoyendetsera zinthu, zogwirira ntchito, komanso zoyendetsedwa ndi deta, komanso kufotokozera zamtundu.
  • Sonkhanitsani ndondomeko yoyendetsera molunjika, ndikulongosola koopsa kwazomwe zimakhazikika mozungulira magulu ophatikizika ndi semantics yotambalala.
  • Zimabwera ndi kusamalira zokumbukira zokha ndikungotola zinyalala. Izi zimapangitsa kukhala njira yabwino yosinthira malembedwe.

Momwe mungakhalire Lua pa Ubuntu

Lua ali likupezeka m'malo osungira ovomerezeka a Gnu / Linux. Mu Ubuntu wathu titha kukhazikitsa chilankhulo ichi pogwiritsa ntchito phukusi poyang'anira terminal (Ctrl + Alt + T) ndikulemba:

sudo apt install lua5.3

Lembani Lua

Choyamba, onetsetsani khalani ndi zida zofunikira m'dongosolo lanu. Mutha kutsatira lamulo lotsatira kuti muwaike kuchokera ku terminal (Ctrl + Alt + T):

sudo apt install build-essential libreadline-dev

Mukamaliza kukhazikitsa, ku pangani ndikuyika mtundu waposachedwa (mtundu 5.3.5 panthawi yolemba mizereyi) kuchokera ku Lua, tsatirani malamulo awa kutsitsa phukusi la tar, kulichotsa, kulisunga, ndi kuliyika.

mkdir lua_build

cd lua_build

curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz

tar -zxf lua-5.3.5.tar.gz

cd lua-5.3.5

make linux test

sudo make install

Mukangomaliza kukonza, thandizani womasulira wa Lua kulemba mu terminal (Ctrl + Alt + T):

lua mkonzi 5.3.5

lua

Pangani pulogalamu yanu yoyamba ndi Lua

Kugwiritsa ntchito yathu wolemba mawu wokondedwa, tingathe pangani pulogalamu yathu yoyamba ya Lua. Timasintha mafayilo motere:

vim ubunlog.lua

Ndipo tiwonjezera nambala iyi pa fayilo:

vim pulogalamu lua

print("Hola lectores de Ubunlog”)
print("Estamos probando el lenguaje Lua en Ubuntu")

Tsopano timasunga ndikutseka fayilo. Ndiye titha yambitsani pulogalamu yathu kulemba mu terminal (Ctrl + Alt + T):

kukhazikitsa pulogalamu yolembedwa ndi lua

lua ubunlog.lua

Para phunzirani zambiri ndikuphunzira kulemba mapulogalamu ndi Lua, titha kupita ku tsamba la projekiti.


Khalani oyamba kuyankha

Siyani ndemanga yanu

Anu email sati lofalitsidwa. Amafuna minda amalembedwa ndi *

*

*

  1. Wotsogolera pazosankhazi: Miguel Ángel Gatón
  2. Cholinga cha deta: Control SPAM, kasamalidwe ka ndemanga.
  3. Kukhazikitsa: Kuvomereza kwanu
  4. Kulumikizana kwa zomwe zafotokozedwazo: Zomwezo siziziwululidwa kwa anthu ena kupatula pakukakamizidwa mwalamulo.
  5. Zosunga: Zosungidwa ndi Occentus Networks (EU)
  6. Ufulu: Nthawi iliyonse mutha kuchepetsa, kuchira ndikuchotsa zidziwitso zanu.