Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I'm getting ready to open source some code I'm working on. This would be my first open source project, and I'm not really sure which license to pick.

Anyone have a good resource describing the implications of the different licenses out there?

I mean, it's easy enough to read Apache, MIT, GPL, etc...but there's implications for each that makes it hard to compare.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
:worms:


It's personal choice.


I like MIT/zlib style licenses.

You will find people enthuse about stuff and whatever. Pick the license other people in the community use.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
It depends on what you want people to do with it. If you don't give a poo poo then go for BSD. If you do want them to contribute any modifications back then use an lgpl.

If it's a library and you want people to use it, then you really shouldn't release it as GPL. lgpl, Apache or BSD are more appropriate and will help in convincing others to use it.

edit: This question has some good commentary. http://stackoverflow.com/questions/40100/apache-licence-vs-bsd-vs-mit

Janitor Prime fucked around with this message at 00:44 on Sep 25, 2010

Vanadium
Jan 8, 2005

If you do not release your thing under AGPL v3 you are literally Steve Ballmer

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Meat Treat: if you don't give a poo poo, you really ought to use the WTFPL.

shrughes
Oct 11, 2008

(call/cc call/cc)
Use the AGPLv3 unless you want to be a shmuck, and don't allow people to apply later versions of the AGPL.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
I would say dual license under the AGPLv3 and old-style BSD (w/ advert clause).

Vino
Aug 11, 2010
Okay so I picked up Visual Studio 2010 recently. The Express feature was enough for my needs so I didn't even pirate it! It's really nice and the new intellisense actually kinda works half the time. Except one of my favorite features has been removed. It used to be that if I double clicked or ctrl-clicked on whitespace, it would select the whitespace and not any of the text surrounding it. That was pretty pro and now it's gone and I can't figure out how to get it back. I looked around in the options a bit but maybe I'm blind and I didn't see any options for it. I also googled a bit but how do you google for something like that? I certainly can't. Anybody have any clue?

Opinion Haver
Apr 9, 2007

If you use the GPL for a library you're literally the worst person.

Actually if you use the GPL or anything like it at all you're the worst.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The application I'm going to be open-sourcing is a Windows app that can't really be used a library. Here's my SH/SC thread about the app.

The two things I'm concerned about is getting credit for my work, and I think it'd really suck if someone just packaged up my code and sold it as their own.

edit: added "as their own".

Thermopyle fucked around with this message at 03:10 on Sep 26, 2010

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Thermopyle posted:

I think it'd really suck if someone just packaged up my code and sold it.

There aren't any open source licenses that prevent this; to qualify as an open source license, a license must not prevent people from redistributing the software even if they do so by selling it. This is important enough that it's in the very first sentence of the Open Source Definition, and is generally held by all other major definitions of open source licenses, such as the DFSG.

If you don't want your software to be redistributed for profit, you may want to consider the CC-BY-NC-SA license or some similar more traditional copyright. Keep in mind that this will have a huge effect on people being willing to contribute to your codebase, though.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

ShoulderDaemon posted:

There aren't any open source licenses that prevent this; to qualify as an open source license, a license must not prevent people from redistributing the software even if they do so by selling it. This is important enough that it's in the very first sentence of the Open Source Definition, and is generally held by all other major definitions of open source licenses, such as the DFSG.

If you don't want your software to be redistributed for profit, you may want to consider the CC-BY-NC-SA license or some similar more traditional copyright. Keep in mind that this will have a huge effect on people being willing to contribute to your codebase, though.

I'm sorry, I should have said "sold it as their own".

LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!
Are there any JavaScript syntax highlighters that can take streaming text as input and output a stream of recognized tokens? All the JS ones I've seen so far take a whole file in memory and just process it at once.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'm getting fed up with scons for a C++ project. Since I haven't been able to get any advice on how to structure a project using scons, I have been just trying to get it to do what I need to do in the current structure, and trying to come to a better understanding as I go. I think I've run into a situation I can't seem to resolve in any good way.

Say that within this project I want to produce multiple binaries, using source files that are included in many of the binaries. Right here I have a collision problem where scons notices multiple targets referring to the same object file, and it shits itself.

ok then, have a different build directory per target. However, one file in common is referred to as a relative path in the source list, notably that current form, it goes "../some/path/file.cpp." So it goes running up into there to try to compile and collides. I can't just throw the build directory in front of that either.

