Wikipedia:Reference desk/Archives/Computing/2017 August 30

From Wikipedia, the free encyclopedia
Computing desk
< August 29 << Jul | August | Sep >> August 31 >
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.


August 30[edit]

Java: at bytecode level, is try { super(...) } catch ... legal?[edit]

In bytecode for the Java Virtual Machine, is it legal for a constructor to catch Throwables thrown by the superclass's constructor, thus supplying the caller with a reference to an uninitialized object? In other words, would bytecode equivalent to the following Java code be legal if it didn't have to come from a standards-compliant Java compiler?

public class WithNonNullField {
  protected final Object o;
  public WithNonFullField(Object o) {
    if (o == null) {throw new NullPointerException("o can't be null in WithNonNullField constructor");}
    this.o = o;
  }
}
public class WithNullableField extends WithNonNullField {
  public WithNullableField(Object o) {
    try {
      super(o);
    } catch (NullPointerException ignored) {/* Lo and behold, this.o == null */}
  }
}

Given that the caught Throwable instances might include an IllegalAccessError, would doing this allow a class with only private constructors to be subclassed with public constructors in a JVM launched with -Xverify:none? (I know that at the bytecode level, a class with no access to the superclass's constructors can be generated to have no constructors at all, and can still be instantiated through the backdoors that Objenesis uses. However, neither it nor its subclasses can be deserialized from a standard ObjectInputStream if the super-constructor access check cannot be bypassed.) NeonMerlin 01:59, 30 August 2017 (UTC)[reply]

You can look here and here. Ruslik_Zero 19:21, 30 August 2017 (UTC)[reply]

Embed popular videos from YouTube channel[edit]

The following discussion is marked as answered. If you have a new comment, place it just below the box.

How to embed popular videos from my YouTube channel?--Joseph 12:57, 30 August 2017 (UTC)[reply]

Where? If you click on share between Add to and More under the uploader name of the video on Youtube desktop, a tab should open up below. By default this tab will be on share, but to the right on share in the tab there is an embed option and if you click on that there will be a text box with code. You can try copying this code to wherever you want to embed the videos, but depending on where you're trying to embed them, this may or may not work. If you click on show more in that tab, you will get more options for what you embed, but this still isn't going to help if you're not pasting the code somewhere where it will just work. If you directly control the webpage you're trying to embed them into and so can directly edit the HTML file, then it should work provided there isn't something weird in your HTML that will break it, and obviously you're still going to have to work out where to embed it. Please do not try to embed videos on wikipedia, it won't work and is not allowed. Nil Einne (talk) 17:07, 30 August 2017 (UTC)[reply]
Nil Einne I think you haven't read the question carefully. I know how to embed a particular video. And I know how to embed a playlist. What I need to get is, the script to embed most viewed (popular) videos of my channel as a playlist. Do you know how to do it?--Joseph 17:13, 30 August 2017 (UTC)[reply]

I did read your question, it's very unclear and my question did answer your question as originally posted. If you want want to embed popular videos from your Youtube channel, open up each popular Youtube video from you channel, follow what I said, and then paste the code into wherever you are trying to embed.

Your question is still unclear as you clarification has not helped. Where do you want this playlist which you've now brought up for the first time. Are you saying you want to embed a Youtube playlist if popular videos, or you just want to embed a bunch of popular videos on a site and call it a playlist? If the later, just do what I said, and add these videos to your website or whatever and call it a play list. If you want to add videos to a Youtube playlist and then embed the playlist, add them to the playlist and embed the playlist, I'm not sure why you need us to tell you how to do that. You claim you already know how to embed a playlist.

Are you saying you don't know how to add videos to a Youtube playlist? If so this has nothing to do with embedding so I have no idea why you even brought that up. If you want to add videos to a Youtube playlist, just click on 'add to' on the video page, and then choose a playlist or create a new one to add it to. If they're your own videos, you can also add them to a playlist in the Creator Studio simply by selecting them in the video manager then click the add to at the top. This even shows the view count and you can also sort by view count so you can easily select 'popular videos' whatever you mean by that.

Alternatively also from the Creator Studio, you can edit the playlist directly and add videos including your own videos in that way. You can even define rules to automatically add videos to the play list [1], although none of them involve view count. So if you want to automatically add videos over a certain view count to a playlist, you'll need to use third party software to do so. Even more so if you want to automatically add and remove videos to keep a playlist of a certain size with the most popular videos based on view count.

Incidentally I've tried to provide every single thing I could think of in relation to your question. If you want clearer answers you need to be clearer on what you're asking about.

Nil Einne (talk) 17:34, 30 August 2017 (UTC)[reply]

I still don't know why you're spending time explaining things I never asked for. Hope you know the meaning of embed (incorporate (a video or other item of data) within the body of a web page or other document). Hope you use YouTube. If you visit a channel, you could see a section Popular uploads, where the most viewed videos on that channel get listed up. That's the thing I'm talking here. I need to embed that into my blog. Here is an example code for embedding the latest videos of a channel.
<iframe width="600" height="340" src="http://www.youtube.com/embed?max-results=1&controls=0&showinfo=0&rel=0&listType=user_uploads&list=YOUR_CHANNEL_NAME_HERE" frameborder="0" allowfullscreen></iframe>
I'm not much experienced with coding and that's why I came here. Sorry, I can't explain any more than this.--Joseph 18:12, 30 August 2017 (UTC)[reply]
@Joseph please be aware that the verb embed has been used in English for over 200 years while YouTube has been around only 12 years. Responders at this desk tend to have ages between these. Without your guidance some could have mistaken your meaning of embed as a geological term, in reference to fossils in rock or as "to place (a journalist) within a military unit at war". Thank you for coming back and clarifying. Blooteuth (talk) 11:08, 31 August 2017 (UTC)[reply]
Blooteuth Well, one can guess that I'm not talking about fossils here in Computing section. No offense meant.--Joseph 14:50, 31 August 2017 (UTC)[reply]

Embed has a specific meaning when it comes to the web. It refers to adding content to a website from another website in such way that it appears as part of the first website. Adding Youtube videos to a Youtube playlist is not embeding. Your own definition seems to agree with that. So I don't know why you even bring this nonsense up since you were the one complaining about irrelevant responses because even if we ignore that embed has a specific meaning when it comes to the web, what you're trying to do is indeed embedding and no one has questioned that.

The reason I explained so much was because it was entirely unclear what you were asking about. As I already said, if you want clear answers, you need clear questions. This is the first time you explicitly mentioned 'popular uploads'. Previously you mentioned 'popular videos' which is a confusing term since it's not a term used by Google in reference to a specific channels content.

Channels can choose to show 'popular uploads' (which since this is Youtube are all technically videos) but it's not true that all channels have the 'popular uploads' feature. Channels can choose whether to enable it. See for example [2] which shows how this is done. Plenty of channels do not have it enabled [3] [4] [5] [6] [7]. (Admitedly you can generate different channel pages for subscribers and new users, and possibly other things if you have more advanced options, not sure about that one. So it's possible you will see popular uploads on these channels whereas I don't.)

Note that the last one does have a 'popular' playlist but it is not the Youtube 'popular uploads' feature but rather appears to be a custom playlist generated by whoever manages the channel. Other channels may handle this differently, e.g. this [8] has a 'Best of' playlist which is again a custom playlist which I presume was generated by whoever manages the channel.

The popular uploads feature appears to be a special automatically created playlist which behaves in certain weird ways. I suspect it may always exist even if it's not shown but I don't know how to find it if the channel doesn't display it. You can sort videos by view count on the channel's page, but clicking play all will still just play all for the channel's upload playlist not sorted by poularity. Since from all your comments, you're referring to the 'popular uploads' on your own channel, this isn't really an issue here. Still all this is why clarity on your questions is essential since it took your third reply to make clear you were referring to the 'popular uploads' feature of Youtube not something else like 'popular videos' which is what you first mentioned.

Speaking of which, you claim you know how to embed playlists, but do you? Because the example code you have shown is not for embedding a playlist. All it can really do is embed a user's videos. To obtain the code for embedding a playlist, you do a similar thing as you do for embedding a video except you need to be on the playlist page. [9]

An import diversion, at the current time Youtube's Material Design/Polymer framework UI seems to be lacking a button to share playlists unless I'm missing it completely. Which means it's lacking the ability to easily generate the code to share a playlist. (Sharing for videos is there, as is embedding although a little changed.) Mind you I'm not sure if you're seeing the new UI, this page [10] suggests it has had a worldwide launch but it sort of sounds like this may be referring to the ability for anyone to enable it, rather than it being enabled by default. I didn't enable it, nor did my friend who fist pointed out the change to me, so it's possible it was only enable by default in NZ or whatever as many companies do due to the small but English speaking population with widespread internet usage. Anyway if you are seeing the new UI, you can add &disable_polymer=true to the end of your Youtube URL to get back the old UI until Youtube re-adds a share feature for playlists (I'm guessing they will if it really is missing).

