Hot answers tagged

54

If cooling is insufficient, the CPU might overheat. But they all (well, at least all modern PC CPUs) feature various thermal protection mechanisms which will throttle the clock speed or, as a final resort, shut down. So yes, on a dusty laptop, 100 % CPU load could cause temporary problems, but nothing will break or "degrade" (whatever that means). For CPU ...


53

Expressiveness isn't always a positive language trait in a corporate environment. Java is extremely popular partly because its easy to learn, easy to write, and easy to read. Mediocre programmers can still be very productive in Java, even if their code is wordy and inelegant. Furthermore, it's easy to abuse expressive languages. An expert java programmer ...


28

In Item 5, of Effective Java, Joshua Bloch says The lesson is clear: prefer primitives to boxed primitives, and watch out for unintentional autoboxing. One good use for classes is when using them as generic types (including Collection classes, such as lists and maps) or when you want to transform them to other type without implicit casting (for ...


20

Worry about performance when it becomes a problem. If you write a small app to process 10,000 line files and you get a 1,000,000 line file every 100th file, it probably doesn't matter that it takes longer to process that one file. However, if you are regularly getting files that are 5-10 times larger than initially and your application is taking too long to ...


16

The standard practice is to go with the primitives, unless you're dealing with generics (make sure you are aware of autoboxing & unboxing!). There are a number of good reasons to follow the convention: 1. You avoid simple mistakes: There are some subtle, non-intuitive cases which often catch out beginners. Even experienced coders slip up and make ...


14

There is generally nothing wrong with a program using 100% CPU while it is actually doing useful work and is not taking time away from anything more important. If a particular hardware platform is e.g. only capable of using 100% CPU continuously for one second before it has to throttle back to 50% to avoid overheating, it is generally better for an ...


14

Windows programs (winforms/WPF) should at all times stay responsive. With a naive implementation of a process that uses 100% cpu resources it's all too easy to make your program or even your system seem sluggish and hanging. With a good implementation (for instance: use a seperate thread with lower priority) it shouldn't be a problem. You shouldn't worry ...


10

My main question is when should I trade the easy but somewhat inefficient ways of doing tasks for big giant complicated beasts that do things extremely quickly but destroy any possible ways of upgrading and make the code excessively difficult and prone to rewriting anyway by the next developer? This is usually a false dichotomy. You can ...


10

Usually I go with the primitives. However, one peculiarity of using classes like Integer and Boolean is the possibility of assigning null to those variables. Of course, this means that you have to do null checks all the time, but still better to get a NullPointerException than to have logic errors due to using some int or boolean variable that has not been ...


9

Since if/else is similar to a switch and often interchangeable, your confusion is understandable. Some languages, such as Python, don't even have a switch statement. Not surprisingly, when you Google for "python switch", the first result points to an alternative—a map. Not an if/else, but a map. While you can use if/else every time instead of a switch, you ...


8

"modern CPUs are cheap and will degrade quickly at 100% CPU". I don't think anyone's actually addressed the "degrade" part of this question. ICs will degrade when the die temperature exceeds the manufacturer's limits. ICs are usually designed to operate up to 125C, although every 10C increase shortens life by 50% Processors didn't always have thermal ...


7

IMO, it's mostly due to: Poor library support. Sure, there's Quicklisp now, which makes it easy to install libraries, but it doesn't compensate for them being still fairly few, and quite a few are poorly documented or not very well maintained. Compared to Python, there's a good chance that writing non-trivial Lisp application (regardless of the particular ...


7

Why is not Lisp more widespread? If it is really that powerful, people should be using it all over, If you believe that languages are chosen for their technical merits, you are in for a soul-crushing disappointment. Such decisions are made based on Strippers And Steaks. Microsoft can afford them. Oracle can. Sun spent so much money hyping Java that they ...


5

A truism I picked up studying microprocessors in college that stayed with me: "Make the common case fast. Make the uncommon case correct." As long as you have just a small percentage of users choking your code with input two orders of magnitude larger than what it was meant to handle, don't sweat it. Make sure it handles the input correctly if they give ...


4

I think there are a few reasons why developers tend to only use a few data structures. There are general data structures that work well enough most of the time so they become the primary choice of data structures for most problems. I know hash tables and lists are my "goto" data structures. I even know that in some of the cases I used hash tables when Red ...


4

I have no experience in working for a real company, but I know why LISP has been hard for me to use. First of all, this reminds me of this blog post: http://steve-yegge.blogspot.com/2006/04/lisp-is-not-acceptable-lisp.html The main problem that I have with Lisp is the "which Lisp" question. I usually work on Linux as my main platform, but the things I make ...


4

No, switch statements are not generally used wrong. They are mostly used for their intended use: enumerating action alternatives for a smallish set of possible input values. It's more readable then a long if/else chain, compilers can emit very efficient code if the checked values are reasonably contiguous, and it's easier to write error-checking compilers ...


3

To play the devil's advocate: In a way, a program that cannot reach 100% utilization could cause worse wear: Unless it is suspended waiting for a keystroke, chances are that it is suspended waiting for disk I/O most of the time. And disks are (still usually) big mechanical devices that are subject to mechanical wear or the risk of shock/gyroscopic effects ...


3

"..modern CPUs are cheap and will degrade quickly at 100% CPU". You don't have to worry about "CPU degradation" at all. Modern CPUs are not of less quality than in former times. It is very expensive (and is getting more expensive every couple of years) to make CPUs, some billions to build a new fab are not uncommon (see link). http://en.wikipedia.org/...


3

I think one problem with Lisp not yet mentioned is that for a mediocre or novice programmer (like myself, I freely admit), it can be difficult to see how you turn Lisp code into a big program. It's easy to write but hard to architect. I don't think any of the concepts are particularly difficult, but the DIY mentality is so strong that I often feel at a ...


3

I learned LISP a billion years ago in college. LISP, like FORTH, is great for logic. But most programming is not about logic, it's about manipulating data in boring mechanical ways. For example, at the time there as no way to right-justify numeric output. LISP is about nested functionality, and people just don't think that way. They think in terms of DO A, ...


2

It seems that even CL does not have very good library support. At least according to people who switched from Lisp to Python: http://www.redmountainsw.com/wordpress/archives/reddit-switches-from-lisp-to-python Personally, I know some Scheme and enjoy playing with it, but can't imagine doing a non-trivial project in that language.


2

Is it still being maintained or is this a bad choice if I want to do jQuery with RoR? Their website doesn't exist anymore, their Google Group has some spam and their code isn't updated. I guess this isn't maintained anymore and might be a bad choice for continuous development...


2

Keep an eye on Clojure (and maybe learn it since you're on a LISP learning roll). It runs on the JVM so that really gives it an advantage in industry. A craigslist search in SF bay area got me 4 hits for clojure and 1 each for lisp and scheme.


2

I see what you're saying, but this is ultimately not improper. If it's just one or two elses, an if-else change will suffice. But if it grows to be more than that, I'd say switch statements can quickly turn into something that's just cleaner and less of an eyesore to look at. Or...depending on who you are personally, it could turn it into something that's ...


2

Such degradation is theoretically possible and is called "electromigration". Electromigration is temperature-dependent, accelerating as the temperature goes up. Whether it is a practical problem for modern CPUs is up for debate. Modern VLSI design practices compensate for electromigration and chips are more likely to fail for other reasons. Having said that,...


2

Some languages (Scala compiled to JVM, Haskell, Ocaml, etc...) have pattern matching which is superior to switch since its deconstruct data structures and bind variables (locally to the matching case). For example, in Ocaml you might define a simplistic AST data type (a sum type or tagged union) for expressions as: type expr = Num of int | Sum of ...


1

So the situation is this: You have some code that runs say for five hours using 100% of all CPUs, that is optimised as much you can, the owner of the machine is fine with the machine being unusable for five hours, and your colleague claims it would be better to run your code in 6 hours using 83.33% of all CPUs, because it puts less wear and tear on the ...


1

If you are running your code on clients, 100% CPU utilization means that client computers in that time cannot be used for anything else but tasks with higher priority. As most applications usually run in default priority, users using those computers will notice computer freezing and will be unable to do ought else on their computers. Even if we are talking ...


1

For web development with Lisp dialects, there can be a bit of a chicken-and-egg problem - because few people use Lisp, hosts either don't allow it or don't make it easy, and because it's not easy, few people use it. But actually, getting Lisp running on a host can be easier than you might think, even if it requires a bit more work than their out-of-the-box ...



Only top voted, non community-wiki answers of a minimum length are eligible