Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it,
follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given
their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
PA Programming Thread :: PAdev.net - Need hosting for a service of yours? Check it out.
Posts
This is a feature that C has.
Well jesus...I knew it was behind, but not that behind.
Because I was actually eliciting opinion, and I hate it when a post I actually want to get responses for BOTP's.
That is what a function pointer is and Java lacks.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
C++ makes pointers somewhat more type safe, but you can still take any random pointer to an object, cast it to void* and then write random data to that memory block.
What Monkey Ball means is that Java doesn't have first order functions, meaning you can't pass functions around, or assign them to variables. C# supports this via a concept called delegates (basically function pointers with instance information hung off of them), while C has "the original", function pointers, which are simply pointers to a function, because remember, code is just data that is in a different place in memory.
But my favourite code is the kind in the same place as your data! :rotate:
r00t ololol
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
They're hardly dangerous, given the use case. Regular pointer "fun" can cause headaches for those not used to em, but you're unlikely to be doing pointer arithmetic etc. with functions. You just have a pointer and you call it when you want to, it's a common concept and Java has a bunch of shit to get around its lack of supporting it. (Listeners etc. UGLY)
Function pointers are about as dangerous as integer division.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
I am notorious for writing super generic code that takes action predicates as method parameters, allowing me to write 99% of the code completely generic, then let the caller specify that 1% it needs to be different.
The best option you have in Java is functors (objects whose sole purpose is to expose a single point of callable functionality).
Unless it is a Harvard architecture, in which case everything is truly fucked.
Yes, and this is the work around for writing quasi-functional code in Java: You use a Callable interface that has one method, .call(). It is a dirty hack.
My Harvard sim had an interactive debugger! 8-)
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
Yeah I misspoke. I meant "MINDFUCK."
Especially junior programmers that don't know you can point to functions, and member functions.
C# has an okay solution to this, though. I haven't really tried to make delegates in java.
Functors. They are made even worse by the fact that Java can't override the call operator, so you can't actually say "myFunctor()", you have to do "myFunctor.call()" which just looks dirty, though is functionally equivalent.
I'm just now learning C++ and operator overriding seems fundamentally sketchy. I mean yeh, I can see how it can make things prettier, but I don't like the idea of futzing around with the syntax of the language itself, which seems kind of like what you are doing when you mess with operators. I could support it if there was a specific operator that was undefined unless it was overridden, so that it was specifically for the purpose of overriding.
If I made a "money" class, I'd probably want to overload many of the operators.
Other than the obvious ones, it's usually considered bad form. I think = is the most common for a copy constructor that you want to specify behavior for.
As a bonus, overriding certain operators can change the semantics of the language as well by removing short circuit evaluation!
It's a common enough idiom, but calling it a functor is bothersome. It's overloaded already (Prolog's name for 'functions', although that kind of misses the point; category theory)
I've seen chapters in books titled "Functors". Was not amused.
Does anyone have suggestions on relearning form communication? Sorry, noob question.
That's why you should always teach functional programming first(or at least soon after introductory programming...). Once people are used to manipulate functions as objects, it becomes just a matter of being careful with the specific.
What exactly are you asking for, because when I see "forms", I automatically think of html forms and this automatically leads to "You are doing it with ajax, right?".
We aren't trolling you, it's a thing. http://en.wikipedia.org/wiki/Functor.
They are a mathematical construct in category theory, and a synonym for "function object" (http://en.wikipedia.org/wiki/Function_object) in compsci.
e: From that function object article "Java has no first-class functions", poor Java
Come to think of it, yes, I'd like to relearn AJAX too, and yes, I'm just using html forms.
I'm trying to make a website that can control an air conditioner for senior design
Time for some tasty jQuery.
e: Damnit, beaten.
Why Java is still the de facto teaching language is beyond me. C#, javascript (probably via Node.js), Python, Golang, hell even C++11, apparently. These are all improvements. Also java is owned by
naziscommunistsunrepentant assholes now.It is time to move on.
Oh yeh that is almost synonymous with javascript to me. It makes the DOM not (as much of) a horrible nightmare. Until you throw in some ASP.NET, then it becomes silent hill in your IDE.
I personally think they'd all be better off without!
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
And then you think, "Man, this is powerful. I could build a fully-dynamic client-side web application with this and a light backend only used for serving data from the db to the front-end."
No sir, no you should not do this.
Enterprise and large industry are fans of vendor packages. For new application projects, Microsoft can provide the main components and now so can Oracle. This isn't developer decisions, this is architect and executive decisions. Doesn't matter if the technical is the same as it used to be, the marketing and support contracts change things big time.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
You aren't going to have any primarily Microsoft shops changing to Java though, support contracts or otherwise. For UNIX shops, or shops that don't know what they are yet, perhaps Java is appealing, but it's not winning a ton of converts.