Statically Typed Metaprogramming?

后端 未结 5 2239
自闭症患者
自闭症患者 2021-02-18 15:43

I\'ve been thinking about what I would miss in porting some Python code to a statically typed language such as F# or Scala; the libraries can be substituted, the conciseness is

5条回答
  •  故里飘歌
    2021-02-18 16:17

    Very interesting question.

    Some points regarding metaprogramming in Scala:

    • In scala 2.10 there will be developments in scala reflection

    • There is work in source to source transformation (macros) which is something you are looking for: scalamacros.org

    • Java has introspection (through the reflection api) but does not allow self modification. However you can use tools to support this (such as javassist). In theory you could use these tools in Scala to achieve more than introspection.

    • From what I could understand of your development process, you separate your domain code from your decorators (or a cross cutting concern if you will) which allow to achieve modularity and code simplicity. This can be a good use for aspect oriented programming, which allows to just that. For Java theres is a library (aspectJ), however I'm dubious it will run with Scala.

提交回复
热议问题