News for hackers. Stuff that matters.
Re:The //* /*/ //*/ comment toggle trick by SoftwareMaven on Monday April 29, 2013 @11:09AM (#5626625)

  #define DEBUG 1
  #if DEBUG
    test_code()
  #else
    real_code()
  #endif
Much more readable and the DEBUG macro can be defined in a common header, so all of the code can share it.

The comment trick isn't useless during development, but I'd see myself using a macro rather than trying to remember just where a slash goes.

Re:The //* /*/ //*/ comment toggle trick by alexanderbrevig on Monday April 29, 2013 @11:14AM (#5626667)
Run that with vanilla JavaScript, Java, SQL or anything but C/C++ [this is the premise of the protip] and I'll bake you a cake! (One that's not a lie;) Nothing that's discussed here does the same thing, though I completely agree there is a lot of better techniques for various tasks, nothing is functionally the same as the trick. (Why can I not reply the the reply of this post? I'm new here.)
Re:The //* /*/ //*/ comment toggle trick by SoftwareMaven on Monday April 29, 2013 @11:22AM (#5626723)
Well, first, there is nothing preventing you from running JS or Java through the C preprocessor (and we did run JavaScript through it at my last job).

But there are equivalents for any programming language, but others here have already touched on them.

I'm not sure what SQL has built in, but I'd just use the C preprocessor if I needed that. However, I'd much rather not muck with my queries like that, because that will cause nasty surprises in production.

And I don't eat carbs, so your off the hook for a cake.

Re:The //* /*/ //*/ comment toggle trick by kibibu on Monday April 29, 2013 @08:43PM (#5629811)
> Well, first, there is nothing preventing you from running JS or Java through the C preprocessor (and we did run JavaScript through it at my last job).

This is an interesting idea! What was the problem you were solving that required this?

---

I think actually the C preprocessor would solve a lot of the problems that, say, SCSS solves too:

    // put these in a header file, 'cssutil.h'
    #define HASH #
    #define f(x) x
    #define COLOR(c) f(HASH)c

    #define PREFIXED(x, y) \
        -webkit- ## x : y;\
        -moz- ## x : y;\
        -o- ## x : y;\
        x : y
    #define SHADOWED PREFIXED(box-shadow, 10px)

    
    // then in your css
    #include "cssutil.h"

    #define THEME_BG COLOR(fff)

    div.main {
        background: THEME_BG;
        SHADOWED;
    }
There we go, pristine(ish) CSS, unsullied by magic constants and messy prefixes! (note that my preprocessor-fu is weak, I don't know how to do variadic prefixes)
Re:The //* /*/ //*/ comment toggle trick by vowelless on Monday April 29, 2013 @11:45AM (#5626883)
Often times having a one-size-fits-all approach (especially across languages [!]) is not a good idea.

Different languages have different optimization techniques for removing code during compilation. Java, for example [1], can optimize out based on static boolean variables. I recommend learning more about each individual language and what it offers to get the best out of it.

[1] http://stackoverflow.com/questions/1344270/java-preprocessor