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
Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Vanadium posted:

Now if only someone would take all the cool features and put them into a useful language. :c00lbert:

That's pretty much what every language developement in the last 40 years has been (except for the "all").

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Sgt. Raisins posted:

I guess COC is a good place to put this question.

There is a site with the same theme as http://getsatisfaction.com/ only you vote on what people want with points. It has the same 'Feedback' button and all.

That isn't a question.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Ringo R posted:

Web design question:
Is there a way to increase scroll bar size using CSS or whatever? Same effect as going to (in Windows) Windows color and appearance / Appearance / Advanced and then increasing scroll bar size. It only has to work in IE7.

I guess you could completely reimplement the scroll bars from scratch in javascript and then make them look however you want.

Don't do this.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Linq in C#.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Changing it to "at least once" has no effect on the problem. Any graph can be transformed into one where the triangle inequality holds (i.e. ∀x∀y∀z: d_{xy}+d_{yz} > d_{xz}), and once that is done the optimal path will obviously not include visiting any nodes twice, as A->B->A->C could be replaced with A->B->C without increasing the length.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
What exactly do you gain from validation that says that asdjfhklsdjfh@sdjhfiuyiulkjdhf.com is a valid email address?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

shrughes posted:

Nothing guarantees it's a valid email address. It just shows that it's not garbage.
How is the result of mashing keys for a few seconds then tossing in @ and .com at the end not garbage? How would you ever gain something from treating that as an email address?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

sentientcarbon posted:

Really? I'm not talking 'professional-level mastery', I'm talking 'roughly competent enough to get through a higher-level undergrad compsci course' or so.

I was expecting something on the order of a couple of years, but admittedly I have no idea.
It's quite possible to get through most undergrad cs programs without being competent at all, so zero days.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
3652425 * 2009 is significantly larger than 2^31, so it's overflowing and happening to end up negative.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

H0TSauce posted:

Yeah I used .bak as an insurance policy. It's annoying but it beats having a whackload of crap files. :)
If at any point you find yourself tempted to create a .bak file, you should check the files into a version control system of some sort instead.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Richard M Nixon posted:

the CS department has 3 intro CS classes that must be taken before you can move on to take whatever sort of programming you want (AI, embedded device, gui poo poo). That is 3 semesters of prereqs that are broken up as such: Class 1 is an intro to programming and goes from hello world to arrays. Class 2 goes from a review on arrays to very basic classes and functions, with pointers being the last thing covered. Class 3 is a review of memory and classes/functions, intro to modular programming, and fun things like inheritance, encapsulation, polymorphism, linked lists, trees, and the rest of the good and fun CS stuff. There is also a corequisite of discrete math I and II before any of those upper level CS classes can be taken.

Goddamn I am bored in school.
There's a programming class that doesn't even cover functions? :psyduck:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

RussianManiac posted:

True nerds take Latin not Japanese.
Latin was my favorite class in high school. Sadly I've forgotten 90% of it now.

Also, learning to read hiragana and katakana took me a weekend :smugdog:.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Internet Janitor posted:

In most languages with short-circuiting the bitwise operators don't short circuit, so that could occasionally be desirable. I can't think of an instance where that would make code clearer, though.
"Most" is a bit of an understatement. A short-circuiting bitwise operator would be like short-circuiting multiplication.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Nippashish posted:

In Java | and & are the non-short-circuiting versions of || and &&.
Compare 1 && 2 and 1 & 2.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Nippashish posted:

They're also bitwise operators when the operands are integral types. Maybe you should try them with boolean operands.
In many languages you often happen to be able to use + and * as non-short-circuiting versions of || and &&, but that doesn't make describing + and * as such in any way sane.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
C# 4.0 adds optional and named arguments for exactly that reason.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Working yes, readable probably not. f2c is basically just a compiler that outputs C instead of assembly or machine code.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

tractor fanatic posted:

This is a problem I'm kind of curious about :

If you had a computer that had the locations of all the stars in the galaxy, and then gave it a random picture of the sky from some point within the galaxy, what would the time complexity be for triangulating its exact position, if there are N stars in the galaxy, and K stars in the picture?
With just locations there's a horrifically large number of cases where it isn't solvable.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Orzo posted:

I almost made a thread out of this because it can turn into a pretty big discussion, but I'll try my luck here instead.

