Wikipedia:Reference desk/Archives/Computing/2017 May 17

From Wikipedia, the free encyclopedia
Computing desk
< May 16 << Apr | May | Jun >> May 18 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 17[edit]

Best programming language to learn for someone with only expereince of writing windows batch scripts?[edit]

I can currently only write windows batch scripts that use a bunch of other peoples programs to acumplish various tasks. I would like to get into writing more complicated scripts that don't rely so heavily on pre-complied win32 exes for doing everything. What programming lanaguage would be best for me? I am not a smart person so high level programming is not something I feel capable of right now. I just want an easy to use language that can do everything windows batch scripting can do but with the ability to write more complex scripts with logic, functions and routeins and stuff that wouldn't be possible in windows batch. It needs to be able to run on Windows. Thanks for your time.

207.29.220.154 (talk) 11:57, 17 May 2017 (UTC)[reply]

C++. I would say C, but there is so much OOP now that C++ is just as good. If you are Windows-centric, you can go with C#, but I would still learn C++. 209.149.113.5 (talk) 12:03, 17 May 2017 (UTC)[reply]
  • Python. Hits the sweet spot between being useful and not too complicated. It's particularly good at being flexible across all tasks: most first encounter it as a better sort of Perl and a much better sort of shell script. It's also good for web server back ends, for general fun programming and teaching, and even for manipulating BigData or large scientific or statistical computing. As a language it's pretty straightforward, Beazley's book is a good cross-trainer for programmers from other languages. For absolute beginners, as Python is also popular in education there are a wide range of guides.