Another thing is that these build directories are pooping out all over the source file system, which I didn't think was the point, so generally how do people handle this in scons? Assume I want to have multiple targets so that I can run things like unit tests and basic integration tests. I first though maybe if I had a root build directory I could resolve some things, but then I realize that two targets looking at the same build directory referring to the same source will still end up colliding.

For now I'm just selectively commenting and uncommenting code in the scons files as I desire to build different things, but I am hoping to get into something that is much more robust. I do like the idea of removing build files from the source tree.

litghost
May 26, 2004
Builder

Rocko Bonaparte posted:

I'm getting fed up with scons for a C++ project.

Use CMake. CMake provides out of source builds by default. The exception is if you use add_custom_command, you need to make sure your output goes to the binary directory.

In your particular problem it could be as simple as:

In parent dir:
code:
add_subdirectory(test)
add_definition(-DSOMETHING)
add_subdirectory(test "test2")
remove_definition(-DSOMETHING)
add_definition(-DSOMETHINGELSE)
add_subdirectory(test "test3")
or maybe
code:
add_subdirectory(test)
set(FLAG 1)
add_subdirectory(test "test2")
set(FLAG 2)
add_subdirectory(test "test3")
This parses the same build script 3 times, each time placing it in a separate build directory. You would need to make sure they get unique target names, but it does what you would expect. This works on a directory basis.

If you need to change the files in the target you can do that too.

Oh and repeating the same source in multiple targets, the object files do not collide, and the object files are consider separate dependencies.

litghost fucked around with this message at 15:55 on Sep 26, 2010

ufarn
May 30, 2009
This is pissing me off; I've spent too many hours staring at my code, and I remembered the nice advice I've received in here.

In SML (Moscow ML), a function is supposed to convert a list of elements [x1, x2, x3, x4, ...] to a list of grouped elements [(x1, x2), (x3, x4), ...].

I wrote a function that I believed solved this, but couldn't know for sure, because I got a Warning: pattern matching is not exhaustive. However, running the function shows that it does in fact do what I want it to. Now I just need to figure out the problem.

The code:
code:
fun group [] = []
  | group (x::y::ys) = (x, y)::combine(ys)
The error seems to point towards the first line with the termination condition. The error log is not very elaborate, and I'm not too far into the course to know how to construe the solution from the error logs yet.

ufarn fucked around with this message at 16:09 on Sep 26, 2010

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

ufarn posted:

This is pissing me off; I've spent too many hours staring at my code, and I remembered the nice advice I've received in here.

In SML (Moscow ML), a function is supposed to convert a list of elements [x1, x2, x3, x4, ...] to a list of grouped elements [(x1, x2), (x3, x4), ...].

I wrote a function that I believed solved this, but couldn't know for sure because I got a Warning: pattern matching is not exhaustive. However, running the function shows that it does in fact do what I want it to. Now I just need to figure out the problem.

The code:
code:
fun group [] = []
  | group (x::y::ys) = (x, y)::combine(ys)
The error seems to point towards the first line with the termination condition. The error log is not very elaborate, and I'm not too far into the course to learn how to construe the solution from the error logs yet.

I'm not too up with ML, but what about the case of a one-element array?

ufarn
May 30, 2009

Jonnty posted:

I'm not too up with ML, but what about the case of a one-element array?
The premise is that the list always has an even number of elements. As such, I assumed that it wouldn't be something that needed to be addressed.

I could be wrong.

BigRedDot
Mar 6, 2008

Another vote for cmake, in 20 years it's the best platform detection/build system I've run across. Out-of-tree builds, flexible configuration, pretty output, correct dependencies for build-time generated subtargets, simple config files for simple cases.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

ufarn posted:

The premise is that the list always has an even number of elements. As such, I assumed that it wouldn't be something that needed to be addressed.

I could be wrong.

You know that, but ML doesn't, so it complains. A single-element array could conceivably be passed in, whether you lie it or not.

ufarn
May 30, 2009

Jonnty posted:

You know that, but ML doesn't, so it complains. A single-element array could conceivably be passed in, whether you lie it or not.
Hmm. What would be a good rule to address that?

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

ufarn posted:

Hmm. What would be a good rule to address that?

