|
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. |
On March 12 2014 09:40 Manit0u wrote:Show nested quote +On March 12 2014 08:47 Cyx. wrote:On March 12 2014 03:14 Manit0u wrote:I guess I should explain the "on the fly" compilation I mentioned. It's a mudlib gamedriver. It runs perpetually for two weeks non-stop with players running around etc. Every object there is loaded and compiled when required (ex: when a player enters the location object or interacts with other objects - everything is an object there). The coders have dual-acces, both as GM's in the game, where they can view all the code and even edit it from inside the game (it's a bit tricky though as the only editor available there is ed) and regular ftp server acces. The GMs can load/destruct/update all objects from within the game. You can change everything on the fly (when a bug occurs for example and needs to be fixed quickly) without having to pre-compile anything and it will be fully functional. You can add new stuff or modify existing stuff in the game even while it's running simply by adding/editing .c files. I'm not entirely sure about the underlying technology since I'm too newb at it still. Here you can view the gamedriver itself: https://github.com/cotillion/cd-gamedriverHere's some info on how the stack works in it. It appears it's using some form of virtual stacks: https://github.com/cotillion/cd-gamedriver/blob/master/doc/STACKMACHINE Sounds basically like just-in-time compilation, which is the same thing that you can use in some scripting languages (Lua, Python etc...) when you don't want the overhead of running your code through an interpreter all the time ^^ e: so I guess I should tell you guys how my 'command line interview' went... it was not as complex as previously thought, I just had to write a couple of scripts and fix some bugs in some stuff. It was on the command line on Ubuntu so all the stuff I had been worrying about for the last couple days was still pretty useful, but I didn't have to know how to grep anything or anything dumb like that ^^ But grep is awesome... I have no idea how people can do anything other than gaming on Windows. I feel lost without console and I barely ever use a mouse aside from gaming. And the fact that you can combine commands in Linux terminal (especially with grep) is also amazing. You can for example get through entire file and write lines that contain certain pattern into another file all with one command. Hell, you can even get entire file sections thrown out onto your screen/written to another file or get a listing of all files containing the pattern etc.
You can get most of the linux commands in windows through Cygwin. Prolly the most useful thing I ever installed.
|
anybody knows about webapi routing? i try to make an additional action for my web api controller
web api action + Show Spoiler + [Authorize] public class GuestsController : ApiController { [AllowAnonymous] [HttpPost] [ActionName("login")] public HttpResponseMessage PostLogin(string guestCode) { var login = new AccountController().GuestLogin(guestCode);
if (login.Result == "Ok") { return Request.CreateResponse(HttpStatusCode.Accepted); }
return Request.CreateResponse(HttpStatusCode.NotAcceptable); }
web api routing + Show Spoiler + config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );
config.Routes.MapHttpRoute( name: "ApiWithAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } );
config.Routes.MapHttpRoute( name: "ControllerAndAction", routeTemplate: "api/{controller}/{action}" );
my http post + Show Spoiler + $http({ method: 'POST', url: "http://10.10.0.151:8888/api/guests/login/", data: guestCode
}).success(function () { console.log('succ'); }) .error(function () { console.log('fail'); });
am i missing something here? i made some breakpoints in VS and it always points to the Get method + Show Spoiler + [AllowAnonymous] [Queryable] public IQueryable<Guest> Get() { List<Guest> guests = new List<Guest>();
guests = _repository.FindAll().ToList();
return guests.AsQueryable(); }
|
I have to do some online assessment as part of a job application in the UK as a graduate software developer. The topics are logical reasoning and numerical reasoning. Any advice what to revise?
|
On March 11 2014 04:14 RoyGBiv_13 wrote:Show nested quote +On March 11 2014 00:13 ParasitJonte wrote: Escaping from code and software for a while:
What sites/blogs/magazines/other do you browse to keep up with latest trends in hardware and computer architecture?
Like most programmers (?) I am more interested in software than hardware but obviously it's important to understand what you are programming against. Especially if you work in a niche environment such as high performance computing.
So any tips on sources one might use to stay up to date? Hacker News is a pretty popular news aggregator. /r/programming would be another. I'd suggest glancing at them occasionally until you find specific blogs that interest you. Don't get too sucked into meta-programming discussions that thrive on aggregator sites.
Thank you.
|
Oh dear... I am very upset.
So we have this class. It's called 'Principles of Software Development'. It's the class where we learn about inheritance and polymorphism and all of those important concepts.
We did the first half of the course in Java, and now we're moving on to C++. So I've written a bit of C++ in the last few years, and I feel pretty good about these labs, you know? Then the FIRST LAB that we have in C++ is about multiple inheritance (since we did single inheritance in Java). And the ONLY THING they ask us to do that involves multiple inheritance is... can you guess? They make us inherit from two classes with the SAME BASE CLASS. Literally every book I've ever read has started its chapter on multiple inheritance with the 'avoiding the diamond of death' caveat... apparently my professor/TAs have never read said books.
I am not happy.
|
On March 13 2014 01:48 ParasitJonte wrote:Show nested quote +On March 11 2014 04:14 RoyGBiv_13 wrote:On March 11 2014 00:13 ParasitJonte wrote: Escaping from code and software for a while:
What sites/blogs/magazines/other do you browse to keep up with latest trends in hardware and computer architecture?
Like most programmers (?) I am more interested in software than hardware but obviously it's important to understand what you are programming against. Especially if you work in a niche environment such as high performance computing.
So any tips on sources one might use to stay up to date? Hacker News is a pretty popular news aggregator. /r/programming would be another. I'd suggest glancing at them occasionally until you find specific blogs that interest you. Don't get too sucked into meta-programming discussions that thrive on aggregator sites. Thank you.
Also, slashdot is a good place to look for stuff and news. They even have more specific branches (like Linux, Data Storage, Security etc.) if you're interested in that.
|
Hello again everyone,
I am looking to use an .asm function in my C code as a training exercise for myself. This is using x86 on Ubuntu, with nasm and gcc, and -m32 flags for it.
The prototype function in C is:
extern int isPalindrome(int n, char* s);
The call is:
if (isPalindrome(strlen(strings[i]), strings[i]))
And the .asm file starts off with:
segment .text: global isPalindrome
isPalindrome: enter 0,0 pusha
The whole Makefile is(I think this may be the one causing the problems, but I can't see what is wrong or how to fix it):
CFLAGS = -Wall -m32 LDFLAGS = -m32
%.o: %.asm nasm -f elf32 -o $@ $<
%.o: %.c gcc -o $@ $<
isPalindrome: asmisPalindrome.o cisPalindrome.o
clean: rm isPalindrome *.o *~
and the error printed is
nasm -f elf32 -o asmisPalindrome.o asmisPalindrome.asm gcc -o cisPalindrome.o cisPalindrome.c /tmp/cc88ZPCc.o: In function `main': cisPalindrome.c:(.text+0x54): undefined reference to `isPalindrome' collect2: ld returned 1 exit status make: *** [cisPalindrome.o] Error 1
Currently only asmisPalindrome.asm is made into asmisPalindrome.c, with cisPalindrome.c not being made into an object file. Could someone at least point me in the direction of where to look for this?
Thank you.
|
Undefined reference in makefile is a linking error. What happens if you add a command here?
isPalindrome: asmisPalindrome.o cisPalindrome.o gcc -o $@ $<
|
On March 13 2014 02:13 Cyx. wrote: Oh dear... I am very upset.
So we have this class. It's called 'Principles of Software Development'. It's the class where we learn about inheritance and polymorphism and all of those important concepts.
We did the first half of the course in Java, and now we're moving on to C++. So I've written a bit of C++ in the last few years, and I feel pretty good about these labs, you know? Then the FIRST LAB that we have in C++ is about multiple inheritance (since we did single inheritance in Java). And the ONLY THING they ask us to do that involves multiple inheritance is... can you guess? They make us inherit from two classes with the SAME BASE CLASS. Literally every book I've ever read has started its chapter on multiple inheritance with the 'avoiding the diamond of death' caveat... apparently my professor/TAs have never read said books.
I am not happy.
The diamond-death-dumb-problem-name can be resolved perfectly well in C++ by declaring the multiple derived classes virtual so they only resolve to a single instance. If your lab instructors aren't doing that, tell them. The only reason people hate multiple inheritance is because they see one way of how C++ resolves it with the scope operator. There's nothing fundamentally broken about inheriting from multiple classes with the same base class.
|
On March 13 2014 09:54 Manit0u wrote:Undefined reference in makefile is a linking error. What happens if you add a command here? isPalindrome: asmisPalindrome.o cisPalindrome.o gcc -o $@ $<
It does the same thing. The original was something I saw on my Professor's slides and wanted to try out. It apparently autofills in the gcc command. It still gives me the undefined reference error.
Honestly, where else could the problem be stemming from? I could pastebin my whole .asm code and the whole C code(.asm is about 40-50 lines and C is about 30) if it would help, but it should be somewhere in the things I originally included, right?
|
|
|
On March 13 2014 12:27 Nesserev wrote:Show nested quote +On March 13 2014 02:13 Cyx. wrote: Oh dear... I am very upset.
So we have this class. It's called 'Principles of Software Development'. It's the class where we learn about inheritance and polymorphism and all of those important concepts.
We did the first half of the course in Java, and now we're moving on to C++. So I've written a bit of C++ in the last few years, and I feel pretty good about these labs, you know? Then the FIRST LAB that we have in C++ is about multiple inheritance (since we did single inheritance in Java). And the ONLY THING they ask us to do that involves multiple inheritance is... can you guess? They make us inherit from two classes with the SAME BASE CLASS. Literally every book I've ever read has started its chapter on multiple inheritance with the 'avoiding the diamond of death' caveat... apparently my professor/TAs have never read said books.
I am not happy. As Blisse said earlier, this is not a problem at all. 'Avoiding the diamond of death' is a SHOULD IF POSSIBLE, not a MUST. The reason can be bad class design but sometimes, it's just not possible to avoid this. Imagine if a superman is a man that is both a policeman and a firefighter. Then that superman has to inherit from both the policeman class and the firefighter class, which are both derived from the man class. Makes sense, right  Then again, that doesn't mean that your professors are using it in the right way, but because it's for educational reasons, that's kinda out of the picture right now.
Although it does make your program very fragile.
Its kind of like saying global variables are not a problem at all. Well it is a problem, but you don't know enough about design to circumvent it or you're just feeling lazy.
On March 13 2014 12:27 Nesserev wrote: Imagine if a superman is a man that is both a policeman and a firefighter. Then that superman has to inherit from both the policeman class and the firefighter class, which are both derived from the man class. Makes sense, right 
Sorry I know I'm being an asshole, but nope, it doesn't make sense.
I think I know what you're saying but design-wise if it were to be correct, Superman is not a policeman or a fireman, he is a man capable of being a fireman or a policeman. There is a difference.
These are called traits, some languages have them, others get around them similarly with mixins. C++ doesn't have either of them but that doesn't mean you should solve the problem with multiple C++ inheritance. An alternate design should be used.
|
|
|
On March 13 2014 14:12 Nesserev wrote: The moment that multiple inheritance is making your program 'fragile', is when you're not using it properly. Also, why bring up global variables... it's far worse, and very messy to use global variables. Sometimes, multiple inheritance is the best option, especially due to practical reasons.
I guess I shouldn't have used that example, because it had nothing to do with the point that I was trying to bring across.
Not really. Both techniques introduce a situation which makes your program fragile, that's why it is bad.
Not that I never said multiple inheritance was bad... it is using multiple inheritance to solve the diamond problem that is bad.
Just like global variables, the diamond problem isn't going to be an issue if nothing changes. Yes you can use global variables in a way that causes the least amount of side-effects too.
In the end you have to realise that using these techniques just sets yourself up for major headaches in the long run.
|
On March 13 2014 14:31 sluggaslamoo wrote: In the end you have to realise that using these techniques just sets yourself up for major headaches in the long run. do an assert(reality) plz.
|
On March 13 2014 10:35 WarSame wrote:Show nested quote +On March 13 2014 09:54 Manit0u wrote:Undefined reference in makefile is a linking error. What happens if you add a command here? isPalindrome: asmisPalindrome.o cisPalindrome.o gcc -o $@ $<
It does the same thing. The original was something I saw on my Professor's slides and wanted to try out. It apparently autofills in the gcc command. It still gives me the undefined reference error. Honestly, where else could the problem be stemming from? I could pastebin my whole .asm code and the whole C code(.asm is about 40-50 lines and C is about 30) if it would help, but it should be somewhere in the things I originally included, right?
No need to post your code. What you should do is try doing all the things in the makefile step by step manually first, then see where it goes wrong. As I mentioned, it most likely doesn't have anything to do with the code in files since the error you're getting indicates a problem with linking files.
|
On March 13 2014 16:43 nunez wrote:Show nested quote +On March 13 2014 14:31 sluggaslamoo wrote: In the end you have to realise that using these techniques just sets yourself up for major headaches in the long run. do an assert(reality) plz.
Well... the reality is most employees would CU_ASSERT_FATAL(wound_from_angry_mob_of_programmers) and CU_ASSERT_TRUE(totally_fired_and_reputation_lost) and CU_FAIL(at_life) for solving the problem using a diamond structure.
You can solve these problems perfectly fine without a diamond.
eg, instead of class Superman : Fireman, Policeman
you could do
Superman : Person, Extinguishable, Policeable
That way the Person class is no longer coupled with the Fireman and Policeman capabilities, makes it much easier to maintain.
|
you have solved an imaginary problem that you created yourself in an incredibly vague imaginary example that some other guy created in an attempt to show him how one pattern trumps another in general.
it's ridic, i'm sure his point was along the lines of: it has its uses. a fair point imo (maybe his example was so-so).
personally i have been delving into static polymorphism, and i bet native trait / mixin support is delightful.
|
Multiple public inheritance is what you should avoid as much as possible. It's not so bad with private inheritance. But still, it's rarely a good idea to use multiple inheritance.
Never use multiple inheritance with "small" objects. They will become huge. Even though C++ technically supports the "empty base class optimization", afaik none of the big compilers actually apply it due to binary compatability reasons.
|
You are in a 1st semester programming course, the teachers just wanted to show you what you can do. Its probably the first example because you couldnt do it in java, its a nice contrast.
This is not a Skyrim magic class where you have to keep problematic things a secret to the students because they can blow themselves up. They teach you what things you can do.
I dont know you and i dont know where this class is held, but i have seen a lot of young students who think they know everything better than the professor because they had a bit of experience and the intro course is boring to them and they make the mistake of thinking the level of the course is the level the professor operates at on a daily basis.
|
|
|
|
|
|