美国研究者分析了开源代码库Github 140万用户的数据。他们发现和男性相比,女性发送的“拉请求”(代码更新提议)更容易被接受。由数据上看,女性提交代码的通过率为78.6%,而男性的通过率仅为74.6%。
在中国程序媛中,她们的代码又有什么样的魅力,青根联合云栖社区,饿了么,钉钉,阿里云,天猫发起首届程序媛比码大赛活动 - 不秀大长腿,秀高智商;不秀美图照,秀代码图,参与晒码互动游戏赢“83行代码” T恤!
视障工程师蔡勇斌和女朋友为83行代码Ť恤带盐照
虐完狗,我们继续说说这群女工程师的第83行代码及代码背后的故事:
有被代码耽误的钉钉吃货程序媛,写代码写到忘记吃饭的采霜,她急需能把她从代码中叫醒去吃饭的小伙伴,赶紧勾搭;
有以代码为乐的饿了么大前端打(BEI)杂(国)工程师张蓓楚
还有全栈美女工程师 - 前端后端一锅端的朱默女神
还有阿里云像男人一样活好码赞的技术妹子清宵妹子
有天猫的Java的程序媛女神采月
想看程序媛的代码,点我穿越来看程序员比码大赛
附送一段阿里云清宵妹子的golang代码,看完“药神”之后的彩蛋感悟,求程序猿们诗意解读
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
var (
r = rand.New(rand.NewSource(time.Now().Unix()))
disasterSignal = make(chan string)
accidentSignal = make(chan string)
diseaseSignal = make(chan string)
)
// Element : abstract factor which life consisted by
type Element interface {
Improve()
Depress()
Stable()
Enable() bool
BeAbleHandle(event string) bool
}
type Activity interface {
IsSuitable(life *Life) bool
Do(life *Life)
Interrupted()
}
type Life struct {
Sex string
Age time.Duration
Health Element
Knowledge Element
Ability Element
RelationShip Element
Wealth Element
OtherElement Element
Work Activity
Study Activity
Exercise Activity
Entertain Activity
Rest Activity
OtherActive Activity
isDoings []Activity
vitalitySignal chan struct{}
NaturalDeath chan struct{}
}
func (f *Life) Join(oppositeSex *Life, love, family Element) (*Life, error) {
if !love.Enable() || !family.Enable() || f.Sex == oppositeSex.Sex {
return nil, fmt.Errorf("Sorry, no boby should be borned!")
}
boby := &Life{
Sex: []string{"male", "female"}[r.Intn(2)],
Age: 0,
isDoings: []Activity{},
NaturalDeath: make(chan struct{}),
vitalitySignal: make(chan struct{}),
}
return boby, nil
}
func (f *Life) Run() {
go ExternalEndanger(f)
// time elapses day by day
for {
startTime := time.Now().UTC()
wg := &sync.WaitGroup{}
for _, active := range []Activity{f.Study, f.Work, f.Entertain, f.Exercise, f.Rest, f.OtherActive} {
if f.SuitableFor(active) {
wg.Add(1)
go func(activity Activity) {
defer wg.Wait()
activity.Do(f)
}(active)
}
}
select {
case <-f.NaturalDeath:
f.Close()
fmt.Println("Life is short, make it colourful and cherish the love around all!")
return
case <-f.vitalitySignal:
fmt.Println("记得买保险!")
return
case <-time.After(24*time.Hour - time.Now().UTC().Sub(startTime)):
fmt.Println("One day went by...")
}
//wg.Wait()
f.Age += 24 * time.Hour
}
fmt.Println("Goodbye, life!")
}
func (f *Life) Somehow() {
// happened something to effect one to reach some life stage
}
func (f *Life) SuitableFor(active Activity) bool {
return active.IsSuitable(f)
}
func (f *Life) Survive(event string) bool {
for _, e := range []Element{f.Health, f.Knowledge, f.Ability, f.RelationShip, f.Wealth, f.OtherElement} {
if !e.BeAbleHandle(event) {
return false
}
}
return true
}
func (f *Life) Close() {
for _, doing := range f.isDoings {
doing.Interrupted()
}
close(f.vitalitySignal)
}
var female = LifeFromSomeWhere("female")
var male = LifeFromSomeWhere("male")
func ExternalEndanger(f *Life) {
for {
event := ""
select {
case event = <-diseaseSignal:
case event = <-disasterSignal:
case event = <-accidentSignal:
}
if !f.Survive(event) {
f.Close()
return
}
}
}
func LifeFromSomeWhere(sex string) *Life {
life := &Life{Sex: sex}
life.Somehow()
return life
}
func main() {
// I don't know the question of "鸡生蛋 or 蛋生鸡"...
newLife, err := female.Join(male, ElementImp{Type: "love"}, ElementImp{Type: "family"})
if err != nil {
newLife.Run()
}
}