Coding straight into the cloud

Today each developer need to download the code locally, do a lot of config, make sure they are connected to the correct db, and endure “it works on my machine”-bugs. Why can’t we instead write code straight into a web interface? Then all developers would get the exact same environment as in prod, and they wouldn’t need to spend any time on setup whenever they enter a new project.

These web interfaces could even be framework specific, and help the developers way better than if they write just a bunch of text, as today.

This is what it could look like:

In the code, userId comes straight from the URL. Since the type Int is given in the URL, the constant will get type Int in the code. To view the endpoint, as the user would see it, click on Preview (in a statically typed language, like Kotlin, you would need to wait a few seconds until the build is finished).

With this type of framework, there could simply be generated code behind the scenes based the user inputs. This could be built on top of Ktor, so the above example could compile to (slightly simplified):

    get("/users/{userId}"){
        val userId = call.parameters["userId"]!!.toInt()
        val user = User.findById(userId)
        call.respondHtmlTemplate(LayoutTemplate()) {
            content {
                h1 { user.username }
                // and so on
            }
        }
    }

I hope I have given Jetbrains a new, exciting project to work on :smiley:

Furthermore, I would love to hear your thoughts on this!

That’s mainly solved by docker containers and other such tools. Also, instead of a web interface, which would be terrible for developer productivity (something like IDEA needs to be quite optimized, and while JS has gotten faster, running on the web still has somewhat of a performance tax), companies instead have remote development machines that you log into remotely and develop there. That has been standard practice for at least a decade, and probably longer.

The root idea is good. In fact I’d say it’s been solved many ways. Anyone that has many “works on my machine” issues for application level programming is probably not using modern development practices or is working in a particularly challenging environment.

Gradle checks in the wrapper to VCS
The JVM ecosystem expects no machine environment dependencies.
Docker and other containerization adds even more consistency on top of byte code.
Function As A Service (FaaS) allows developers to code directly to the cloud.

Specific, FaaS does exactly what OP is requesting.
And for IDE and environment consistency, there’s Jetbrains Gateway and Gitpod.

EDIT:
It might be worth noting that while “works on my machine” is pretty well known as a problem, the other monster is “works on the build machine”. Ideally, everything, including application builds, infrastructure, environment configuration, and app configuration, should all be captured in code and version controlled. (i.e. Infra-as-code, config-as-code… etc).

3 Likes

JS is not good enough yet? Probably true, but maybe web assembly could be used? Also a possibility would be to just run the editor locally, and then the code and methods of the objects etc are sent to the local editor. Then the local editor POSTs the edited code back to the web interface.

The nice thing with this kind of framework, is that you can make it specific for the things you are developing. As in my example, you can go straight to the endpoint you want to test instead of having to navigate forth and back in a browser.

FaaS is not exactly what I’m referring to. I want the whole application to run directly in the cloud, with a framework specifically to the type of application I’m building. If you build a web app, you get the tools directly for that: Entry endpoints, templates, database etc. The framework could also look different between different types of web apps, for example you could choose “SaaS app with one db per customer” etc.

In the case I’m referring to, “works on the build machine” would always work as it’s always the same environment.

This way of explanation is just how one would describe FaaS. The other parts of having entry points, templates, DB, that is all usually included with whichever FaaS framework you choose.

Still, I do think I’m understanding what you mean. I’d describe it as “an opinionated FaaS framework with dressing included”. All a developer needs to focus on is small functions of responsibility and they get to edit focused sections of code to perform one function. Developers don’t need to worry about endpoints, arguments, and other dressings like setting up database connections, they just implement their functions. Lastly, the tool has an IDE plugin to show those specific blocks of code in a nice drop-down view.

^ I’d say that’s describing another FaaS framework. Albiat with the option and ability to run locally–which is the case for many FaaS frameworks. Also adding in a bit of a code builder or IDE support.

This is another feature common to cloud development. It makes sense and it’s true that it’s always the same environment. When introducing a new FaaS, the problem of “it works on my machine” doesn’t distinguish FaaS from other solutions.
Containers and cloud platforms have dealt with these for so long that it makes more sense to sell a FaaS based on simplifying development or simplifying your platform engineering needs.

EDIT:
I do like the idea of a simplified application builder. It could be a really nice low-code framework. I like that angle a lot since it’s solving the problem of complex application development. :slightly_smiling_face:
And that angle is much more appealing than a framework trying to solve the same issues that cloud development solves.
Of course, I’d expect the low-code framework might output containers or maybe a Helm chart. If it’s fancy enough maybe it would integrate with registries, or have some easy hooks into common CI/CD–as long as it uses them instead of reinventing them.

1 Like

It’s kinda like FaaS, but it’s more than the regular FaaS, which is just a function (?) where you can give in different args.

It would be great with the possibility to, for example, read parameters directly from the URL, and get it as the right type. If you add the route "/users/{userId:Int}", the framework creates a variable of type Int and assigns the value from the path. The route would only match if the parameter is an integer, parsable to Int.

Another feature that I forgot mentioning: Testing can be done much easier this way. You simply click on “Add test” beside the endpoint, and then write a test that automatically calls that specific endpoint. No need for a lot of ceremony with booting up a web client and calling the endpoint from that. It’s also easier than having to jump forth and back between the test file and the implementation file.

Links to paths would also be much easier: There could be an auto-generated Paths object where paths to each endpoint can be found: Paths.users(userId).edit goes to /users/{userId:Int}/edit etc.

Please let me know if anyone knows any framework like this :smiley: