https://serverless-stack.com/ logo
#sst
Title
# sst
j

Jimmy

08/05/2021, 8:22 AM
Are there any plans for JVM/Java support?
t

thdxr

08/05/2021, 10:42 AM
We add languages as they're requested. Is this something you'd like?
j

Jimmy

08/05/2021, 8:37 PM
I just did a project with SST and TypeScript and was very impressed with the quick iteration workflow. Today we write Lambdas in Scala, and using AWS SAM, and our workflow does not have anything near the easy of use and iteration speed of what I’ve just experienced. Scala is fairly niche but if there’s Java support you can usually get things working for Scala pretty easy, so.
t

thdxr

08/05/2021, 8:39 PM
I'll create an issue for this. Frank is working on dotnet support right now but can probably move to Java after that. Long term we're looking to create a plugin model so people can easily specify how to compile and deploy any language they want which should make all of this more flexible
j

Jimmy

08/05/2021, 9:05 PM
sounds awesome
f

Frank

08/05/2021, 9:51 PM
Hey @Jimmy, a couple of questions on Java: 1. what commands are you running to build ur Java lambdas? 2. is it built inside a docker container? 3. what package managers are commonly used for Java? gradle? And which one r u using?
Hey @Jimmy, just circling back on this. Do you still need the Java runtime?
p

Pål Brattberg

08/26/2021, 7:56 AM
I believe @Jimmy is using gradle and buidling inside docker using sbt @Frank
j

Jimmy

08/26/2021, 8:05 AM
sorry, was a bit laid back during vacation and was going to come back to this once I was at the office again 🙂
what commands are you running to build ur Java lambdas?
we currently only have scala lambdas, and it differ from Java up until the JAR is produced, then it’s handled just like any Java JAR. Like Pål says we use SBT to both build our Scala projects (though no gradle in there atm) and handle the package management for them. Builds are done within docker containers with the proper scala and sbt versions
we’re basically doing it like this https://github.com/fancellu/scala-sam-app
so in our build scripts we first do
sbt assembly
which produces a JAR
and then we do the same `sam package`as one does for Java
f

Frank

08/26/2021, 5:08 PM
@Pål Brattberg @Jimmy Thanks guys for the details.
j

Jimmy

08/26/2021, 5:09 PM
Np, ask away if you have any follow-up at any time
f

Frank

08/26/2021, 5:10 PM
btw do you have scala and sbt installed on ur machine (outside of docker)?
j

Jimmy

08/26/2021, 5:10 PM
Yes, for convenience when developing
We use intellij idea and it kinda assumes you have the tools locally (though I think it should be possible to run your compiler etc in docker). Docker performance on mac is pretty noticable for Java and .net development in my experience
When you have a big monolith, as one does, compiling in docker can be quite painful
But for microservices it can be tolerable
f

Frank

08/26/2021, 5:14 PM
Yup that makes sense. I was asking b/c
sst start
tries to build your function code live as you are developing. So it’d be much faster to do it natively on ur machine.
And when you deploy, it can build inside the docker.
j

Jimmy

08/26/2021, 5:15 PM
Yeah that makes a lot of sense
f

Frank

08/26/2021, 5:16 PM
Btw, are the JARs OS dependent? As in a JAR built on Windows, can it be run on linux? (excuse my lack of Java knowledge 😔)
j

Jimmy

08/26/2021, 5:16 PM
They're OS independent
f

Frank

08/26/2021, 5:17 PM
So you are building in docker just to ensure consistent scala and sbt versions are used. Right?
j

Jimmy

08/26/2021, 5:17 PM
Well unless you have some native bindings, but I think you usually distribute builds for "all" platforms along with the JAR then, normally
Yes, mostly because our CI/CD pipeline uses docker
f

Frank

08/26/2021, 5:20 PM
Got it!
When do you need the Java support by timeline wise?
j

Jimmy

08/26/2021, 5:22 PM
We're doing most of our new development as lambdas and we manage with the current setup, though "developer experience" and particularly iteration speed and unclear process around mocking/live resources/etc are the main complaints
So yeah it would be a fantastic improvement whenever it arrived 😄
We're up to our ears with compliance until October/November so we're not writing that many new lambdas atm at least
f

Frank

