gotchas

C++ template gotchas

just now I had to dig through the website to find out why template class template member function was giving syntax errors: template<class C> class F00 { template<typename T> bar(); }; ... Foo<C> f; f.bar<T>(); // syntax error here I now realize that template brackets are treated as relational operators. To do what was intended th...

What is the motivation for Scala assignment evaluating to Unit rather than the value assigned?

What is the motivation for Scala assignment evaluating to Unit rather than the value assigned? A common pattern in I/O programming is to do things like this: while ((bytesRead = in.read(buffer)) != -1) { ... But this is not possible in Scala because... bytesRead = in.read(buffer) .. returns Unit, not the new value of bytesRead. S...

C++0x move constructor gotcha

The C++ move constructor and move assignment operator seem like really positive things. And they can be used in situations where the copy constructor makes no sense because they don't require duplicating resources being pointed at. But there are cases where they will bite you if you aren't careful. And this is especially relevant as I...

Vala: Gotchas, Tips and Tricks.

As a programmer who is new to Vala, what is your number one piece of advice to someone who is new to the language? ...

What should i know about F# before starting a large project?

I don't know much F# and i never used a functional programming language in the past (i was interested in oCaml). I am about to rewrite my entire website and i think i want to do it in F#. I would like to know if there is anything i should know about before starting or development. NOTE: The site is fairly large and MUST be maintained fo...

Any potential gotchas or things to be aware of for a newcomer to Django?

In other words, what did you not know when you started with Django that you wish someone had told you? I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go. ...

Regex common pitfalls/gotchas (Java flavor)

Are there common patterns that people often use regex for (Java flavor) that is usually: incorrect due to various corner cases (but works "most of the time") correct but very slow etc... Also, more generally, what other tips are there for people who use regex-es in Java? I find that I often struggle due to: lack of named capturing ...

[r] Converting unix seconds in milliseconds to POSIXct/POSIXlt

Why do I see a difference when I convert a unix timestamp to datetime object in R? > as.POSIXlt(1268736919, origin="1970-01-01", tz="America/New_York") [1] "2010-03-16 06:55:19 EDT" > as.POSIXct(1268736919, origin="1970-01-01", tz="America/New_York") [1] "2010-03-16 11:55:19 EDT" The result from POSIXlt is actually correct. Also, is...

C++ brain teaser

I recently refactored code like this (MyClass to MyClassR). #include <iostream> class SomeMember { public: double m_value; SomeMember() : m_value(0) {} SomeMember(int a) : m_value(a) {} SomeMember(int a, int b) : m_value(static_cast<double>(a) / 3.14159 + static_cast<double>(b) / 2.71828) {} }; class MyClass ...

What Gotchas When Learning C++, If I came from PHP/Java?

Hi, I need to learn C++ in order to learn building Nokia WRT and or maemo application. I need to know what gotchas and what aspect of C++ that I need/have to learn or focus more. One thing I got in my mind is that C++ doesn't have garbage collector. Therefor, I need to focus on variable type. But, is there any others that really importa...

Why static fields are not initialized in time?

Somebody tell me: class MyClass { private static MyClass myClass = new MyClass(); private static final Object obj = new Object(); public MyClass() { System.out.println(obj); // will print null once } } I wonder, isn't this a bug? Why static objects are not initialized before the constructor runs? --update I'd just copied...

Looking for a clear and concise web page explaining why lower bits of random numbers are usually not that random.

I am putting together an internal "every developer should know" wiki page. I saw many discussions regarding rand() % N, but not a single web page that explains it all. For instance, I am curious if this problem is only C- and Linux-specific, or if it also applies to Windows, C++,. Java, .Net, Python, Perl. Please help me get to the bo...

Gotchas for writing rubygems

There have been questions with answers on how to write rubygems, but what should you avoid in writing a rubygem? What can cause problems for people using your rubygem? ...

Gotchas of moving from developing ASP.NET to Winforms apps

Hi, After developing ASP.NET apps exclusively for several years I'm about to start developing Winforms apps. What are the gotchas that I should be looking out for with this changes? For instance the way object lifetime is managed in the winforms paradigm. I'm sure there must be plenty of gotchas / differences between the two that I need...

Cross Platform Tips, Tricks & Gotchas

If you've worked on a cross platform development project what advice do you have for someone (like myself) considering starting one? Examples: What worked? What didn't? What problems did you run into and how did you solve them? Did you aim for consistent appearance and functionality across all platforms or try to take advantage of each...

Switch from C# to Java, which "gotchas" I should care?

I'll maybe have to switch to Java for new project. I have very few experiences about Java, because I've mainly studied and used C#, and I'm afraid of the differences between these two language/platform should likely to cause me many problems. Which are pitfalls/gotchas I should care about? ...

Gotchas when making use of Nullable<T> in C# 4

I've just started writing on a component where I found it might be useful to declare some of the properties nullable, instead of letting them resort to default values. However, I realized that I've never before used the non-nullable-type? syntax or the Nullable<T> type before, so there are probably some gotchas that'll soon jump out and ...

Occasions when the using statement and IDisposable should never be used

Hi, I was reading about this scenario where making use of the C# using statement can cause problems. Exceptions thrown within the scope of the using block can be lost if the Dispose function called at the end of the using statement was to throw an exception also. This highlights that care should be taken in certain cases when deciding w...

Moving from Classic ASP to ASP.net

Hi all! I've come from a Classic ASP background, done it for years and years and moving to .net has been way overdue, so I've started to learn .net. It's very different to say the least! It's structured a lot differently, and seems to work a lot differently, it's a huge leap upwards. However, it is appearing to me to be more and more...

Dependency Injection Gotchas...

Does anyone have a list of link(s) on the www for a good list of DI gotchas? I have been trying to inject controls using DI, in an asp.net webforms app and found that on recursive build up that ViewState is lost. Also would be helpful a list of articles where the developer needs to be aware to gotchas before taking teh big step in implem...