Posts

quick note on dotty, graaljs interop: structural typing with Selectable

quick note on dotty, graaljs interop: structural typing with Selectable This is a quick note on dotty’s structural typing via Structural and graaljs interop. graaljs is nodejs on the graal vm with interop to JVM. You can run dotty as the JVM language quite easily, just like any other JVM language. Dotty has a new feature for structural typing ( https://dotty.epfl.ch/docs/reference/changed-features/structural-types.html ) based on the Selectable trait. It implements a dynamic lookup to values based on application specific metadata. The example given on the web site is: case class Record ( elems : ( String , Any ) * ) extends Selectable { def selectDynamic ( name : String ) : Any = elems . find ( _ . _1 == name ) . get . _2 } type Person = Record { val name : String val age : Int } val person = Record ( "name" - > "Emma" , "age" - > 42 ) . asInstanceOf [ Person ] println ( s ...

zio layers and framework integration

zio layers and framework integration https://github.com/zio/zio is a FP library for scala. When used to organize your entire program, your main function inherits from the zio App and you return a zio effect ( ZIO ). You don’t need to worry about creating a default environment or other such details. This blog touches on using zio in an existing framework and composes services using ZLayer . When zio is inserted into an existing framework, the setup is different. We will add zio to an existing javascript app stack with only a few lines of extra “glue” code–that’s how easy it is. If your app is not complex, you should stick with javascript/typescript and async/await or stick with composing js.Promise in scala.js–they are good enough for a wide range of work. If you have something more complicated, read on. Some useful ZLayer blogs: https://timpigden.github.io/_pages/zlayer/Examples.html?utm_campaign=ZIO News&utm_medium=email&utm_source=Revue newslet...

null was not the billion dollar mistake

null was not the billion dollar mistake There is always much buzz about programming language and features. One claim is that “null” was a billion dollar mistake. I think that’s not actually true. I think the billion dollar mistake was using null in a programming language that has too few tools to manage null as a value. The issue is actually not about “null” but about “worlds.” Let me explain. My perspective is informed from ployglot programming. For example, you can do polyglot programming with the same “value” on Oracle’s graal platform. You can use both dynamically typed and statically languages on the same value since the same values can be accessed from different languages. Once you start switching between languages operating on the same value, you realize that issues for managing “values” is usually influenced by programming language limitations. Some languages are better at others at handling different concerns around values than others. Take a value “a”...