douhuang2218 2017-10-10 02:07
浏览 409

为什么golang选择syscall而不是libc

Go wraps all syscall-s in package syscall, just like what libc does if I understand them right.

I've researched a few languages,

  • Haskell, using libc in compiler and the libraries normally use it too, although there is a few libraries wrapping syscall for users.

  • Java and almost all JVM languages choosing libc.

No need mention script languages, such as lua, ruby or python, they need portable, so they need libc as an implementation of POSIX.

I didn't use rust recently, but there are some people just said rust using libc too.

So, why golang decided to implement a syscall package at first. It's not portable, cost more people to port to each kernel, even each major version of the same kernel.

  • 写回答

1条回答 默认 最新

  • dongling4383 2019-03-14 14:38
    关注

    Because Go manages its processes in goroutines managed by the Go Runtime which is written in C and statically linked to the compiled user code during the linking phase. Since go manages its syscall with its own runtime not directly in the OS, that is why it implemented its own syscall package.

    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教