Getting back to how to actually embed a playlist, if you go to Al Jazeera English's channel [11] then click on videos [12] then click on play all you should be taken to the first video of the all uploads playlist page which is currently this [13]. If you then click on the playlist name 'Uploads from Al Jazeera English' you'll be taken to the playlist proper albeit with the possible polymer issue. Anyway this is the all uploads play list for Al Jazeera English [14] with the necessary string to disable polymer. You should be able to use it to generate code for embedding a playlist:

<iframe width="1280" height="720" src="https://www.youtube.com/embed/videoseries?list=UUNye-wNBqNL5ZzHSJj3l8Bg" frameborder="0" allowfullscreen></iframe>

By doing so, you can see how this code itself can easily be changed to embed some other playlist simply by changing the list string. this is actually quite important for what you want to do. So there's actually a very important and not just aside reason for you know how Google apparently recommends you embed playlists. Rather than the adhoc way you appear to be using for simply embedding a user's videos which I'm guessing is just some code you took off some site without knowing what you're doing.

But also it's helpful to use the Youtube feature to generate the code since you can change the settings. Your example has several presets. Do you actually know what they are and what they do and how to change them? I don't think there's any Youtube feature to automatically generate your code so you will have to change them manually, precisely because as I said, it's probably not how Google would suggest you embed a user's videos since I'm sure they recommend you just embed their all uploads playlist. And remember, you don't have a way to embed a generic playlist, you have some possibly hackish way to embed a user's upload playlist.

