[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/tech/ - Technology

Catalog

Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Flag
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 3 per post.


File: 1458578676111.jpg (76.35 KB, 1920x1200, 8:5, java.jpg)

 No.547826

Is Java is a good platform to use to write Linux applications? I am a new comer to Linux and am wondering what the more popular GUI Toolkits are. I see GTK and QT but GTK seems to not be very popular and QT is C++. What would you recommend /tech? Java is my choice right now.

 No.547851

Java has an integrated GUI toolkit, I don't know why you would want to use anything else.

Unless you're retarded, it's extremely easy to write portable programs in Java.

GTK+ and Qt only add more baggage that needs to be taken into consideration when "porting" to other operating systems.

If you're worried about the theme (some people find the default "Metal" look ugly), the GUI can be automatically themed to GTK+ or even Windows look.


 No.547856

Java is a go-to choice for enterprise GUI apps but it's somewhat unpopular on consumer desktop for being a resource hog and depending on JVM.

Qt is the primary toolkit, apart from C++ it has ruby, python and perl bindings, probably more.

Everything else is quite marginal, except maybe GTK+ which used to compete with Qt, but now it is pretty much irrelevant and used only in old complex projects that can't afford transition to Qt.


 No.547865

No.


 No.547867

>>547826

Do you already know Java? It's annoying as a language, you have to repeat what you are trying to say a bunch of times. As >>547851 mentions, you should use the integrated GUI toolkit if you use Java, because kind of the whole point of Java is "write once, run anywhere". C and C++ are obviously extremely powerful, but are confusing as fuck for anything even a little bit complicated.

I'll probably get a lot of hatred (easy = bad, duh), but python is pretty amazing, so I'd at least try it if you haven't already. It's really cool to be able to download html from a webserver, create your own server, connect to irc, etc, etc, all with basically an import *module name* and a few lines of code, vs many hours faffing around with things in other languages.

I'm not a professional programmer (no shit, right?) but this is great for hacking stuff together, it's not bogged down by little details stopping the whole show, and it lets you have fun making stuff, and there's something really satisfying about that.

There's a built in GUI binding to tkl/tk, which I haven't used personally (I tend to make programmes like web scrapers/parsers and irc bots, that kind of crap), but I imagine this works well too.

The community around the language is probably mostly social justice faries and land beasts but who even gives a fuck if you're just making some shit for fun? Everything is "botnet" anyway to the point the word no longer means anything so fire away..


 No.547901

>>547867

Python and Django are great but Java seems like a better fit for a desktop application.


 No.548057

>>547867

Python is a poor choice of language for GUI programming.

PyQt is probably the best balance of easy to program for and fully featured, but on some distros (CentOS 6) PyQt applications will just crash with no warning.

PyGTK is deprecated and replaced with the seemingly infinitely more complex pyGObjectIntrospection or whatever the fuck it's called, and it doesn't seem nearly as easy to use as PyQt either way. The python 3 version (you ARE using python 3, right?) removes the deprecated pygtk namespace which is the final nail in its coffin IMO. It looks like they made little to no effort to make gtk more usable to python developers than to C developers, and you only get gtk3.

tkinter is under-featured and horrendously ugly, and keyboard input is very very second-class. The only thing it has going for it is that it comes with Python, except if you didn't install tk on your distro in which case it doesn't. It has infuriating quirks, like the inability to create dialog boxes without having a root window, and the unbelievably loosely typed (and often poorly documented) use of keyword arguments leading to very hard-to-solve bugs in the program.

I would recommend PyQt unless you want to target the kind of windows user who doesn't want to have to run your installer followed by a python installer followed by a PyQt installer (and windows users wonder why we like package managers)!

Otherwise, I would recommend C++ with Qt if you have the effort to put into it, but be very wary that Java programmers tend to write horrible C++ code, so you can't just coast along on your existing knowledge from other languages.

Wildcard options:

- learn vala and write vala with GTK. It's a very specific language, but it seems a good way to stay sane while writing for GTK. I don't think it will get you employed though.

- Java is okay for cross-platform GUI. Not the best, because it's clunky and takes a year to start up, but it's okay. If you are going to deal with the Java virtual machine, make sure to write in a worthwhile language like Scala.


 No.548063

>>548057

Yes I'm using 3 now learned 2 first and used a tool called 2to3 in the transition stages in learning.

I did do some C++ with gtkmm that was fun (probably the most GUI stuff I've done that's not HTML+friends tbh), and I've used qt creator which wasn't terrible.

It's just a shame that python isn't (by the sound of it) equipped for gui stuff like it's equipped for cli.

Thanks for the educated reply, it's nice to know this place isn't all hurr durr botnet tier.


 No.548071

>>548057

>>547867

you guys may want to checkout kivy. it is a python framework intended to build multiplatform multi-touch applications (ios, android, linux, mac, windows). But you can make decent desktop apps with it too. It's very mature and well documented. touch optimized though


 No.548075

You'll never achieve Satori by writing GUIs.


 No.548383

Java is great for CLI and simple 2D games, but it's bullshit for GUI stuff.

Basically, if you want a polished interface, you won't use the Java GUI libraries because they look different to everything else on the system, the font rendering is awful and menus may be slow depending on the implementation (I remember JavaBeans' drop down menus taking several seconds to open).

