Clojure, Haskell thiab Erlang – Tus txheej txheem cej luam hais

Clojure Haskell and Erlang

Clojure Haskell thiab Erlang – Wb tshawb

Taw qhia :

Programming lus, Ua peb sawv daws paub txog yog txheej txheem ntxaws qhia rau cov computer cov computer. Tab sis peb muaj tsuas muaj ib hom lus programming? Tsis yog, Muaj ntau hom lus txawv thiab tus nab npawb yog ua hnub los ntawm ib hnub vim hais tias cov lus tshiab programming yog emerging ua ib qho kev lag luam uas yuav tsum tau kev lag luam. Qhov tseeb software txoj kev loj hlob yog ib lub teb dynamic teb thiab developers xav tau lossi ua tej yam tshiab tseem ceeb nyob. Rau lwm cov tes, yog peb txheeb nws nrog lub neej ces hloov yog txoj cai ntawm lub neej ib yam nkaus thiab. Nyob rau cov tshooj no, Peb yuav muab ib tug overview ntawm peb hom lus programming lus, Clojure, Haskell thiab Erlang, uas accomplish cov kev hloov hauv kev lag luam software heev zoo.







Clojure: ib dialect ntawm DI NCAUJ

Clojure, tsim los ntawm nplua nuj Hickley, Yog ib tug dynamic functional programming lus uas nws tsim raws li LISP programming lus. Txoj kev zoo nkauj ntawm Clojure kuj tsub kom vim yog lub compilers uas ua rau nws khiav rau ob Java thiab..Net framework. Koj yuav xyuas tau nws lub website https://clojure.org/.

Vim li cas thiaj nyiam Clojure?

Thaum kuv ua haujlwm nyob rau hauv hom lus no thawj zaug, nws zoo li ib nqa ntawm parenthes. Koj yuav xav tias qhov no yog nonsense li kuv tab sis thaum koj pib ua hauj lwm; ntev koj yuav mus poob rau kev hlub nrog Clojure. Kuv yog hais tias thiaj hais tias vim yog lub hwj huam, li qub tas li thiab s-expression raws li syntax ntawm hom lus no. Yog hais tias koj yog ib tug hlub java lover ces Nws embraces Java zoo heev thiab nws yuav ua tau siv tag nrho Java ecosystem rau kev tswj tus khiav ntawm qhov chaws ntawm lub JVM.

Ua hauj lwm nrog Clojure

Yog koj xav mus ua hauj lwm nrog Clojure ua ib hom lus kom koj xaiv los ntawm ob qho kev xaiv:

  • Leiningen: Nws yog ib qho cuab yeej tseem ceeb los tsim, txug tej yaam num thiab txug tej yaam num. Peb yuav download tus binary plahaum ntawm qhov txuas http://leining-winstaller. Tiam sis kom koj muaj JDK 1.7 los yog saum koj lub cev thiab tsawg kawg yog 2 GB RAM.
  • Eclipse Plugin: Peb yuav siv CounterClockwise plugin uas muaj rau Eclipse nqa tawm Clojure kev loj hlob nyob rau hauv lub tswv yim Eclipse. Ua ntej yuav pib siv nws, nco ntsoov tias koj muaj JDK 1.7 los yog saum toj rau koj lub cev thiab dab noj hnub 4.5(Mars).

Basics of Clojure

Ntu no, Kuv yuav muab ib nyuag kev ntsuam xyuas ntawm no zoo nkauj. Peb yuav pib nrog rau daim ntawv ntawm tsab ntawv, nram qab no, kom koj to taub txog qhov syntax of Clojure: (+ 2 3)

Raws li kuv hais kom koj dhau txog parenthes, Koj yuav saib tau cov lus qhia saum toj no yog enclosed braces ib yam nkaus thiab. Ua ntej yuav tau txais kev qhia saum toj no, Kuv xav qhia rau koj tias muaj nuj nqi yog cov khoom xyaw cov khoom xyaw txhua daim ntawv qhia nyob rau hauv Clojure. Piv txwv, Saum toj no qhia cov ' ' tus neeg teb xov tooj ua zoo li ib tug muaj nuj nqi uas siv los ntxiv cov zauv 2 thiab 3.

Tam sim no, Es ____ ne (qauv "Tech" "Alpine") tsab ntawv, Yog ib tug neeg teb xov tooj uas siv los txhawb ob txoj hlua uas siv raws li cov parameters thiab saum toj no "Tech" thiab "Alpine" yog ob txoj hlua. Peb yuav tsim tau ib qho kev pab nyuaj heev, nram qab no, ua ke los ntawm combining cov nqe lus saum toj no:

