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 4060490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:20:40+00:00 2026-05-20T15:20:40+00:00

I am in the process of starting to write a Java library to implement

  • 0

I am in the process of starting to write a Java library to implement high-performance Finite State Machines. I know there are a lot of libraries out there, but I want to write my own from scratch, as almost all the libraries out there construct automatons optimized for handling only one at a time.

I would like to know what the people in the SO community who have dabbled in state machine design feels are the most important / best design principles when it comes to implementing high-performance libraries like these.

Considerations

  1. The automatons generated are typically not massive. (~ 100-500 states).
  2. The implementation should be able to scale though.
  3. The implementation should enable fast transformations (minimization, determinization etc.).
  4. Looking to implement DFA, NFA, GNFA, PDA and possibly Tree Automata. Hopefully under a single interface if possible.
  5. Should have a good balance between memory use and performance.

Current questions regarding design for me at the moment are:

  1. Should classes for State, Symbol and Transition be defined? Or should a “hidden” internal structure be used. Personally I feel that using classes as such would waste a lot of memory since the same information can be stored in a much more condensed form. But, does this enable faster transformations? Does it hold any other pros / cons?

  2. What would be the best way to store the data internally? Using data structures like HashMap and HashSet enables amortized constant time lookups, but there is an element of overhead involved. Is this the best way? Storing the transition information as a primitive (or not) array seems to waste quite a bit of memory. Especially when the library needs to handle a lot of automatons at a time. What are the pros / cons of the different data structures?

I appreciate any input. Thanks!

  • 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-20T15:20:41+00:00Added an answer on May 20, 2026 at 3:20 pm

    Well how fast do you want it to be? The code at brics.dk/automaton does declare its own State and Transition classes altough, obviously, these could be rewritten using primitives (heck, the entire Transition class’s state apparently would easily fit on a long).

    Thing is, if you move, for example, the Transition class to simply a primitive, then you’re not forced to use anymore the slow HashMap<Transition,...> default Java collections: you can use libraries like Trove’s TLongObjectHashMap (or TLongInt… or TLongLong, whatever) which owns the default HashMap big times (the Trove libraries basically provides maps and sets that are super efficient, both fast and small, when you work with primitives: you don’t generate countless garbage nor constant needless wrapping around primitives, so less GC etc. If you’re into performance, then you do want to check Trove… And their 3.0 upcoming release is 20% faster than Trove 2.0).

    But is it really useful? Apparently that library is already plenty of fast. There’s no doubt it can be made faster by not wastefully creating objects and by using collections that do actually perform well but it’s not clear that it would be desirable.

    Besides that, I’m pretty sure that the library above is not thread safe. The State constructor creates a unique ID by doing this:

    static int next_id;
    .
    .
    .
    id = next_id++;
    

    and that constructor is called from… 90 different places!

    Textbook example of a way to not create a unique ID in a multi-threaded scenario (heck, even making next_id volatile wouldn’t be sufficient, you want, say, an AtomicInteger here). I don’t know the library well enough but this ID thinggy looks very fishy to me.

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

Sidebar

Related Questions

I'm starting to write a small web application and have started thinking about securing
I am just starting to write ruby rails. I wrote a controller but is
So, I'm starting to write some logic for a simple program (toy game on
I want to write a DOS batch process which will go through my Directory
I am trying to integrate a non-Java executable into a Java webapp on the
I am trying to write tests that interact with GDB but am having trouble
While installing SQL Server 2005, I unknowingly uninstalled the existing SQL Express(I dont know
I need to automate an command line application. It asks the user to enter
I've run into a weird error with a Qt program running on Windows. The
Good afternoon, After computing a rather large vector (a bit shorter than 2^20 elements),

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.