Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Scala Lang #235

Open
Velythyl opened this issue Jul 21, 2020 · 12 comments
Open

Add Scala Lang #235

Velythyl opened this issue Jul 21, 2020 · 12 comments
Labels
idea lang-idea An idea for a new language.

Comments

@Velythyl
Copy link

Here's the language's website https://www.scala-lang.org/

@JRaspass JRaspass changed the title Add "Scala" lang Add “Scala” Lang Jul 25, 2020
@JRaspass JRaspass added the idea label Jul 25, 2020
@MichalMarsalek MichalMarsalek added the lang-idea An idea for a new language. label Mar 23, 2022
@FlorianCassayre
Copy link
Contributor

Note that as for Python there are two major Scala versions (2 and 3); but unlike Python the newer one is very recent (less than two years old). Since Scala 3 is still evolving very quickly, if we were to add this language I think it would be best to rely on version 2 which is actively maintained but will not benefit from any new language features.

@Steffan153
Copy link
Contributor

I'd add Scala 3. It's been around for enough time (imo) that it's plenty stable enough.

However, we have the same problem as Kotlin: It takes >=5s to run a program.

@FlorianCassayre
Copy link
Contributor

Scastie, the official Scala sandbox running on the web, have managed to do it for both versions (<1s on a cold start). We should study how they did it and decide how to proceed (source code).

@Steffan153
Copy link
Contributor

Interesting. This is what I get on my machine:
image

@FlorianCassayre
Copy link
Contributor

Yes, this is to be expected on a "regular" environment. Part of that time is spent compiling the code, and the other part starting up the program (slowed down by the standard library).

@Velythyl
Copy link
Author

Velythyl commented Oct 20, 2022

The issue is also that on a local machine, the programs run on the JVM, which tends to be very bloated and slow to boot up

@FlorianCassayre
Copy link
Contributor

Unless I am mistaken I don't think the JVM is the main issue. According to Scastie:

We run your code in an isolated Java Virtual Machine on our servers.

I am currently checking how they implement this "isolated JVM".

@Steffan153
Copy link
Contributor

Here's what I get on a fresh Alpine image. No extra junk and bloat installed, just JRE and Scala.

image

Would it be faster to use sbt?

@JRaspass JRaspass changed the title Add “Scala” Lang Add Scala Lang Dec 2, 2022
@Steffan153
Copy link
Contributor

I was looking into this and noticed that even on Scastie, it's technically slow, because on the first run, it starts up sbt and takes over 5 seconds. On subsequent runs, it's fast because it uses the same running sbt instance.

@FlorianCassayre
Copy link
Contributor

I was looking into this and noticed that even on Scastie, it's technically slow, because on the first run, it starts up sbt and takes over 5 seconds. On subsequent runs, it's fast because it uses the same running sbt instance.

Is it?
I tried loading the page in incognito mode and quickly executing a script and I didn't notice any delay. Perhaps they are preloading sbt instances in a pool and then use them as they are requested by the clients? Or could they be sharing instances between clients?

@Steffan153
Copy link
Contributor

Steffan153 commented Feb 18, 2023

I don't know but I've tried several times and on each load, it takes a while to start up.

Using Scala 2 is quite a bit faster though.

@frankchoongsaeng
Copy link

Maybe ditch sbt and use ammonite instead. I've used this a few times and I think it'll be perfect for this usecase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea lang-idea An idea for a new language.
Projects
None yet
Development

No branches or pull requests

6 participants