If you already did know how to do what I said, why on earth are you using the crappy code you've shown?

Note that your example code says the last parameter is for the channel name but this is confusing. AFAICT, using the channel ID sting in the paramater, i.e. the string you see when the URL is /channel doesn't actually work. You need to use the user profile name i.e. the string you see when the URL /user. As an aside, I should add if you try to actually embed Al Jazeera's uploads playlist you'll find it doesn't work because they don't allow embedding so you can't play the videos.

And another point, although Youtube seems to work with your code when embedded, it breaks if you go to Youtube from it. You can watch the video, but any semblance of a playlist is lost. The next video will be whatever Youtube has algorithmically chosen for you. A simple example would be to compare these two.

<iframe width="1280" height="720" src="https://www.youtube.com/embed?listType=user_uploads&list=BBCEarth" frameborder="0" allowfullscreen></iframe>

<iframe width="1280" height="720" src="https://www.youtube.com/embed/videoseries?list=UUwmZiChSryoWQCZMIQezgTg" frameborder="0" allowfullscreen></iframe>

You will see both give you playlists of 100 videos when embedded, but while the later allows you to visit Youtube and continue watching the playlist, including going past the 100, the code derived from your example does not. It breaks in the way I said it does so the playlist is los and it seems to do this whether or not polymer is enabled. Since you disabled controls anyway maybe you don't care. However are you certain your example code is actually well supported by Youtube? Because this weird issue makes me wonder if it's the sort of thing which isn't really supported and so could break at any time. Maybe there's something in the API to suggest what you're doing is okay but I somewhat doubt you know that. So yes, using adhoc methods with code you found from some random site is risky and pointless when you don't understand what you're doing and when the site itself provides a method to generate the necessary code based on their recommended method.

