Forgive my insolence, but aren't pointers just a reference to an object in memory? Objects in Java are almost always passed by reference rather than value. If I'm remembering right..
That is what a function pointer is and Java lacks.
0
Options
GnomeTankWhat the what?Portland, OregonRegistered Userregular
Pointers are just a memory address, they have nothing to do with objects. They point to an address in memory, what happens to be at that address could be anything.
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.
Oohhh okay. That makes sense... I'm not sure if I've ever wanted/needed to pass a method as a parameter. But now I'll see its uses everywhere and not be able to do anything about it... Thanks a lot!
Function pointers are fantastic to play around with, sooooo many things to shoot yourself in the foot with.
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.
0
Options
GnomeTankWhat the what?Portland, OregonRegistered Userregular
Oohhh okay. That makes sense... I'm not sure if I've ever wanted/needed to pass a method as a parameter. But now I'll see its uses everywhere and not be able to do anything about it... Thanks a lot!
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).
Forgive my insolence, but aren't pointers just a reference to an object in memory? Objects in Java are almost always passed by reference rather than value. If I'm remembering right..
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.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
Function pointers are fantastic to play around with, sooooo many things to shoot yourself in the foot with.
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.
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.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
Options
GnomeTankWhat the what?Portland, OregonRegistered Userregular
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.
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.
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
That wouldn't be the first time I failed my CS vocabulary roll.
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.
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
Generally you only overload if there is a specific function you need to emulate. Adding fractions, matrices are the most common of the CS degree examples.
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.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
That wouldn't be the first time I failed my CS vocabulary roll.
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.
As a bonus, overriding certain operators can change the semantics of the language as well by removing short circuit evaluation!
baronfelWould you say I havea _plethora_?Registered Userregular
edited February 2012
@gnometank I read your BOTP, but for some reason it's greek to me. I think I'm a little blitzed due to work, but I'll take a peek when I get home and see if I can noodle over it a bit more in depth.
This is the first time I've ever heard of a Functor and I feel like you guys are trolling me. :P
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 need to relearn PHP/SQL. I already made the database and need to learn to make properly functioning forms. It makes me delighted to see that Dreamweaver has improved so much on detecting PHP errors that I don't need to buy Zend Studio.
Does anyone have suggestions on relearning form communication? Sorry, noob question.
Function pointers are fantastic to play around with, sooooo many things to shoot yourself in the foot with.
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.
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.
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.
I need to relearn PHP/SQL. I already made the database and need to learn to make properly functioning forms. It makes me delighted to see that Dreamweaver has improved so much on detecting PHP errors that I don't need to buy Zend Studio.
Does anyone have suggestions on relearning form communication? Sorry, noob question.
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?".
0
Options
GnomeTankWhat the what?Portland, OregonRegistered Userregular
I need to relearn PHP/SQL. I already made the database and need to learn to make properly functioning forms. It makes me delighted to see that Dreamweaver has improved so much on detecting PHP errors that I don't need to buy Zend Studio.
Does anyone have suggestions on relearning form communication? Sorry, noob question.
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?".
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
3DS Friendcode 5413-1311-3767
0
Options
admanbunionize your workplaceSeattle, WARegistered Userregular
I need to relearn PHP/SQL. I already made the database and need to learn to make properly functioning forms. It makes me delighted to see that Dreamweaver has improved so much on detecting PHP errors that I don't need to buy Zend Studio.
Does anyone have suggestions on relearning form communication? Sorry, noob question.
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?".
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
e: From that function object article "Java has no first-class functions", poor Java
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 naziscommunists unrepentant assholes now.
Wow, I have never ever heard of jQuery. But that's because I'm five years out of practice. Sweet!
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.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
0
Options
GnomeTankWhat the what?Portland, OregonRegistered Userregular
Unless you are using ASP.NET MVC 2+, which has perfectly fine jQuery integration. Then it's no big deal.
Funny enough, education is starting to look into dropping Java, just as the industry is starting to take it more seriously due to Oracle. :rotate:
I personally think they'd all be better off without!
0
Options
admanbunionize your workplaceSeattle, WARegistered Userregular
re: jQuery
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."
GnomeTankWhat the what?Portland, OregonRegistered Userregular
I don't know that the industry is taking it more seriously. Maybe inside Java circles, people are less doom and gloom about it since Oracle took over, but outside Java circles it's not gaining any popularity. The Java language committees refusal to add really anything modern to the language has hurt it in the long run.
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited February 2012
Yeh, from what I heard, I would have liked MVC. But none of that during my internship. We still had mission critical VB6 code running around; .NET in general was considered "fancy new stuff".
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
I don't know that the industry is taking it more seriously. Maybe inside Java circles, people are less doom and gloom about it since Oracle took over, but outside Java circles it's not gaining any popularity. The Java language committees refusal to add really anything modern to the language has hurt it in the long run.
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.
I don't know that the industry is taking it more seriously. Maybe inside Java circles, people are less doom and gloom about it since Oracle took over, but outside Java circles it's not gaining any popularity. The Java language committees refusal to add really anything modern to the language has hurt it in the long run.
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.
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.
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.
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
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.
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-)
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 nazis communists unrepentant 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!
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.
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.