I don't know what error-handling is like - you could look into that - or you could devise a default strategy for arrays of single values - perhaps you could just return them as they are, or return something like [(x)] or [(x, 0)] (though the last one would probably be more trouble that it's worth). Think about typical use-cases and design it based on what would be useful.

ufarn
May 30, 2009

Jonnty posted:

I don't know what error-handling is like - you could look into that - or you could devise a default strategy for arrays of single values - perhaps you could just return them as they are, or return something like [(x)] or [(x, 0)] (though the last one would probably be more trouble that it's worth). Think about typical use-cases and design it based on what would be useful.
I chose to let it throw an exception, and it worked! Thanks a million.

An ML programmer I wasn't meant to be.

Vino
Aug 11, 2010
CMake is nice but I just wish that the markup language for it would be a little bit less WTFey. It was kinda hobbled together as they went along with no real standards or design thought into how to do things, and for large projects it starts to get unwieldy. Works great for little stuff though.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'm wary to make the change because I switched to scons from make due to initial problems. I wouldn't want to jump build systems every time one of them gives me a problem. I figure there's a way for scons to handle this that I don't know.

BigRedDot
Mar 6, 2008

Vino posted:

Works great for little stuff though.
Like KDE and VTK...

Vino
Aug 11, 2010
Never said it doesn't work well for big stuff too. It just gets a bit difficult to work with. I had a job once where I had to make a mess of cmake scripts for a huge project and do some special stuff that I don't want to remember anymore, me and Bill Hoffman exchanged more than a few emails at the time.

MrMoo
Sep 14, 2000

BigRedDot posted:

Another vote for cmake, in 20 years it's the best platform detection/build system I've run across. Out-of-tree builds, flexible configuration, pretty output, correct dependencies for build-time generated subtargets, simple config files for simple cases.

It's cute, especially for the administrator, but it has poor platform support and unbelievably lovely for modifying for even basic stuff like PIC enabled static libraries.

The CMake team aren't too hot at supporting the versions in stable Linux distributions so you end up with significant changes between releases that really doesn't make CMake look remotely useful.

MrMoo
Sep 14, 2000

Rocko Bonaparte posted:

Another thing is that these build directories are pooping out all over the source file system, which I didn't think was the point, so generally how do people handle this in scons?

You can check out what I have done, it certainly could be better but I don't know how,

http://code.google.com/p/openpgm/source/browse/#svn/trunk/openpgm/pgm

Autoconf isn't reliable enough for this project so I have one SConstruct for each compiler. There are plenty of SCons bugs that are tedious to workaround.

Removing flags is lovely and I have an annoying problem managing external dependencies such as Google Protobufs.

shrughes
Oct 11, 2008

(call/cc call/cc)
I'm trying to teach myself a bit about concurrency. I'm trying to write a simple readers-writer lock out of basic mutexs. Here is the first version I wrote. Is this reasonable?

code:
// the declaration of the mutex that we're using
struct Lock {
    void acquire(); // can block
    void release();
};



struct RWLockStarvation {
  private:
    Lock writeLock;
    int numReaders;
  public:
    void acquire_read() {
      top:
        writeLock.acquire();
        numReaders = numReaders + 1;
        writeLock.release();
    }
    void release_read() {
        writeLock.acquire();
        numReaders = numReaders - 1;
        writeLock.release();
    }

    void acquire_write() {
      top:
        writeLock.acquire();
        if (numReaders != 0) {
            writeLock.release();

            thread_yield();
            goto top;
        }
    }
    void release_write() {
        writeLock.release();
    }
};
I figured that it was technically correct (is it?), but it could lead to write starvation. Here is a workaround to fix that problem.

code:
struct RWLock {
  private:
    Lock writeLock;
    int numReaders;
    Lock writeWaitingLock;
    int numWaitingToWrite;
  public:  
    void acquire_read() {
      top:
        if (numWaitingToWrite == 0) {
            writeLock.acquire();
            numReaders = numReaders + 1;
            writeLock.release();
        } else {
            thread_yield();
            goto top;
        }
    }
    void release_read() {
        writeLock.acquire();
        numReaders = numReaders - 1;
        writeLock.release();
    }