Anyway as for the main question after all these distractions arising from your confusing comments and poor way of doing things, well as I said earlier, the code has a playlist string. So if you have a playlist string you can simply substitute in another playlist string. But how do we get the playlist string for popular uploads? Well if you visit a channel with the 'popular uploads' feature enabled, you'll see there is a play all button next to the playlist. (I presume you know this since you talked about the feature anyway.) If you look at the URL or just click on it, you'll notice there is actually a playlist string embedded in it. Al Jazeera is one example, but since they don't allow embedding maybe not the best one here. So let's use Vsauce [15]. If you look for the popular uploads list, you should see in the URL it has the string PU6nSFpj9HTCZ5t-N3Rm3-HA. So using that, we can subsitute it into the earlier code:

<iframe width="1280" height="720" src="https://www.youtube.com/embed/videoseries?list=PU6nSFpj9HTCZ5t-N3Rm3-HA" frameborder="0" allowfullscreen></iframe>

I've tried it with some minor testing and it seems to work. If you're not happy with the parameters I specified, either change them in the code yourself or generate your own playlist code since I've told you how, as does Google. Anyway although it seems to work, I'm not sure how well this is supported by Youtube. As I mentioned, the popular uploads seems to be a special playlist and behaves in unusual ways. For example, if you are on the video of playlist playing page, you'll find the title for the playlist isn't a link, i.e. you can't click on it to be taken to the main playlist page. If you simply subtitute the playlist string into a playlist URL e.g. [16] it doesn't work. And all these with or without polymer. I'm not certain if the playlist string itself is constant or ever changes. Note also if you click on the playlist name (popular uploads) in a Youtube channel, it just takes you to the videos page sorted by view count. (So clicking play all doesn't actually work as may wish, as said above.)

Incidentally I tried adding both &sort=p and &search_sort=video_view_count to both your code and a properly embedded playlist, neither work. I'm not that surprised since AFAICT, playlists aren't inended to be re-sorted by end users. You can shuffle during playback, but the playlist has a fixed order which whoever manages it sets. (Or in the case of the all uploads playlist, the sorting is most recent. Re-sorting on the videos page is not affecting the playlist per se, just affecting what's shown on the video page.)

In other words, you should be able to use the method I've shown to embed the automatically generated 'popular uploads' playlist on an external website, provided you can see the playlist, e.g. if it's your own. But there's a chance it may break or otherwise not work as expected at any time, and you may be SOL since I'm not sure this is really something well supported by Google. (Although I haven't look into their API so maybe there are other options.)

Nil Einne (talk) 18:18, 31 August 2017 (UTC)[reply]

P.S. Your responses also illustrate another point and why I worded my responses carefully. When trying to help, you always have to be careful about what someone says, especially when their comments suggest such caution and you have no desire for long back and forths. I could have ignored you, but I'm not sure if anyone else would have helped and I did give you what I assume is an answer from all you've said in the end, even if it took way too many back and forths. Ultimately you can ignore me, so if you refuse an answer to your question because you don't like my responses, well that's up to you. Your first two comments said nothing about embedding in blog. I therefore had no reason to think you really knew what embedding was, or what sort of access is required to allow it. Once you mentioned in your blog, it became far more likely that you did know what embedding was and had the necessary access to do so. Yet if I had simply assumed you knew everything, I would have also assumed you really knew how to embed a play list since you said you did, and would have just mentioned the playlist string bit. Yet I'm seeing strong indications you did not know how to embed a playlist, and all you knew how to do was the weird thing you showed here in which case you still wouldn't know since the playlist string is useless if you don't have the proper code to embed a playlist, code which Youtube generates for you. If I was also wrong about the playlist but, then as I already said, why on earth are you ever using the code you showed here when you can embed the user upload playlist and it works properly all the time (I assume)? And frankly 3 replies is more than I'd normally bother with so if you haven't learnt by now, well you'll have to hope someone else helps. And I admit, I wonder if youcn actually figure out how to extract the list paramater from the popular uploads URL, or how to subsitute it into the embed playlist URL, but I kept it perfunctory mostly because I'd already said so much in relation to all the confusing issues your comments raised and because of your complaints about unneeded replies. Nil Einne (talk) 18:56, 31 August 2017 (UTC)[reply]
As a final comment, I should mention that the first two times I replied, I knew next to nothing about the popular uploads feature of Youtube channels. Yes I do use Youtube but as shown from the examples provided, a lot of the stuff I look at simply doesn't have it. (Seriously it was about the number above before I actually found an example with 'popular uploads'.) I did vaguely remember having seen channels with popular uploads listed but I'd never paid much attention to it since even for those which do have it, it's not something I feel the need to use much. (Ditto with sorting by view count except to see how popular someone is.) Again maybe I shouldn't have replied but I did search and your initial two comments didn't give any indication you were discussing a specific Youtube special playlist. Once your third comment clearly specified you were referring to a specific feature and also gave the correct name, it was much clearer what you were referring to so it helped jog my memory and searches were easier (although still hard given it's a generic term). 'Popular videos' is a very generic term which doesn't have to mean the auto generated Youtube list. So again clarity helps ensure people know what you're asking about. You simply had to make clear you were referring to an auto generated list that you can choose to add to your Youtube channel, and use the correct name. Nil Einne (talk) 19:29, 31 August 2017 (UTC)[reply]
Nil Einne I have to say again that I'm not much experienced in coding. So, there is no point in writing long essays asking Do you know?, LOL. And you've not well read the 2nd reply. I never said that example code I provided is to embed a playlist. That example was to show you what type of code I'm talking about. In YouTube, under the Share tab, there is Embed option which generates code to embed videos or playlists. But it will not work with Popular Uploads playlist. And that's why I came here for getting assistance. Anyway, I really appreciate your effort in providing the answer finally. Thanks for the help.--Joseph 10:53, 2 September 2017 (UTC)[reply]

Shelf life of computer science books[edit]

How long are computer science books worth reading? That is, besides for the historical interest. After books of the 80s still interesting or are they always inevitably needing updating. — Preceding unsigned comment added by 31.4.143.40 (talk) 15:45, 30 August 2017 (UTC)[reply]

To be pedantic. The very moment a book hits the book-store it is already obsolete if your riding the crest of the wave. Your question of worth, really means I think how much one will gain form reading such books. This depends on why your reading them. Believe it or not COBOL programmers are still wanted for legacy environments (circa 1960's). Why do you ask? Think the general opinion here might be, is stick to being informed about the very latest IT. That doesn't come from printed books. Aspro (talk) 16:15, 30 August 2017 (UTC)[reply]
I should think some general "how to do computer programming" books would still be good. A particular sort technique can still work decades later, for example. Specific computer languages change more often. StuRat (talk) 16:17, 30 August 2017 (UTC)[reply]
Relevant re languages changing. Ian.thomson (talk) 18:10, 30 August 2017 (UTC)[reply]
Even the high level concepts change - like object oriented programming. But you might get better answers on the Computing desk! Wnt (talk) 17:36, 30 August 2017 (UTC)[reply]
Structure and Interpretation of Computer Programs is from the 80s. Still an interesting read. --B8-tome (talk) 17:55, 30 August 2017 (UTC)[reply]
Computer science is a very large field and still growing. What are you specifically asking about? A book on TCP/IP is still pertinent because we are still using TCP/IP and the fundamentals aren't changing. There are many areas of computer science that haven't fundamentally changed in years. Knuth's work on algorithms is just as pertinent today as it was in the 60's. I know that most kids can't read the assembly code in his books and, therefore, say that they just too cool for his old crap. That doesn't mean that his books are obsolete. It just means that the field is growing. There are a lot of computer scientists who cannot read assembly and no reason to learn to do so. There are computer scientists who cannot even write a program in any programming language. So, what is pertinent to them? What is obsolete? The field is simply to big to have a definitive answer. 209.149.113.5 (talk) 18:10, 30 August 2017 (UTC)[reply]
I know a FORTRAN programmer who makes a lot more money than I do using skills he learned back when I was a little kid tiny potato. (((The Quixotic Potato))) (talk) 19:11, 30 August 2017 (UTC)[reply]
The Art of Computer Programming is timeless. TCP/IP Illustrated and Advanced Programming in the Unix Environment are still excellent. Introduction to Algorithms will still be good in 15 years. CSS and C# for Edge 3.5 will be obsolete before it hits the shelves. --Stephan Schulz (talk) 20:57, 30 August 2017 (UTC)[reply]
  • Most "books" in this field are only read once (if at all) because they're broadly tutorial. They don't become obsolete, they become irrelevant. If you share them around a library or office, many people might read them, for some years, each learning the same topic. The topic described might have a few years life in it, but a single-reader book is discarded because it has been used, rather than no longer usable. Also the supposed "fast moving technology" is a misleading idea. The technologies don't change that fast (the people using them can't), but some technologies either thrive and survive, or wither and vanish quickly. It's not the successful ones that are superseded so fast, it's the ones that weren't adopted.
So a book on a successful technology can have years of life to it. Håkon Lie and Bert Bos' CSS book ISBN 0201596253 is 20 years old and still one of the best (readable and least inaccurate) CSS primers for a new developer. My dusty old book on relational database theory is from the 70s, my networking books (Andrew S. Tanenbaum) are barely into the 1980s. Even for Windows, one of the best primers and user interface guides (up to Windows 7) was the new "welcome to the new desktop" book produced for Windows '95 developers in the mid '90s. Yet another M$oft book from much the same time was Inside Windows NT ISBN 155615481X, which was supposed to be The Soul of a New Machine for a new generation - yet it was obsolete before it was printed, because NT changed before it was released. One of the most useless books I've ever read.
Then there are essential books for any developers, which are simply timeless. Anything by Edward Tufte. Andy Dingley (talk)
Goodreads has a list of essential books: [17]. Some are not really old, and some are not really computer science, but in general it's a really good list. Most of the recommended books above are in the list.B8-tome (talk) 13:50, 31 August 2017 (UTC)[reply]
As always, the answer is "It depends". Ones tied to a specific technology "Teach Yourself [XYZ] in 30 days" go out of date real fast. Knuth's books are probably as close to timeless as Computer Science can get. ApLundell (talk) 22:09, 31 August 2017 (UTC)[reply]
In 30 days? People are getting less and less patient. First came the books teach yourself xyz in 10 days, the out was in 24 hours and nowadays we have in YouTube python/Java/js in ONE hour.
Every programmer should read The_C_Programming_Language at least once: it is the sine qua non of elegant programming technique. Personally, I've learned a great deal from older books on MS-DOS and CP/M programming: I started reading them because that's what I grew up with, and I wanted to learn how things really worked, but learning about the design choices people made back then (especially those that we're still paying for today, like the 8.3 filename) has certainly made me a better programmer. OldTimeNESter (talk) 19:30, 4 September 2017 (UTC)[reply]
And once you get past the initial learning curve, assembly language is no more difficult than any other programming language: in fact, personally, I find it easier than languages like C++ and Java, because there's no abstraction layer between your code and the hardware. It's just not practical to use today for most purposes because you need that abstraction layer to use the dozens of libraries that a typical program relies on.OldTimeNESter (talk) 19:30, 4 September 2017 (UTC)[reply]
Every C programmer should read Herb Schildt's books. Commit each lesson to memory...so that you never forget how a proper C program should not be written! 73.232.241.1 (talk) 00:23, 5 September 2017 (UTC)[reply]