Jump to content
Beiling

Alfred workflow please support Java

Recommended Posts

Please support Java in workflow ~~!

 

Since I'm a java programmer and I'm familiar with Java, if I want to write a complex workflow using python, then I will spend a lot of time to learn python and all kind of library, it's really inconvenient.

 

There are more and more Java programmer, so please support Java in workflow ~!

Share this post


Link to post
Share on other sites

You are welcome to write a Java library -- Alfred can use any language on the system.  All the libraries for building workflows are user-created -- I imagine if there were demand for Java, someone would have written one.

Share this post


Link to post
Share on other sites

It’s not an issue, it’s a thread, so no need to close it. 

 

You don’t need a library to write workflows. They were more important in Alfred 2, where you had to generate XML for Script Filters and do your own result filtering. Alfred 3 uses JSON and can filter results for you.

 

Be warned that Java is not a good fit for workflows, however. Workflows are very short-lived processes, and Alfred tries to run Script Filters every time the query changes (i.e. on every keypress).

 

So Java’s slow start-up time makes it a really bad choice for workflows.

Share this post


Link to post
Share on other sites

Thank you for your advice, Java is slow indeed.

 

"hello world" in Java spends 160ms.

"hello world" in shell script spends only 4ms.

 

really a large gap between them.

 

Thank you for your advice~!

Share this post


Link to post
Share on other sites

Java is that fast? I was expecting more like 500ms. I’d be interested to hear how it does when you load more libraries to do something useful. 

 

160ms is about the load time for a large Python or Ruby workflow (i.e. including quite a lot of libraries).

 

Obviously, they don’t run anywhere near as fast as Java, though.

Share this post


Link to post
Share on other sites

@deanishe I have an app, written in kotlin, that is packaged as a 22Mb fat jar file.  Libraries are non-trivial -- sqlite, micronaut, picocli, kotlin statistics.  There's really no need for micronaut in this app, but I'm experimenting with it, so there it is.  I have not yet done any testing with Alfred

 

The app does a read-only query on the sqlite database of the application "Bear" to get the text of all the notes modified in the last month, then does some regex matching on note text to find certain things and compile a little report that is formatted as a markdown outline.  My current Bear database isn't very large, but grows every day.  This application runs (timed by the unix 'time' command) from the command line in about 180ms.

 

Startup time is, indeed, java's weakness when compared to something like a shell script. But if you don't use reflective DI frameworks like Spring you can keep things reasonable.

Share this post


Link to post
Share on other sites
5 minutes ago, kastork said:

Startup time is, indeed, java's weakness when compared to something like a shell script. But if you don't use reflective DI frameworks like Spring you can keep things reasonable.

 

Yeah. I've been using a few command-line Java programs recently, and I've come to the conclusion that the problem isn't Java itself, but the way a lot of Java developers use it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...