TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Where are the unit-typed languages?

1 pointsby univackyover 5 years ago
Are there any programming languages that treat, say, numbers like adjectives, as human languages do, and have units typing?<p>Instead of an integer being a standalone noun, &quot;5&quot;, it would be &quot;5 apples&quot;, or &quot;5 meters&#x2F;second&quot;. Multiplying a variable of 3 meters&#x2F;second by a variable of 2 minutes could give a result of 180 meters, and adding nautical miles to dollars would give an exception. I&#x27;ve played around with this idea a little bit in objects, but it seems like a language with such features built in or an object library should already exist somewhere.

2 comments

kognateover 5 years ago
You can do this sort of thing with Ada&#x27;s type system. There is also a blog post about units of measure in F# <a href="https:&#x2F;&#x2F;blogs.msdn.microsoft.com&#x2F;andrewkennedy&#x2F;2008&#x2F;08&#x2F;29&#x2F;units-of-measure-in-f-part-one-introducing-units&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blogs.msdn.microsoft.com&#x2F;andrewkennedy&#x2F;2008&#x2F;08&#x2F;29&#x2F;un...</a><p>It&#x27;s a pretty niche topic. You can do this in a language like c++ or even python but unit aware calculations aren&#x27;t a requirement for a lot of systems.
blandflakesover 5 years ago
Have you seen <a href="https:&#x2F;&#x2F;frinklang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;frinklang.org&#x2F;</a> ? I think that&#x27;s supposed to be its Big Idea.