Peb yuav pib nrog tus piv txwv yooj yim heev ntawm printing 'Hello ntiaj teb'.

Qhia 1: Piv txwv Clojure qauv

(techalpine.techalpine

(:class))

(ywj siab []

(println “Tech Alpine”))

(println +2 3)))

Nws yuav muab lub tso zis:

TechAlpine

5

Yog hais tias koj xav los txhais lus zoo meej ces Clojure tsis yog rau koj tiam sis yog hais tias koj xav kom lawv muaj kev zoo meej software ces nws yog ua rau koj. Pib ua hauj lwm nrog Clojure.







Haskell: Purely functional lus

Haskell, kev pab qhia ntawv, yog tsim rau tuav cim symbolic computation. Kuv vam tias tag nrho koj yog paub zoo tias kev ua tau hauj lwm raws li txoj cai ntawm kev kawm txog zauv. Txawm muaj npe hu ua tom qab Haskell Brooks Curry, Ib tug neeg American mathematician thiab logician. Koj yuav xyuas tau nws lub website https://www.haskell.org/.

Dab tsi tshwj xeeb txog Haskell?

Thaum uas siv Haskell, Kuv xav hais tias tshuav nyiaj li cas tom qab peb yooj ywm thiab tsis yooj ywm kom nws tshwj xeeb:

  • Tswjhwm Cov Tswjhwm: Functions (Functions): – Raws li peb paub tias tswj constructs txhais tau qhov kev txiav txim ntawm qhov kev luj xyuas thiab Haskell muaj cov kev ua num raws li nws cov thawj tswjhwm. Nyob rau hauv Haskell, Peb txawm ntxiv tau ib tug muaj nuj nqi rau cov nuj nqi lwm txoj kev uas peb yuav ntxiv ib qho integer rau lwm integer.
  • Semantics tsis-nruj: – Lwm cov khoom uas zoo li ntawd, tshwj xeeb yog cov tsis-nruj semantics. Tag nrho cov lus coj nruj semantics uas yog yam ntxwv ncua tsis muaj muaj nqis, qhov kev qhia tseem tsis nrog nws.
  • Statically ntaus: – Haskell yog ib hom lus typed nruj me ntsis uas txhais tau hais tias Haskell compiler yog ntse txaus paub hom kuj sib txawv thiab cov txais thiab peb yuav tsum tsis ntsees pav hom siv zog.

Ua hauj lwm nrog Haskell

Kuv vam tias tom qab koj nyeem ntawv hais txog tej yam uas ua rau Haskell li ntawd, tshwj xeeb, koj yeej xav kom ua hauj lwm nrog Haskell. Pib ua hauj lwm nrog Haskell peb tau mus download tau lub Haskell teeb muaj nyob ntawm cov nom webpage- https://www.haskell.org/downloads. Ces peb yuav teem tau rau ib puag ncig raws li peb kev khiav hauj lwm raws li lawv taug:-

  • Rau qhov rais: – Peb yuav tsum download tus nruab nrab ntawm lub website

https:// www.haskell.org/paltform/windows.html.

  • RAU MAC: – Peb yuav tsum download tus nruab nrab ntawm lub website

https:// www.haskell.org/paltform/mac.html.

  • Rau Linux: – Peb yuav tsum download tus nruab nrab ntawm lub website

https:// www.haskell.org/paltform/mac.html. Tom qab ntawd xaiv koj tis, khiav qhov hais kom ua sudo apt-get platform Haskell-platform thiab nws tseem npaj siv.

Basics of Haskell

Ntu no, Kuv yuav muab ib nyuag kev ntsuam xyuas ntawm cov lus txawj ntse. Raws li kuv tau hais kom koj dhau tej yam ua ntej lawm uas yog tus thawj tswj constructs ntawm hom lus no li kuv muab cov piv txwv ntawm ntxiv Kev ua num los piav cov dynamism ntawm Haskell.

Qhia 2: Qauv Haskell piv txwv

ntxiv : : Integer -> Integer -> Integer

ntxiv x x = x x + y

tswj

PutstrLn " The ntxiv yog "

luam(ntxiv 1 2)

Cov chaws saum toj no tsis yog txhua tawv rau kev nkag siab. Yog muaj, cov nram no yog ib tug kab chaws ntawm Haskell los sau ib txoj hlua:

lub ntsiab = putStrLn "Tech Alpine"

