Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

feedmegin posted:

Some of the time, sure, but it's a difference of degree. It's all over the place in gtk because they thought it would be a wizard idea to recreate C++ inheritance and vtbls in plain C, rather than just, y'know, using C++.

C++ has order-of-magnitude-longer compilation times and isn't easily bindable to other languages because of name mangling. Qt, the competitive toolkit, requires a custom preprocessor to even make C++ usable for their use case.

GTK+'s object system uses checked casts that will give a runtime warning if you cast incorrectly, something C++ doesn't have (unless you use dynamic_cast, at which point you're left with C++'s batshit insane exception model)

Adbot
ADBOT LOVES YOU

feedmegin
Jul 30, 2008

Suspicious Dish posted:

GTK+'s object system uses checked casts that will give a runtime warning if you cast incorrectly, something C++ doesn't have (unless you use dynamic_cast, at which point you're left with C++'s batshit insane exception model)

Uhh. You don't need to cast at all in C++ as a rule, the language provides virtual functions and inheritance for you, that's the whole point. If you have a Foo * and you try and call a Bar::something on it without Bar being a superclass of Foo the compiler will tell you that at compile time, which is when you want it. Gtk is manually doing stuff that C++ specifically has syntactic sugar (and compile-time checks) for, and doing it worse. My point is, if this is a thing that you want, why not use the language that actually has it built in, kind of thing?

