Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror

Comment Re:Tiresome (Score 1) 782

Yeah my main language is C++... I don't really like GC. I know the patterns to not leak (ex: use reliable primitive containers and let their destructors do the work... slap anyone's fingers if they try to type malloc, free, new, or delete). I then have to go into C# and Java and its like... why... why did IDisposable turn out this way?

I digress.

Back to your point... I mean... everything should be a local variable. Everything should be owned by a stack frame that's somehow attached to main. Any heap allocations should be done by the container that's sitting at some level in the stack. Those containers have some API to access its contents. That's what OOP is good at.

Like... you don't say, "Hey table + 508 bytes, how are you?" You say, "Hey table -- what's in row 6 column 4?" and it gives you some view into it (reference, copy, whatever). That's OOP. It should be used as a parameter of a pure function that cannot affect any state (except logging) outside of itself, which is where the meaningful work will be done. That's Functional.

Comment Re:Tiresome (Score 1) 782

It's actually kind of simple.

Pure functional encapsulates state to a stack frame, accessed by the function's parameters. OOP encapsulates state to a container, encapsulated by the class's public API.

Containers can persist. A stack frame, on the other hand, is born when you push a question onto the stack and dies when the answer pops from the stack.

Ideally, you want to give the compiler as much information as possible to limit you... because if you're telling it inconsistent things, then you're in the progress of writing bugs. Encapsulation prevents you from accidentally reading from or writing to memory that you told the compiler isn't relevant (because it's not a parameter, you're not accessing it in a public way, etc.). A function can further protect you by allowing you to declare parameters as read-only (const in C++) or write only (return value in C++... a write-only equivalent to const would be nice).

For example: Let's say you want to see where two curves intersect. A bug-resistant way to program this would be to have a class for each curve, and a function that compares when they intersect.

Why classes for the curves?
Each curve would give you a set of methods / properties that ensure you're on the curve. It prevents the function from accidentally breaking the curve.

Why a function for the comparison?
This tends to be where OOP goes wrong. A function cannot affect state other than its writable parameters... and it cannot be messed with outside of its readable parameters. In fact, when given the same inputs, a function will always produce exactly the same output. If the containers provide a sufficient public API for the function to do its job, then there really isn't a whole lot of ways that the function can screw up. (And, once you have a spec, you can verify that it's being followed with unit tests... because of the "always produce exactly the same output" property above.)

As usual, the real way to look at "X or Y" arguments is to identify the things that X and Y are good at, and use the correct one for the right situation.

Submission + - What Might Have Happened to Windows Media Center

Phopojijo writes: Microsoft has officially dropped Windows Media Center but, for a time, it looked like Microsoft was designing both Windows and the Xbox around it. That changed when Vista imploded and the new leadership took Windows in a different direction. Meanwhile, Valve Software and others appear to be tiptoeing into the space that Microsoft sprinted away from.

Submission + - Khronos Group Announces Vulkan to Compete Against DirectX 12.

Phopojijo writes: The Khronos Group has announced the Vulkan API for compute and graphics. Its goal is to compete against DirectX 12. It has some interesting features, such as queuing to multiple GPUs and an LLVM-based bytecode for its shading language to remove the need for a compiler from the graphics drivers. Also, the API allows graphics card vendors to support Vulkan with drivers back to Windows XP "and beyond".

Submission + - $3000 GeForce GTX TITAN Z Tested, Less Perf than $1500 R9 295X2 (pcper.com)

Vigile writes: NVIDIA announced its latest dual-GPU flagship card, the GeForce GTX Titan Z, at the GPU Technology Conference in late March with a staggering price point of $2999. Since that time, AMD announced and released the Radeon R9 295X2, its own dual-GPU card with a price tag of $1499. PC Perspective finally put the GTX Titan Z to the test and found that from a PC gamers view, the card is way overpriced for the performance it offers. At both 2560x1440 and 3840x2160 (4K) the R9 295X2 offered higher and more consistent frame rates sometimes by as much as 30%. The AMD card also only takes up two slots (though it does have a water cooling radiator to worry about) while the NVIDIA GTX Titan Z is a three-slot design. The Titan Z is quieter and uses much less power, but gamers considering a $1500 or $3000 graphics card selection are likely not overly concerned with power efficiency.

Submission + - Judge Says You Can Warn Others About Speed Traps