    void acquire_write() {
        writeWaitingLock.acquire();
        numWaitingToWrite = numWaitingToWrite + 1;
        writeWaitingLock.release();
      top:
        writeLock.acquire();
        if (numReaders != 0) {
            writeLock.release();

            thread_yield();
            goto top;
        }
        writeWaitingLock.acquire();
        numWaitingToWrite = numWaitingToWrite - 1;
        writeWaitingLock.release();
    }
    void release_write() {
        writeLock.release();
    }
};
Is that reasonable?

Also, is it reasonable to express thread blocking by spinning through a loop that calls thread_yield every time through? Is there a better way to express waiting?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Your first version looks correct except for the starvation issues. You noticed the write-starvation; there's also a remote possibility of read-starvation depending on the underlying lock implementation, if for some reason two writer threads kept trading the lock.

The second version again looks correct, but (1) you can use atomic operations instead of a second lock, and (2) read-starvation is now very likely if there's dense competition for the write lock.

pthread_yield in a loop has the disadvantage of keeping the CPU active if the current lock-holder is waiting on I/O. It's probably better to use a condition variable, which might have scheduler integration.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

MrMoo posted:

You can check out what I have done, it certainly could be better but I don't know how,

http://code.google.com/p/openpgm/source/browse/#svn/trunk/openpgm/pgm

Autoconf isn't reliable enough for this project so I have one SConstruct for each compiler. There are plenty of SCons bugs that are tedious to workaround.

Removing flags is lovely and I have an annoying problem managing external dependencies such as Google Protobufs.
After looking over things I think I figured out in more detail what my problem is with scons. I don't know if you have a similar thing cooking in your project but I'll see tonight. The problem is that I will have two programs with their own main() functions defined. However, one program uses the source of the other. Normally I'd get an error of multiple definition of main, so I wrap main in each of my programs with a preprocessor directive. This creates two different rules for compiling one of the programs (with main and without), and it pukes.

I figure I should put each in a build directory but I don't know how to set up that hierarchy; the problem is that I refer to source that's above the current source tree. Do you know the proper way to do that?

Say I have right now:

code:
sources = Split("""
lalala.cpp
foofoofoo.cpp
../ugly_dependency
""")
I know with build directories I could just prepend build/ on most of those, but what about ../ugly_dependency?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The obvious solution is to just move the shared code into a separate file rather than relying on stupid preprocessor hacks.

MrMoo
Sep 14, 2000

It sounds like unit testing, I managed to get Scons to cope with that. Basically make all the names #define macros then #include the source.

If you want to rebuild the same file with multiple options, clone the environment and set new object suffix or prefix.

Farchanter
Jun 15, 2008
Hey, I'd appreciate any help that you guys would be willing to share here.

A bunch of people and I are working on a game as a quasi-hobby thing. We've all got decent-ish programming experience, but we feel that what we're looking at doing would be particularly well-suited for being optimized for dual monitors. Trouble is, we're not sure how to do that. Is there a way to do that in either ActionScript or, especially, Java? If it's a huge pain we'll start looking in different directions.

Thanks a bunch in advance.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Farchanter:

In Java, you should be able to access screens via GraphicsEnvironment.getScreenDevices(). Unfortunately, in my experience this doesn't always work properly. On laptops, for example, I often just get the primary display. Your mileage may vary.

gib
Jul 14, 2004
I am probably Lowtax
How do those of you using smaller laptop monitors (1366x768 for example) and Windows manage your screen real estate when programming? Any particular fonts, editors, layouts, etc? Do you use desktop switchers / virtual desktop apps? If so, which ones?

gib fucked around with this message at 11:34 on Sep 29, 2010

Vino
Aug 11, 2010
Since when is 1366x768 small? I must be old.

Anyway, I bought a second 30" monitor that I run at 1440x900. At Tiger Direct it only cost me some $200. Between the original and this one I have more than enough space.

I know that doesn't answer your question, but.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

gib posted:

How do those of you using smaller laptop monitors (1366x768 for example) and Windows manage your screen real estate when programming? Any particular fonts, editors, layouts, etc? Do you use desktop switchers / virtual desktop apps? If so, which ones?

Gratuitous use of alt-tab. It's the only way. I'm stuck at 1280x800, it's the only time I wish I had the 15" MBP instead of the 13".

Adbot
ADBOT LOVES YOU

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Vino posted:

Since when is 1366x768 small? I must be old.

1024x768 has been pretty popular for...15 years now?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply