A
A
avadakeda2021-06-22 14:29:31
Programming languages
avadakeda, 2021-06-22 14:29:31

Is there a statically typed homoiconic programming language?

Interested in languages ​​with a rich and developed ecosystem, such as those based on the JVM, .NET or javascript. I liked the Julia language, but there is no real typing, i.e. checks are not made at the stage of writing. The only such language I could find is Typed Racket, but there's a small ecosystem there.

If there are no other languages, is it possible to develop a version of the popular statically typed language with the homoiconic property , it is important for me that the code can be represented as data and vice versa, data as code. Which popular statically typed language would then be easier to modify?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Roo, 2021-06-22
@xez

The article you cite refers to Clojure.
https://clojure.org/
https://ru.wikipedia.org/wiki/Clojure
https://clojurecourse.by/

V
Vasily Bannikov, 2021-06-22
@vabka

In F# and Scala, it is possible to save an AST to a variable.

A
Alexey Bereznikov, 2021-06-22
@gdt

Find a list and go through it, check each language for support for what you need. I found this one:
rnxb-rpqv11edjmdnkckpnlpuzk.png

M
mikhanoid, 2021-07-29
@mikhanoid

The compiler or interpreter of any language presents the code as data during processing. But this data is not always available to the programmer for free work with them. Homoiconality simply means that code and data "look" the same. Therefore, the question is: why do you need homoiconism?
If there is, then you need to look at the languages ​​of the Lisp family. If for some practical purposes, like writing macros, then you can look at Rust, Haskell or Scala, which have such features in some form, or any other programming language and think about how to pull out the code representation at the compilation stage for the programmer. Not such an easy task for a classic statically typed language, because you have to somehow make sure that code transformations do not break types.
In any case, the system will be a multi-stage compiler, because you will need to first compile the code that is required to manipulate the syntax, call this code, get new code, possibly compile it again in order to further process expressions.
Julia works like this. The compiler is part of the runtime, so it's hard to tell if Julia is statically typed or not. In any case, the compiled code is fast, sometimes even faster than similar C code.
Typed Racket is built on top of Racket, like a set of macros, and the type system is not normal, and occurence typing is a lot more complex than traditional static typing systems. There is also Typed Clojure, based on Typed Scheme, which is also in this category.
Finally, there is a relatively raw but relatively workable Lisp with static typing: carp-lang. In which, in fact, you also have to have two languages: a dynamic language for working with macros, and a static main language. They look the same, but the semantics are different.
Maybe you can come up with something about this. Good luck with your exploration!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question