08/26/2021, 5:25 PM
Sounds good! I think i’ve got most of the stuff required to get us started.
j

Jimmy

08/26/2021, 5:25 PM
Cool!
f

Frank

08/26/2021, 5:25 PM
I’m sure I will bug you again for some details later 🙂
j

Jimmy

08/26/2021, 5:26 PM
How does the proxy lambda communicate with the locally running code?
Is it making http requests locally to the server running in c# etc?
I'm asking because thinking a bit on Scala which has some interesting solutions around "hot reloading"
f

Frank

08/26/2021, 5:28 PM
It sends a websocket message to ur local with entire event and content;
sst start
then runs ur code with it; and sends the response back as a websocket message again.
j

Jimmy

08/26/2021, 5:30 PM
I see, I'll give it a look and ponder the Scala application, thanks!
f

Frank

08/26/2021, 5:30 PM
Yeah, let me know if the process can be improved by Scala’s hot reloading!
@Jimmy @Pål Brattberg Can
sbt package
be used instead of
sbt assembly
to build the JAR? I’m trying out the scala-sam-app.
sbt assembly
generated a 12MB JAR.
sbt package
generated a 16KB JAR, and also runs faster.
j

Jimmy

08/30/2021, 9:44 AM
sbt package
only generates a JAR for your code, so any dependencies won’t be include, whereas
sbt assembly
createas a “fat jar” with all dependencies baked in. Since Lambda wants a (one) JAR for the JVM Lambda you need a fat jar, and otherwise you’d still need to include the other library JAR’s
perhaps it’s a smart optimization to have a lambda layer with the Scala standard library though, which would reduce the size
f

Frank

08/30/2021, 7:51 PM
Thanks @Jimmy! May I ask: 1. how long does
sbt assembly
take for your project? 2. are all of your Lambdas in the same
sbt
project? Or 1
sbt
project per Lambda?
j

Jimmy

08/30/2021, 8:21 PM
1. it takes a while, especially since it runs tests by default, 2 minutes on a project I just tried. For hot reloading the thing with scala is that one usually wants to keep sbt running and have it recompile on changes, so having an external watcher doing that is ideal. I guess you currently detect changes from outside and restart the language runtime? 2. one sbt project per “service”, which can be composed of multiple lambdas
since you proxy the lambda to the local code I guess doing an `assembly`etc might not be needed?
one can do `sbt ~assembly`which will do a hot recompile & assembly on a source code change, but the assembly still takes 20s for me (compilation 4s)
f

Frank

08/30/2021, 8:46 PM
Yeah,
sst start
currently restarts the language runtime. If we were to keep
sbt
running, do we need to have multiple
sbt
processes running, 1 for each service?
j

Jimmy

08/31/2021, 4:18 AM
good question, I assume you do if we’re not doing something custom
f

Frank

09/02/2021, 8:32 PM
@Jimmy @Pål Brattberg hey guys, I have an early version with Scala + sbt support. It works well on Mac/Linux, but has an issue on Window. If you guys are on windows, I’m hoping for some help 😔
So this is what I’m running to build the jar file on Linux:
Copy code
sbt 'set assemblyOutputPath in assembly := new File("/path/to/project/build/index.jar")' "set test in assembly := {}" assembly
On windows, I can’t seem to be able to escape the
"
or the
)
inorder to set the
assemblyOuputPath
. I tried this:
Copy code
sbt "set assemblyOutputPath in assembly := new File(""/path/to/project/build/index.jar"")" "set test in assembly := {}" assembly
And I’m getting the error:
Copy code
set was unexpected at this time.
Any ideas guys?
j

Jimmy

09/03/2021, 11:51 AM
Hey Franke that sounds amazing, I’ll set aside some time to check it out today or tonight. From the windows message it appears set is evaluated by the shell (regular windows cmd.exe), not sure why at first glance though.
f

Frank

09/03/2021, 6:59 PM
Thanks @Jimmy. I can cut a canary release for you to try it out after getting around this issue.
t

Tomasz Sobczyk

09/24/2021, 8:45 PM
i guess I could be interested in this as well, due to certain level of obession we have with Kotlin & Java within our developers 😄 (kotlin folks are particullary obsessed with their language of love) 😄 did you guys get anywhere with this first version?
2 Views