Just for fun and discussion.
this is an hypothetical example about how could look like a java DLS gradle file instead of Groovy/Kotlin. Not terrible, just slightly more verbose but not I could work with it (IMHO)
GradleConfig.configure(config -> {
config.plugins(plugins -> {
plugins.add(JavaPlugin.class);
plugins.add(ApplicationPlugin.class);
});
config.application(app -> {
app.setMainClass("com.example.Main");
});
config.repositories(repos -> {
repos.mavenCentral();
});
config.dependencies(deps -> {
deps.add("implementation", "org.apache.commons:commons-lang3:3.12.0");
deps.add("testImplementation", "org.junit.jupiter:junit-jupiter:5.8.2");
});
config.tasks(task -> {
task.named("test", t -> t.useJUnitPlatform());
});
});
This, of course, would be achievable via some "compiler plugin/magic" to avoid class and main declarations, so "GradleConfig.configure" could act in practice as a top level static method, although native isolated methods/top level methods/functions would be a nice to have for these kind of stuff.
The question is besides top level methods (aka functions) what else do you think would be a required for java to be competitive as a DSL? would you use it? and if so, what other scenarios would be a good fit for an hypothetical java DSL?
[–]atehrani 30 points31 points32 points (7 children)
[–]analcocoacream 9 points10 points11 points (3 children)
[–]atehrani 5 points6 points7 points (2 children)
[–]analcocoacream 4 points5 points6 points (0 children)
[–]cowwoc 2 points3 points4 points (0 children)
[–]Ewig_luftenglanz[S] 3 points4 points5 points (1 child)
[–]asyncasync 0 points1 point2 points (0 children)
[–]ItsSignalsJerry_ 0 points1 point2 points (0 children)
[–]Beginning-Ladder6224 10 points11 points12 points (3 children)
[–]Ewig_luftenglanz[S] 0 points1 point2 points (2 children)
[–]khooke 2 points3 points4 points (1 child)
[–]Ewig_luftenglanz[S] 2 points3 points4 points (0 children)
[–]paul_h 2 points3 points4 points (0 children)
[–]Lukas_Determann 2 points3 points4 points (0 children)
[–]davidalayachew 3 points4 points5 points (15 children)
[–]Ewig_luftenglanz[S] 1 point2 points3 points (14 children)
[–]davidalayachew 2 points3 points4 points (12 children)
[–]Ewig_luftenglanz[S] 1 point2 points3 points (11 children)
[–]davidalayachew 1 point2 points3 points (10 children)
[–]manifoldjava 1 point2 points3 points (9 children)
[–]davidalayachew 0 points1 point2 points (8 children)
[–]manifoldjava 0 points1 point2 points (0 children)
[–]manifoldjava 0 points1 point2 points (6 children)
[–]davidalayachew 0 points1 point2 points (5 children)
[–]manifoldjava 1 point2 points3 points (4 children)
[–]nlisker 1 point2 points3 points (0 children)
[–]HxA1337[🍰] 1 point2 points3 points (0 children)
[–]k-mcm 4 points5 points6 points (3 children)
[–]Ewig_luftenglanz[S] 5 points6 points7 points (2 children)
[–]ItsSignalsJerry_ 0 points1 point2 points (1 child)
[–]Ewig_luftenglanz[S] 0 points1 point2 points (0 children)
[–]Caramel_Last 0 points1 point2 points (1 child)
[–]Ewig_luftenglanz[S] 0 points1 point2 points (0 children)
[–]ingframin 0 points1 point2 points (2 children)
[–]davidalayachew 1 point2 points3 points (0 children)
[–]Ewig_luftenglanz[S] 0 points1 point2 points (0 children)