One of the things I ask interview candidates (C# application design, mostly) is an example of when they would use inheritance over composition. Nobody has given me a really good answer (they aren't necessarily supposed to get it 'right', it's just for discussion), and to be honest I'm not sure I have one myself. So, with the exception of deriving from third party base classes where required, where would you use inheritance over composition?
Never, except for when you have to. If it's possible to do something via composition, doing it via inheritance probably doesn't result in a sensible class hierarchy.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

hayden. posted:

I'm pretty new to coding so I don't really understand how http://www.reddwarfserver.org/ works with programs - but does using something like this licensed under GPL mean that the entire program (such as a game) would also have to be licensed under GPL?
If you plan to distribute the server you'll have to GPL that, but note that simply running a server yourself does not count as distributing it.

The supplied client libraries are BSD licensed, so you don't have GPL the game client.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Putty has a SFTP client. Most good GUI FTP clients support it too.

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.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Internet Janitor posted:

I propose "snake-loving". If an exception is thrown, you have the opportunity to examine and edit the callstack. When you make changes, the runtime modifies the sequence of calling classes so that it would have worked how you describe. Then just try it again.

Coming soon to a batshit scripting language near you.

I sort of want to implement this.

Actually I think I just want to think about how you'd do it but never actually write anything.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Well the obvious ultimate extension of the idea is a language where the only two operations are exception throwing and stack rewriting but I have a feeling that if one somehow found a way to make that work it'd be boringly similar to lambda calculus.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Let's imagine a hypothetical snake loving implemention in Python. There's a few obvious "practical" applications:

VB's greatest contribution to programming, On Error GoTo Next:
code:
try:
    ...
except Exception as e:
    frame = e.stack_frame
    while frame:
        # if there are any more statements in the current function, move to the next one
        if frame.current_statement < len(frame.statements):
            frame.current_statement += 1
            frame.resume()
        # otherwise go up a step in the call stack
        frame = frame.parent
    # no remaining statements after the one that failed so we win
    sys.exit(0)
Get rid of that annoying requirement to give variables values before using them:
code:
try:
    ...
except NameError as e:
    name = re.search("'([^']+)'", e[0]).group(1)
    e.frame.locals[name] = None
    e.frame.resume()
Of course, this'll usually just result in type erorrs instead, so we need to set up some automatic type conversion:
code:
try:
    ...
except TypeError as e:
    if re.search("is not subscriptable", e[0]) or re.search("does not support item assignment", e[0]):
        e.source = {}
        e.frame.resume()

    # tried to call a non-function
    if re.search("is not callable", e[0]):
        e.source = lambda *args: pass
        e.frame.resume()

    # wrong number of arguments
    match = re.search("takes exactly (\d+) arguments \((\d+) given\)", e[0])
    if match:
        if e[1] < e[2]:
            e.args = e.args[0:e[1] - 1]
        else:
            e.args.extend([None] * (e[1] - e[2]))
        e.frame.resume()

    # right number of args, wrong types
    for arg in e.args:
        if "int" in arg.expected_types:
            if arg.type == "string":
                arg.value = int(arg.value)
            else
                arg.value = 0
        elif "string" in arg.expected_types:
            arg.value = str(arg.value)
        # and so on
    e.frame.resume()

except KeyError as e:
    e.source[e[0]] = None
    e.frame.resume()
I guess this doesn't actually involve any callstack rewriting and so doesn't have much to do with snake loving but the idea of implementing weak typing via userland error handling is sort of amusing too. I suppose the snake-fucker way to do this would be to rewrite the call stack such that the variables are of the correct type (preferably introducing a lot of side effects in the process) instead of just directly "fixing" them.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Hilarious overzealous anti-XSS protection. iframe used to be filtered to YAMS for similar reasons.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

ToxicFrog posted:

I suspect that if you revise the algorithm to "if the start time is earlier than the latest recorded end time" rather than just the end time of the previous event, it'll work (and still be O(nlogn)), but I don't have a proof.
If those are ever not the same thing you would have already detected an overlap, as a non-overlapping sequence must have monotonically increasing end times when sorted by start times. The originally stated algorithm handles pseudorandom name's example correctly.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

pseudorandom name posted:

The question was "Does this specific job conflict with any other job in this set?" not "Does at least one job in this set conflict with another job?"
"It doesn't matter to me which job it is in conflict with which other job or how many other jobs" quite explicitly says the opposite. Of course, he does go on to contradict that so I guess I should not assume that when someone restates a problem five times that they will all say the same thing.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
They're proud that they haven't done a terrible enough job to break it in VMs.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
if something isn't worth checking into a vcs you should probably just delete it now as you've clearly decided that you'll never need it again

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Let the linker build the lookup table for you:

code:
#include <windows.h>

typedef void (*solution_function)(void);

__declspec(dllexport) void problem1(void) {
    ...
}

__declspec(dllexport) void problem2(void) {
    ...
}

int main(int argc, char **argv) {
    char func_name[8200] = "problem";
    HINSTANCE hinstLib = LoadLibrary(argv[0]);
    strcat(func_name, argv[1]);
    ((solution_function)GetProcAddress(hinstLib, func_name))();
    FreeLibrary(hinstLib);
    return 0;
}

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

cannibustacap posted:

Also, ideally, is there a way to get my C++ functions to talk with Java also? Specifically, I compile my Matlab code into C++ shared libraries, so I have the working .DLL's and .H files, but without some kind of shell, they won't work with Java.
In this specific case the simplest method is to pay a few thousand dollars for a Builder JA license.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Misogynist posted:

What's Scala good at?
Being less lovely than Java when you have to run on the JVM for whatever reason.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Taken too far it's really easy to end up with incomprehensible spaghetti code that might as well be using goto for everything.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
python's lovely lambda really isn't much of a problem because if your function needs to be more than just an expression it's probably worth giving it a name anyway

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
even if you never actually use it everyone should learn a lisp

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
which has been extended far beyond its original capabilities by people who had no idea what they were doing

so basically php but even worse

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Assuming that they've actually accepted external contributions and can't simply relicense the code, then the simplest method is to put the non-GPL code in a seperate program, ensure that the main program remains functional when the upload executable is missing, and don't use shared memory to communicate between the programs.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

pokeyman posted:

I'ma guess baquerd's confusing JavaScript and PHP there, and while I agree with you that it's unhelpful to make an array and then never use it as an array, there's nothing wrong with it.
Writing new Array() (or new Object()) in javascript is nearly always wrong. They're just there as a practical joke on people used to other languages.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The correct way to create arrays and objects in javascript is to use the literal syntax (i.e. var foo = {}; to create an empty object). The constructor syntax is slower, more verbose, and more prone to breakage if some rear end in a top hat defines a function named Array.

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