简体   繁体   English

独立于平台的轻量级编程语言

[英]Platform Independent, Lightweight Programming Language

I need to write an extremely lightweight program (trying to get below 8Kb) that performs some simple math. 我需要编写一个非常轻量级的程序(试图低于8Kb)执行一些简单的数学运算。 The language also needs to be platform independent. 该语言还需要与平台无关。 Which language do you think would work the best? 您认为哪种语言效果最好? (Oh, and no frameworks allowed.) (哦,没有框架允许。)

C.当然,您需要为每个平台单独编译,但除此之外,它非常轻,并且与平台无关(或多平台,无论您喜欢哪种表达)。

Which platforms are the program targeting? 该计划的目标是哪些平台?

So far, we have the following requirements: 到目前为止,我们有以下要求:

  • Program must be under 8 kilobytes. 程序必须低于8千字节。
  • Must be platform-independent. 必须与平台无关。
  • No frameworks allowed. 没有框架允许。

Here are some questions: 以下是一些问题:

  • Can the 8 KB program be a script for a scripting language? 8 KB程序可以作为脚本语言的脚本吗?
  • How big can the runtime environment for the program be? 程序的运行时环境有多大?
  • Should the program be native code on its own? 该程序应该是自己的本机代码吗?
  • Which target platforms should the code run on? 应该运行代码的目标平台是什么?
  • Is cross-compiling the code for each platform an option? 是否为每个平台交叉编译代码?

The questions that I've presented are going to affect the desirable options. 我提出的问题将影响理想的选择。 If the program must be 8 kilobytes with the runtime environment, then there really isn't much of a choice other than compiling against the target environment. 如果程序在运行时环境中必须是8千字节,那么除了针对目标环境进行编译之外,确实没有太多选择。

If the target is an embedded device, or non-x86, then its likely that the choices will be further restricted. 如果目标是嵌入式设备或非x86,那么可能会进一步限制选择。 Small embeddable langugages such as Lua can still be used (written in C), but that would require a fairly large "runtime" for the script to execute. 仍然可以使用诸如Lua之类的小型可嵌入语言(用C语言编写),但这需要相当大的“运行时”来执行脚本。

If cross-compiling to the targets are an option, then writing a program in C and compiling to each target platform will probably yield fairly small native programs. 如果交叉编译到目标是一个选项,那么用C编写程序并编译到每个目标平台可能会产生相当小的本机程序。

With the current requirements, there are a few questions that need to be addressed in providing a good comprehensive answer. 根据当前的要求,在提供良好的综合答案时需要解决一些问题。 Other than that, the best that can be done is a brainstorming of options that may or may not lead to a desirable solution. 除此之外,可以做的最好的事情是集体讨论可能会或可能不会产生理想解决方案的选项。

Would browser based JavaScript be an option? 基于浏览器的JavaScript是一种选择吗? Lightweight and runs on almost all platforms via browser. 轻量级,可通过浏览器在几乎所有平台上运行。

Lua是跨平台,重量极轻。

Forth怎么样?

你在想像pico这样的东西吗?

c or assembly (though you'll need to compile for each platform) c或汇编(虽然你需要为每个平台编译)

TCL is a scripting language that's cross-platform (not sure how lightweight it is) TCL是一种跨平台的脚本语言(不确定它有多轻量级)

I'd suggest Java but the VM probably thrashes your size requirements 我建议使用Java,但虚拟机可能会超出您的尺寸要求

dc DC

It's basically an overblown calculator but it's 25K and zips down to 12K. 它基本上是一个夸张的计算器,但它是25K并且拉低至12K。 It also does some string operations, macros and runs external processes. 它还执行一些字符串操作,宏和运行外部进程。 You won't find much smaller without writing it yourself. 如果不自己编写,你将找不到更小的东西。 Source and win32 binaries available. 源和win32二进制文件可用。

You'd be surprised how much you can get done in less than 4k of Java: 你会惊讶地发现,在不到4k的Java中你可以完成多少工作:

http://www.java4k.com/ http://www.java4k.com/

Of course that doesn't include the JVM :-) 当然那不包括JVM :-)

Not sure what you mean by framework?? 不确定你的框架意味着什么?

python 蟒蛇

why? 为什么?

  1. It comes installed on my linux distributions, OSX and can be packaged as a native executable on windows. 它安装在我的Linux发行版OSX上,可以打包为Windows上的本机可执行文件。 In other words the user of your app won't have to install anything 换句话说,您的应用的用户将不必安装任何东西
  2. It's really easy to learn. 这真的很容易学习。

Bespin from Mozzila is an online environment. 来自Mozzila的Bespin是一个在线环境。 So it is, by definition, platform independent. 因此,根据定义,它与平台无关。 Try at https://bespin.mozilla.com/ 试试https://bespin.mozilla.com/

Even C requires a runtime. 即使C也需要运行时。 Only realistic answer to this question is dc, or even a custom calculator that executes scripts, implemented in C. (Such a calculator could be smaller than dc, if it doesn't depend on arbituary precision). 对这个问题的唯一现实答案是直流,甚至是执行脚本的自定义计算器,用C实现。(如果它不依赖于arbituary精度,这样的计算器可能小于dc)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM