Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 696855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:06:28+00:00 2026-05-14T03:06:28+00:00

When and where do you put type annotations in Clojure code? Obviously when performance

  • 0

When and where do you put type annotations in Clojure code? Obviously when performance counts. But are there rules by which you can live of when (only when doing Java Interop?) and where to add them (function definition arguments)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:06:29+00:00Added an answer on May 14, 2026 at 3:06 am

    The overriding reason that I"m aware of is performance. Type hinting in clojure removes reflection, which can slow down performance. So I would put type hints in functions which I’ve measured to be performance critical.

    There is a description in the java interop section at clojure.org. Among the remarks:

    Clojure supports the use of type hints to assist the compiler in avoiding reflection in performance-critical areas of code. Normally, one should avoid the use of type hints until there is a known performance bottleneck.

    …
    Once a type hint has been placed on an identifier or expression, the compiler will try to resolve any calls to methods thereupon at compile time. In addition, the compiler will track the use of any return values and infer types for their use and so on, so very few hints are needed to get a fully compile-time resolved series of calls. Note that type hints are not needed for static members (or their return values!) as the compiler always has the type for statics.

    You can always turn on the warn on reflection flag to see where reflection is being called, and consequently, where type hints might help.

    EDIT:

    Regarding your question "Only for java interop?" –no. Type hints will be useful even in a pure clojure application. The issue of reflection slowing down performance is a fact of life on the JVM, and is an issue that dynamic languages have to deal with in general.

    Regarding where type hints can be placed, from clojure.org:

    They can be placed on function parameters, let-bound names, var names (when defined), and expressions:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put this data type in a Haskell Set, but I don't
So I have a anonymous type which I have used ToString on, and put
How to check if I the type hints I have put to my code
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
Put them all in one separate folder structure or along with classes which implements
Put value as a field makes sense only if this one represents some object's
I'm adding new content to a node, but I'm stuck on what to put
I've written some code for showing annotations with custom images in a mapview. My
In Visual Studio, there is __declspec(property) which creates properties similar to C#. Borland C++
How can you get the data type of a variable argument in Java if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.