Scala 中的 GUI 编程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/981399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 01:27:37  来源:igfitidea点击:

GUI programming in Scala

javaswingscalauser-interfacefunctional-programming

提问by thatismatt

I'm trying to learn Scala, and I'd like to learn by writing a simple swing app, but I'm unsure what GUI programing looks like in a functional world, and specifically when using Scala.

我正在尝试学习 Scala,我想通过编写一个简单的 Swing 应用程序来学习,但我不确定 GUI 编程在函数式世界中的样子,特别是在使用 Scala 时。

Any pointers, or tutorials, or gotchas when coming from an OO/Java background would be really welcome.

任何来自 OO/Java 背景的指针、教程或问题都将非常受欢迎。

采纳答案by Tristan Juricek

The Programming in Scalabook did contain an overview of the scala-swing project. The book is very good, overall, and worth the money as a general reference, and sounds just like what you're looking for.

在Scala编程书确实含有斯卡拉摆项目的概述。总的来说,这本书非常好,作为一般参考物有所值,听起来就像您要找的东西。

Scala-swing is a "wrapping" library approach, so, I wouldn't call it functional, really. State is mutated all over the place, mostly because that's just how Swing works.

Scala-swing 是一种“包装”库方法,因此,我真的不会称其为函数式的。State 到处都是变异的,主要是因为这就是 Swing 的工作方式。

I'm not really aware of many "free as in beer" resources for this topic yet, and I think the Syngeca scala wikiprobably lists some preliminary approaches that became scala-swing, but, that's just a guess. :)

我还没有真正了解有关此主题的许多“像啤酒一样免费”的资源,我认为Syngeca scala wiki可能列出了一些成为 scala-swing 的初步方法,但这只是一个猜测。:)

回答by Daniel C. Sobral

The only functional paradigm of GUI programming I know of is Lisp's Cells.

我所知道的唯一的 GUI 编程功能范例是 Lisp 的 Cells。

Scala's present Swing library is reactive, which isn't bad. It's being reworked for version 2.8, I have heard.

Scala 现有的 Swing 库是响应式的,这还不错。我听说它正在为 2.8 版重新设计。

There are, though, alternative frameworks. One recent one, for instance, is a Scala wrapper for SWT.

但是,有替代框架。其中最近的一个,例如,是斯卡拉包装的SWT。

I think that, at this point, there hasn't been enough projects done for any particular pattern to emerge as a superior choice. I'd advise taking a look at everything out there, and choosing one that fits you better. Who knows? You might even become a major contributor to the best Scala GUI framework that comes to be...

我认为,在这一点上,还没有足够的项目让任何特定模式成为更好的选择。我建议你看看那里的所有东西,然后选择一个更适合你的。谁知道?您甚至可能成为最好的 Scala GUI 框架的主要贡献者……