cartechboy writes: Speeding is against the law, and yes, even going 5 mph over the speed limit is breaking the law. But everyone does it, right? You do it, your friends do it, heck, your grandmother does it. But what about when you see a cop? Some cops are ticketing people for notifying fellow motorists about speed traps. In Florida, Ryan Kintner simply flashed his high-beams to warning oncoming cars that there was a cop ahead. He was given a ticket for doing so. He went to court to fight the ticket, and a judge ruled that flashing lights are the equivalent of free speech, thus he had every right to flash his lights to warn oncoming cars. So what have we learned here? Basically, if you are a good Samaritan, flash your lights and warn oncoming traffic of speed traps, because this is America ,and we are allowed freedom of speech.

Submission + - Ask Slashdot: How to Protect Your Passwords from Amnesia.

Phopojijo writes: So, you can encrypt your password library using a client-side manager or encrypted file container. You could practice your password every day, keep no written record, and do everything else right. You then go in for a serious operation or get in a terrible accident and, when you wake up, suffer severe memory loss. Slashdot readers, what do you consider an acceptable trade-off between proper security and preventing a data-loss catastrophe? I will leave some details and assumptions up to interpretation (budget, whether you have friends or co-workers to rely on, whether your solution will defend against the Government, chance of success, and so forth). For instance, would you split your master password in pieces and pay an attourney to contact you with a piece of it in case of emergency? Would you get a safe deposit box? Some biometric device? Leave the password with your husband, wife, or significant other? What can Slashdot come up with?

Submission + - Are new technologies undermining the laws of war? (sagepub.com)

Lasrick writes: This is a great read--as the author writes: 'Today, emerging military technologies—including unmanned aerial vehicles, directed-energy weapons, lethal autonomous robots, and cyber weapons—raise the prospect of upheavals in military practice so fundamental that they challenge assumptions underlying long-established international laws of war, particularly those relating to the primacy of the state and the geographic bounds of warfare. But the laws of war have been developed over a long period, with commentary and input from many cultures. What would seem appropriate in this age of extraordinary technological change, the author concludes, is a reconsideration of the laws of war in a deliberate and focused international dialogue that includes a range of cultural and institutional perspectives.'

Submission + - Bribe Devs To Improve Open Source Software (i-programmer.info) 1

mikejuk writes: Bribe.io announces itself as:
A super easy way to bribe developers to fix bugs and add features in the software you're using.
Recognizing the fact that a lot of open source projects are maintained by developers working alone and in their spare time, the idea is to encourage other developers to by specifying a monetary value to a bug report or feature enhancement. Once an initial "Bribe" has been posted others can "chip in" and add to the financial incentive.
Obviously there are problems to overcome — will it lead to devs introducing bugs at the same time as new features just to get paid to fix them? Also how does this fit with the underlying ethos of open source software? I Can hear RMS already....

Submission + - Battlefield 4 DRM Locking Part Of North America Out Of Its Release Date.

An anonymous reader writes: On the whole, Battlefield 4 had a reasonable launch. The have clearly learned from their past experiences with Battlefield 3 and, more notably, SimCity. Still, some customers are unable to access the game (until presumably October 30th at 7PM EDT, 39 hours after launch) because they are incorrectly flagged by region-locking. Do regional release dates help diminish all the work EA has been putting into Origin with their refund policy and live technical support? Should they just take our money and deliver the service before we change our minds?

Submission + - Next Gen Graphics and Process Migration: 20 nm and Beyond (pcper.com)

JoshMST writes: So why are we in the middle of GPU-renaming hell? AMD may be releasing a new 28 nm Hawaii chip in the next few days, it is still based on the same 28 nm process that the original HD 7970 debuted on nearly two years ago. Quick and easy (relative terms) process node transitions look to be a thing of the past with 20 nm lines applicable to large ASICs not being opened until mid-2014. This covers the issues that we have seen, that are present, and that which will be showing up in the years to come. It is amazing how far that industry has come in the past 18 years, but the challenges ahead are greater than ever.

Comment Re: Will it work with game consoles? (Score 1) 139

Actually, Gabe Newell at last year's CES (last January) was talking about NVIDIA Maxwell architecture. He claims NVIDIA will allow GPU virtualization for gaming applications. In other words, one PC could power multiple netbooks or Roku-style Steam boxes.

That said, split-screen (even multi-monitor "split-screen") is cool and occasionally occurs in PC games.

Slashdot Top Deals

Parkinson's Law: Work expands to fill the time alloted it.

Working...