|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On December 26 2014 05:39 delHospital wrote:Show nested quote +On December 26 2014 05:29 spinesheath wrote: Technically that's not too far off the mark. But usually a bunch of other stuff is associated with functional programming as well since it wasn't really supported in non-functional languages for a long time.
Robert C. Martin had a talk at the Norwegian Developer's Conference where he basically said: Structured programming is not using goto, OOP is not using function pointers (replaced by the safer virtual methods/interfaces), functional is not using assignments (immutability).
Imo that captures the essence pretty well, but since the OOP and functional branches have evolved seperately for a long time each of them developed specific higher level concepts that are just now being merged into the respective other branch. If OOP is not using function pointers, then FP is closer to structured programming than to OOP, as functions in FP are first-class, and get passed around all the time. You're mixing up function references and function pointers here. In machine code there's no real difference between the two, but on the language level function references are transparent and immutable. Then again you obviously can't have mutable pointers in FP if FP is defined by immutability...
|
On December 26 2014 06:38 spinesheath wrote:Show nested quote +On December 26 2014 05:39 delHospital wrote:On December 26 2014 05:29 spinesheath wrote: Technically that's not too far off the mark. But usually a bunch of other stuff is associated with functional programming as well since it wasn't really supported in non-functional languages for a long time.
Robert C. Martin had a talk at the Norwegian Developer's Conference where he basically said: Structured programming is not using goto, OOP is not using function pointers (replaced by the safer virtual methods/interfaces), functional is not using assignments (immutability).
Imo that captures the essence pretty well, but since the OOP and functional branches have evolved seperately for a long time each of them developed specific higher level concepts that are just now being merged into the respective other branch. If OOP is not using function pointers, then FP is closer to structured programming than to OOP, as functions in FP are first-class, and get passed around all the time. You're mixing up function references and function pointers here. In machine code there's no real difference between the two, but on the language level function references are transparent and immutable. Then again you obviously can't have mutable pointers in FP if FP is defined by immutability... How am I mixing up anything? OOP (I'm assuming a language like Java here) doesn't use function pointers, function references, or anything like that (the fact that you have to wrap a function in a class to pass it around shows how much this is discouraged in OOP). Therefore, if the thing that distinguishes structured programming and OOP best is replacement of function pointers with inheritance and method overriding, then FP is much closer to structured programming.
|
Well, C# makes it fairly easy to pass around functions (or rather methods, of course) as delegates, plus lambdas also do that and have been added to Java too afaik. I'm just saying that FP doesn't use function pointers, it uses function references. I'm not denying that FP is closer to structured than it is to OOP.
|
On December 26 2014 06:48 delHospital wrote:Show nested quote +On December 26 2014 06:38 spinesheath wrote:On December 26 2014 05:39 delHospital wrote:On December 26 2014 05:29 spinesheath wrote: Technically that's not too far off the mark. But usually a bunch of other stuff is associated with functional programming as well since it wasn't really supported in non-functional languages for a long time.
Robert C. Martin had a talk at the Norwegian Developer's Conference where he basically said: Structured programming is not using goto, OOP is not using function pointers (replaced by the safer virtual methods/interfaces), functional is not using assignments (immutability).
Imo that captures the essence pretty well, but since the OOP and functional branches have evolved seperately for a long time each of them developed specific higher level concepts that are just now being merged into the respective other branch. If OOP is not using function pointers, then FP is closer to structured programming than to OOP, as functions in FP are first-class, and get passed around all the time. You're mixing up function references and function pointers here. In machine code there's no real difference between the two, but on the language level function references are transparent and immutable. Then again you obviously can't have mutable pointers in FP if FP is defined by immutability... How am I mixing up anything? OOP (I'm assuming a language like Java here) doesn't use function pointers, function references, or anything like that ( the fact that you have to wrap a function in a class to pass it around shows how much this is discouraged in OOP). Therefore, if the thing that distinguishes structured programming and OOP best is replacement of function pointers with inheritance and method overriding, then FP is much closer to structured programming.
Umm... why? I don't think it's discouraged. It's just a lack of language feature. C++/C# both support method pointers.
|
It all boils down to one simple statement:
"Any pure paradigm is bad."
Pure procedural: Bad Pure OOP: Bad Pure Functional: Bad
It's about mixing those 3 and combining the best of each world that makes a good, easy to maintain program. That is the big thing about lambdas as they've been introduced in C++ and C#. It's not that they are new, everyone who ever picked up a programming book knows that they are ancient, but it's new that they combine OOP with functional programming, creating a sum that is bigger than it's parts.
If you program pure object-oriented code without using lambdas where appropriate, you lose a lot of potential. There are OO languages that don't allow for lambdas, which is a flaw in the languages, not in OOP. If you program pure functional code... well, you're probably a math professor, an emacs developer or escaped from an insane asylum, so you don't count. If you, at this day and age, still program procedural code, i.e. C, then you either have a very, very good excuse (microprocessor/driver/kernel programming) or you have only seen the bad sides of OOP without it's good sides and you need to learn that good OOP is more than putting everything into objects and creating insane inheritance trees.
There was a phase where OOP was quite over-the-top, which was the high time of Java and why that language is so terribly designed, but things have calmed down a lot and simpler approaches are a lot more common now. The time when everything was a noun has come and gone.
I love C# because it does the combination of functional and object-oriented code so extremely well that it appears seamless, which is a huge difference to other languages (haven't gotten around to working with the C++ lambdas yet) and really sets it apart. Neither functional nor OOP are new, both go all the way back into the '70s, but combining it in that way is new and that is why many people are excited about it.
Javascript has done the similar combination several years before with a bigger focus on the functional part, but the language has a lot of other... problems that makes programmers avoid it, not just because of nightmares from the combination of javascript and web browsers. Javascript is a great language to learn outside of a browser context because it does the combination of OOP and functional programming as well, but sadly the environment around the language is too limited for most uses, though nodejs is trying to improve that.
|
JS really needs some coherent way of writing code. Like you can use the semicolon but you can just as well not use it at all. And then you have to deal with code written by various people that mixes the styles and it's a mess even bigger than in the other languages that adhere to a much more strict way of doing things. And because in JS everything is an object you can chain everything and you end up working with lots of code violating the Single Responsibility Principle etc.
Seriously, JS scripts suffer from excessive code bloat more often than anything I've seen and debugging it is painful as hell.
|
Mod edit
User was banned for this post.
|
On December 26 2014 12:28 Morfildur wrote:It all boils down to one simple statement: "Any pure paradigm is bad." Pure procedural: Bad Pure OOP: Bad Pure Functional: Bad It's about mixing those 3 and combining the best of each world that makes a good, easy to maintain program. That is the big thing about lambdas as they've been introduced in C++ and C#. It's not that they are new, everyone who ever picked up a programming book knows that they are ancient, but it's new that they combine OOP with functional programming, creating a sum that is bigger than it's parts. If you program pure object-oriented code without using lambdas where appropriate, you lose a lot of potential. There are OO languages that don't allow for lambdas, which is a flaw in the languages, not in OOP. If you program pure functional code... well, you're probably a math professor, an emacs developer or escaped from an insane asylum, so you don't count. If you, at this day and age, still program procedural code, i.e. C, then you either have a very, very good excuse (microprocessor/driver/kernel programming) or you have only seen the bad sides of OOP without it's good sides and you need to learn that good OOP is more than putting everything into objects and creating insane inheritance trees. There was a phase where OOP was quite over-the-top, which was the high time of Java and why that language is so terribly designed, but things have calmed down a lot and simpler approaches are a lot more common now. The time when everything was a noun has come and gone. I love C# because it does the combination of functional and object-oriented code so extremely well that it appears seamless, which is a huge difference to other languages (haven't gotten around to working with the C++ lambdas yet) and really sets it apart. Neither functional nor OOP are new, both go all the way back into the '70s, but combining it in that way is new and that is why many people are excited about it. Javascript has done the similar combination several years before with a bigger focus on the functional part, but the language has a lot of other... problems that makes programmers avoid it, not just because of nightmares from the combination of javascript and web browsers. Javascript is a great language to learn outside of a browser context because it does the combination of OOP and functional programming as well, but sadly the environment around the language is too limited for most uses, though nodejs is trying to improve that.
I'm not sure if lambdas are purely from functional programming although Wikipedia says they're popular in that paradigm, but I know for a fact that C# LINQ is a lot easier with lambdas.
|
|
|
On December 26 2014 12:28 Morfildur wrote: If you program pure functional code... well, you're probably a math professor, an emacs developer or escaped from an insane asylum, so you don't count.
Contrary to what people usually think, FP is actually (quite minor compared to other paradigms but still) used in industry. For example, Chucklefish, the developers of Starbound are using Haskell for their new game. It's also used in banking/automated trading and critical systems.
|
On December 27 2014 05:31 Liebig wrote:Show nested quote +On December 26 2014 12:28 Morfildur wrote: If you program pure functional code... well, you're probably a math professor, an emacs developer or escaped from an insane asylum, so you don't count.
Contrary to what people usually think, FP is actually (quite minor compared to other paradigms but still) used in industry. For example, Chucklefish, the developers of Starbound are using Haskell for their new game. It's also used in banking/automated trading and critical systems. To add to this: Klarna, a big payment processor in Sweden, is built with Erlang.
|
Windows 8 Memory Consumption
More granular prioritization of memory:
Windows 8 has a better scheme for the prioritization of memory allocations made by applications and system components. This means that Windows can make better decisions about what memory to keep around and what memory to remove sooner.
For example, antivirus programs (AV) do various checks on files when they are being opened by other programs. The memory that the AV program allocates to check virus signatures is usually a one-time allocation (it is unlikely that specific memory will be needed again). On Windows 7, the memory is treated as if it had the same priority in the system as other memory (say, memory allocated by a running instance of Microsoft Excel). If memory became scarce, Windows 7 could end up removing the memory that helps another running application (like Excel) stay responsive for the user, which wouldn't be the best choice for system responsiveness in this case.
In Windows 8, any program has the ability to allocate memory as "low priority." This is an important signal to Windows that if there is memory pressure, Windows can remove this low priority memory to make space, and it doesn't affect other memory required to sustain the responsiveness of the system.
So, how do you allocate memory at low and high priority? Is 'new' in Java/C#/C++ enough? Is it up to Windows to decide which is low and high priority? Or do you just use task manager to set priorities?
|
Functional programming is much more than just using a few lambda's here and there, though. There is much more to it, like the concept of pure functions, monads, using recursion A LOT, etc. Although I myself admit not having used FP a lot.
|
On December 27 2014 22:56 darkness wrote:Windows 8 Memory ConsumptionShow nested quote + More granular prioritization of memory:
Windows 8 has a better scheme for the prioritization of memory allocations made by applications and system components. This means that Windows can make better decisions about what memory to keep around and what memory to remove sooner.
For example, antivirus programs (AV) do various checks on files when they are being opened by other programs. The memory that the AV program allocates to check virus signatures is usually a one-time allocation (it is unlikely that specific memory will be needed again). On Windows 7, the memory is treated as if it had the same priority in the system as other memory (say, memory allocated by a running instance of Microsoft Excel). If memory became scarce, Windows 7 could end up removing the memory that helps another running application (like Excel) stay responsive for the user, which wouldn't be the best choice for system responsiveness in this case.
In Windows 8, any program has the ability to allocate memory as "low priority." This is an important signal to Windows that if there is memory pressure, Windows can remove this low priority memory to make space, and it doesn't affect other memory required to sustain the responsiveness of the system. So, how do you allocate memory at low and high priority? Is 'new' in Java/C#/C++ enough? Is it up to Windows to decide which is low and high priority? Or do you just use task manager to set priorities? I haven't heard about this yet but it sure sounds as something useful.
|
On December 28 2014 02:41 WindWolf wrote:Show nested quote +On December 27 2014 22:56 darkness wrote:Windows 8 Memory Consumption More granular prioritization of memory:
Windows 8 has a better scheme for the prioritization of memory allocations made by applications and system components. This means that Windows can make better decisions about what memory to keep around and what memory to remove sooner.
For example, antivirus programs (AV) do various checks on files when they are being opened by other programs. The memory that the AV program allocates to check virus signatures is usually a one-time allocation (it is unlikely that specific memory will be needed again). On Windows 7, the memory is treated as if it had the same priority in the system as other memory (say, memory allocated by a running instance of Microsoft Excel). If memory became scarce, Windows 7 could end up removing the memory that helps another running application (like Excel) stay responsive for the user, which wouldn't be the best choice for system responsiveness in this case.
In Windows 8, any program has the ability to allocate memory as "low priority." This is an important signal to Windows that if there is memory pressure, Windows can remove this low priority memory to make space, and it doesn't affect other memory required to sustain the responsiveness of the system. So, how do you allocate memory at low and high priority? Is 'new' in Java/C#/C++ enough? Is it up to Windows to decide which is low and high priority? Or do you just use task manager to set priorities? I haven't heard about this yet but it sure sounds as something useful.
It sounds good indeed but I doubt it can be used properly if it's not Windows which makes the decision.
|
How does it sound useful when it's just a performance thing? Have you ever profiled an application to be slow because windows had bad memory priorities? If you didn't profile it, don't optimize it.
|
On December 26 2014 19:04 Manit0u wrote: JS really needs some coherent way of writing code. Like you can use the semicolon but you can just as well not use it at all. And then you have to deal with code written by various people that mixes the styles and it's a mess even bigger than in the other languages that adhere to a much more strict way of doing things. And because in JS everything is an object you can chain everything and you end up working with lots of code violating the Single Responsibility Principle etc.
Seriously, JS scripts suffer from excessive code bloat more often than anything I've seen and debugging it is painful as hell. JSLINT is your friend.
If you use the module design pattern you can more strictly adhere to SRP. The language is not at fault here, it's the programmers.
|
On December 27 2014 22:56 darkness wrote:Windows 8 Memory ConsumptionShow nested quote + More granular prioritization of memory:
Windows 8 has a better scheme for the prioritization of memory allocations made by applications and system components. This means that Windows can make better decisions about what memory to keep around and what memory to remove sooner.
For example, antivirus programs (AV) do various checks on files when they are being opened by other programs. The memory that the AV program allocates to check virus signatures is usually a one-time allocation (it is unlikely that specific memory will be needed again). On Windows 7, the memory is treated as if it had the same priority in the system as other memory (say, memory allocated by a running instance of Microsoft Excel). If memory became scarce, Windows 7 could end up removing the memory that helps another running application (like Excel) stay responsive for the user, which wouldn't be the best choice for system responsiveness in this case.
In Windows 8, any program has the ability to allocate memory as "low priority." This is an important signal to Windows that if there is memory pressure, Windows can remove this low priority memory to make space, and it doesn't affect other memory required to sustain the responsiveness of the system. So, how do you allocate memory at low and high priority? Is 'new' in Java/C#/C++ enough? Is it up to Windows to decide which is low and high priority? Or do you just use task manager to set priorities?
http://blogs.msdn.com/b/b8/archive/2012/04/17/reclaiming-memory-from-metro-style-apps.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/hh465088.aspx
|
On December 27 2014 22:56 darkness wrote:Windows 8 Memory ConsumptionShow nested quote + More granular prioritization of memory:
Windows 8 has a better scheme for the prioritization of memory allocations made by applications and system components. This means that Windows can make better decisions about what memory to keep around and what memory to remove sooner.
For example, antivirus programs (AV) do various checks on files when they are being opened by other programs. The memory that the AV program allocates to check virus signatures is usually a one-time allocation (it is unlikely that specific memory will be needed again). On Windows 7, the memory is treated as if it had the same priority in the system as other memory (say, memory allocated by a running instance of Microsoft Excel). If memory became scarce, Windows 7 could end up removing the memory that helps another running application (like Excel) stay responsive for the user, which wouldn't be the best choice for system responsiveness in this case.
In Windows 8, any program has the ability to allocate memory as "low priority." This is an important signal to Windows that if there is memory pressure, Windows can remove this low priority memory to make space, and it doesn't affect other memory required to sustain the responsiveness of the system. So, how do you allocate memory at low and high priority? Is 'new' in Java/C#/C++ enough? Is it up to Windows to decide which is low and high priority? Or do you just use task manager to set priorities?
thread priority is used to set the scheduling priority.
http://msdn.microsoft.com/en-us/library/system.threading.threadpriority.aspx
windows then interprets this scheduling priority like this
The system treats all threads with the same priority as equal. The system assigns time slices in a round-robin fashion to all threads with the highest priority. If none of these threads are ready to run, the system assigns time slices in a round-robin fashion to all threads with the next highest priority. If a higher-priority thread becomes available to run, the system ceases to execute the lower-priority thread (without allowing it to finish using its time slice), and assigns a full time slice to the higher-priority thread.
Windows - Scheduling priority
|
They're writing about memory priority, not thread priority...
|
|
|
|
|
|