首页 \ 问答 \ JavaScript来clojure(Javascript to clojure)

JavaScript来clojure(Javascript to clojure)

我知道ClojureScript - 可以将clojure代码编译为javascript,但是有可能做相反的事情,需要JavaScript代码的一些子集并将其翻译回clojure?


I am aware of ClojureScript - possibility to compile clojure code to javascript, but is it possible to do the reverse, take some subset of javascript code and translate it back to clojure?


原文:https://stackoverflow.com/questions/6788212
更新时间:2022-03-15 14:03

最满意答案

它可以,但据我所知,事实并非如此。 为了解决这个问题,Scala最近增加了对编译时类型专用化的泛型代码的支持,该代码生成了该类的专用版本 - 没有任何转换 - 并将它们透明地放置到代码库的其余部分,以便代码仍然按预期工作。 在这些情况下,编译好的Scala代码实际上可能比Java快得多,因为带泛型的Java将始终使用强制转换。


It could, but as far as I know it doesn't. To work around this, Scala added support somewhat recently to compile-time type specialization of generic code which generates specialized versions of the class - without any casts - and places them to the rest of the codebase transparently so that the code still works as expected. In these cases, compiled Scala code can actually be noticeably faster than Java since Java with Generics will always use casts.

相关问答

更多
  • Java代码通常分布为字节码,这是与机器无关的伪代码 。 (同样的想法以前在70年代开发的UCSD-p系统中使用过。)其优点是相同的应用程序可以在不同的处理器和操作系统中运行。 另外,字节码通常比编译的应用程序小。 缺点是与运行编译代码相比,解释代码很慢 。 为了解决这个问题,开发了JIT编译器 。 JIT编译器在执行代码之前将代码编译为机器代码。 与解释器相比,这样可以加快执行速度,但每次运行程序时都会花费额外的时间进行编译。 另外,由于JIT编译器必须快速编译,因此不能使用静态编译器中使用的复杂优化技术 ...
  • 它可以,但据我所知,事实并非如此。 为了解决这个问题,Scala最近增加了对编译时类型专用化的泛型代码的支持,该代码生成了该类的专用版本 - 没有任何转换 - 并将它们透明地放置到代码库的其余部分,以便代码仍然按预期工作。 在这些情况下,编译好的Scala代码实际上可能比Java快得多,因为带泛型的Java将始终使用强制转换。 It could, but as far as I know it doesn't. To work around this, Scala added support somewha ...
  • 我可以举一个优化的例子。 假设你有某个地方的功能。 (可以把它看成类似C的伪代码。) void function(MyClass x) { x.doSomething(); for (obj in x.getWidgets()) obj.doSomethingElse(); } 这是适当的模糊。 但是,假设您在整个图像中只有一个从MyClass继承的具体类: MyConcreteClass 。 在这种情况下,JIT可以内联doSomething和getWidgets 。 如 ...
  • 使用泛型具有显着的性能优势 - 您可以摆脱拳击和拆箱 。 与开发自己的课程相比,这是一个硬币投掷(硬币的一边比另一方重)。 只有当你认为你可以超出框架的作者的时候,才能自己滚动自己。 There's a significant performance benefit to using generics -- you do away with boxing and unboxing. Compared with developing your own classes, it's a coin toss (wi ...
  • 在你之前的问题中,JIT优化了方法start的完整代码,没有分析方法返回时变量中出现了什么数字。 这是因为你选择让你的方法void ,给JIT一个简单的线索,任何计算的值都将被丢弃。 将你当前的例子与前一个问题的例子相比较,没有void方法调用,所以自然不会发生优化。 为什么没有其他优化可以帮助完全不同的案例是一个无法回答的问题。 在spencefic JVM实现中没有这样的优化,以及您测试代码的特定JVM调用。 In your previous question the JIT optimized awa ...
  • 我找到了一个锻炼来解决这个问题。 在编译期间,不得以任何方式指定目标GPU(删除-gencode或-gencode标志)。 随后,驱动程序在运行时生成目标二进制文件。 I found a workout to handle the issue. During compile, the target GPU must not be specified in anyway (Remove -arch or -gencode flags). Subsequently, the driver generates t ...
  • 尝试考虑使用PrintAssembly命令行参数集。 以下HotSpot选项(命令行中带有-XX:前缀)需要OpenJDK 7和可外部加载的反汇编程序插件 建议尝试hsdis插件实现。 但是你需要手动构建它。 要查看生成的代码,您还应该首先使用-XX:+ UnlockDiagnosticVMOptions 。 换句话说,JVM将无法识别另一个PrintAssembly选项。 在你的情况下应该帮助下一个选项: -XX:CompileCommand可以帮助您过滤应用程序的输出。 -XX:LogFile = fo ...
  • 我不认为你可以令人信服地证明使用JIT的Java比C / C ++静态编译的代码更快。 你可以在java中找到一些击败其c / c ++实现的代码。 为此,您需要搜索关键字,如(基准,Java,JIT,C,C ++) 我故意没有提到上述任何代码或链接,因为我的观点如下。 大多数时候,人们都会用以下方式显示java代码以静态方式编译c / c ++ 找到java比c / c ++(内存分配)快的部分,并且只写代码来突出显示它。 找到c / C ++代码的弱点,并尝试编写超过c / c ++代码来实现结果的ja ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)