在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Frege/frege开源软件地址(OpenSource Url):https://github.com/Frege/frege开源编程语言(OpenSource Language):Frege 67.9%开源软件介绍(OpenSource Introduction):What is Frege?Winner of the JavaOne Emerging Languages Bowl 2015, 2016, 2017 Frege is a Haskell for the JVM. Like any Haskell, it is purely functional, enjoys a strong static type system with global type inference and non-strict - also known as lazy - evaluation. Frege compiles to Java, runs on the JVM, and uses any Java library you want. It can be used inside any Java project. A Taste of Frege1. Hello World This is the classic starter with a slight extension to show the fluent usage from Java and the benefits of having a type system that can recognize purity. module Hello where
greeting friend = "Hello, " ++ friend ++ "!"
main args = do
println (greeting "World") This code will compile to Moreover, the
that one can call from Java or any other JVM language. The The "Hello World" already shows the tenet of "islands of purity" (greeting) in a "sea of imperative code" (main). Since the purity information is carried through the type system, the compiler can potentially use it for many optimizations such as pre-calculation, deferred execution, parallel execution, caching, and elimination of common subexpressions.
2. Expressive code Much can be achieved in Frege in one line of code and here is an example that you can paste into the
Online REPL. It calculates pythagorean triples below
After execution, you should see a list of triples containing the solutions Such a comprehension reads almost like an SQL statement:
3. No mutable state Mutable state is the source of many bugs and makes code less modular. Frege allows interesting ways to avoid it. That style is very unfamiliar to many developers that come from the imperative world. Be brave. It is different but there are a huge benefits to be discovered. Let's go for a more advanced example where we calculate the fixpoint of the cosine function, i.e. the
value where Implementations in imperative languages usually involve introducing local mutable state. Not so in Frege: import frege.prelude.Math (cos)
cosines = iterate cos 1.0
pairsOf xs = zip xs (tail xs)
head [ x | (x,y) <- pairsOf cosines, x == y] After execution, it should show you the value
The code is most likely incomprehensible for a Frege/Haskell newcomer at first, but it becomes less intimidating once you know the parts. With a bit of experience, you may even find it clear and obvious.
This code is pure. The inferred type is What's in it for me?For the Java programmer Frege offers you the opportunity to learn and use a new programming paradigm that shines with
You can still reuse your existing knowledge of the Java platform and its vast set of libraries. Frege interoperates with Java such that you can easily call Frege from Java code and vice versa. But unlike other approaches, calling Java from Frege doesn't undermine the language guarantees.
Learning Frege essentially means that you will also learn Haskell and thus your effort pays off twice, since you also get to know a very popular non-JVM language with 25+ years of development, a great community, many (free) books, publications, tutorials, online courses, and considerable industry demand. For the Haskell programmer Frege gives you the opportunity to use your skills on the JVM. Most idiomatic Haskell code will run in Frege unmodified or with only minimal, obvious adaptations. Even more important: you can bring your purely functional solution strategies to your Java projects. From now on you can also enjoy on the JVM:
Frege aims at compiling most "vanilla" Haskell code that has no external dependencies "as is" or with only minimal, obvious changes. Likewise, Frege code that makes no use of JVM specifics should easily run through other Haskell compilers. We are currently in the progress of coming closer to this goal by ironing out insubstantial differences. The NameThe Frege programming language is named after and in honor of Gottlob Frege who published the ideas of higher-order functions, partial function application, and many more concepts of formal logic that we now take for granted back in the 19th century. If you are curious how this name is pronounced, you can use this translator page to get it right. Just click the audio symbol in the left (german) part. Project StateThe compiler, an Eclipse plugin, and a provisional version of the documentation can be downloaded. Note that Frege requires at least JDK 7 to compile and run programs. A number of tools are written in Frege:
This should speak for itself regarding stability, functional completeness and performance of the language. The documentation is provisional, and the library supports almost all of the Haskell 2010 standard library with the remaining known differences being there for good reason. See the Getting Started page for getting started at the command-line or read the Eclipse plugin page. You can develop Frege inside Intellij IDEA with an Intellj IDEA plugin being under active development and there is build automation support for Maven, Gradle, Leiningen, SBT, and Bazel. The awesome QuickCheck library for advanced unit testing comes bundled with the language. Related Projects
ContributionsIf you are interested in contributing, here are some hot topics:
ContactMeet Frege friends in person Talk to us at any of the upcoming events or view historic presentation slides and videos! For discussions You can contact the project members through the discussion group devoted to the Frege programming language. For questions Specific programming problems are best solved on Stack Overflow, we check questions tagged "frege" on a regular basis. For casual chat (and quick questions) There's a #frege channel on Freenode IRC where some project members and Frege users hang out. You can use any IRC client you like or Freenode's WebChat interface if you don't want to install IRC software. The Frege Gitter channel is also a way tool to connect to the community. Staying up to date
For issues only If you find a bug or have an idea for enhancements, please let us know by opening an issue in the issue tracker. (You'll need a GitHub account to do this.) Please keep discussions to the forum and questions to Stack Overflow. Links
Recommended reading
API DocsCopyright and LicenseCopyright (c) Ingo Wechsung, 2011-2021. All rights reserved. The use and distribution terms for this software are covered by the BSD 3-clause license which can be found in the file LICENSE.txt at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论