Course එකට ආපසු

Syntax vs Logic

20 මිනිත්තු📖Lecture

Syntax vs Logic Explained

YouTube Video

🎯 පාඩමේ අරමුණු

මේ පාඩම ඉවර වෙද්දී ඔයාට:

  • Syntax (ව්‍යාකරණ නීති) සහ Logic (තර්කනය) අතර වෙනස හරියටම තේරුම් ගන්න පුළුවන් වෙයි
  • AI විසින් මොනවද handle කරන්නේ, ඔයා මොනවද handle කරන්නේ කියලා දැනගන්න පුළුවන් වෙයි
  • Coding process එකේ ඔයාගේ role එක ගැන confident වෙන්න පුළුවන් වෙයි

📖 Introduction: Programming වල කොටස් දෙක

Instagram වගේ complex app එකකින් පටන් ගෙන simple calculator එකක් දක්වා හැම program එකක්ම හදලා තියෙන්නේ දේවල් දෙකකින්:

  1. Logic — Program එක කරන්න ඕන මොකක්ද
  2. Syntax — ඒක code වලින් ලියන්නේ කොහොමද

මේ වෙනස තේරුම් ගන්න එක effective vibe coder කෙනෙක් වෙන්න key එක.


🧠 Logic කියන්නේ මොකක්ද?

Logic Definition

Logic කියන්නේ programming වල thinking part එක. ඒ කියන්නේ:

  • මොන problems solve කරන්න ඕනද
  • ඒවා solve කරන්න මොන steps ගන්න ඕනද
  • මොන conditions ආවම මොනවා වෙන්න ඕනද
  • Data flow වෙන්න ඕන කොහොමද

Real Life වල Logic Examples

SituationLogic එක
Sandwich එකක් හදන එකBread පළවෙනි, ඊට පස්සේ ingredients, ඊට පස්සේ bread උඩින්
පාර පන්නන එකVehicles බලන්න, ඕන නම් ඉන්න, ඊට පස්සේ යන්න
Alarm එකක් set කරන එකඑනම් වෙලාව calculate කරන්න, time set කරන්න, alarm enable කරන්න
Route plan කරන එකDestination එක හොයන්න, options check කරන්න, fastest එක choose කරන්න

Programming වල Logic

Simple password checker එකක LOGIC මෙන්න:

1. User ගෙන් password ගන්න 2. Save කරලා තියෙන password එක්ක match වෙනවද බලන්න 3. Match වෙනවා නම් → Access දෙන්න 4. Match වෙන්නේ නැත්නම් → Error පෙන්නන්න 5. වරද්දර 3 පාරක් ගැහුවොත් → Account lock කරන්න

මේක pure logic. Code syntax තාම නැහැ!


📝 Syntax කියන්නේ මොකක්ද?

Syntax Definition

Syntax කියන්නේ programming languages වල grammar එක. ඒ කියන්නේ:

  • Use කරන්න ඕන exact words සහ symbols
  • Brackets, semicolons, quotes දාන්න ඕන තැන්
  • Code correctly format කරන විදිය
  • Language එක එක්කෙකේම specific rules

එකම Logic, වෙනස් Syntax

Password logic එක මතකද? ඒක different languages වලින් පෙනෙන්නේ මෙහෙම:

Python
# Python syntax
password = input("Enter password: ")
if password == "secret123":
print("Access granted!")
else:
print("Access denied!")

බලන්න: LOGIC එක තුනේම identical. SYNTAX එක completely different!


🎯 කවුරු මොනවද කරන්නේ?

ඔයාගේ Job එක (Logic)
AI ගේ Job එක (Syntax)
Program එක කරන්න ඕන මොකක්ද decide කරන්න
Actual code ලියන්න
Steps සහ sequence define කරන්න
Correct keywords select කරන්න
Conditions සහ rules specify කරන්න
Brackets සහ semicolons place කරන්න
ඕන behavior describe කරන්න
Code properly format කරන්න
Output එක correct ද review කරන්න
Language-specific rules handle කරන්න

🎮 Practice: Logic ද Syntax ද?

ඔයාගේ understanding test කරමු! Item එක එක්කෙක Logic concern ද Syntax concern ද decide කරන්න:

Logic (L) ද Syntax (S) ද mark කරන්න

0/8

💡 Vibe Coding වලට මේක Important ඇයි

Key Insight

AI ට prompt කරනකොට, ඔයා focus කරන්නේ LOGIC එකට. ඔයා describe කරන්නේ:

  • මොකක් වෙන්න ඕනද
  • මොන conditions වලදී මොන actions trigger වෙන්න ඕනද
  • User experience එක කොහොමද වෙන්න ඕන

AI ඔයාගේ logic එක proper syntax එකට translate කරනවා ඔයා use කරන language එකට.

Example Prompt

හොඳ Prompt (Logic එකට Focus)
Password checker එකක් හදන්න: - User ගෙන් password ගන්න - 'secret123' එක්ක match වෙනවද check කරන්න - Correct නම් 'Access granted!' පෙන්නන්න - Wrong නම් 'Access denied!' පෙන්නන්න - Wrong attempts 3න් පස්සේ lock කරන්න
ChatGPTClaude

💡 Tips:

  • බලන්න අපි describe කරන්නේ මොකක් වෙන්න ඕනද කියලා
  • Code ලියන්නේ කොහොමද specify කරන්නේ නැහැ
  • AI syntax figure out කරයි

🚫 Common Mistake

Prompts වල Logic සහ Syntax Mix කරන්න එපා

Bad Prompt: "checkPassword කියලා function එකක් හදන්න triple equals එක්ක if statement එකක් use කරලා console.log output වලට"

ඒක bad ඇයි:

  • ඔයා syntax dictate කරන්න try කරනවා
  • AI ට better approaches දන්න පුළුවන්
  • AI ගේ capabilities limit කරනවා

Good Prompt: "User input එක stored password එක එක්ක validate කරන password checker එකක් හදන්න"

ඒක good ඇයි:

  • Outcome එකට focus
  • AI ට best implementation choose කරන්න දෙනවා
  • මොකක් DO කරන්න ඕනද clear

🧠 Analogy: Translator

AI ව Translator කෙනෙක් විදියට හිතන්න:

  • ඔයා කියනවා: "මට red button එකක් ඕන 'Click me' කියලා, click කළාම popup එකක් පෙන්නන"
  • AI translate කරනවා: HTML + CSS + JavaScript code එකට

Paris වලදී French translator කෙනෙක් help ගන්න French දන්න ඕන නැහැ වගේම, software build කරන්න AI help ගන්න programming syntax දන්න ඕන නැහැ.

ඔයාගේ job එක ඔයාට කියන්න ඕන මොකක්ද කියලා දැනගෙන ඉන්න එක. AI ගේ job එක ඒක right language එකෙන් කියන එක.


✅ පාඩමේ සාරාංශය

Logic (ඔයාගේ Focus)
Syntax (AI ගේ Focus)
මොකක් වෙන්න ඕනද
ලියන්නේ කොහොමද
Problem-solving
Code formatting
User experience
Language rules
Conditions සහ flow
Keywords සහ symbols
Requirements සහ goals
Implementation details

මතක තියාගන්න: ඔයා ideas ගෙනෙනවා. AI code ගෙනෙනවා.


📝 Mini Quiz

📝 ඔයාගේ Understanding Check කරන්න

1/3

Which of these is a LOGIC concern?