Skip to main content

标  题: 两个我永远都不想碰的语言

FatWallet Coupons and Deals发信人: coconut (向唐僧大师学习中), 信区: Programming
标  题: 两个我永远都不想碰的语言
发信站: BBS 未名空间站 (Tue Oct 27 04:52:29 2015, 美东)


最近无聊,稍微研究了下两个语言,彻底被雷了。

第一是 R 。可以说是世界上最 fucked up 的语言之一(COBOL 是另外一个)。
你看一下这篇文章就明白了:

https://xianblog.wordpress.com/2010/09/13/simply-start-over-and-build-
something-better/

如果你非要写 R 代码。建议你把所有的 variable 都弄个 prefix 。免得你
不小心碰到这种麻烦事。

第二就是 Go 。整个一傻逼语言。

1) 如果该语言有 pointer,但是其速度比 Java 还慢点,谁 TMD 有病才用它。
再不用说,Go 里面需要知道很多很多 low level 的东西,但是搞了半天比 Java
还慢?!!

2) Stupid copies 。好吧,你有 pointer 不用,非得 pass by value (i.e.
struct copy),真是脑袋抽筋了。copy 大部分情况下比 reference 慢。
reference 是可以放在 register 里的,而 struct 一旦比 register 大,
就会占内存。然后 Go idiots 说 cache 很 precious,那你还搞那么多 copy
干嘛?这么多 copy,debug 成了问题。C/C++ debugging 常用的 watch r/w
办法彻底被废了。到目前为止,Go 的 debug 也是主要靠 printf 。

好吧,Go 大概是为了避免产生太多的 object on heap,但是你看看下一步:

3) 为了保证 pass by reference ,有些代码还特意就是
type dumb struct {
  wtf * pointer
}
真是什么样的傻逼语言才产生这种怪胎。如果该 struct 是 pass by reference,
该 struct 又得放在 heap 上。真是有够无聊。

4) 傻逼的 error handling 。Exception 是慢,但是 Go 的 error handling
整个一个失败。如果某人大意了没读 error return,该 error 就彻底消失,
这就是一个大 bug,而且是很难 trace 的一个问题。你如果每一个 function
call 都读一下 error,整个屏幕上 50-75% 的代码都是 error handling 。

更不用说,return multiple value 也不快。

写 Java 的人都知道,Java 的 exception 对 debugging 帮助很大。Go lang
有 panic / recover,但是太原始了。Go 语言对 debugging 的不重视本身就
是一个致命伤。

5) 没有 generics 。一个没有 generics 的语言根本没资格谈论 type safety 。

6) 傻逼的 map, array, slice, range 。这个语言搞了那么多 syntax sugar,
然后这些不支持 user 的 container 。更因为没有 generics ,user container
根本没法提供 type safety 。然后 map / array / slice somehow 有 type
safety 。都 1.5 版本了,连最基本的东西都没有。

7) 傻逼的 typed nil != nil 。Go 语言是可以产生 typed nil 。这玩意还不能
简单的 nil check 。玩玩下面的代码。想吐了么?

package main

type A struct{}

func foo (a interface{}) {
    if (a == nil) {
        println ("is nil")
    }
    if (a == (*A)(nil)) {
        println ("is type A nil")
    }
}

func main() {
    var p *A   // p is initiated to typed nil

    foo (p)
    println ("==========")
    foo (nil)
}

当你写个程序以为 a == nil 是 nil check 却发现不工作,会不会吐血?

8) 傻逼的 syntax 。居然强制性的要求 { 必须在 function / if 的那一行末尾。
事实上,{ 在下一行一般来说查找起来更方便。就算你喜欢在行末尾,也没必要
强制性搞成这样吧。

9) 傻逼的 instance method / composition / inheritance 。这方面 Go 彻彻
底底是个烂摊子。随便给你个例子:

package main

import "fmt"

type A struct{ string }

type C struct {
    A
    s1 A
}

func (a *A) fooA () {
    fmt.Printf ("fooA: %v\n", a)
}

func fooB (a *A) {
    fmt.Printf ("fooB: %v\n", a)
}

func main() {
    c := C{ A{ "a" }, A{ "b" } }

    c.s1.fooA ()
    c.fooA ()

    fooB (&c.s1)
    fooB (&c)  // prog.go:27: cannot use &c (type *C) as type *A in argument
to fooB
}

看看 fooA 和 fooB 的区别。再看看 compiler error 。Go 语言这里的问题太多
了。

同学们,珍惜生命,远离 R 和 Go 。

Comments

Popular posts from this blog

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...