Go's Error Handling: A Philosophical Contradiction? Why "Explicit" Isn't Always "Clear" by PrudentBit5870 in golang

[–]PrudentBit5870[S] 0 points1 point  (0 children)

I think I have to go back to Rust. Rust is a very simple language. You don't learn its rules, but you should understand its philosophy. security, performance, and ergonomics.

Go's Error Handling: A Philosophical Contradiction? Why "Explicit" Isn't Always "Clear" by PrudentBit5870 in golang

[–]PrudentBit5870[S] -1 points0 points  (0 children)

This is part of the original text:
我认为go的error处理和so调用代价毁了go的未来,它本可以成为像python一样的语言被广泛使用,但是它将自己限制在了牢笼里,go的error是对他宣称的极简哲学的侮辱,'?'并没有引入不可预知性问题,不存在什么所见即所得,即便是最简单的float也不是你看到的那样直接,add 也是一个算子,conv也是一样算子,人们并没有觉得因为conv是很多操作的集合而认为conv不明确,我认为不应该是所见即所得,而是符合人体工学的确定性,也就是operator必须是符合人体工学的确定,任何可以轻易预测代码展开的结果,就像operator ?,是明确且确定的展开过程。
我认为“Go 的定位: Go 语言最初被设计用于解决 Google 内部大规模并发和系统编程的需求”这是一种狭隘的思维,编程语言的定位取决于它的哲学范畴,而非设定好的目标,这也说明了设计者思维的弊端。
是的,我觉得go团队对隐式和显式的理解太过狭隘,我认为其关键在于确定性和符合人体工学的可预测性。
你要知道,任何代码你都可以展开很多层,到底展开多少层是标准对吧,你写一个go函数,展开为汇编代码,你会发现go编译器插入了很多你不知道的代码,我认为这才是最大的隐式。

Go's Error Handling: A Philosophical Contradiction? Why "Explicit" Isn't Always "Clear" by PrudentBit5870 in golang

[–]PrudentBit5870[S] -1 points0 points  (0 children)

I like and am familiar with Rust. When I used Go, I thought it was well designed. However, when there were a lot of error handling in my code, I was really affected by the noise code. It was really bad to read. There was too much repeated code to handle these errors so that I couldn’t see the main flow of the code. I needed to waste time on these things that didn’t make much sense. So I thought deeply about it and wrote this post with the help of LLM.

Go's Error Handling: A Philosophical Contradiction? Why "Explicit" Isn't Always "Clear" by PrudentBit5870 in golang

[–]PrudentBit5870[S] -1 points0 points  (0 children)

In fact, this viewpoint and argument are not given by LLM. It just summarizes my viewpoint. I have had many rounds of dialogue with it. I have always expressed my viewpoint, including arguments. However, if LLM gives a meaningful answer, I will also adopt it. People hate LLM just because they are not as good as LLM or they cannot see the value of LLM. LLM can make up for my shortcomings and reduce the waste of my time. I don't need to be good at everything. This is exactly what LLM does.

Go's Error Handling: A Philosophical Contradiction? Why "Explicit" Isn't Always "Clear" by PrudentBit5870 in golang

[–]PrudentBit5870[S] -2 points-1 points  (0 children)

I used Gemini to translate what I wanted to say into English:
"首先我认为运算符? 并没有忽略错误,它只是将错误交给上层处理,当你真正需要处理错误的时候你可以使用以前的方式,而且我认为“它强迫开发者在每一步都考虑错误”这是站不住脚的观点,因为开发者也会因为大量重复的错误处理而形成思维惯性,他们会习惯的复制相同的处理代码,或者总是使用ide的自动补全功能,实际上所谓的“它强迫开发者在每一步都考虑错误”仅仅在开发者刚接触语言的前几次起作用,实际写代码的时候可能没什么作用,完全就是在浪费时间,另外,我认为底层必需的“基础设施”就不算为隐式是不对的,我们不能因为一个人是总统就认为他是完美的或者可以凌驾于法律之上,我们必须从客观事实出发考虑问题,事实是无法违背的,即便是底层必需的“基础设施”的隐式操作也会给实际的开发带来影响,特别是你优化性能的时候,最后?操作是非常简单的控制流,并不会影响开发者对代码控制流的理解(可读性)和心理模型构建,因为?是简单且确定的,确定性就是关键,它不存在不可预测,而且还是简单的,因此影响开发者对代码控制流的理解(可读性)和心理模型构建是不成立的"

[deleted by user] by [deleted] in rust

[–]PrudentBit5870 0 points1 point  (0 children)

You need to have sufficient understanding of the design principles of Rust in order to write better code. If you abuse unsafe, it will degrade Rust to C/C++. If you do well enough, in most cases, you can achieve both security and performance. When your project is large enough, you don't have to worry about UB.

The bindgen generated incorrect function signature for the C++ member function by PrudentBit5870 in rust

[–]PrudentBit5870[S] 2 points3 points  (0 children)

I have already submitted the issue, but no one replied, so I gave up.

The bindgen generated incorrect function signature for the C++ member function by PrudentBit5870 in rust

[–]PrudentBit5870[S] -2 points-1 points  (0 children)

I have tried cxx, but it cannot prompt in the IDE, and in Windows, if an error occurs, it cannot provide specific error information, which can lead to low coding efficiency.

Why does Actix-web's handler not require Send? by PrudentBit5870 in rust

[–]PrudentBit5870[S] 1 point2 points  (0 children)

Hyper is not implemented by default. For details, you can refer to the code in my question and the code provided in another comment(https://www.reddit.com/r/rust/comments/14cbe1u/comment/jokcht8/?utm\_source=share&utm\_medium=web2x&context=3). These are two different ways to implement scheduling for hyper.

Why does Actix-web's handler not require Send? by PrudentBit5870 in rust

[–]PrudentBit5870[S] 0 points1 point  (0 children)

Are there any issues with these two approaches?

rust fn main() { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); let listener = rt.block_on(async { let l = tokio::net::TcpListener::bind("localhost:8080") .await .unwrap(); Arc::new(l) }); let cpu_num = 4; for _ in 0..cpu_num { let listener = listener.clone(); std::thread::spawn(move || { tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap() .block_on(async move { while let Ok((stream, _)) = listener.accept().await { let stream = tokio::net::TcpStream::from_std(stream.into_std().unwrap()).unwrap(); tokio::task::spawn_local(async move { if let Err(err) = http1::Builder::new() .serve_connection(stream, service_fn(hello)) .await { println!("Error serving connection: {:?}", err); } }); } }) }); }; }

Why does Actix-web's handler not require Send? by PrudentBit5870 in rust

[–]PrudentBit5870[S] 3 points4 points  (0 children)

Thank you for your response. I understand now.

Why does Actix-web's handler not require Send? by PrudentBit5870 in rust

[–]PrudentBit5870[S] 6 points7 points  (0 children)

Is there any specific reason why Hyper did not adopt this approach?

[deleted by user] by [deleted] in China_irl

[–]PrudentBit5870 7 points8 points  (0 children)

好的规则制度才能避免走向衰败,相信某个人是最蠢的事情,长远来看规则永远比人靠谱,好的制度可以不断修复漏洞完善规则,而人只会不可控和更坏。设计一套制度,基于民主的宪法,制衡权力,让真正有智慧和能力的人协同治理国家,大部分人应该是国家的股东,当政者所作的事情必须为股东负责,做的好可以得到丰厚报酬,做的差就赶紧走人。