Java ඉවරයි ගුපියනේ... ඉස්සරහට Go තමයි... 🦾😎

Draco Malfoy

Well-known member
  • Feb 9, 2019
    8,433
    16,638
    113
    Malfoy Manor, Wiltshire, England.
    මම zed කිව්වේ ide එක බන්. https://zed.dev/
    ඒක පට්ට. Vscode වගේ රැම් කන්නෙ නෑ.

    උඹ කියන්නේ Zig language එක වෙන්න ඇති. Rust වගේම හොඳ එකක්. 🙂👍
    https://ziglang.org/

    උබ කියලා තියන කතාව හරි.
    ඒ උනාට දැන් llm සපෝට් එක එක්ක language එක ලොකු ප්‍රශ්නයක් නෙමෙයි.
    ඕන එකෙක් දම්මලා CRUD API ගහගන්න පුළුවන්. (සාමාන්‍ය දැනුම තියෙන)
    ow ow mama kiwwe zig lang eka gana. rust eka wagema extreme high-performance kiyala ahala thiyenawa

    Mama python, nodejs packages rust වලින් ලියලා port කරා python, wasm වලට. ඉස්සරහට ගොඩක් ඒව එහෙම කරයි. Natvie වලට වඩා හොදයි. මට නන් තියෙන ලොකුම වාසිය runtime error near zero වගේ ගන්න පුළුවන් වෙන එක. ඒ උනාට server application එහෙම හොදට ලියන්න පුළුවන් ඔහොම නැතුව. කෙස් එක අර learning curve එක ටිකක් උඩ නිසා project කරන්න උන් හොයාගන්න ලේසි නෑ.
    eka loku watayak gahillak nemeda? wasm walatai python walatai integrate karanna.
    direct ma rust walin api, micro-services liyana eka wada hoda nadda if possible? or e athin gatthama go or nestjs backend wage gahala dammanam almost same performance neda cloud, micro-service context ekedi?
    but rust eke error-free nature eka thama bestma feature eka but ekata henama learning curve ekak thiyenawa kiyala ahala thiyenawa C++, java walatath wada :cry:
    ------ Post added on Jan 31, 2026 at 1:20 PM
     

    හෙළයෙක්

    Well-known member
  • Apr 26, 2014
    49,318
    100,170
    113
    ow ow mama kiwwe zig lang eka gana. rust eka wagema extreme high-performance kiyala ahala thiyenawa


    eka loku watayak gahillak nemeda? wasm walatai python walatai integrate karanna.
    ඔය මගේ usecase එකක් කිව්වේ. performance සහ error අඩු වෙන එක ඔය විදියට ගන්න ගාණට python වලින්ම ලියලා ගන්න බෑ.
    direct ma rust walin api, micro-services liyana eka wada hoda nadda if possible? or e athin gatthama go or nestjs backend wage gahala dammanam almost same performance neda cloud, micro-service context ekedi?
    but rust eke error-free nature eka thama bestma feature eka but ekata henama learning curve ekak thiyenawa kiyala ahala thiyenawa C++, java walatath wada :cry:
    ------ Post added on Jan 31, 2026 at 1:20 PM
    ඒත් වෙබ් apps ලියන්න backend වලට ගන්න පුළුවන්. ඔව් learning curve එක නිසා තමා ගොඩක් use කරනවා අඩු.
     
    • Like
    Reactions: Draco Malfoy

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,400
    19,550
    113
    Colombo
    .Net 🥳🩷
    මේක සෑහෙන productive නේ.
    මට පොඩි වැඩක් කරගන්න ඕන වෙලා නිකමට කරලා බැලුවා. මාර ඉක්මනට වැඩ කරන්න පුලුවන් NodeJS වගේම.
    JB Rider එක ෆ්‍රි නේ, මැක් එකේ ඩිවලොප්මන්ට් කරන්නත් පුලුවන් ඒකෙන්.
     
    • Like
    Reactions: RealityOfX

    CorD SaC

    Well-known member
  • Feb 4, 2015
    15,764
    28,126
    113
    මේක සෑහෙන productive නේ.
    මට පොඩි වැඩක් කරගන්න ඕන වෙලා නිකමට කරලා බැලුවා. මාර ඉක්මනට වැඩ කරන්න පුලුවන් NodeJS වගේම.
    JB Rider එක ෆ්‍රි නේ, මැක් එකේ ඩිවලොප්මන්ට් කරන්නත් පුලුවන් ඒකෙන්.
    ඔව් bro, මම හිතුවා ඔයා ඒ කාලෙත් .NET කියලා. මන් හිතන්නෙ සෑහෙන්න senior කෙනෙක් වෙන්න ඔනි මතකෙ විදිහට :cool:
     
    • Like
    Reactions: NEMISIS

    Anonymous_Abstract

    Well-known member
  • Aug 7, 2018
    6,036
    4,570
    113
    Messier 87
    language valin or LLM karnna beri real world case godak thiyanava, simple CURD application ekak ganin, mata mekata solution ekak dipanko AI use karala. simple Create request ekak.

    ex:

    mata one 1000000 requests concurrently handle karanna, fifa ticket booking, booking order ekata anuwa thama payment venna ona (payment is another service), order guarantee must.

    mata mekata soltion ekak ona AI use karala ubalage experience valin. but follwing conditions follow karanna ba.

    1. request-response - (n) (1000000 request response based karala execute karanna giyouth ekata venama dedicated server ekaka ganna venava nethnam aws bill dekala client bankrupted, and takes too much time 😆)

    2. event-based (recommended) but single partion use karanna ba multiple partions use venna ona, and consumer side concurrency level 1 venna ba, ehema vunoth single thread per partion use venna (there is no anynchronus).

    kafka cluster with 20 brokers and 100 partions, hithpanko single partion thama use venne and consumer use karanne sigle thread read karanna, becuse it needs to maintain order. ithin kafka cluster ekak ona na and singel partion valin okkoma handle karanna giyoth awla thiyenna time consumption too high.

    den mata mekata real world solution ekak ona.

    hint: onema modern language ekak with AI or without AI there is no solution for this, but if you can give me a solution i will appreciate you.
     
    • Love
    Reactions: goBeyond

    thota_langa_sirikkiya

    Well-known member
  • Jan 30, 2017
    367
    332
    63
    ගෙදර
    language valin or LLM karnna beri real world case godak thiyanava, simple CURD application ekak ganin, mata mekata solution ekak dipanko AI use karala. simple Create request ekak.

    ex:

    mata one 1000000 requests concurrently handle karanna, fifa ticket booking, booking order ekata anuwa thama payment venna ona (payment is another service), order guarantee must.

    mata mekata soltion ekak ona AI use karala ubalage experience valin. but follwing conditions follow karanna ba.

    1. request-response - (n) (1000000 request response based karala execute karanna giyouth ekata venama dedicated server ekaka ganna venava nethnam aws bill dekala client bankrupted, and takes too much time 😆)

    2. event-based (recommended) but single partion use karanna ba multiple partions use venna ona, and consumer side concurrency level 1 venna ba, ehema vunoth single thread per partion use venna (there is no anynchronus).

    kafka cluster with 20 brokers and 100 partions, hithpanko single partion thama use venne and consumer use karanne sigle thread read karanna, becuse it needs to maintain order. ithin kafka cluster ekak ona na and singel partion valin okkoma handle karanna giyoth awla thiyenna time consumption too high.

    den mata mekata real world solution ekak ona.

    hint: onema modern language ekak with AI or without AI there is no solution for this, but if you can give me a solution i will appreciate you.
    Just a response from Gemini

    1. The Virtual Waiting Room (VWR)​

    To keep costs low, you must stop the "Million-User Surge" before it reaches your actual servers.

    • Implementation: Use a Cookie-based Token system. When a user hits your URL, a lightweight edge worker (like Cloudflare Workers or an Nginx script) checks for a "Passed_Queue" cookie.
    • The Logic: If they don't have it, they are redirected to a static waiting page. This page is served from a CDN (Content Delivery Network), meaning it costs you almost nothing.
    • The "Trickle": Your backend tells the VWR: "I can handle 2,000 new checkouts per minute." The VWR then releases exactly that many tokens.
    • Budget Benefit: You only pay for a server capable of handling 2,000 active users, even though 1,000,000 are "waiting."

    2. Inventory Management via Redis Lua​

    Standard SQL UPDATE tickets SET status = 'booked' WHERE id = 1 will fail under high concurrency due to row-locking. Instead, use Redis.

    • Atomic Decrement: Redis is single-threaded, making it perfect for counting. You can use a Lua Script to ensure that "Check availability" and "Deduct ticket" happen in one atomic step.
    • Sample Logic:
      Lua

      -- KEYS[1] = event_id, ARGV[1] = quantity_requested
      local count = tonumber(redis.call('get', KEYS[1]))
      if count >= tonumber(ARGV[1]) then
      redis.call('decrby', KEYS[1], ARGV[1])
      return 1 -- Success
      else
      return 0 -- Sold out
      end

    • Why Go? Use Golang for this API. Go’s "Goroutines" are extremely lightweight. A $20/month server running Go can handle 10x the traffic of a similarly priced Node.js or Python server because Go manages memory much more efficiently.

    3. Asynchronous Ordering (The Buffer)​

    Once Redis says "Success," do not write to the SQL database yet. That is the slowest part of any system.

    • Message Queue (MQ): Push the booking details into a queue (like NATS—which is faster/cheaper than RabbitMQ).
    • Worker Pattern: A "Worker" service reads from the queue at its own pace and writes to the PostgreSQL database.
    • Order Preservation: NATS and RabbitMQ can be configured for FIFO (First-In, First-Out). Because you only push to the queue after the Redis Lua script confirms availability, the order is naturally preserved based on who "won" the Redis race.

    4. Payment & Idempotency​

    Payment is the most dangerous part because you can't "undo" a credit card charge easily.

    • The 10-Minute Hold: When Redis deducts a ticket, set a "Pending" key with a TTL (Time-to-Live) of 10 minutes.
    • Idempotency Keys: Every request must have a unique request_id. If a user clicks "Pay" twice because their internet is slow, your backend checks the request_id in Redis. If it exists, it ignores the second click. This prevents double-charging.
    • Webhooks: Use a Serverless Function (like AWS Lambda) to listen for the payment gateway's "Success" signal. This scales automatically and you only pay per "Success" message, saving money during the 99% of the year when there are no events.

    5. Summary of Costs vs. Performance​

    LayerStrategyBudget Status
    Front DoorCDN + Static Waiting RoomVery Cheap (Pay per GB)
    ApplicationGo (Golang) MicroservicesHighly Efficient (Small servers)
    InventoryRedis (In-memory)Predictable (One fixed-size instance)
    DatabasePostgreSQL (RDS/Cloud)Optimized (Only handles confirmed sales)

    Pro-Architect Tip:​

    Warm the Cache. 10 minutes before the event starts, "pre-load" all ticket counts into Redis. Never let your million users trigger a "SELECT COUNT(*)" on your SQL database during the rush.

    fRE7yzW.png
     
    • Like
    Reactions: Inigo Montoya

    Thilantdm

    Well-known member
  • Sep 15, 2010
    22,607
    5,865
    113
    අද නම් හදට ආවා
    මේක සෑහෙන productive නේ.
    මට පොඩි වැඩක් කරගන්න ඕන වෙලා නිකමට කරලා බැලුවා. මාර ඉක්මනට වැඩ කරන්න පුලුවන් NodeJS වගේම.
    JB Rider එක ෆ්‍රි නේ, මැක් එකේ ඩිවලොප්මන්ට් කරන්නත් පුලුවන් ඒකෙන්.
    mac eke .net dev walata uba monada use karana tools bn?
    rider eka nm shape with vs dark theme :D

    wena monada use karanne?
     
    • Like
    Reactions: NEMISIS

    Draco Malfoy

    Well-known member
  • Feb 9, 2019
    8,433
    16,638
    113
    Malfoy Manor, Wiltshire, England.
    මේක සෑහෙන productive නේ.
    මට පොඩි වැඩක් කරගන්න ඕන වෙලා නිකමට කරලා බැලුවා. මාර ඉක්මනට වැඩ කරන්න පුලුවන් NodeJS වගේම.
    JB Rider එක ෆ්‍රි නේ, මැක් එකේ ඩිවලොප්මන්ට් කරන්නත් පුලුවන් ඒකෙන්.
    C# ekath java wagema VM ekaka neda run wenne (bytecode layer)? eka efficient da aluth java walata wada?
     
    • Like
    Reactions: NEMISIS

    Edward Kenway

    Well-known member
  • Jan 8, 2015
    12,630
    14,280
    113
    අම්මෝ අම්මෝ. 2012 පටන් ගන්නකොට කිව්වේ php dead language එකක් කියලා.
    තාම websites වලින් 50% ක් විතර use කරන්නේ php.

    ගෙදර ආතල් එකට කරන project වල Go use කාරාට ඔවා enterprise level එකට ලේසියෙන් එන්නේ. bank, telecom වල ගොඩක් core systems දුවන්නේ java.

    1.6 වගේ version යන ඒවා jdk 7වලට upgrade කරන්නේ නෑ. ඉතින් කොහෙද බන් go වලින් කරන්නේ.

    අනික dev tools, cicd ඔක්කොම ගොඩක් කොම්පනුන්වල java වලට ලියලා තියෙන්නේ.

    අනික go popular උනාට වැඩක් නෑ. experience උන් market එකේ නැත්නම්

    තාම COBOL පවා තියනවා මුන් මේ පම්කක් කියනවා :rofl:
     

    Anonymous_Abstract

    Well-known member
  • Aug 7, 2018
    6,036
    4,570
    113
    Messier 87
    Just a response from Gemini

    1. The Virtual Waiting Room (VWR)​

    To keep costs low, you must stop the "Million-User Surge" before it reaches your actual servers.

    • Implementation: Use a Cookie-based Token system. When a user hits your URL, a lightweight edge worker (like Cloudflare Workers or an Nginx script) checks for a "Passed_Queue" cookie.
    • The Logic: If they don't have it, they are redirected to a static waiting page. This page is served from a CDN (Content Delivery Network), meaning it costs you almost nothing.
    • The "Trickle": Your backend tells the VWR: "I can handle 2,000 new checkouts per minute." The VWR then releases exactly that many tokens.
    • Budget Benefit: You only pay for a server capable of handling 2,000 active users, even though 1,000,000 are "waiting."

    2. Inventory Management via Redis Lua​

    Standard SQL UPDATE tickets SET status = 'booked' WHERE id = 1 will fail under high concurrency due to row-locking. Instead, use Redis.

    • Atomic Decrement: Redis is single-threaded, making it perfect for counting. You can use a Lua Script to ensure that "Check availability" and "Deduct ticket" happen in one atomic step.
    • Sample Logic:
      Lua

      -- KEYS[1] = event_id, ARGV[1] = quantity_requested
      local count = tonumber(redis.call('get', KEYS[1]))
      if count >= tonumber(ARGV[1]) then
      redis.call('decrby', KEYS[1], ARGV[1])
      return 1 -- Success
      else
      return 0 -- Sold out
      end

    • Why Go? Use Golang for this API. Go’s "Goroutines" are extremely lightweight. A $20/month server running Go can handle 10x the traffic of a similarly priced Node.js or Python server because Go manages memory much more efficiently.

    3. Asynchronous Ordering (The Buffer)​

    Once Redis says "Success," do not write to the SQL database yet. That is the slowest part of any system.

    • Message Queue (MQ): Push the booking details into a queue (like NATS—which is faster/cheaper than RabbitMQ).
    • Worker Pattern: A "Worker" service reads from the queue at its own pace and writes to the PostgreSQL database.
    • Order Preservation: NATS and RabbitMQ can be configured for FIFO (First-In, First-Out). Because you only push to the queue after the Redis Lua script confirms availability, the order is naturally preserved based on who "won" the Redis race.

    4. Payment & Idempotency​

    Payment is the most dangerous part because you can't "undo" a credit card charge easily.

    • The 10-Minute Hold: When Redis deducts a ticket, set a "Pending" key with a TTL (Time-to-Live) of 10 minutes.
    • Idempotency Keys: Every request must have a unique request_id. If a user clicks "Pay" twice because their internet is slow, your backend checks the request_id in Redis. If it exists, it ignores the second click. This prevents double-charging.
    • Webhooks: Use a Serverless Function (like AWS Lambda) to listen for the payment gateway's "Success" signal. This scales automatically and you only pay per "Success" message, saving money during the 99% of the year when there are no events.

    5. Summary of Costs vs. Performance​

    LayerStrategyBudget Status
    Front DoorCDN + Static Waiting RoomVery Cheap (Pay per GB)
    ApplicationGo (Golang) MicroservicesHighly Efficient (Small servers)
    InventoryRedis (In-memory)Predictable (One fixed-size instance)
    DatabasePostgreSQL (RDS/Cloud)Optimized (Only handles confirmed sales)

    Pro-Architect Tip:​

    Warm the Cache. 10 minutes before the event starts, "pre-load" all ticket counts into Redis. Never let your million users trigger a "SELECT COUNT(*)" on your SQL database during the rush.

    fRE7yzW.png
    redis use karnne in memory architecture ochchara request handle karanne dunnoth kelevena server ekata. redis khomath use karanna ba. RabbitMQ vala disk enable karanna puluwan storage valata but websocket vage simple communication ekak handle karata kafka tharam resilience na 1000000 request handle karanna concurrently. anith eka oka push based, so backpressure handle karnna hari amarui.

    Idempotency 😆 😆

    RabbitMQ and Redis dekama EOS support karanne na, let's comes to Kafka. Producer side ekin EOS enable karala Idempotency achieve karanna puluwan. othanath kelvaenna puluwan mama passe explain karannam. consumer side ekin idempotency achieve karanna nam, one partion and concurrency level 1 ekata yanna venava. ehem neththnam Redis or DB use karala track karanna venava, Redis is in memory and not suitable for this, when it comes to DB it is fucking expensive. but achieve karanna puluwan but the problem is.

    "it is not guaranteed Orders"

    mama prashna awwema mata ona multiple request execute karnna order based with multiple partions.

    passe explain karnnam kiwwe. verdaila hari load balancer ekin ekama request ekak service dekaketa send karaoth EOS enable karath thibbath instance dekak two different producer vidiya salakanna and message sequence number also differnt. so data duplicate venava, payment or banking app nam loku payment ekak nam kelvenava.
     

    thota_langa_sirikkiya

    Well-known member
  • Jan 30, 2017
    367
    332
    63
    ගෙදර
    redis use karnne in memory architecture ochchara request handle karanne dunnoth kelevena server ekata. redis khomath use karanna ba. RabbitMQ vala disk enable karanna puluwan storage valata but websocket vage simple communication ekak handle karata kafka tharam resilience na 1000000 request handle karanna concurrently. anith eka oka push based, so backpressure handle karnna hari amarui.

    Idempotency 😆 😆

    RabbitMQ and Redis dekama EOS support karanne na, let's comes to Kafka. Producer side ekin EOS enable karala Idempotency achieve karanna puluwan. othanath kelvaenna puluwan mama passe explain karannam. consumer side ekin idempotency achieve karanna nam, one partion and concurrency level 1 ekata yanna venava. ehem neththnam Redis or DB use karala track karanna venava, Redis is in memory and not suitable for this, when it comes to DB it is fucking expensive. but achieve karanna puluwan but the problem is.

    "it is not guaranteed Orders"

    mama prashna awwema mata ona multiple request execute karnna order based with multiple partions.

    passe explain karnnam kiwwe. verdaila hari load balancer ekin ekama request ekak service dekaketa send karaoth EOS enable karath thibbath instance dekak two different producer vidiya salakanna and message sequence number also differnt. so data duplicate venava, payment or banking app nam loku payment ekak nam kelvenava.
    what exactly do you want machan, is it low cost or high performance and reliability? in this kind of scenario you cannot achieve both, you asking bugatti for 50laks and also without taxes too. 😆 😆