As for dynamic_cast, if you are using it, normally you're operating on a pointer. Dynamic casting a pointer doesn't throw an exception on failure, it returns a null pointer. No exceptions required (and indeed Qt doesn't use exceptions at all!).

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I thought dynamic_cast threw a std::bad_cast if it was incorrect, and all the documentation I've found says this. That said, I can't find any good official C++ documentation.

As I said, GTK+ doesn't use C++ because of horrendous compile times and lack of bindability. Also, it was 1996, when C++ support was completely lovely and half-baked everywhere.

nielsm
Jun 1, 2009



Suspicious Dish posted:

I thought dynamic_cast threw a std::bad_cast if it was incorrect, and all the documentation I've found says this. That said, I can't find any good official C++ documentation.

As I said, GTK+ doesn't use C++ because of horrendous compile times and lack of bindability. Also, it was 1996, when C++ support was completely lovely and half-baked everywhere.

http://en.cppreference.com/w/cpp/language/dynamic_cast

quote:

If the cast is successful, dynamic_cast returns a value of type new_type. If the cast fails and new_type is a pointer type, it returns a null pointer of that type. If the cast fails and new_type is a reference type, it throws an exception that matches a handler of type std::bad_cast.

feedmegin
Jul 30, 2008

Suspicious Dish posted:

As I said, GTK+ doesn't use C++ because of horrendous compile times and lack of bindability. Also, it was 1996, when C++ support was completely lovely and half-baked everywhere.

Qt supported about a zillion different platforms/compilers back then and indeed still does (this is one of the reasons it has its own collection types and doesn't use exceptions, actually). Nor are compile times as bad as you're making out.

Bindability, sure, I guess I can kind of get behind that though bindings to Python do exist for Qt. But that, uh, doesn't really apply to the giant mound of software written in C using gtk!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Aha, I missed the pointer vs. reference distinction.

feedmegin posted:

Qt supported about a zillion different platforms/compilers back then and indeed still does (this is one of the reasons it has its own collection types and doesn't use exceptions, actually). Nor are compile times as bad as you're making out.

I work on C++ projects all the time. They consistently take 5 or so times longer to compile than the corresponding C program. I don't like working on C++ projects. And yes, Qt works around the platform issues by not using basically anything from the C++ standard library and opting to use their own, including their own object system using moc. Qt effectively has its own standard library inside of it.

feedmegin posted:

Bindability, sure, I guess I can kind of get behind that though bindings to Python do exist for Qt. But that, uh, doesn't really apply to the giant mound of software written in C using gtk!

Why doesn't it apply? You can introspect and bind against any library written in C super duper easily from a large number of runtimes including Python, JavaScript and Lua.

That said, I don't see why "casts, casts everywhere" is particularly bad if the casts are minimal and checked. Engineering is full of trade-offs. I don't necessarily think all of C is great, but I understand why things were done the way they were, and I don't have a particularly great appetite for full C++.

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!

pokeyman posted:

"I don't know what I'm talking about. Here is an obviously stupid generalization."

I'm not a chef, but I can tell when something tastes like dogshit.

feedmegin
Jul 30, 2008

Suspicious Dish posted:

Why doesn't it apply? You can introspect and bind against any library written in C super duper easily from a large number of runtimes including Python, JavaScript and Lua.

If you are writing a program in C, you don't care about interoperability in languages that are not C. Because you're writing it in C.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

feedmegin posted:

If you are writing a program in C, you don't care about interoperability in languages that are not C. Because you're writing it in C.

But if, as in the post you quoted, you're writing a library, you might well write it in C specifically so that it can be easily bound to other languages. (Though you can also write the bulk in C++ with an extern "C" API exposed.)

JawnV6
Jul 4, 2004

So hot ...
I'm using a javascript tool that grabs a bunch of streams of data, douses them in callback soup, then inflates a visualization. I'm trying to point it at a local CSV instead and the stupid parts of it are difficult.

My favorite bit is the canonical (as in other questions are marked duplicate and rerouted) "how do I parse CSV in JS" SO question is ultra-specific to single-quoted strings, so much so that it's outside of the RFC and Excel implementations and won't help anyone who just wants to do that.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
https://github.com/ansible/ansible/blob/devel/lib/ansible/template/__init__.py#L331-L335

The future of DevOps.

(This is causing us an issue in production right now where Ansible wants to replace all double quotes with single quotes causing output to be invalid JSON)

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
The very existence of a method named "safe_eval" fills me with deep unease.

xzzy
Mar 5, 2009

Any time I encounter a solution that involves eval or exec I close the tab. Never really seen a situation where using it wasn't a cheap hack filled with future regret or risking a gaping security hole.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane
Whoever said earlier that a WordPress plugin wants .htaccess to be writeable by the server is incorrect. It is, in fact, WordPress itself which tries to get that capability. All so delicate little flowers don't have to copy and paste generated code into a text file. I don't really want to know what horrors lay even deeper down, that I haven't seen :smith:

At least I'm getting to the point where I think I understand the way the designers think. It's a horrible way to think and I disapprove of it, but it means that if you're wondering how to do something, you just have to consider how an utter moron would've expected you to do something (often involving a database structure that is an affront to the LORD our God) and, voila, you've done it the Proper WordPress Way.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

TooMuchAbstraction posted:

The very existence of a method named "safe_eval" fills me with deep unease.

I found a function used in our code called "easyrpc" which wraps an rpc call to the serve in a way that's really easy to pass arguments into. Unfortunately, it also handles all errors returned by the rpc internally by swallowing them, and this isn't documented at all despite having an "error" outparam that is never populated. Which has led to a lot of areas in our client that just crash and burn if whatever code is being called on the server stops working for whatever reason.

Any time a function is named "easy*" or "safe*", it's a good shorthand for "this developer did not think hard enough about what they were doing".

xzzy
Mar 5, 2009

Or they lump more and more logic/parameters until it's as complex (and less documented) than the original thing they were trying to simplify.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

LeftistMuslimObama posted:

I found a function ... which [performs] an rpc call ... [w]hich has led to a lot of areas in our client that just crash and burn if whatever code is being called on the server stops working for whatever reason.

Omit needless words!

Soricidus
Oct 21, 2010
freedom-hating statist shill

rjmccall posted:

Omit needless words!

and then you left in anything beyond "I found [...] an rpc call"

JawnV6
Jul 4, 2004

So hot ...

rjmccall posted:

Omit needless words!

1337JiveTurkey
Feb 17, 2005

All that talk of RPC reminded me of this disasterpiece:

http://www.omg.org/news/meetings/workshops/RT_2003_Manual/Tutorials/T2_SCA_Hayes.pdf

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

LeftistMuslimObama posted:

I found [...] an rpc call to [...] burn

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Suspicious Dish posted:

C++ has order-of-magnitude-longer compilation times and isn't easily bindable to other languages because of name mangling. Qt, the competitive toolkit, requires a custom preprocessor to even make C++ usable for their use case.

Also, C++ is really, really lovely for creating libraries that need to be separately compiled, if you also want clients of the library to derive from the interface classes. This was one of the main problems with the BeOS API (which was very nice otherwise), "solved" by stuffing the interfaces full of dummy member variables and virtual functions.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Zopotantor posted:

Also, C++ is really, really lovely for creating libraries that need to be separately compiled, if you also want clients of the library to derive from the interface classes. This was one of the main problems with the BeOS API (which was very nice otherwise), "solved" by stuffing the interfaces full of dummy member variables and virtual functions.

I thought the standards committee was actually looking at fixing this by providing a standards-compliant way of exporting certain types/interfaces?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Ender.uNF posted:

I thought the standards committee was actually looking at fixing this

yeah, c++42 is gonna be great

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

JawnV6 posted:

I'm using a javascript tool that grabs a bunch of streams of data, douses them in callback soup, then inflates a visualization. I'm trying to point it at a local CSV instead and the stupid parts of it are difficult.

My favorite bit is the canonical (as in other questions are marked duplicate and rerouted) "how do I parse CSV in JS" SO question is ultra-specific to single-quoted strings, so much so that it's outside of the RFC and Excel implementations and won't help anyone who just wants to do that.

I love the stupid bureaucracy of Stack Overflow where they have an impoverished set of reasons for closing a question so if they want to close some question for a reason that's not in the pre-approved list of radio buttons, they just choose some random reason like "not clear what you're asking" even if it obviously doesn't apply.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Hammerite posted:

I love the stupid bureaucracy of Stack Overflow where they have an impoverished set of reasons for closing a question so if they want to close some question for a reason that's not in the pre-approved list of radio buttons, they just choose some random reason like "not clear what you're asking" even if it obviously doesn't apply.

There's an "other reason" where you can fill in your own.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Soricidus posted:

and then you left in anything beyond "I found [...] an rpc call"

sadly, it's the only way to get vb6 to talk to caché.

pseudorandom name
May 6, 2007

Ender.uNF posted:

I thought the standards committee was actually looking at fixing this by providing a standards-compliant way of exporting certain types/interfaces?

The "fix" will end up being an LTO IR unique to every compiler, instead of generating the class and vtable layout at runtime.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
C++ is a mess

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner
C++ is actually good

feedmegin
Jul 30, 2008

Zopotantor posted:

Also, C++ is really, really lovely for creating libraries that need to be separately compiled, if you also want clients of the library to derive from the interface classes. This was one of the main problems with the BeOS API (which was very nice otherwise), "solved" by stuffing the interfaces full of dummy member variables and virtual functions.

Qt is pretty good about binary compatibility within each major version, actually, though it does take some effort internally. I assume that's what you're talking about, anyway, since the article you linked is instead about semantic changes in a base class and you're going to have that problem in any language with inheritance - the example on there is in Java, after all - and indeed in gtk/gnome since that has its own virtual method system.

Absurd Alhazred
Mar 27, 2010

by Athanatos

feedmegin posted:

Qt is pretty good about binary compatibility within each major version, actually, though it does take some effort internally. I assume that's what you're talking about, anyway, since the article you linked is instead about semantic changes in a base class and you're going to have that problem in any language with inheritance - the example on there is in Java, after all - and indeed in gtk/gnome since that has its own virtual method system.

Inheritance was a mistake.

quiggy
Aug 7, 2010

[in Russian] Oof.


Absurd Alhazred posted:

Inheritance was a mistake.

Excuse me but without Cat extends Animal how can you teach freshmen about computers :colbert:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Notorious QIG posted:

Excuse me but without Cat extends Animal how can you teach freshmen about computers :colbert:

From what I hear you pretty much assume they already had exposure to programming of some sort already and if they didn't they slam into a learning cliff Wile E. Coyote style and burn out.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Ithaqua posted:

There's an "other reason" where you can fill in your own.

I just checked and I don't see that option as a top-level thing, although there is an "other" option hidden under "off topic". Anyway I've seen questions get closed with erroneous reasons cited plenty of times on there.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Notorious QIG posted:

Excuse me but without Cat extends Animal how can you teach freshmen about computers :colbert:

I will have you know that cat implements animal. :3:

quiggy
Aug 7, 2010

[in Russian] Oof.


Absurd Alhazred posted:

I will have you know that cat implements animal. :3:

Well I mean I mainly code in C++ so actually class Cat : public Animal, but point taken.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Nearly every place I've seen inheritance used what the developer really wanted was an interface. And there's no excuse for not using them. Even VB6 has interfaces ffs.

Carbon dioxide
Oct 9, 2012

Notorious QIG posted:

Excuse me but without Cat extends Animal how can you teach freshmen about computers :colbert:

I had a teacher talk about design patterns, and he started with something like:
Java code:
public abstract class Duck {
  FlyingBehaviour flyingBehaviour;
  public void fly() {
    flyingBehaviour.execute();
  }
}

public class Mallard extends Duck {
  flyingBehaviour = new FlyWithWings();
}

public class WoodenModel extends Duck {
  flyingBehaviour = new FlyNoWay();
}
(Taking shortcuts here, it's just about the example, not about code correctness)

Then he started talking about "but what if we need to implement a new way of flying", and started changing the code to
Java code:
public class WoodenModel extends Duck {
  flyingBehaviour = new FlyRocketPowered();
}
And by then everyone was imagining a rocket-powered wooden duck.

Adbot
ADBOT LOVES YOU

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Absurd Alhazred posted:

I will have you know that cat implements animal. :3:

In Inform 7:

pre:
Cat is a kind of Animal.
Clearly the best language.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply