this post was submitted on 24 Feb 2024
25 points (96.3% liked)

Programming

17540 readers
71 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

Hello everyone, first post over here, I'm a junior dev that was working on an open source picture organizer based on location groups within sub-directories, like streets and cities (inferred from EXIF geotags being extracted and sent to a reverse geocoding API) which I've first coined as GeoPicSorter (outlined in its home page). There's a TL;DR at the bottom if you want to get right into my questions, but I felt like talking about my tool could be of help and worth it in case anyone ever wants to help with its development, anyway...

To develop it, I used Java and NetBeans (as the only IDE I found with a free GUI editor at the time I started ― at least over a year ago) and GeoPicSorter accomplishes the goal I needed it for, however, as I updated it, I started to feel like I've underestimated how hard to maintain and messy code becomes for the GUI part. NetBeans had its own gimmicks like making it read-only, fully naming the Swing classes every single time they were called, etc. The Swing GUI also feels kind of uncomfortable to me (specially in the folder selection part where I choose a folder with the pictures to organize, it's too compact/constrained) and I'd like for my program to use the system GUI, or at least something that makes it feel classic yet user-friendly. But it's not like Java is the worst option to use, I just feel like there could be better options suited for the project, and I want to learn a new language in the process.

I've attempted to re-write my tool (and rebrand it in hopes the name can be shortened without conflict with "GPS"), to write cleaner code while attempting to retain cross-platform compatibility (which ideally, I'd like my tool to have so more people can try it. I'd like it to work at least for Windows, and hopefully Linux without Wine, maybe Mac too). It's not a necessity though, just would be great to reach more users. The re-write would be available at a Codeberg repo.

For the re-write: I've tried Dart, Python, and C++ so far, however, I struggle with different things in each language that make it impossible for me to figure out on my own with my experience, and I feel like I'm wasting time going in circles. The problems I have are:

  • Dart: I haven't touched it in a long time, but I believe my issue was the lack of documentation and functions/methods for the only EXIF reader I could find, and how it extracts the coordinates (into an array-like set of 3 numbers that represents latitude/longitude in DMS format) without functions to handle them and convert them to DD easily.
  • Python: while it was a satisfying language to learn and experiment with (and had everything I needed), I couldn't figure out how to make an executable that could detect (and depend) on the system installation of Python (instead of bundling one), I've exhausted every EXE-generating option I could find, and none worked the way I needed it to. If there's one you think I possibly didn't try, I'd love to know!
  • C++: I'm having trouble to start a project properly. I'm pretty much a newbie with CMake (which seems I need to use if I want to make a cross-platform C++ project), and my greatest struggle was setting up the dependencies so as to not to give a hard time to new contributors to join or make one-time contributions (and when I move to another setup). I've tried Conan, and its repository has everything I needed (including Qt for the GUI), but for some reason it's been a struggle to get the dependencies (and the project itself) set up around it. I'm using Visual Studio for now since I found it best to get into C++ and it was recommended, but I'm open to other options. Qt always failed to install via Conan on the command line (IIRC, the error was just a generic one and occurred after waiting for the download and install).

So, I've been using FLTK, but the GUI options and components feel very limited, and I'm stuck with VS2017 and Conan 1.x, because the add-on for VS is outdated, and I couldn't integrate 2.x into VS.

After all this context (which I'm sorry it dragged for so long already), I can finally ask: what can I do to properly start my project from scratch? Or is there a language/framework that'll best suit my needs? The dependencies it has are already mentioned on the home page, but the EXIF reader should be able to at least make it possible to get the coordinates in DD format, and consider the reference cardinals for latitude and longitude before the conversion from DMS format.

Should note that I'm determined to see my project through, I'm just lost on what to do and in need of advice.

Any help is appreciated, thanks in advance!

TL;DR: I'd like directions on how to set up a software project with dependencies, so that future contributors can pitch in with the least amount of set-up required when they clone the repo. The original program is an open source location-based picture organizer for desktop systems, and I want to rewrite it with a different set of tools (preferably not Java with NetBeans), its code will be hosted at Codeberg.

top 24 comments
sorted by: hot top controversial new old
[–] Azzu@lemm.ee 15 points 9 months ago

Usually, unless there's a specific reason to rewrite a project in another language (like performance, maintainability requirements, skillsets of available developers, dead ecosystem, etc) I wouldn't do it. Java is perfectly suited for your goal of "least amount of setup required for future contributors" and many contributors will know Java well.

In general, it is much much easier to make existing code readable than to create new code already readable while maintaining the same feature set. So if you have a problem with FLTK, I would just switch to another GUI library. In the process of changing your code, you'll actually start to understand how to separate layers of concern. Because theoretically, if your code were set up properly, it should be relatively easy to replace GUI libraries. It is likely not set up properly with lots of interdependency between UI concerns and application logic.

Netbeans is also a pretty terrible IDE imo. With an open source project, you can apply for the open source license of intelliJ, which is the gold standard.

That being said. If you really don't want to use Java anymore just to learn something new, I would suggest a JVM language that can even use Java dependencies, like Kotlin or Clojure. Especially Clojure will teach you a lot of new things that will make you more productive as a programmer. However, every language will come with tooling-related quirks, it will be impossible for you to find a language that doesn't have any problems at all like you describe. Why do you think there are so many languages in the first place? Because people didn't like something about the other ones, often also tooling related.

[–] Traister101 7 points 9 months ago (1 children)

NetBeans??? In 2024??? Intellij has a free community version which I'd recommend over literally anything else for JVM langs.

If you really do wanna swap languages (tbh I'd recommend you just stick with Java) of those choices C++ is probably the best one? Python definitely isn't a good choice for what you want. I haven't used dart but I'm pretty familiar with Java, Python and C++. C++ build systems are frankly very pooie. Cmake is hard to get into because it's purpose is to generate make files which are essentially files which store a bunch of commands to run in the terminal. You can have Cmake generate stuff for ninja (recommend) but it's still just kind of a mess. Since you want to support cross platform C++ might be a huge pain.

You could use a different JVM lang like Kotlin. If you want a compiled language you could maybe do Zig? I'm not very familiar with it outside of knowing the tool chain is much better than C++ or C. I'll toss in the obligatory Rust mention but you'll need to dedicate quite a lot of time and effort before you'll be proficient. The tool chain however is fantastic.

Kinda long rambly response hopefully it'll be helpful somehow

[–] afa1997@programming.dev 3 points 9 months ago (2 children)

Thanks, it was definitely helpful.

I wanted to use IntelliJ IDEA as well but as I said, NetBeans was my only choice with a free GUI editor at the time, I was kind of constrained by time and was still new to coding a program with GUI.

C++ could work and I'm still open to use it, but if I end up going back to Java, I'll definitely use IntelliJ IDEA and see what I can do about the GUI. I also considered Rust but wasn't entirely sure about it, sounds promising though.

[–] Traister101 3 points 9 months ago (1 children)

Okay so what do you actually mean by "GUI" I assumed you mean a Graphical editor IE Eclipse, Intellij, Visual Studio ect. A non GUI editor would be a terminal editor along the lines of Vim with an LSP and other such things. All out of the box IDEs are graphical in nature, that's kind of their entire point so I can't believe we're talking about the same thing here.

[–] dis_honestfamiliar@lemmy.world 4 points 9 months ago (1 children)

I'm pretty sure by GUI they mean a WYSIWYG type thing where you drag and drop things into a GUI (meaning user interface) and then you have code. So again WYSIWYG.

Since they mentioned Swing and also there's a link to the GUI code.

I like GUI code. Meaning I like that they exist. But, also yes, they can get messy.

[–] Traister101 4 points 9 months ago (1 children)

Oooh like a GUI designer thing. That seems pretty nifty never used one before haha

[–] afa1997@programming.dev 0 points 9 months ago

Oh yeah, sorry if it wasn't clear! I meant a WYSIWYG GUI editor (to create the different windows and thing a program has).

For Swing, I only had luck with NetBeans, last I tried IDEA's, it had less features to work with (and maybe controls), but I can't specifically recall and there's a chance that changed (?). There was one for Eclipse too, but same problem. There's also a paid editor for IDEA, but I can't afford it.

Anyway, after experimenting with Tk on Python, and not having time constraints now, I'm willing to find a library with which I can write the GUI code.

[–] coloredgrayscale@programming.dev 2 points 9 months ago

You couldn't find a gui designer for intellij, so you consider rewriting the whole application? in C++?!

Would seem easier to learn that ui framework.

For UI maybe look into javafx as an alternative. I haven't used it, so can't tell how the design process goes. But it seems to be the only current ui framework for Java.

[–] Black616Angel@feddit.de 6 points 9 months ago (1 children)

First off, cause you are programming under windows, a lot of things will be harder for you. As seen on your problems with Python.
Most Linux installs have it right from the get-go and everything else is as simple. So giving directions for developers on other platforms might be much easier than what you had to go through. (Maybe use WSL?)

Let's get to your real question: How does one organize dependencies in a way easy for new contributors?
Since you will use Python, I will use that as example.

Most languages have a way to automagically import dependencies. Python has the requirements.txt file. Installing dependencies is then really easy. It is also a widely known way to do that, has lots of explanation online etc. so seasoned pythoneers will know what to do and younglings will get to know a good standard right away.

Bonus tip: If you don't have a GUI library yet, maybe also search for game engines. They provide all the necessary tools as well, oftentimes have good GUI add-ins and are (mostly) for all mayor platforms.

[–] afa1997@programming.dev 3 points 9 months ago* (last edited 9 months ago)

Thanks. I understand, with your example and using WSL, I might have some luck with Python (I'll have it into consideration), I still have the code for that re-write attempt and it was going pretty well. Hopefully I'll figure out the packaging part if I go with Python because I want to version my program.

For the GUI, I had the built-in Tk libraries, but I appreciate the tip neverthless (will be useful if I end up going with another language). Reminds me I was considering to use ImGui for C++, but ended up using FLTK.

[–] jeffhykin@lemm.ee 5 points 9 months ago* (last edited 7 months ago) (1 children)

Also

I've exhausted every EXE-generating option I could find [for python]

Unfortunately software is one giant mess right now. You'd think things like compiling to an EXE for python would be standard. They're not. One day, maybe 15 years from now, we will have Nix be user friendly, a single line installer for everything, and have it all "just work". But until then, almost everything is hacked together.

Overview of (basically) all GUI systems

I believe Flutter, React Native, and Android studio are the only major ones I don't have experience with.

EDIT! (2024-4-30) .NET Avalonia seems like a great modern option that I have not gotten to try. Its C# and fully cross platform. It could be a real game changer compared to the options I've listed below

  • Yes as far as I know theres no good exe maker for python. Python without dependencies (or async) is great, a nice little scripting lang for prototyping or data analysis. Python with dependencies is terrible, truly awful for packaged user-applications.
  • C++ / C are and effectively will always be miserable IMO. You'll basically never be able to automate it without nix. Make, cmake, autoconf, pkg-tools, ant, etc they're all a mess. For example, biggest blocker to python packaging is that many python packages are wrappers around C/C++ packages. The most annoying thing about one of the tools I'm about to mention (electron) are the dependencies that secretely use C++.
  • The most modern, consistent, and cross platform graphical systems right now are Electron and Tauri, which are literally browsers with URL bar/buttons removed. Electron is what Discord, Spotify, and VS Code use. Its bulky but theres a lot of support/tutorials. Tauri is the new, faster/cleaner kid on the block and uses the Rust language, which has good dependency management. But Tauri doesn't have the tutorials or ecosystem yet. Also Rust is a very hard language. For both you'll need to learn Javascript/HTML/CSS, which is probably good. But you'll also need the terrible npm ecosystem, and get introduced to javascript frameworks which seem great until theyre not. That said, basically every cross platform not-browser GUI I know of (JavaFX, QT, TCL/TK, WxWidgets, FLTK) has exactly the miserable experience you're getting; lots of dependency hedaches, and weird graphical differences between operating systems. Also that list is in order, with FLTK being untouchable garbage, and JavaFX being the least-bad in my experience.
  • Even if you're okay with using a broswer, (which solves lots of dependency/setup problems, and is the most useful/flexible UI system I've used) it still has stupid API problems because HTML was originally made to display documents (like microsoft word documents). It wasn't meant to be a full blown UI system; it just became that over time. Stuff like styles and positioning in HTML has edgecases, like "fixed" meaning absolute and "absolute" actually meanting "relative to parent" and "relative" meaning "relative to where the element would normally be".
  • Unity game dev (uses C#, which is similar to Java, but better IMO) might actually be worth looking into for your case. First check the unity API's for your images and GPS tasks. The good news is they support packaging up applications for every OS. The bad news is you can't automate the setup because its proprietary. The (very good) open source alternative is Godot.
  • The final alternative is, just don't go cross platform. This is the only not-mess, not hacky, intentionally-designed toolset approach I know of. MacOS has Swift and XCode, Microsoft has Visual Studio and C#. Neither are great but they're both the "this is how we expect you to do it" approches. You might be able to adapt these to other platforms (swift has been gaining some cross platform support and the .net runtime for C# can be cross platform).

My perfect setup would be Tauri (with all security disabled), with Deno accessible on the front end, all installed/setup by Nix. But alas, that doesnt exist yet. Even with +3 years of nix experience I can't even get Tauri running in Nix.

[–] demesisx@infosec.pub 5 points 8 months ago (1 children)

I’ve been looking into building and developing a Lemmy fork using Nix but I got stuck on nixifying the part of the build instructions where you have to combine front end and back end in git submodules. It’s a bummer too because I won’t even write a single line of code on this fork until I have it properly setup with flakes. It’s just how I am. 🤣

Maybe my flake can help you get Tauri working and maybe that would motivate you to help me get Lemmy working with Nix tooling instead of Ansible and Docker as it is now? ;)

[–] jeffhykin@lemm.ee 2 points 8 months ago* (last edited 8 months ago)

Same haha.

I've already started it twice for lemmy, but didn't put in heavy effort yet. I've got a wrapper for nix that helps with common issues, but its on the messy side.

There are so many small GUI apps I want to make but I refuse until I can get Tauri to build an appimage and macos app within nix. It was more than a year ago since I put a lot of effort on that though. If you've got any tips/pointers or examples for tauri I'd be happy to hear them.

[–] solrize@lemmy.world 5 points 9 months ago* (last edited 9 months ago) (1 children)

Your question is about code packaging and tooling and that's a messy topic in for any environment. It's not my area but tbh these days, there's a tendency to just throw up your hands and wrap the entire app and tooling as a Docker container.

Can I ask what platform(s) you are targeting? Linux? Windows? Mac? Mobile?

I saw a very wise remark a while back, that a lot of making code stability amounts to minimizing the depth of the dependency tree. Unfortunately, ecosystem maintaners have not yet taken this to heart.

GUI code is inherently messy but after you've done a few of them, some patterns do emerge. I think it's an especially bad situation with Java but I don't use that.

[–] afa1997@programming.dev 2 points 9 months ago

Thanks for your input, I think that's where my issue is, since a few external libraries/APIs are required and I can't settle with a solution, I didn't have such issues with Java, as it was easy to configure dependencies and how to build the JAR with Maven.

Ideally I'm looking for it to be available for Windows, Mac and Linux. Windows is the minimum due to how widely it's used and my program would work on Wine for Linux users.

That's some good advice to keep in mind. My project isn't planned to have many dependencies for now, at least, so I don't believe the dependency tree will be too complex/large.

If you like, you can take a look at this example of my code, not only NetBeans generated the GUI code in a messy way, it's made read-only, and if edited externally, things break on the project in the IDE.

[–] dis_honestfamiliar@lemmy.world 5 points 9 months ago

Umm... Keep in mind that I lack experience. Take the following with grain is salt.

I understand your pain with Swing. Not sure how to help other than change to another GUI framework. I think maybe eclipse does thins thing where it allowed me to make code GUI changes. Maybe?

Change GUI framework?

Consider doing a web base where the server does the folder structure?

I know nothing about Dart.

Finally, super personal opinion, but go with C++ and wxWidgets. I love this library.

[–] sgh@lemmy.ml 4 points 9 months ago

Have you tried Qt but with QMake instead of CMake?

Use Qt Creator instead of Visual Studio.

It is much much easier to manage the project with QMake in my personal opinion, and Qt Creator blends beautifully with the Qt Framework with the kit manager, and the form designer, qmake/cmake integration...

Qt (Framework) manages so much behind the scenes that cross platform is trivial.

[–] iawia@feddit.nl 4 points 9 months ago

There's a few different things, I think, that are wrapped up in this.

  • Generated UI code is unmaintainable
  • Finding (and using) a good cross-platform UI library is hard
  • Setting up a new project and packaging for it is hard

To start with the first, yes, generated code can be useful to quickly get something started. After that, in general you'll need to adapt it and grow it be coding from there on. Round-trip (going back to the design tool from code) tends to not work that well.

There's good UI libraries, but cross platform tends to be difficult. Oddly enough, a lot more work has been done to create good cross-platform UI on mobile than for desktop. Interestingly enough, flutter seems to also be bridging that towards desktop. Another ecosystem, another language (dart), but much clearer about how you should build, and plenty of documentation on easily building, from code, user interfaces.

Taking a small step back, I'd like to say that one thing you might want to start with is to look at your current code and try to restructure it in such a way that you separate the core of the functionality from the user interface. This can be a tricky process, and reading up on refactoring techniques is going to be useful. It might also really help in this process of potentially moving to a different language, because it will be so much clearer what you are moving, and what is incidental and just related to the framework you are working in.

[–] jeffhykin@lemm.ee 3 points 9 months ago* (last edited 9 months ago)

I'd like directions on how to set up a software project with dependencies, so that future contributors can pitch in with the least amount of set-up required when they clone the repo

Unforunately that kind of task, with our current tools, is not a junior level task. I have worked on automating project setups for almost a decade; creating a single command that is cross platform install of all dependencies, project ENV setup, and in a way that doesn't break the users existing system(s), or causes the project to bitrot. The only real way at the moment is through Nix (nixpkgs), which is unfortunate because Nix is very difficult to setup and use. If you start a small project in nix its not too bad, but adapting an existing project often is, especially anything with graphical tooling.

I made Deno gulliotine to help with first step of cross-platform setup, but once the setup begins to install packages/languages it all needs to be done with nix to be reliable.

Also FLTK is miserable. I'm not a huge fan of QT, but it is at least definitively better than FLTK. Wx Python is also miserable, avoid it like the plague.

[–] Miaou@jlai.lu 3 points 9 months ago

I didn't bother reading the other answers, but few things I can say:

  • netbeans is crap, intellij is much better
  • if you go with python, please do bundle the runtime and do not use the system one. No one will if your software is 5mb bigger, but they will care if they need to manually create the python environment (if they have both the patience and knowledge to do so, the intersection of which is rather small I reckon)
  • if you go with Qt, use QtCreator, the integration is great. Please do not use visual studio (especially if you're going to use qt). It's slow, expensive, unstable, dumb, slow, both too complex yet missing trivial features, and slow.
[–] qaz@lemmy.world 2 points 9 months ago

That seems like an interesting project. I’ll probably take a look at the repository later.

[–] Kissaki@programming.dev 2 points 9 months ago

I'm familiar and usually working with .NET, and am a strong advocate for it.

  • The language is similar to Java, so not that difficult of a switch language-wise. Visual Studio makes good suggestions introducing you to newer and more concise syntax too. If you install the VS SonarLint extension it'll guide you to good practices.
  • Excluding the GUI for now; you can target cross-platform.
  • GUI is somewhat of a mess like anywhere else, but you have decent options and you certainly have more viable alternatives compared to other languages. If your target is cross platform, check out MAUI for the recommended/officially suggested approach. I find the XML GUI coding irritating and inconvenient, but it is well-established and popular. Although I haven't implemented a noteworthy project with it, I prefer coding UI in web tech, so I like that you can embed a WebView2 and connect and bind between the C# code and the HTML rendering. Using WebView2 for program GUI requires a container app window. Targeting Web/Browser-rendering directly is viable too with Blazor and more broadly ASP.NET with multiple alternatives and openness to web frontend UI frameworks and libs.
  • With one project structure the project can be worked with with dotnet CLI (leaving users open to use their own IDE or text editor choice), Visual Studio, or Visual Studio Code. NuGet packages as dependencies are automatically handled within the default build toolchain.
  • .NET is well-established and popular.
  • Official documentation is great. It is exhaustive, with guidance, references, examples, and tutorials. It is open to feedback and change requests/suggestions.

As for what you tried, how I would personally react to a project:

I don't like python. For anything that is not a script, I would likely skip considering contributing. It is an overall popular language though. Prevalent as a language, and at least reasonably popular / niche-popular for apps with UI.

C++ is a mess to set up and manage. Qt is huge. It's popular and powerful. But in the aspect of low-barrier, it is the opposite.

[–] jeffhykin@lemm.ee 1 points 7 months ago

Just commenting here to ping you that I found a new major alternative! I've edited the comment but TLDR; search ".NET Avalonia" and see what you think

[–] afa1997@programming.dev 1 points 9 months ago

Thanks a lot for the suggestions!

I'll be trying at least some of the options that were brought up and see what works for my project, I'm still open to feedback, but I'll report back and mark the thread as solved once I find a solution.