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 checking a shared sec

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 /opt/course/1/context_default_no_kubectl.sh , but without the use of k

标 题: 关于Daniel Guo 律师

发信人: q123452017 (水天一色), 信区: I140 标  题: 关于Daniel Guo 律师 关键字: Daniel Guo 发信站: BBS 未名空间站 (Thu Apr 26 02:11:35 2018, 美东) 这些是lz根据亲身经历在 Immigration版上发的帖以及一些关于Daniel Guo 律师的回 帖,希望大家不要被一些马甲帖广告帖所骗,慎重考虑选择律师。 WG 和Guo两家律师对比 1. fully refund的合约上的区别 wegreened家是case不过只要第二次没有file就可以fully refund。郭家是要两次case 没过才给refund,而且只要第二次pl draft好律师就可以不退任何律师费。 2. 回信速度 wegreened家一般24小时内回信。郭律师是在可以快速回复的时候才回复很快,对于需 要时间回复或者是不愿意给出确切答复的时候就回复的比较慢。 比如:lz问过郭律师他们律所在nsc区域最近eb1a的通过率,大家也知道nsc现在杀手如 云,但是郭律师过了两天只回复说让秘书update最近的case然后去网页上查,但是上面 并没有写明tsc还是nsc。 lz还问过郭律师关于准备ps (他要求的文件)的一些问题,模版上有的东西不是很清 楚,但是他一般就是把模版上的东西再copy一遍发过来。 3. 材料区别 (推荐信) 因为我只收到郭律师写的推荐信,所以可以比下两家推荐信 wegreened家推荐信写的比较长,而且每封推荐信会用不同的语气和风格,会包含lz写 的research summary里面的某个方面 郭家四封推荐信都是一个格式,一种语气,连地址,信的称呼都是一样的,怎么看四封 推荐信都是同一个人写出来的。套路基本都是第一段目的,第二段介绍推荐人,第三段 某篇或几篇文章的abstract,最后结论 4. 前期材料准备 wegreened家要按照他们的模版准备一个十几页的research summary。 郭律师在签约之前说的是只需要准备五页左右的summary,但是在lz签完约收到推荐信 ,郭律师又发来一个很长的ps要lz自己填,而且和pl的格式基本差不多。 总结下来,申请自己上心最重要。但是如果选律师,lz更倾向于wegreened,