Hot answers tagged

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 ...


52

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 ...


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 ...


25

A lack of proper input validation is one of those things which tends to lead quite quickly to users doing "bad" things with your application, when it should really be handled by the programmer. I've seen legacy apps where users have been trained to: not enter apostrophes in names not enter any symbol other than a-z0-9, ensure there are no spaces before or ...


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

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 ...


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 ...


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 ...


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 ...


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

Almost every program that I write is invoked strictly from the command line. I've also written some fancier things that started out as CLI interfaces and rapidly grew into something more shell like than anything. So, I can speak only for what I know. Here's some common issues with command line programs: Way too many options Unless you are writing a ...


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 ...


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 ...


6

I once got a customer support call because my app just disappeared. Turned out they opened another app on top of it. ... I decided not to ensure that didn't happen again, since it was the users computer illiteracy that caused the problem, not the app. Anything I could have done to fix it would have lead to a poor user experience for others.


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

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

"Are you sure you want to delete this file/record? Yes/No". Clicked yes and then got a call that it "mistakenly" clicked the red delete button and it needs that data back:)


3

I don't feel like getting specific break/fix examples is as important as realizing this: Users do not read your manual, or watch your tutorials. They learn your software through exploration. If through that exploration they break something, as a programmer it is your job to either warn them of the danger or prevent it from happening in the first place. I ...


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). ...


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 ...


2

I don't think users are stupid. They don't want to use your or any program at all. All they want is to get their things done. Help them and prevent harm from happening to them along the way.


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

Here is one I heard this week. A user asks for a feature "send me a notification when an event occurs". Simple enough and the developer goes ahead and implements it. Sure, the first question should have been "what are trying to address by this notification?". I won't go into that. Few days later the user stops by the developer and asks "I got this ...


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...



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