Kuna programming language nyingne ni bora uzitumie tu kuandika web Apps za kawaida sana

kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
Kuna programming language nyingne ni bora uzitumie tu kuandika web Apps za kawaida sana na usije ukazitumia kufanyia projects za mahesabu makubwa makubwa otherwise a single 'human error' can cost you deadly.

Yaan baada ya kupata error call au exception unapofanya human error hizo language zitarun hivyo hivyo kimya kimya na kukupa loss ya maana.

Mfano wa language hizi ni javascript na php ila leo nataka tuongelee javascript.

Kwenye javasript
'2' + '2' + '2' = '222';

lakini

'2' + '2' - 2 = 20 (hapa ilibidi i throw error coz number na strings haziwezi kuwa operated mathematically lkn yenyewe inacalculate tu.!!!!)

img_20190813_121524_348-jpg.1180186


I hope real programmers mtaelewa hii kitu
 
Graph

Graph

JF-Expert Member
Joined
Jul 20, 2016
Messages
2,003
Points
2,000
Graph

Graph

JF-Expert Member
Joined Jul 20, 2016
2,003 2,000
Haha its obvious, strings concatenation inawezekana kwa kutumia + sign kwenye languages kibao.
Ila - sign siku zote inatumika kwenye math so its obvious "2" + "2" - "2" itasoma kwanza "2" + "2" ita-assume unafanya string concatenation alafu ikifika part ya mwisho ita-assume unajaribu kufanya arithmetic na javascript itachukua string na kuconvert to number moja kwa moja.

Je ni style nzuri? Hapana, languages nazozichukia 1. Php 2. JavaScript.
Nikiona developer anaandika code hivyo lakini namfukuza, sipendi ujinga, number siku zote iachwe kua number na string iwe string. Na mnapofanya project devs wengi kuna coding style ya wote kutumia, mfano concatenation ya strings badala ya kutumai + unahakikisha mara zote unatumia str.concat().

Kuna tool ya kufanya code checking inaitwa sonarcube, inaonyesha mistakes kama hizo all the time unafix unaendelea na kazi. Mistakes kama hizi ni ndogo zinaweza epukika kwa kutumia lint tu. Ambacho sipendei javascript ni design nzima ya language sio matatizo kama haya ambayo solution yake ipo.
 
kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
Ambacho sipendei javascript ni design nzima ya language sio matatizo kama haya ambayo solution yake ipo.
Hata hio inasababishwa na designing ya language.

Maybe kwako utaona ni kawaida kwa sababu ya experience ulonayo lakini kwa coder wa kawaida anaweza kuandika KIMAKOSA line yenye nature kama hio kwenye notepad++ ambayo haina extensions za lint (esLint) na mwisho wa siku program ikarun lkn ikaleta undesired results. Ni bora program i throw error (coz ntaiona na kurekebisha) kuliko kurun na kutoa undesired results
 
kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
All in all hizi php na js naona their primary goals were based in web development sema watu wenye mapenzi nazo ndo wanalazimisha kuzitumia kwenye fields kama A.I na M.L ambazo zinahitaji sana high-level maths

Japo hata uko napo bado zinategemea python coz ukicheki hata tensorflow.js ni result ya tensorflow library(python + c++)
 
ymollel

ymollel

JF-Expert Member
Joined
Aug 23, 2012
Messages
2,432
Points
2,000
ymollel

ymollel

JF-Expert Member
Joined Aug 23, 2012
2,432 2,000
hapo sijaona shida kwa sababu kila kitu kina application yake. kwa mfano unataka kufanya concatenation ya "First Name"+"Middle Name"+"Last Name" ili kupate output ya majina matatu. Sasa hapo ukiweka alama ya Minus - badala ya Plus + ambapo + ndio concatenation operator utaishia kwenye error.

hiyo inaApply hata kwenye kwenye Visual Basic , endapo tu ume declare number kama String usitegemee kama itafanya calculation ya String.

kwa mfano ukifanya CStr(4) + CStr(2) , sio njia sahihi ya kufanya arrithmetic calculation. Instead lazima ufanye declaration ya namba kama interger /Double/Long .

kwa hivyo unapofanya "2" + "2" output itakuwa 22 lakini nikiweka "2"-"2" , hiyo kutokana na language husika inaweza kuwa incorrect operator, na italeta error.
Yeah it's concatenation but is it safe???
 
kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
hapo sijaona shida kwa sababu kila kitu kina application yake. kwa mfano unataka kufanya concatenation ya "First Name"+"Middle Name"+"Last Name" ili kupate output ya majina matatu. Sasa hapo ukiweka alama ya Minus - badala ya Plus + ambapo + ndio concatenation operator utaishia kwenye error.
hiyo inaApply hata kwenye kwenye Visual Basic , endapo tu ume declare number kama String usitegemee kama itafanya calculation ya String.
kwa mfano ukifanya CStr(4) + CStr(2) , sio njia sahihi ya kufanya arrithmetic calculation. Instead lazima ufanye declaration ya namba kama interger /Double/Long .
kwa hivyo unapofanya "2" + "2" output itakuwa 22 lakini nikiweka "2"-"2" , hiyo kutokana na language husika inaweza kuwa incorrect operator, na italeta error.
Unachosema ni sahihi kabisa lkn JS haikupi error yyt ile bali inaendelea tu. Pia unachanganya contexts za matumizi ya hizi lugha mbili VISUAL BASIC na JAVASCRIPT.
JS inatumika sana kwenye web Apps ambapo iko na risk ya kupokea user inputs zenye mkanganyiko saana na sio Kama ilivyo kwa Visual Basic. Hio ni kutokana na jinsi user input inavyochukuliwa
Mfano tuchukulie script inayohitaji watu wenye namba zinazoishia 74 kuweka namba zao za simu kwenye database kwa kuandika 'country_code' na namba saba za kwanza ('seven_digits') then script itaadd automatically 74 mwisho wa kila namba zinazoingizwa.
Check this short script
<input id="contry_code" type="text">
<input id="seven_digits" type="text">
var country_code = document.getElementById('contry_code').value;
var seven_digits = document.getElementById('seven_digits').value;
var constant_digits = 74;
var phone_number = country_code + seven_digits - constant_digits; (mark the typing mistake, - instead of +)
/*
hapo naassume kuna human error(typing error) ambayo developer kafanya Kwenye last line, yaani baada ya plus (+) sign yeye kaweka (-) neg sign. Kumbuka tu 'country_code' na 'seven_digits' zinachukuliwa kama STRINGS coz of 'type="text" ' hapo kwenye input tag lkn constant_digits inachukuliwa kama namba tu kutokana na jinsi nilivyoideclare hapo juu
Sasa Javascript hapo haitothrow error yoyote ile lkn itakupa weird 'phone_number'. Ni bora ingethrow error thn watu watareport na itarekebishwa, lkn kama isipo throw error hio weird 'phone_number' itatunzwa kwenye database hivo hivo na mwisho wa siku mkiangalia db mnaona namba za ovyo ovyo tu.
Mfano user country_code kaingiza 255 afu seven_digits kaingiza 7232385
final result itakua ni = '255' + '7232385' - 74;
Ambayo itakua ni 7232566 (according to JS) wakati developer alitaka iwe '255723238574'
Kitu ambacho kina nature ile ile na '2' + '2' - 2 ambayo nmeiongelea mwanzo kabisa
So my point ni kwamba kwa situation kama hizo JS inabidi i throw error ili kumsaidia developer kugundua makosa mapema na hivyo kuifanya language iwe developer-friendly
JS bado iko na issue nyingi zinazoweza kuleta utata mkubwa endapo ukifanya some typing mistakes na haitokuletea error lkn cha moto utakiona baadae ikikupa result. Sema tukianza kuambiana hapa tutapotezana tu coz kama hio case ya hapo juu ambayo ni rahisi mno kueleweka inasumbua watu kuelewa, hizo nyingine natia hofu.
 
ymollel

ymollel

JF-Expert Member
Joined
Aug 23, 2012
Messages
2,432
Points
2,000
ymollel

ymollel

JF-Expert Member
Joined Aug 23, 2012
2,432 2,000
nimeelewa point yako kwamba kwanini Js isi throw error while kuna Syntax error.

Lakini sasa Swali langu ni: , Haiwezekani kwamba Minus - Symbol katika mazingira hayo ikawa inafanya another operation?

Yaani katika Js language unapotumia minus symbol hapa "2"-"2" pengine pia ni sahihi kwaajili ya another operation ...
Unachosema ni sahihi kabisa lkn JS haikupi error yyt ile bali inaendelea tu. Pia unachanganya contexts za matumizi ya hizi lugha mbili VISUAL BASIC na JAVASCRIPT.
JS inatumika sana kwenye web Apps ambapo iko na risk ya kupokea user inputs zenye mkanganyiko saana na sio Kama ilivyo kwa Visual Basic. Hio ni kutokana na jinsi user input inavyochukuliwa
Mfano tuchukulie script inayohitaji watu wenye namba zinazoishia 74 kuweka namba zao za simu kwenye database kwa kuandika 'country_code' na namba saba za kwanza ('seven_digits') then script itaadd automatically 74 mwisho wa kila namba zinazoingizwa.
Check this short script


var country_code = document.getElementById('contry_code').value;
var seven_digits = document.getElementById('seven_digits').value;
var constant_digits = 74;
var phone_number = country_code + seven_digits - constant_digits; (mark the typing mistake, - instead of +)
/*
hapo naassume kuna human error(typing error) ambayo developer kafanya Kwenye last line, yaani baada ya plus (+) sign yeye kaweka (-) neg sign. Kumbuka tu 'country_code' na 'seven_digits' zinachukuliwa kama STRINGS coz of 'type="text" ' hapo kwenye input tag lkn constant_digits inachukuliwa kama namba tu kutokana na jinsi nilivyoideclare hapo juu
Sasa Javascript hapo haitothrow error yoyote ile lkn itakupa weird 'phone_number'. Ni bora ingethrow error thn watu watareport na itarekebishwa, lkn kama isipo throw error hio weird 'phone_number' itatunzwa kwenye database hivo hivo na mwisho wa siku mkiangalia db mnaona namba za ovyo ovyo tu.
Mfano user country_code kaingiza 255 afu seven_digits kaingiza 7232385
final result itakua ni = '255' + '7232385' - 74;
Ambayo itakua ni 7232566 (according to JS) wakati developer alitaka iwe '255723238574'
Kitu ambacho kina nature ile ile na '2' + '2' - 2 ambayo nmeiongelea mwanzo kabisa
So my point ni kwamba kwa situation kama hizo JS inabidi i throw error ili kumsaidia developer kugundua makosa mapema na hivyo kuifanya language iwe developer-friendly
JS bado iko na issue nyingi zinazoweza kuleta utata mkubwa endapo ukifanya some typing mistakes na haitokuletea error lkn cha moto utakiona baadae ikikupa result. Sema tukianza kuambiana hapa tutapotezana tu coz kama hio case ya hapo juu ambayo ni rahisi mno kueleweka inasumbua watu kuelewa, hizo nyingine natia hofu.
 
kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
nimeelewa point yako kwamba kwanini Js isi throw error while kuna Syntax error.
Lakini sasa Swali langu ni: , Haiwezekani kwamba Minus - Symbol katika mazingira hayo ikawa inafanya another operation?
Yaani katika Js language unapotumia minus symbol hapa "2"-"2" pengine pia ni sahihi kwaajili ya another operation ...
Kwa JS neg sign inatumika kama operator kwenye substraction tu(numbers), na pia kwenye REGEX (hapa haitumiki kama operator bali kuonesha range tu mfano *A-Z*).

Hakuna matumizi mengine zaidi ya hayo kadri ya uzoefu wangu
 
mathsjery

mathsjery

JF-Expert Member
Joined
Sep 26, 2015
Messages
713
Points
500
mathsjery

mathsjery

JF-Expert Member
Joined Sep 26, 2015
713 500
Kama in unafahamu coercion ya js na unaielewa kwanini usiwe makini
Kuna watu bado wanatumia Js kwenye AI na ML
 
ray57

ray57

Member
Joined
Oct 29, 2013
Messages
92
Points
125
ray57

ray57

Member
Joined Oct 29, 2013
92 125
Tatizo la programmers wengi tuna fail si kwa kuwa hatujui ku code ila hatujui which is best language to use when it comes to solve problems.
Yani tunasomaa somaa tuu kisa umesikia flan anafanya java na wewe unaenda soma java kuna watu wana fanya python na wewe unakimbilia python mwisho wa siku huelew unasoma hizo languages ili ufanye nini.

Kila programming language or script zina advantage and disadvantages zake unapokuja kwenye solving of problems. Na hapo ndipo tunapima uelewa wako kama uko unaelewa unachofanya au ni ile ili mradi ime run.
 
kali linux

kali linux

JF-Expert Member
Joined
May 21, 2017
Messages
549
Points
1,000
kali linux

kali linux

JF-Expert Member
Joined May 21, 2017
549 1,000
Tatizo la programmers wengi tuna fail si kwa kuwa hatujui ku code ila hatujui which is best language to use when it comes to solve problems.
Yani tunasomaa somaa tuu kisa umesikia flan anafanya java na wewe unaenda soma java kuna watu wana fanya python na wewe unakimbilia python mwisho wa siku huelew unasoma hizo languages ili ufanye nini.

Kila programming language or script zina advantage and disadvantages zake unapokuja kwenye solving of problems. Na hapo ndipo tunapima uelewa wako kama uko unaelewa unachofanya au ni ile ili mradi ime run.
You nailed it sir.

Tatizo ninaloliona ni kwamba watu wanaruka stages. Mtu anapewa project na hapohapo anaanza coding bila hata kuandika some flowcharts ya jinsi atakavyo fanya coz ukishakuwa na flowchart au some sort of algorithms utakua kwenye position nzuri ya kuchagua utumie language ipi
 
mathsjery

mathsjery

JF-Expert Member
Joined
Sep 26, 2015
Messages
713
Points
500
mathsjery

mathsjery

JF-Expert Member
Joined Sep 26, 2015
713 500
Hakuna language ambyo ipo perfect kusolve kila problem, cha muhimu ni kuchagua language sahihi kwa kila project
ndo hapo sasa mtu unataka kutengeneza project za AI na Ml tumia perfect/special language kama python na nyinginezo zinajitosheleza


but kuna jamaa wa ajabu huwa wanachukia language flani na wakati huo huo hawafanyi project zinazo relate na hizo lugha dah!

sasa kama mtu analenga kuelimisha anavyozungumza anachangia wengine kushindwa kuchukua maamuzi hasa kwa mabigina dah!

kiufupi chagua lugha sahihi kwa project sahihi
 

Forum statistics

Threads 1,324,982
Members 508,911
Posts 32,179,451
Top