Type Safety definition alvin July 5, 2019 - 3:34pm

I saw this definition of type safety yesterday in a book named Programming TypeScript and I thought it was very simple and good:

Type Safety: Using types to prevent programs from doing invalid things.

Kotlin: How to show an instance’s data type (class) in the REPL alvin August 2, 2018 - 11:00am

If you need to see the data type (or class) of an instance in the Kotlin REPL, you can use the javaClass method to see that type. Here are a few examples:

The lack of type safety was difficult to scale ... alvin July 15, 2018 - 1:36pm

From this AirBnB article about using React Native: “JavaScript is an untyped language. The lack of type safety was both difficult to scale and became a point of contention for mobile engineers used to typed languages who may have otherwise been interested in learning React Native ... A side-effect of JavaScript being untyped is that refactoring was extremely difficult and error-prone.”

Functional Typelevel Programming in Scala alvin July 9, 2018 - 12:18pm

If you’re interested in the future of Scala, i.e., Scala 3, also known as Dotty, Martin Odersky recently shared a working draft document titled, Functional Typelevel Programming in Scala. See the “Files Changed” link on that page for the complete working document.

Scala: How to define a generic method parameter that must extend a base type

In today’s installation of “how to have fun with Scala,” if you want to define a method that takes a parameter that has a generic type, and want to further declare that the parameter must extend some base type, use this syntax:

def getName[A <: RequiredBaseType](a: A) = ???

That example says, “The parameter a has the generic type A, and A must be a subtype of RequiredBaseType.”

Two steps to deriving a generic algorithm alvin June 16, 2017 - 11:00am

“Two steps are required to write a good piece of code. The first step is to get the algorithm right. The second step is to figure out which sorts of things (types) it works for.”

From the “Deriving a Generic Algorithm” chapter in the book, From Mathematics to Generic Programming.

Pure Function Signatures Tell All alvin May 28, 2017 - 6:26pm

“In Haskell, a function’s type declaration tells you a whole lot about the function, due to the very strong type system.”

Learn You a Haskell for Great Good!

One thing you’ll find in FP is that the signatures of pure functions tell you a lot about what those functions do. In fact, it turns out that the signatures of functions in FP applications are much more important than they are in OOP applications. As you’ll see in this lesson:

Java int, double, float, and mixed-type arithmetic rules alvin September 14, 2016 - 11:16pm
Table of Contents1 - The answer2 - More Java division and arithmetic rules3 - Summary

Java FAQ: What are the rules about Java arithmetic (multiplication, division) involving mixed data types?

While working on a math problem in Java just a little while ago, I realized that I wasn’t comfortable with the Java mixed-type division rules. That is, I wondered if the result of this equation:

3 / 2

the same as the result of this equation:

3 / 2.0

or this equation:

3.0 / 2.0
Scala’s types of types alvin April 12, 2016 - 7:20am

If you ever want to learn more about Scala “types,” this page about Scala’s types of types is a good reference.