I personally recommend Qt. It will look and perform better.


 No.548404

>>548383

While I also prefer Qt, at lot of what you said about swing just isn't true.

It is easy to have your swing GUI adopt the native look and feel of the platform, or you can go the intellij route and roll your own style. Users may also customize the appearance if they wish.

Honestly the main reason swing is shit is that it's tied to Java.


 No.548520

>>547851

>If you're worried about the theme (some people find the default "Metal" look ugly), the GUI can be automatically themed to GTK+ or even Windows look.

Can it detect the current theme in use on an OS and use that to theme the Window?


 No.548522

is java best language to sell stuff to normies ?


 No.548531


 No.548536

Is Java that bad of a language? C-style syntax, classes, GC, has a library for everything, very fast but still below C/C++. What is wrong with Java for application development?


 No.548541

Java is a programming language that you should know, but definitely should avoid working with.

Java comes with runtime APIs which are so inintuitive and buggy that it pretty much nullifies the benefits of the static type system. You always have to write extensive unit tests for about everything. Null pointer exceptions are at every corner.

The fact that Apache offers API for a lot of basic stuff already covered in the standard runtime should give you a good idea of its mediocre quality.

Also it's a terribly inexpressive language that forces you to compensate with stereotypically awful "enterprise-quality" design patterns. Java gives OOP as a whole a bad name.

Also it has no such things as macros, an important form of metaprogramming.


 No.548547

>>548520

There's no "detection"; it's all done automatically.

If you select, for example, the GTK+ look, Java will automatically theme the interface according to the GTK+ theme that is currently set in the system.

That means that if you have Adwaita set, it will look like Adwaita. If you have Numix selected on your system, it will look like Numix.

Also, you can choose two versions of the default Metal look (the older one and the current one) and even the ancient Motif/CDE look.


 No.548548

>>548547

That's what I meant. Thanks! This clears up alot.


 No.548549

>>548536

>Is Java that bad of a language?

Not really, it's just more verbose than it should and fairly obtuse in some very specific parts, but let's not act like other /g/ /tech/ approved languages are free of flaws.

The biggest flaw it has is the standard library, which often gets reimplemented in every project, as >>548541 said.

That said, just as a language? It's not bad. As a language inside the JVM? It has its problems, namely bizarre bugs regarding constructors that manifest themselves only from time to time, and also some probably minor, depending on your standards and the type of program speed problems. As a language with a standard library? Mediocre, but I have seen worse.

However, if you don't plan on landing a Java job but you want to program for the JVM, save yourself the pain and learn Scala or any other JVM language. Scala is, more specifically, what Java should have been.


 No.548552

>>548383

> they look different to everything else on the system, the font rendering is awful and menus may be slow depending on the implementation

Don't worry, someone as big as Microsoft has already shown that it is acceptable with .Net GUI toolkit change.

> Java

> simple 2D games

> Java

> games

If by “simple” you mean “homework in programming class” level, then I agree.


 No.548562

>>548552

>obviously never played need for madness


 No.548592

>>548562

are you from java-gaming.org ?


 No.548593

>>548552

Play a bit with libGDX. You can make pretty much anything that doesn't intentionally try to rape the JVM with creation-destruction of objects or thousands of objects in the screen at once.

There was a blog post somewhere in badlogicgames' blog where they benchmarked libGDX against SFML at some point in time and libGDX was surprisingly faster than SFML just because they bothered optimizing their library better. Really, the JVM isn't that slow, and as surprising as it may be, even Minecraft could run well if they bothered optimizing the game fuck, it's not like Minetest doesn't have performance problems despite being built in the "fastest language known to man" and even bothered to make a more efficient map structure system. Octrees/3D grids and chunk pooling would have done wonders to the game's performance.