Chaws ib kab saum toj no yuav muab lub tso zis ntau lawm:

TechAlpine

Tam sim no, koj yuav hais li cas, Nws yog tawv?







Erlang: Tej qhov chaw programming lus runtime zoo

Erlang yog tsim los ntawm Ericsson, ib tug neeg loj heev Swedish telecom, nyob rau hauv 1986 nrog lub tswvyim uas tau muaj kev txhawb rau cov concurrency thiab txhaum thiaj kam rau ua. Nws tseem muaj tej qhov chaw programming lus xws li Haskell, tiam sis nws cia lub sij hawm zoo. Nws yog tus qhib tau qhov twg los lus txij thaum 1998. Nws yog lug hu ua Erlang/OTP vim OTP muaj nws ib puag ncig lub sij hawm cia thiab nws yuav txaus siab thiab ntawm OTP khoom unit ntawm Ericsson. Koj yuav xyuas tau nws lub website http://www.erlang.org/.

Vim li cas thiaj yuav qhuas Erlang?

Yog hais tias cov lus no yog lub qaum ntawm messaging apps zoo li WhatsApp, TigerText thiab Facebook sib tham ces yeej muaj ib yam dab tsi nyob rau hauv cov lus no los admire hais txog. Koj tsis tas yuav txhawj txog txiaj thiab txhaum kam rau ua thaum koj txiav txim siab pib ua hauj lwm nrog cov lus no wonderful lus. “Nrog Erlang hluas ua ib messaging app uas muaj coob coob tus neeg thiab tsis txhawj txog seb lawv sib txuas lus,” Hais tias Chad Depue, NKAUM ntxhi, Ib app rau anonymous posts uas tau opted siv cov lus.

Ua hauj lwm nrog Erlang

Kuv vam tias tom qab nyeem txog tej chaw thiab ntseg ntawm Erlang, Koj kuj xav mus ua hauj lwm nrog rau qhov lus zoo. Pib ua hauj lwm nrog Erlang peb yuav tsum download tau lub Erlang setup los ntawm cov web sab web site- http://www.erlang.org/downloads. Ces peb yuav teem tau rau ib puag ncig raws li peb kev khiav hauj lwm. Tom qab xov tus setup, peb yuav tau ua tus configuration ntawm kev rau peb. Tam sim no, Qhib tus txhob hais kom ua thiab yam erl koj yuav tsum tau nrog Erlang. Yeej zoo siab coding nrog Erlang. Koj yuav nruab nws cov plugin rau IDEs ntau heev.

Tsim los ntawm Erlang

Ntu no, Kuv yuav muab ib lub luag hais no hais lus zoo. Peb yuav tsum siv raws li nyias lub cim thaum ua coding hauv no hais lus:

  • Hyphen(-): – Muab lub ntsiab lus rau tsab ntawv peb yuav siv tus cim hyphen. Nws mas siv nrog module li zoo li import tsab ntawv export.
  • Teev(.): Tsab ntawv yuav tsum delimited nrog cov teev(.).
  • Luaj(/): – Nws yog siv nrog rau cov kev ua los txhais tau ntau tsis uas tau txais los ntawm qhov muaj nuj nqi.
  • Modules: – Txhua nqe lus hauv Erlang faib ua modules. Koj yuav tau ntxiv rau qhov no nyob rau hauv qhov piv txwv uas peb yuav muab cov.
  • Daim ntawv ntshuam: – Siv cov functionality uas muaj module Erlang, peb yuav tau siv daim ntawv ntshuam.

Nram no yog ib qho piv txwv yuav to taub tsim ntawm Erlang:

Qhia 3: Yooj yim piv txwv Erlang

-Module(TechAlpine).

-export([pib/0]).

pib() ->

rhuav tshem cov ntaub:fwrite(“TechAlpinen”).

Qhov kev pab cuam saum toj no yuav muab lub tso zis ntau lawm:

TechAlpine







Xaus tsab ntawv

Kuv vam tias koj muaj enjoyed no sib tham hais dua peb kees, zoo thiab zoo nkauj programming lug. Pib coding cov lus tau los tsis tau zoo kawg. Yog hais tias koj tuaj nyob tej teeb meem no thaum ua hauj lwm nrog cov lus, los yog koj muaj tej tswv yim / tswv yim thov cuag rau rooj vag hauv lawv lub

============================================= ============================================== Yuav zoo TechAlpine phau ntawv rau Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Txaus siab rau qhov blog? Tshaj tawm lus thov :)

Follow by Email
LinkedIn
LinkedIn
Share