The Big Programming Thread - Page 334
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
Yoshi-
Germany10227 Posts
| ||
|
Shield
Bulgaria4824 Posts
std::chrono::steady_clock::now();from the previous page. Can anyone please explain what each bit is? E.g. what is steady_clock? I guess now() is a method, but what are chrono and steady_clock? Now I know why C++ is complex. Edit: Is this equivalent to superclass.subclass.method()? So basically chrono.steady_clock.now()? But then again it's weird to see a class with _ character, so I guess I'm wrong there. | ||
|
LukeNukeEm
31 Posts
As for the underscore, this is just the naming convention used by the c++ standard library. | ||
|
Shield
Bulgaria4824 Posts
On the other hand, I've seen code like stuff.stuff2.method() in Java, but I don't remember/know what the idea is. I don't even know what to type on google to read about it. Could you enlighten me please? | ||
|
LukeNukeEm
31 Posts
- stuff is a class, which has a static member called stuff2, which has a static method called method(), - stuff is a variable containing an object of a type which has a membervariable called stuff2 of a type which has a method called method() just look through the java documentation | ||
|
nunez
Norway4003 Posts
On August 03 2013 05:15 LukeNukeEm wrote: std and chrono are something called namespaces. Basically like a folder structure. std is the c++ standard library, chrono is the time-library. steady_clock is a class representing a clock, now() is a method of that class returning the current time point. As for the underscore, this is just the naming convention used by the c++ standard library. also note that the member function now() is static so you don't need an instance of the object when calling it and that :: is the scope resolution operator whereas . is a member access operator. #include <functional> for future reference check f.ex cppreference for quick std related stuff: steady_clock::now() | ||
|
sqrt
1210 Posts
P.S. I'm using Windows. | ||
|
Zocat
Germany2229 Posts
On August 04 2013 10:16 sqrt wrote: I looked at the tutorials for OpenGL in the OP, but they seem to be quite dated, can anyone recommend me a more modern tutorial? Or should I just work with older versions? P.S. I'm using Windows. http://www.arcsynthesis.org/gltut/index.html | ||
|
Blisse
Canada3710 Posts
On August 04 2013 10:16 sqrt wrote: I looked at the tutorials for OpenGL in the OP, but they seem to be quite dated, can anyone recommend me a more modern tutorial? Or should I just work with older versions? P.S. I'm using Windows. Unless you're trying to learn OpenGL, I would recommend using some library. http://gamedev.stackexchange.com/questions/23652/what-alternatives-to-glut-exist | ||
|
ObliviousNA
United States535 Posts
I've been using his site for the past few weeks, I just want to reiterate for anyone looking to learn openGL (or generic graphics programming principles taught with openGL) - it's awesome. | ||
|
sqrt
1210 Posts
On August 04 2013 12:48 ObliviousNA wrote: I've been using his site for the past few weeks, I just want to reiterate for anyone looking to learn openGL (or generic graphics programming principles taught with openGL) - it's awesome. Thank you. On August 04 2013 11:38 Blisse wrote: Unless you're trying to learn OpenGL, I would recommend using some library. http://gamedev.stackexchange.com/questions/23652/what-alternatives-to-glut-exist I am, I'd still file this for later after I have a better grasp at OpenGL. | ||
|
Encdalf
Germany66 Posts
On August 03 2013 03:47 HardlyNever wrote: [...] Does anyhow know how to get this piece of crap to load at an earlier version correctly, so I don't have to physically go check it on an old machine? The developer tools in the IE are good for a quick peek, but well that's about it. It won't simulate an earlier version 100%, instead you get an earlier version with enhancements, i.e. IE9 debug tools would make you think media queries work in IE8. As for the mentioned IE Tester, I havn't used that for a while since it constantly crashed on my system and printing didn't work. In my current setup I use virtual machines with remote desktop connections for compatibility checks in older IE versions since that way I also have the operating system as a test platform, which at least for me is a requirement in some cases. There are also services like https://saucelabs.com/ or http://www.browserstack.com/ which will provide you with other version/os combinations but these cost money. | ||
|
one-one-one
Sweden551 Posts
On August 01 2013 10:18 darklordjac wrote: Cool taking in everyone's input and asking some of my friends that are into coding (they all said C was a good idea except for one who said C++ but all my programmer friends make fun of him for being a C++ fanboy lol) I've decided to go ahead and start with C. Now onto the next question, where do you guys suggest to start? I'm guessing a book or something since I don't wanna go for classes or anything of the sort (takes too much time + money) so can any of you recommend a book? Also if I have any questions would it be okay to ask here? You are lucky. There is a very very good book for you: http://en.wikipedia.org/wiki/The_C_Programming_Language It is widely considered as one of the best programming books out there. I have one copy at work and one at home. Learning C is a very good idea. Don't let people scare you. There are no shortcuts in the programming world. By getting a solid foundation in C you will also get a good understanding of how computers work from a really low level. If you are a student I would recommend that you take courses in machine level programming and operating systems. These will have very good synergies with your C studies. This should be a motivator for you - look at the language trends: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | ||
|
Shield
Bulgaria4824 Posts
So to give you an idea of what I already know in programming so you can give me better advice, here is a simple list. Java: I. Threads, ExecutorService way of threads, 'synchronized' methods. A bit of semaphore knowledge, but never quite developed this and relied on synchronized instead. II. Simple I/O network knowledge which I developed when I had to do a simple chat server at university. III. Inheritance, arrays, an idea of what a linked list and how it works but I should implement it some day to see things for myself, HashTable IV. An idea of generics but I haven't had practice which is something to do V. Just bare touch on TLS and keystore to add SSL support to a small java http server as an assignment for university VI. Limited experience with Java RMI VII. Really, really basic GUI (awt/swing) C: I. Really basic stuff like using some of the common libraries like stdlib (dynamic memory, exit), stdio (printf, scanf, sscanf, fgets)... also strlen, sizeof but I think they come from stdlib. I haven't touched C recently. II. Struct (data structure), array obviously, typedef I also studied basic Objective-C, but I'd rather focus on other languages for now. I'm not into Apple. Edit: When people say "study algorithms and data structures", do you mean to memorise algorithms or just to have an idea about an algorithm and to know how to google it? | ||
|
heroyi
United States1064 Posts
On August 05 2013 10:30 darkness wrote: I'm looking to sharpen my programming skills as I feel I'm not doing anything useful these days to become better. Once I'm done with studies, I'd like to work as a software engineer, but I'd rather use the time while I'm studying at university. I'm on my 3rd and last year of BSc in Software Development programme. I plan to follow it up with MSc in the same field if possible. ... Edit: When people say "study algorithms and data structures", do you mean to memorise algorithms or just to have an idea about an algorithm and to know how to google it? Essentially the latter. A lot of languages come with their own little algorithms built in (i.e java for sort etc...). Essentially know the practicality and downfall of each and know when to implement which (red black tree vs sorts etc...). It seems a lot of programming is just knowing the abstract level which makes sense considering if you can't design a blueprint of what you want the program to do then it doesn't matter how well you know about a language. | ||
|
teamamerica
United States958 Posts
Hey guys I was looking at the python intro (http://docs.python.org/3/tutorial/introduction.html#strings) and saw an example of multiple assignments in a way I'm not used to (coming from Java/PHP). Basically the code in question was
Wherein a takes the value b had (before the assignment) and b takes the value of b + a (before the assignment). So somewhere the interpreter has to store a temp variable for the value of "a" or "b", or does some trick about switching two variables without using a temp like the following from Java, right? The only equivalent way I can think of doing it in Java is:
Is there some way simpler to what Python does? Simplified my question down to: I was reading python intro @ the python site and realized in python you can switch two variables a,b using the line a,b = b, a But in Java the simplest way I can think of (and this only works for switching two integers) is
So I have a few questions: 1) In Java, is there a simple way to switch two objects without creating a temp object? 2) How does that line of python code get interpreted? Does it go something like
Or does it do some optimization I don't know about? I put both a tempA and tempB because it seems arbitrary of there was a tempA and not tempB created by the intrepreter.... | ||
|
CecilSunkure
United States2829 Posts
temp = A; And that's that! There's not really a "faster" way unless you start getting into assembly stuff afaik. | ||
|
Nesserev
Belgium2760 Posts
| ||
|
Blisse
Canada3710 Posts
Here's what it does if you disassemble the code. Code:
Backend:
Python optimizes it by recognizing the swap assignment. It loads, the two values into the stack, calls ROT_TWO (ref) which swaps the stack, and then stores them back into their variables. No tuples here! Code:
Backend:
With a constant RHS* it creates the tuple, and then we have the sequence unpacking into the variables. http://stackoverflow.com/questions/4554130/fastest-way-to-swap-elements-in-python-list Python is awesome. And any swap mechanism other than swapping with the temp. variable is really discouraged unless you have a space requirement. | ||
|
gedatsu
1286 Posts
On August 05 2013 16:49 teamamerica wrote: But in Java the simplest way I can think of (and this only works for switching two integers) is
You can avoid overflow by using xor: b = a^b; a = a^b; b = a^b; I think this (and your method) can create a pipeline stall however, so it's not necessarily faster than swapping with the normal method of using an extra variable. So I have a few questions: 1) In Java, is there a simple way to switch two objects without creating a temp object? You only create objects by using the 'new' command. Since you can have two names referencing the same object, that is the best way to swap them and no extra object is created. | ||
| ||