用python编写系统_例如,可以用Python编写多少操作系统?

This is a pretty-much theoretical question, but..

How much of an operating system could be written in a language like Python, Ruby, Perl, or Lisp, Haskell etc?

It seems like a lot of the stuff like init.d could trivially be done in a scripting language. One of the firewall-device-OS's (m0n0wall) uses PHP for its system-configuration (including on boot). And one could argue that "emacs is an OS, mostly written in Lisp"..

Of course there are bits that would have to be assembly/C, but how much could be regular .py/rb/.pl/.el/.hk files..? It might not have the best performance, but it would be, by far, the most easiest-to-modify OS ever...

解决方案

Technically, any of it could be, if you write a compiler to do so. OSes have been done in Java (JNode), .NET (MOSA, Singularity, SharpOS, Cosmos), Haskell (HOUSE), Python (Unununium), etc.

Edit: I see a lot of people talking about the very lowest level being an area where this couldn't be done; this isn't true.

There's no reason that the compiler for X language can't be extended to handle any low-level operation and expose it to the language. All functionality can be achieved from any language, it's simply a matter of picking the right tool for the job. Sometimes this is Python, sometimes this is C, sometimes this is assembly.

Look to projects like Cosmos and SharpOS to see a pure high-level OS Done Right (TM).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
抱歉,作为AI语言模型,我无法编写和执行代码。以下是基本的机器人操作系统的概述,您可以使用Python或其他编程语言来实现它。 机器人操作系统(ROS)是一个用于机器人开发的开源框架。ROS提供了一种通用的方法来管理硬件抽象、驱动程序、通信、控制、仿真和导航等功能。它还提供了大量的库和工具,用于构建机器人应用程序。 以下是一个简单的ROS程序示例: ```python #!/usr/bin/env python import rospy from std_msgs.msg import String def callback(data): rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data) def listener(): rospy.init_node('listener', anonymous=True) rospy.Subscriber("chatter", String, callback) rospy.spin() if __name__ == '__main__': listener() ``` 这个程序创建了一个ROS节点,订阅一个名为“chatter”的主题,并在接收到消息时调用回调函数。回调函数将消息记录到ROS日志中。 您可以通过创建发布者来向主题“chatter”发送消息: ```python #!/usr/bin/env python import rospy from std_msgs.msg import String def talker(): pub = rospy.Publisher('chatter', String, queue_size=10) rospy.init_node('talker', anonymous=True) rate = rospy.Rate(10) # 10hz while not rospy.is_shutdown(): hello_str = "hello world %s" % rospy.get_time() rospy.loginfo(hello_str) pub.publish(hello_str) rate.sleep() if __name__ == '__main__': try: talker() except rospy.ROSInterruptException: pass ``` 这个程序创建了一个ROS节点,创建一个名为“chatter”的主题发布者,并在循环中发布消息。消息包含当前时间,并在ROS日志中记录。 这只是ROS的基础知识,您可以使用ROS来构建更高级的机器人应用程序,例如导航、感知、操作、控制等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值