|
I want to write a program for my research group that will let us know which of our workstations are under heavy load so we can tailor our simulations appropriately. The picture I have in my head is a service that runs on each simulation workstation (Windows) and can report who is running how many instances of this simulation software we use and how many cores, gb of ram, etc. they are using and it will all be displayed on a web interface so everyone has access to it. My main question is what language(s) would most easily facilitate this kind of thing in a Windows environment? I worked as a software engineer for many years but I only used C# and computational languages to make desktop software and I have zero experience with anything web based. I don't mind learning a new language or two if that is the best way to go about it.
|
# ? Jul 12, 2015 03:08 |
|
|
# ? May 15, 2024 07:50 |
|
C# is absolutely fine for both web stuff and desktop.
|
# ? Jul 12, 2015 03:15 |
For that sort of administative-ish task, consider Power Shell.
|
|
# ? Jul 12, 2015 06:53 |
|
IratelyBlank posted:(Windows) and can report who is running how many instances of this simulation software we use and how many cores, gb of ram, etc. they are using and it will all be displayed on a web interface so everyone has access to it. You want to do this in powershell, enable psremoting on your remote computers/workstations/servers (command is "Enable-Psremoting" and then hit "a") it would be something like this run on your webserver, with it (the powershell script running what, every 2 minutes via windows task scheduler code:
code:
code:
We have a powershell thread http://forums.somethingawful.com/showthread.php?threadid=3286440 double edit: where $servers is an array (basically an ArrayList but powershell lets you get super lazy) of server names imported from a CSV file, $csv = Import-CSV -path c:\wwwroot\mysimsdashboard\myservers.csv; foreach ($line in $csv){$servers += $csv.server} Hadlock fucked around with this message at 07:35 on Jul 12, 2015 |
# ? Jul 12, 2015 07:21 |
|
Does anyone have a good article explaining the pros and cons of the Single function exit point practice? My teacher for most of my classes had us doing it that way, but she also started coding when they had to reserve time to compile their code. I don't see many other people using it, so I'm wondering why.
|
# ? Jul 15, 2015 19:50 |
Pros: Cons: - Need to introduce additional flags and conditionals to prevent flow from entering code not desired - Incompatible with exceptions - Pre-condition checks that would cause an early return instead cause pyramid code syndrome
|
|
# ? Jul 15, 2015 19:57 |
|
Okay, I'll break that habit, then. Why did it originate? Was there some sort of technical limitation decades ago?
|
# ? Jul 15, 2015 20:15 |
|
Resource cleanup.
|
# ? Jul 15, 2015 20:18 |
|
I don't have an article handy, but the pros that you will most often see are that it makes error cleanup easier and that it ostensibly makes control flow easier to follow. The cons that you will generally see are that it makes control flow harder to follow by requiring a bunch of conditionals to be added. Consider the following function:code:
The single-point-of-return version might look something like this: code:
The goto solution might look something like code:
Blotto Skorzany fucked around with this message at 20:23 on Jul 15, 2015 |
# ? Jul 15, 2015 20:20 |
|
One of the big ideas of Structured Programming was single-entry, single-exit subroutines, where all jumps into a subroutine went to a single entry point, and all jumps out came from a single exit point. The first half was such a good idea that most programming languages don't even support multiple entry points into functions, and the second half got pulled along for the ride despite being much less useful.
|
# ? Jul 16, 2015 01:44 |
|
There's nothing wrong with functions having multiple points of entry either, given reasonable variable scopage and rules about mandatory variable initialization.
|
# ? Jul 16, 2015 01:55 |
|
I recently got access to a major proprietary codebase from a major hardware vendor that uses single-exit, Yoda style, custom defines for every constant, and requires braces around every block.C++ code:
|
# ? Jul 16, 2015 02:54 |
|
Suspicious Dish posted:I recently got access to a major proprietary codebase from a major hardware vendor that uses single-exit, Yoda style, custom defines for every constant, and requires braces around every block. I don't see anything questionable about forbidding magic numbers or requiring mandatory braces, and Yoda style is hardly a horror.
|
# ? Jul 16, 2015 03:02 |
|
Single point of exit is nice when you're debugging, you can put just one breakpoint to see what the function returns.
|
# ? Jul 16, 2015 03:08 |
|
omeg posted:Single point of exit is nice when you're debugging, you can put just one breakpoint to see what the function returns.
|
# ? Jul 16, 2015 03:27 |
|
omeg posted:Single point of exit is nice when you're debugging, you can put just one breakpoint to see what the function returns. Breakpoint at function entry, step out, inspect returned value?
|
# ? Jul 16, 2015 03:36 |
|
GrumpyDoctor posted:I don't see anything questionable about forbidding magic numbers or requiring mandatory braces, and Yoda style is hardly a horror. I find it uncomfortable and hard to read. Here's more of their code style (this one is a public function from a GPL source dump, with names changed) C++ code:
|
# ? Jul 16, 2015 03:41 |
|
Sedro posted:I've always wondered why debuggers can't just show me Good ones can and do.
|
# ? Jul 16, 2015 05:00 |
|
Volmarias posted:Breakpoint at function entry, step out, inspect returned value? If the returned value is wrong (type wise) you can get yourself stepping into an exception handler before the caller gets control.
|
# ? Jul 16, 2015 11:38 |
|
22 Eargesplitten posted:Okay, I'll break that habit, then. Why did it originate? Was there some sort of technical limitation decades ago? Like "GOTO Considered Harmful", it's a relic of the war between structured and unstructured programming practices -- a war won so completely by the structured programming side that these days it's hard to believe it even happened. The original argument wasn't "one point of return" vs. "multiple points of return"; it was "functions and blocks" vs. "just use globals everywhere and CMP/JMP for all flow control". A lot of the arguments made by the structured programming camp are rooted in the structured program theorem, which -- among other things -- forbids both multiple entries and exits from a function and "unstructured jumps" (goto/break/continue). These days we're no longer working in assembler, and most languages have structured programming woven into their design even if they have features -- like multiple return points in a function, coroutines, or "break" -- that mean they don't strictly conform to the Böhm-Jacopini theorem. But you still get people slavishly repeating the arguments of the structured programming war without understanding why they were necessary at the time or why, today, they often are not.
|
# ? Jul 16, 2015 12:30 |
|
Suspicious Dish posted:Here's more of their code style (this one is a public function from a GPL source dump, with names changed)
|
# ? Jul 16, 2015 15:03 |
|
ToxicFrog posted:Like "GOTO Considered Harmful", it's a relic of the war between structured and unstructured programming practices -- a war won so completely by the structured programming side that these days it's hard to believe it even happened. Looking that whole thing up, that makes sense. My teacher also taught us never to use GOTOs, and any global variables had to be thoroughly defended as necessary. The one case I remember her allowing it in was when someone used multithreading to clone Pipe Dream for a final project. She seemed old enough to have been in college in the 80s or late 70s,and I think she had taught her whole career. Are GoTos still considered bad? I read up on Google's Java standards, since I want to start coding in what at least someone would consider best practices, but none of that was brought up. I am just now realizing how far I have to go before I'm good enough to win anyone over with a portfolio. It's probably not even worth putting any of my current work in the portfolio.
|
# ? Jul 16, 2015 21:41 |
|
22 Eargesplitten posted:Are GoTos still considered bad? I read up on Google's Java standards, since I want to start coding in what at least someone would consider best practices, but none of that was brought up. The use of goto isn't going to be addressed in a lot of coding standards documents because the languages in question don't have it. It's a relic of an old time, and will eventually be forgotten.
|
# ? Jul 16, 2015 21:51 |
|
Ah, okay. This is one of those times that starting on C++ gives me a weird outlook, because C++ still has it.
|
# ? Jul 16, 2015 21:55 |
|
22 Eargesplitten posted:Looking that whole thing up, that makes sense. My teacher also taught us never to use GOTOs, and any global variables had to be thoroughly defended as necessary. The one case I remember her allowing it in was when someone used multithreading to clone Pipe Dream for a final project. She seemed old enough to have been in college in the 80s or late 70s,and I think she had taught her whole career. As far as Java is concerned, goto doesn't exist. I've never done it, but I imagine that the only arguably sane use for goto today is to explicitly break out of nested loops. It's very complex and confusing for human beings to follow since without some sort of hierarchy we lose the plot real quick.
|
# ? Jul 16, 2015 21:57 |
|
22 Eargesplitten posted:Are GoTos still considered bad? I read up on Google's Java standards, since I want to start coding in what at least someone would consider best practices, but none of that was brought up. Goto is not considered bad (by non-morons) at all. For one, goto statements in modern languages are function-local, not the global beasts of yore. Second of all, prohibiting goto is reasonable for a teacher in some CS intro class to do, because students need to learn how to use control structures. They are the right way to structure your code and your thinking, with, perhaps, some exceptions. One exception is for error cleanup in C. Another is if you've got some tail-recursive function, and you want it to not actually recurse. It can be quite clear to put a label at the top, set the parameters to their new values, and use a goto statement. Sometimes, refactoring that to a while loop is a worse option, like if there'd be nested while loops and you'd need to break out of one. For example, if you're recursing down a tree with arbitrary branching factor. In general, breaking out of nested while loops is an appropriate choice for goto statements. "Labeled break statements" are possible in some languages, but these are not a better option. Sometimes also, a "break to success" idiom is appropriate: code:
code:
|
# ? Jul 16, 2015 22:12 |
|
^ dougdrums posted:As far as Java is concerned, goto doesn't exist. I've never done it, but I imagine that the only arguably sane use for goto today is to explicitly break out of nested loops. It's very complex and confusing for human beings to follow since without some sort of hierarchy we lose the plot real quick. Java's closest thing to goto only works for breaking out of nested loops. You can label loop constructs and break/continue them explicitly. Another thing goto is reasonable for is resource cleanup in C, since you might allocate a dozen buffers throughout a function, and return early at any point. Instead of returning immediately, you assign a result variable and goto a cleanup section that does all of your frees or whatever and then returns. This is more of an argument as to why you shouldn't use C, though, since C++'s RAII removes all of this nonsense.
|
# ? Jul 16, 2015 22:15 |
|
I also like Go's defer for the "goto for error cleanup without exceptions" case.
|
# ? Jul 16, 2015 23:17 |
|
ultrafilter posted:The use of goto isn't going to be addressed in a lot of coding standards documents because the languages in question don't have it. It's a relic of an old time, and will eventually be forgotten. My favorite thing about goto is that apparently PHP added it in 5.3.0, and before that you had to use a library or something. PHP, the archetype of bad languages, didn't have GOTO initially because even they understood how bad it was.
|
# ? Jul 16, 2015 23:44 |
|
sarehu posted:That's just a more convoluted way to do the same thing Nah it's not. That's perfectly fine code. Using a flag variable is the way that most people will naturally reason about the problem. Just for the record I don't even hate the goto here, I think that looks ok, but not particularly "whoa that's so amazing, I wish every modern language had goto so I could be expressive like that!".
|
# ? Jul 16, 2015 23:59 |
|
This question may be more IT-focused but I'm willing to try any tool/language at this point: Can anyone offer advice on printing PDFs to network printers? My goal is to regex a text file, get a string, and print a PDF to a specific network printer based off that string. Right now my current solution is having powershell first make the network printer be the Default Printer for my system, then print to default printer. Clunky, slow and prone to hiccups I think. This will be on a Windows 7 computer.
|
# ? Jul 17, 2015 01:10 |
|
Hughmoris posted:This question may be more IT-focused but I'm willing to try any tool/language at this point: Can anyone offer advice on printing PDFs to network printers? powershell? code:
https://gregcaporale.wordpress.com/2012/01/18/powershell-to-print-files-automatically/ https://technet.microsoft.com/en-us/magazine/2008.09.windowspowershell.aspx
|
# ? Jul 17, 2015 01:22 |
|
darthbob88 posted:My favorite thing about goto is that apparently PHP added it in 5.3.0, and before that you had to use a library or something. PHP, the archetype of bad languages, didn't have GOTO initially because even they understood how bad it was. If anything, this is an argument that GOTOs are good.
|
# ? Jul 17, 2015 02:14 |
|
sarehu posted:Goto is not considered bad (by non-morons) at all. code:
Honestly it's probably better for a language to have some kind of goto construct and encourage its use sparingly, than not to and force folks to to use flag variables, do-while loops, nested-breaks, or non-exceptional exceptions in situations when none of those things is the most natural way to implement the logic. Some folks also have a rule that "forward gotos are OK but backwards ones are not", but the retry idiom is a good example of a reasonable backwards goto.
|
# ? Jul 17, 2015 03:28 |
|
Hadlock posted:powershell? Thanks for the resources. Unfortunately, from what I can gather the "get-content" command just returns gibberish when you use it on a PDF. I actually used that Greg Caporale resource for the "switch network printer to be default printer -> then print" idea.
|
# ? Jul 17, 2015 04:00 |
|
I'm writing some code to break up a large file into smaller files, but I'm having a hard time wrapping my head around the checks. Here's what the large file's format looks like, with specific markers at the end of each line:code:
code:
|
# ? Jul 17, 2015 23:29 |
|
I don't suppose anyone is aware of a free reverse image search API? My friend's photos keep getting taken from his flickr account and used without attribution by commercial websites and it's we'd like to get an idea of just how often this is happening.
|
# ? Jul 17, 2015 23:49 |
|
EAT THE EGGS RICOLA posted:I don't suppose anyone is aware of a free reverse image search API? My friend's photos keep getting taken from his flickr account and used without attribution by commercial websites and it's we'd like to get an idea of just how often this is happening. I believe Google's Custom Search API can do this.
|
# ? Jul 18, 2015 00:06 |
|
kedo posted:I believe Google's Custom Search API can do this. Yeah, it handles 100/day for free. It's not really a time sensitive thing so it can just run for a week or month or whatever.
|
# ? Jul 18, 2015 00:23 |
|
|
# ? May 15, 2024 07:50 |
|
Not a question, but I ran across a paper that looks interesting, and I don't know of any better place to post it. Punctuated equilibrium in the large scale evolution of programming languages quote:Here we study the large scale historical development of programming languages, which have deeply marked social and technological advances in the last half century. We analyse their historical connections using network theory and reconstructed phylogenetic networks. Using both data analysis and network modelling, it is shown that their evolution is highly uneven, marked by innovation events where new languages are created out of improved combinations of different structural components belonging to previous languages. These radiation events occur in a bursty pattern and are tied to novel technological and social niches. The method can be extrapolated to other systems and consistently captures the major classes of languages and the widespread horizontal design exchanges, revealing a punctuated evolutionary path.
|
# ? Jul 18, 2015 02:58 |