News for hackers. Stuff that matters.
Re:An Introduction to C and GUI Programming by sdegutis on Wednesday April 24, 2019 @10:24AM (#19738607)
The embedded environment is what makes this setup make sense. But in the general case, C is less than ideal for GUI programming compared to what's available in other languages, because of lack of first class closures and more complex data types (or at least classes). Otherwise you are basically in the 80s doing Win32 GUI programming all over again.
Re:An Introduction to C and GUI Programming by freshm087 on Wednesday April 24, 2019 @11:08AM (#19739112)
There's a school of thought which considers complex data types to be more a part of problem then a solution. You may disagree with it, but nevertheless one certainly doesn't need complex data types to write GUI (or anything) effectively.

Also, in this universe Win32 API was released in 90s, not 80s.

Re:An Introduction to C and GUI Programming by sdegutis on Wednesday April 24, 2019 @11:26AM (#19739313)
The complexity should be the same no matter what language you use, but how you structure and organize that complexity changes drastically. Hence in Ruby it takes only 2-3 lines of code to accomplish what in Java requires a few ItemFactories.
Re:An Introduction to C and GUI Programming by badsectoracula on Wednesday April 24, 2019 @04:36PM (#19742343)
> Win32 API was released in 90s, not 80s.

Yeah, well, kinda... technically you are correct but Win32 is 99.998% backwards compatible (as an API, not ABI) with Win16 which was first released in the 80s.

Re:An Introduction to C and GUI Programming by Rerarom on Wednesday April 24, 2019 @12:13PM (#19739884)
#MandelaEffect
Re:An Introduction to C and GUI Programming by terryschiavo22 on Wednesday April 24, 2019 @10:35AM (#19738740)
What do first-class closures have to do with anything?
Re:An Introduction to C and GUI Programming by sdegutis on Wednesday April 24, 2019 @11:07AM (#19739091)
Being able to pass a closure (lexically scoped anonymous function) as an event handler is invaluable in GUI programming.
Re:An Introduction to C and GUI Programming by badsectoracula on Wednesday April 24, 2019 @04:43PM (#19742412)
I'm doing GUI programming for many years (from the DOS days) and while closures can be neat for small stuff (like updating an object field and calling some sort of refresh function for a visualization of the object when a GUI widget that represents the field changes), they are certainly not invaluable and you can do GUI programming perfectly fine without them - just pass a method pointer (obj+method) for C++ and similar languages (e.g. "procedure of object" or "function of object" in Object Pascal) or just a function address that takes an extra pointer (or whatever) argument that is given during handler registration (e.g. in a C toolkit of mine you register stuff with "register(widget, event, handler, param)" and handler is defined like "handler(widget, eventinfo, param)").

Actually, IMO if you are using closures for events that are more than 5 or so statements (i'd say lines but people love to pack their lines with multiple statements), you are doing a disservice for every poor soul who will have to understand your code later.

Re:An Introduction to C and GUI Programming by sureaboutthis on Wednesday April 24, 2019 @01:33PM (#19740812)
So you think C can't do that? Of course it can. Anything you want to create, C can handle it just as well if not better.
Re:An Introduction to C and GUI Programming by icedchai on Wednesday April 24, 2019 @01:58PM (#19741099)
C doesn't support closures natively, so have fun building it up yourself. You can pass a function pointer. That's it.
Re:An Introduction to C and GUI Programming by sureaboutthis on Thursday April 25, 2019 @09:57AM (#19748135)
My point is, that in C, you can do anything, including creating closures and passing them however you wish.
Re:An Introduction to C and GUI Programming by icedchai on Thursday April 25, 2019 @11:32AM (#19749185)
With enough coding, you can "do anything" in any Turing complete language. This is meaningless. It doesn't mean it is advisable (simple, maintainable) to do so. C does not support a syntax for closures, so you'll really just be calling functions with an 'environment' arg or something similar. What's the point?
Re:An Introduction to C and GUI Programming by sureaboutthis on Friday April 26, 2019 @12:22AM (#19754855)
My point is that he claims C can't do closures or pass them either. Follow the thread.

As far as being turing complete, CSS is supposedly that, also, so good luck with that.

Re:An Introduction to C and GUI Programming by icedchai on Friday April 26, 2019 @10:36AM (#19757954)
When people say a language supports closures, they are generally talking about syntax. C does not support a convenient syntax for closures, period.

Here's a guy who developed a closure "library" for C: https://nullprogram.com/blog/2017/01/08/

It's clever, but he actually had to resort to assembly...

Re:An Introduction to C and GUI Programming by esrauch on Wednesday April 24, 2019 @03:54PM (#19742041)
You think everyone not using C is just being idiots?