Hell, the JVM is strictly faster and more powerful than anything the GameMaker engine can shit out and you never see people questioning you can't make 2D games with it.


 No.548650

>>548536

Java is a very verbose and restrictive language. It make simple tasks span pages of code. I'm a fan of Scala which makes things a lot easier while still interoperating fully with all of Java's ecosystem.

Compare, btw:

// Java:
public class Person {
private final String name;
private boolean virgin;

public Person(String name, boolean virgin) {
this.name = name;
this.virgin = virgin;
}

public String getName() { return name; }
public boolean isVirgin() { return virgin; }
public void fuck() { virgin = false; }

public int hashCode() {
return 173 * name.hashCode() + (virgin ? 37 : 73);
}

public boolean equals(Object other) {
if (!other instanceof Person) return false;
Person pother = (Person) other;
return pother.isVirgin() == isVirgin() && pother.getName() == getName();
}

public String toString() {
return "Person(" + getName() + "," + isVirgin() + ")";
}
}

// Scala
case class Person(name: String, private[this] var _virgin: Boolean) {
def fuck() { _virgin = false; }
def virgin = _virgin
}

Possible typos aside (I haven't checked the Java one), these classes are pretty much the same.

Actually, Scala's "Person" gets some nice extras like the "copy" function but I'll gloss over that.

Scala is much more expressive and more fun to write in IMO. It also has a scripting REPL for you to try things out in (though you do experience the full force of Scala + Java's slow compilation times).

However you're still saddled with the JVM, and that means you can kiss startup times goodbye. For that reason I'd only run large desktop GUIs or server software under Java.

>>548593

Definitely agree with the Game Maker point here. As much as people shit on Java, Game Maker has even more extreme startup times. Java performs quite well too, which is bad news for Game Maker which runs far slower even than Python or Ruby.


 No.548652

>>547826

Java is shitty windows garbage and QT is a meme. 90% of GNU/Linux graphical applications use GTK and your typical distro/DE/WM has more GTK support than anything else. Just stop being autistic and use GTK.


 No.548701

File: 1458689781535-0.jpg (61.23 KB, 640x480, 4:3, fud.jpg)

File: 1458689781535-1.png (416.9 KB, 1366x768, 683:384, kdead.png)

>>547856

Nice FUD Qt shill. GTK+ is extremely relevant in Linux world.

Posted from KDE Plasma


 No.548733

>>548650

If I recall correctly, Scala did have built in accessors, but does it really generate the toString, equals and hashCode methods on its own?

I remember Scala did some wizardry with attributes, and if I am not mistaken you could even do polymorphism on runtime with it. I almost had autoerotic asphyxia while reading the docs.

Also, what happens in the Scala example if the person fuck()s? I remember Scala did some weird things regarding primitive types that allowed them to be treated as objects of a class without necessarily ceasing to be primitive values (thus requiring no unboxing), but I don't remember them being treated as references. I mean, fuck() would change the private Boolean _virgin field to false, but I don't know if the public virgin field would become false as well because the type inference made it become a reference to _virgin or if it just copied _virgin's value.


 No.548747

>>548733

>but does it really generate the toString, equals and hashCode methods on its own

If you define the class as a "case class" rather than a plain class then yes it does. It does a few other nice things too, like allowing you to use them in a "match" without writing a ton of boilerplate with a companion object.

>I mean, fuck() would change the private Boolean _virgin field to false, but I don't know if the public virgin field would become false as well

Inside the class, there are 3 types of method declaration:

"val", copies the value into a private field at construction time and the method will always return that value.

"var", similar to "val" but creates a mutator method (so you have "object.var" and "object.var_=" methods, the latter of which sugars the assignment operator)

"def", what I'm using to define "virgin" there, is the plainest: it's a normal function that evaluates each time it's called. In the code there it just returns the current value of _virgin whenever it's accessed. Of course, you can also create a "def" method which takes parameters, and you can't do that with a var/val.

The line between methods and attributes is blurred a lot in scala but it's ultimately a good thing in my opinion.


 No.548761

>>548701

I thought people were abandoning GTK in favor QT?


 No.548763

>>548747

>case class

wew lad, I will have to read more about Scala because I never got that far. That language does really have a lot of features so many, the first time I tried to program in it I didn't know where to start or what were the "best ways" to do stuff.

>val, var, def

Ah, yes, now that you mention it, def was indeed the Scala equivalent for defun. For some reason, I was thinking of it as a plain Java-style field declaration.

>The line between methods and attributes is blurred a lot in scala but it's ultimately a good thing in my opinion.

It is, and that's what makes it much better than Java. Have you seen how fucking obtuse lambdas are in Java? That's because methods aren't first class objects and therefore need an anonymous class wrapper around them. If you ever want to access a method directly, you need to use the reflection API to do some ugly fuckery that will never look good. Scala solved all that, and while it was at it it also added stuff like operator overloading with some really clever hacks based around syntactic sugar and "illegal" class names.

I don't fucking know why it isn't more popular. Maybe because it's massive and not that easy to be started with?


 No.548771

>>548763

>Maybe because it's massive and not that easy to be started with?

Most likely. It's got such a large breadth of concepts to grasp even before you can consider yourself to have mastered the syntax, so I suppose that might drive people away from it.

I know people have been scared off by its type system before, since it's apparently turing-complete.

I would consider it to be much more difficult to master than a plainer language like Python, but also I think it's just as easy to start. After all, the hello world is pretty plain:

println("Hello world")

You can get away with writing code almost identical to Java (other than some syntax differences), so the learning curve from zero to "get shit done" really isn't too bad.

So all that said, I've mentioned above why I think some people might be driven away from it but other than that I can't really think of any good reason.


 No.548783

>>548771

>I know people have been scared off by its type system before, since it's apparently turing-complete.

You can't just post that without explaining further, nigga.


 No.548802

>>548783

Yeah I can.

But here you go:

https://michid.wordpress.com/2010/01/29/scala-type-level-encoding-of-the-ski-calculus/ - pretty heavy but it describes how to implement SKI calculus in the scala type system, which proves it's turing complete.

Someone managed to implement "not" and "and" as types in scala too, effectively implementing all of zeroth-order logic, but I can't find that post at the moment.


 No.548809

>>548593

> You can make pretty much anything that doesn't intentionally try to rape the JVM with creation-destruction of objects or thousands of objects in the screen at once.

That's the nicest part. I am sure someone who has the experience of turning garbage-collecting runtime into essentially a passive layer over a fixed memory layout and is aware of every language construct that directly or indirectly creates an object can write any complex game. “Simple” meant either games that are so simple it doesn't affect them, or those that can be managed that way by an inexperienced programmer. Why such backward work to downgrade the JVM combined with bag of tricks from Java ME era should be considered a suitable solution to write games?


 No.548820

.NET on Linux was apparently getting some attention, so maybe that wouldn't be all that bad. I'm not sure about GUI. I had a couple problems with winforms and than there's GTK#. Although (to me) it seems that people prefer to avoid mono/C# if they have a choice, it's even "worse" with Java.

D also seems like a good language that takes some of the good stuff from Java and C#, and they list a bunch of libraries for all major GUI toolkits as wall as their own cross platform one. I've used non of it, but it seems like a solid choice.


 No.548892

>>548761

Not really. If your project is written in C++ of course Qt is much better choice. Also if you're targeting multiple platforms then Qt is also better than GTK+.

So there were few projects in recent years that switched to Qt, because they were written in C++ or wanted to get better multi-platform compatibility.

There are some seriously great changes in recent GTK+ versions, styling the GTK+ widgets is insanely better than in Qt. GTK+ has better support for more languages such as C, Java, Python, Vala.

GTK+ has modern features such as headerbars, client side decorations, interactive pop-ups etc.

Ignore the retardation in this video. I just want to show you the widgets. https://www.youtube.com/watch?v=Kk7yD4yDgm0

Qt is a lot more "bloated" than GTK+. This is because Qt has to cover a lot more areas since it has better support for many different platforms. GTK+ is very GNOME-centric. This enables it to be more lean and more innovative.

Also take in account that there are new projects showing up like Elementary OS & Budgie which are 100% GTK+ only.


 No.548893

>>548892

Also forgot to add: GTK+ has a lot better HDPI and Wayland support.


 No.548895

>>547826

C, C++, Python, QT5.

Now fuck off.


 No.548896

>>548893

Latest QT5 has kwin and wayland support. You are invalid.


 No.548899

>>548896

I didn't say Qt didn't support HDPI or Wayland. I said that GTK+ has a lot better support for HDPI and Wayland, which is true. GNOME has run Wayland session almost flawlessly. This year it going to be default in Fedora 25.


 No.548927

Support sticky

>>>/oven/




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]