IT討論區(127) 邀請 IT 界衰妹出嚟食串燒

實驗羊

1001 回覆
4 Like 4 Dislike
無腦滅火筒 2021-07-10 08:06:01
實驗羊 2021-07-10 08:10:59
咁唔用 null 有咩取替方面?
elon.musk. 2021-07-10 08:19:10
themida 2021-07-10 09:35:14
用Option
每次都要考慮埋None
否則compile time error
強制unwrap會panic
青蛙瓷器 2021-07-10 10:08:13
實驗羊 2021-07-10 10:08:59
首先,後者咪即係有用 null 都係要做 null check 只係 Syntax / Compiler 進步幫你減少錯誤。

所以我覺得應該淨係針對討論前者。

前者即係所有嘢都有 Default value 咁會產生究竟個 Value 係 Default 定係已經改變? 限制咗一定霸住一個值。

對於一定要霸佔一個數值(其實只係將 null 換左一個樣),你有咩睇法?
青蛙瓷器 2021-07-10 10:09:13
實驗羊 2021-07-10 10:10:21
Swift 都有
實驗羊 2021-07-10 10:17:00
Tryfail 2021-07-10 10:34:20
依度有無40歲以上嘅IT狗分享依家做成點?覺得自己仲可以係依行撈幾耐?

做咗幾年,自問資質一般會進修但覺得依家跟新tech都有d吃力,想像唔到自己仲可以撈多幾耐
腦若傷殘 2021-07-10 10:35:44
實驗羊 2021-07-10 10:44:05
即係直接一體化 鮮辣雞燒部新機出嚟
實驗羊 2021-07-10 10:50:59
咁我 get 錯

我以為你話 null 嘅概念喺 Programming Language 係錯,諗緊會唔會有咩方法去取替,連 null 呢個概念都移除埋。

第一個方法係 set default value but as you said it doesn’t always work

第二三係 nnbd 但係都係有 null 呢樣嘢存在

你講嘅嘢其實都係要保留 null,只係有好多方法去幫你完成 null check 同避免 null pointer。
十個幾亳半 2021-07-10 11:10:05
實驗羊 2021-07-10 11:17:01
係 Rust 嗰隻我都用過 其實都係 nnbd 啲另一種呈現

其實我係冇思考過 null 嘅存在問題 單純係接受咗 所以勾起就好奇有冇方法 完全剔除呢個概念

themida 2021-07-10 11:31:12
冇得從概念上移除null
無法確保一個有input既program冇exception
實驗羊 2021-07-10 11:36:36
第二句可唔可以具體啲?

我暫時遇到嘅 null 情況 多數都係同 external system 有關 e.g. IO DB
實驗羊 2021-07-10 11:58:35
I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.


StrongDrinkWater 2021-07-10 12:30:00
女朋友搵工 本身搵Uxui 個邊 點知in 佢間公司直接offer佢做frontend React dev 0底轉行
吹水台自選台熱 門最 新手機台時事台政事台World體育台娛樂台動漫台Apps台遊戲台影視台講故台健康台感情台家庭台潮流台美容台上班台財經台房屋台飲食台旅遊台學術台校園台汽車台音樂台創意台硬件台電器台攝影台玩具台寵物台軟件台活動台電訊台直播台站務台黑 洞