News for hackers. Stuff that matters.
Re:The Era of Visual Studio Code by dheera on Tuesday September 22, 2020 @08:24PM (#24561582)
The way people use Java is a problem.

Spin a blank "hello world" project in Android Studio and you get no less than 79 files, and it won't work the next time you update Android Studio because of some Gradle errors.

I don't know what went wrong, but "hello world" should not be 79 files, it should be something that I can hand-code in something less than an IDE.

Re:The Era of Visual Studio Code by dragonwriter on Tuesday September 22, 2020 @11:16PM (#24562570)
> Spin a blank "hello world" project in Android Studio

That’s Android Studio’s default workflow designed around the expectation that it's going to be used for building Android apps in a particular style, and to optimize for what is usually appropriate for that, which is very much not “Hello, world!” optimized.

As much as Java is a needlessly verbose language, the problem you are looking at is an particular IDE / build system / project type combination issue, not a Java issue.

Re:The Era of Visual Studio Code by sethammons on Tuesday September 22, 2020 @08:30PM (#24561618)
Heh. Some years ago, I thought I’d step away from highly available distributed systems and build an android app. Got to the point in the tutorial where we needed to define a string for “hello, world” and the tutorial said, “ok, navigate to such and such directory and add this xml file and ...”. Closed the tutorial assuming Java is not for me.
Re:The Era of Visual Studio Code by iamcreasy on Tuesday September 22, 2020 @09:18PM (#24561945)
The tutorial also said that you are placing this string in an xml file for easy localization in the future. I am not defending their setup, but it sends a wrong message when you skip parts of the sentence.
Re:The Era of Visual Studio Code by DreadY2K on Tuesday September 22, 2020 @10:14PM (#24562246)
But is it ideal for a "Hello, world" program to follow all best-practices? In my opinion, a "Hello, world" program should do the bare minimum to print "Hello, world" to the screen, and no more, so that it represents the language at its most basic.
Re:The Era of Visual Studio Code by dheera on Tuesday September 22, 2020 @10:37PM (#24562384)
Yeah I mean it should be as basic as

    class MyApp extends AndroidApp {
        void main() {
            Document.write("hello world");
            Document.write("<button id=\"foo\">blah</button>");
        }
    }
javac it, adb sideload the .class file (or .jar file), and you should be done for the day. Unfortunately the bare minimum is way way way more complicated than this. Weird XML files, infestations of manifests (generate them automatically from 'ls' and 'grep' damnit), Gradle files (worst abomination of a build system ever), API levels (how about you just infer it from the functions I use? I shouldn't need to tell you), signing (ok fine but this should only be needed when uploading to an app store), zipaligning (wtf, this should be automatic, don't make me do that nonsense).
Re:The Era of Visual Studio Code by Almad on Wednesday September 23, 2020 @07:10AM (#24565518)
> Gradle files (worst abomination of a build system ever)

Ant? Maven?

Re:The Era of Visual Studio Code by dheera on Wednesday September 23, 2020 @02:41PM (#24570415)
Ugh. Why can't we just make javac [STAR].java work? Tarball the resulting .class files, make sure to have one called Main.class that is the entrypoint, GPG sign the tarball and you should be ready to distribute.

Yeah I know it doesn't work like this now, but the designers of the entire Java/Android ecosystem should have designed it to be that simple.

The moment you get any of these build systems involved you instantly lose all hopes of DRY coding. Excerpts from an Ant build.xml file:

    <target name="jar" depends="compile">
        <mkdir dir="jar" />
        <jar destfile="jar/HelloWorld.jar" basedir="classes">
            <manifest>
                <attribute name="Main-Class" 
                  value="antExample.HelloWorld" />
            </manifest>
        </jar>
    </target>
 
    <target name="run" depends="jar">
        <java jar="jar/HelloWorld.jar" fork="true" />
    </target>
I see "HelloWorld" repeated 3 times. MASSIVE fail. I'd rather no build system than deal with this level of repetitiveness. It's bad enough that Java requires the file name == class name which is already a case of repetition (that design decision is fine with me but then files should start with "class {" and not "class Foo {")
Re:The Era of Visual Studio Code by lmm on Wednesday September 23, 2020 @11:00PM (#24574829)
Maven is wonderful. It's all the best parts of npm or cargo, years before them. Just don't try to fight it - accept that there is a maven way of doing things that you will have to follow. If you need something to build before something else, put it in a separate module. If you absolutely need a custom build step, write a proper maven plugin for it. But 99% of the time your build definition can and should be just a list of dependencies and a couple of basic settings values.
Re:The Era of Visual Studio Code by winrid on Wednesday September 23, 2020 @12:33AM (#24563003)
That's because they want you to get used to properly localizing your app. Work in any localized system and you'll define the text in JSON or XML files.
Re:The Era of Visual Studio Code by sk5t on Tuesday September 22, 2020 @09:49PM (#24562114)
This sad outcome is 100% not Java's fault.
Re:The Era of Visual Studio Code by tomc1985 on Tuesday September 22, 2020 @10:57PM (#24562480)
Yeah but "Hello World" in actual java is a main class and a quick write to stdout, like most any other normal (programming, not scripting) language
Re:The Era of Visual Studio Code by dragonwriter on Tuesday September 22, 2020 @11:14PM (#24562557)
> Yeah but "Hello World" in actual java is a main class and a quick write to stdout, like most any other normal (programming, not scripting) language.

Scripting languages are programming languages, and a class with a method is only typical of a narrow class of languages (most of which that aren't Java are specifically designed to closely follow Java); leaving aside those programming languages typically called “scripting” languages, in C++ it is just a function, just like C; D is pretty similar (as are most procedural languages, including those like C++ that also support class-based OOP without being obsessive about it, and also most impure functional languages.)

In Haskell it's just: main = putStrLn "Hello, World!"

Re:The Era of Visual Studio Code by tomc1985 on Tuesday September 22, 2020 @11:31PM (#24562645)
My point was that Java's hello world is comparable to most other language, and that hello world in Android is a poor example
Re:The Era of Visual Studio Code by dheera on Wednesday September 23, 2020 @06:59PM (#24573244)
Well here's GTK hello world in freaking C. One file that you can gcc and run "./a.out". Not 79 files with a build system that breaks every time you hit "upgrade", and which requires me to install gigabytes worth of SDK API bloat and agree to 10 different license agreements. Want a free build system that works for this for every version of Linux in the past decade and probably the coming decade? All you need is ONE "Makefile" and you're done.

https://developer.gnome.org/gtk3/stable/gtk-getting-started....

Any higher level language and ecosystem than C should be less verbose and less involved than this. Otherwise, what's the point of being higher level?

Re:The Era of Visual Studio Code by brabel on Wednesday September 23, 2020 @02:03AM (#24563504)
The language is not the problem: A Kotlin Android project will have the same number of files.

This is a problem with the Android platform itself.