I'd recommend it highly over Java, C# or C++ as those three are too bloated these days to get started with easily.
Processing might also suit, as a more-accessible Java. Andy Dingley (talk) 13:06, 17 May 2017 (UTC)[reply]
It depends on your application, but Python is probably a good general choice. Especially if your goal is quick-and-dirty scripts for personal use. ApLundell (talk) 13:42, 17 May 2017 (UTC)[reply]
Until you mentioned VB.NET, I couldn't think of a worse choice than the C++ mentioned earlier. Andy Dingley (talk) 18:57, 17 May 2017 (UTC)[reply]
Every year, I have a class of students who think that C++ is the hardest and most useless thing they have to learn. At the end of the semester, they either flunk and continue to think that C++ is just a tool used for torture or they learn C++ and become better programmers in all other languages that they use - even Python. 209.149.113.5 (talk) 19:45, 17 May 2017 (UTC)[reply]
Andy, that was a nice try, but your haven't even come close to convincing me that your neckbeard is as full, luxurious and flowing as mine. (You were trying to compare nerd-penises, right? Because if you really believe that... <shudder>.) ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 22:29, 18 May 2017 (UTC)[reply]
Funny, but even funnier to me. The person who introduced me at a conference last weekend said, as best I can remember, "He doesn't need a neck beard. He's been programming professionally since the first Star Wars movie." I've been seeing a lot of kids with beards, but I am only just realizing that they are using beards as a silly alternative to getting a real education. It used to be that the kids got tons of certificates to avoid actually learning, but I guess beards are cheaper. 71.85.51.150 (talk) 23:04, 18 May 2017 (UTC)[reply]
IP, you should see Neckbeard. Ignore the socio-political views; while lots of MRMs and trolls are neckbeards, most neckbeards aren't MRMs or internet trolls. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 00:52, 19 May 2017 (UTC)[reply]
I have a decade as a commercial VB developer. It was useful in its day for developing Windows desktop apps with Windows GUIs, because nothing else could produce such an interface as quickly (but these days, who wants to build Windows desktop apps?). It is an awful language though: limited, obsolete and with a vile syntax for any sort of formal study. The idea of using it for teaching is horrible. Also it solves the wrong problem: avoiding semicolons is not any serious limitation to language learning. Past the first-steps level, it's not the trivial syntax that causes trouble for learning programmers.
One reason for recommending Python here (rather than Scala or even Scheme) is that it is just about the only language where functional programming can be applied by beginner or mid-level programmers. The need for a teaching language today is to provide an accessible (FOSS, cross-platform, low overhead, easy setup) environment with a vibrant community and to teach concepts of current interest, such as multiprocessing, functional programming, graphical visualisation, web platforms and ability to manage BigData scale data. Outdated concepts like class-based OOP are not so useful. Andy Dingley (talk) 08:43, 19 May 2017 (UTC)[reply]
In *your opinion* OOP is outdated. Functional programming is in. When I took a graduate study course in function programming in the 70s, McCarthy said that the future is functional programming, or, more precisely, he liked to say "You're doing it wrong!" Yes, functional programming is becoming useful, but it isn't paying the bills. In the last two years, I've had jobs programming in C, C++, Java, Scala, PHP, M, Ada, COBOL, and Lua. I haven't had any in Python. 209.149.113.5 (talk) 14:33, 19 May 2017 (UTC)[reply]
That's not what I wrote: class-based OOP. In the tradition of Eiffel, and by extension most of the successors, including MI as either the horrors of C++ or the interface-based approach of Java. Back in the day, "OOP" was presented as a massive exercise in taxonomy, where if only this huge "tree of life" could be built, then everything would be fine. That never worked. It was so inflexible that we even put up with MI to get round it.
Dynamic OOP, as Python offers (and as WP still has no useful content on), is different. It's much more useful. It's also scarily unpredictable, some say unreliable. Developing reliable commercial-grade Python is difficult and no-one knows how to do it properly yet. The implicit potential input domain for modules is vast, compared to their overt defined behaviours, and it's a big and current question for how to manage this, or automatically test it. But it's the way trends are going (it's so much faster to develop in such an environment), so we'd better learn sharpish. Andy Dingley (talk) 15:11, 19 May 2017 (UTC)[reply]
I agree that dynamic OOP is more useful than static OOP. Of course, I'm a LISP (and thus, CLOS) fan, so I might be a bit biased. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 15:14, 19 May 2017 (UTC)[reply]
ne reason for recommending Python here (rather than Scala or even Scheme) is that it is just about the only language where functional programming can be applied by beginner or mid-level programmers. You've just "convinced" me that you don't know anything at all about programming. Hello world can be made into a function in the majority of C-type languages with the addition of two lines (one of which is a single closing bracket). I literally learned functional programming in Visual Basic in 20 minutes before moving on to OOP, the day after I learned imperative programming in BASIC. I took a course in C the next semester. I've yet to ever need to use python for anything. I don't even use any tools written in python, and my only experience with it is on the servers of websites I access and a single test function I wrote in it while playing around a few years ago. That doesn't make it bad, mind.
I really don't understand your comments here because, to someone who writes code in a 3-6 different languages every week, (including writing and modifying lots of desktop apps, surprise surprise) your comments really sound like they come from someone who's never done any coding, but has read a few "angry programmer" articles on random blogs. I'm not saying that is the case. I'm sure you either write code as a part of your job, or that you used to. I'm sure you know a few things about coding, likely even a few things that I don't know. But your comments don't evince that, at all. I mean, the very logic of "language with easy-to-read syntax is a bad language to teach to new coders" is completely irrational, provided as it is without justification. Allow me to offer you some advice: When someone is soliciting suggestions for a language to use; don't start arguments with others who make suggestions, even if you strongly disagree with them. In this case, all it did was ensure that I have significantly less respect for your knowledge and social skills than I would have awarded a complete stranger. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 14:47, 19 May 2017 (UTC)[reply]
"I literally learned functional programming in Visual Basic in 20 minutes before moving on to OOP,"
No, you learned what a function is. Not the same thing at all. Although VB did at least have collection iterators, which are a start. Andy Dingley (talk) 15:14, 19 May 2017 (UTC)[reply]
No, I learned what a function is in high school, and had my memory of it refreshed 45 seconds into that 20 minute period. It really doesn't take long to go over some principles of functional programming, show why they exist and cover the basic features like return values and arguments. I would remind you that dictating to me how my own past experiences went when we both know you weren't there is even less convincing than the rest of your argument thus far. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 15:19, 19 May 2017 (UTC)[reply]
I'm not quite convinced that you got all the aspects of functional programming - check out higher-order function and first-class function. Functional languages typically allow you to define new (often temporary) functions at run time and capturing local contexts, allow you to pass functions around as parameters, and to return new functions (not function values) from functions. --Stephan Schulz (talk) 21:48, 19 May 2017 (UTC)[reply]
That's fine, because I didn't say I learned everything there was to know about functional programming in 20 minutes. I said I learned enough. I learned the basics, the concepts and the theory. I knew how to write and use functions after 20 minutes. I still have, and still use some of the functions I wrote with only 20 minutes of education on the subject. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 22:53, 19 May 2017 (UTC)[reply]
I think in choosing a language one has to think of its popularity in the community, if there are active forums with daily contributions, support by, in the OP's case, Microsoft, since he wants to stick with the Windows, power, samples availability, can it be ported to Linux, etc. I think C++ is an unbeatable winner in this contest. I've never learnt the Python though. --AboutFace 22 (talk) 16:38, 17 May 2017 (UTC)[reply]
Well, Python and most of its library are available cross-platform, and Python is both a lot easier to learn than C++, and much better at solving many simple problems. It also has a very vibrant community. Unless you need the speed, or need to interface nicely with existing code, there is little need to use C++ over Python. --Stephan Schulz (talk) 20:16, 17 May 2017 (UTC)[reply]
  • I don't know what the best choice is, but if a comfortable transition from Windows batch files is the most important factor, I think running the programs created by the OP, rather than running them through a graphical user interface or web browser, is important. It should also be easy to invoke programs and command-prompt commands from within the program. Jc3s5h (talk) 18:33, 17 May 2017 (UTC)[reply]
  • If you want something similar to 'batch' but with lots more, like functions, you could try a basic installation of Cygwin, which includes Bash and can run numerous other shells. -- zzuuzz (talk) 20:09, 17 May 2017 (UTC)[reply]
cmd /? | more --Hans Haase (有问题吗) 09:55, 18 May 2017 (UTC)[reply]


There has been a lot of talk lately about which programming language is best. The following should clear up any confusion.[Citation Needed]

The best programming language is, of course, the BEST programming language. BEST is a programming language that I developed to answer the frequently asked question "Which programming language is best?" once and for all.

BEST is an RFC2795-and-RFC2324-compliant Befunge-93[2] pseudocompiler written in x87 Malborge[3][7] with library calls to routines written in Microsoft[4] Visual BogusFORTH++[5] (!Xóõ edition)[9] that invoke various functions written in[6] Silbo Gomero{π} Reverse Polish Whitespace[1] (for clarity). It requires the GLaDOS operating system or RUM emulator.

I hope this helps...

References:

--Guy Macon (talk) 06:25, 19 May 2017 (UTC)[reply]

Is it possible to secretly exit a WhatsApp group?[edit]

So, a friend recently added me to her WhatsApp group and I started receiving in excess of 40-50 text and voice messages per day. We've always enjoyed a good relationship, but I quickly discovered her other friends are not my cup of tea. I'd like to leave the group, but understand if I do so WhatsApp will notify the rest of the group, and I don't want to offend her. Therefore, I want to know if there's a way to exit WhatsApp groups without notifying the other group members (and more importantly my friend), or if not, whether I can secretly stop the messages being delivered to my phone. I know it's possible to mute messages, but that doesn't stop them sitting on my phone and using up its memory. I've also read about an app named Group Xit, but since I'm an IOS user I don't think that would be usable since I understand it's an Android app. Can anyone offer some advice? 2A00:23C5:733F:BF00:5530:FA7A:5356:B2A2 (talk) 22:08, 17 May 2017 (UTC)[reply]

I'd be hesitant to trust secondary apps with that supposedly specific a function anyway.
According to this muting and deleting is effectively leaving. According to this, you can further turn off group alerts, though it seems to affect all groups (at least in older versions).
According to this, the latest Android versions have the option to turn off notifications for just one muted group. While you are using iOS, it may be worthwhile to update your copy of Whatsapp and see if that adds the same option. Ian.thomson (talk) 22:20, 17 May 2017 (UTC)[reply]

Extracting text from html with PHP[edit]

Resolved

Using PHP I want to extract from this webpage all of the text held inside the <div id="answer_content" tags, ie the block of text that begins "Wednesday 17 May. Normal deliveries and collections should take place in all parts of the UK today" etc. I have spent the past 3 hours looking over the manual pages and reading stackoverflow answers but sadly this is far too complex for my brain to make sense of. I have managed to figure out the following;

<?
$html = file_get_contents('https://personal.help.royalmail.com/app/answers/detail/a_id/5311');
$dom = new DOMDocument;
@$dom->loadHTML($html);

After that I'm at a loss for how to parse the "answer_content" tags and echo/print the contents. Any help would be greatly appreciated. Thank you — Preceding unsigned comment added by 36.66.242.101 (talk) 23:27, 17 May 2017 (UTC)[reply]

Well, if you do it by hand, you recursively traverse the DOM and whenever you find a div with the proper id, you spit out the content. I know nothing about PHP, but there may be service functions making the task easier. Take a look at this function and example - it shows you how to get a list of all nodes with a given tag (in your case div) and iterate over it. Then just check the id and spit the the contents out. Good luck! --Stephan Schulz (talk) 06:29, 18 May 2017 (UTC)[reply]
That is exactly the part I am struggling with. I've already spent hours looking over the getelementsbytagname and getelementsbyid pages but I simply cannot understand them. In all my tests the script either fails or just outputs the word "Array" with nothing else. I really need someone to spoon feed this to me with clear examples so I can see how it works and learn from it. I have reached my limit with trying to decipher the manual pages. Thanks for your time. Myphpbuko (talk) 08:38, 18 May 2017 (UTC)[reply]
You got the hard part done. All you need to do is pull out the divs and dump the textContent of those that have
 id=answer_content:
 $html = file_get_contents('https://personal.help.royalmail.com/app/answers/detail/a_id/5311');
 $dom = new DOMDocument;
 @$dom->loadHTML($html);
 $divs = $dom->getElementsByTagName('div');
 foreach($divs as $div)
   if($div->getAttribute('id')=='answer_content')
     print_r($div->textContent);
If you print_r($div) inside the for loop, you will see all the attributes of the div that you can play with. 209.149.113.5 (talk) 12:05, 18 May 2017 (UTC)[reply]
Thanks! This question was tempting me to learn PHP to answer it, and I really don't have time for that!  ;-) --Stephan Schulz (talk) 13:44, 18 May 2017 (UTC)[reply]
If you know C++ or something very similar like C# or Java, then you know about 95% of PHP. Just slap a $ in front of all your variables. 209.149.113.5 (talk) 16:28, 18 May 2017 (UTC)[reply]
Yes, but I suspect the Pareto Principle apples ;-). --Stephan Schulz (talk) 22:46, 18 May 2017 (UTC)[reply]

Perfect, thank you! Myphpbuko (talk) 15:13, 18 May 2017 (UTC)[reply]