Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 665 666 [667] 668 669 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 890536 times)

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9990 on: September 09, 2016, 07:37:22 pm »

Meanwhile, today I had my Python lab (the prerequisite to Java but I'm able to take both).

"Write a function to find the length of a string! No, you can't use len(string) because we haven't learned that yet. Now write a function to reverse a string! No, you can't just return string[::-1] because we haven't learned that index notation yet. No, you can't use a while loop because we haven't learned that. No, you can't use try-except blocks for your error handling. No, you can't-"

AUUUUUGH! I feel like I'm going to come unglued! Why do I have to take this class?!? Why does the American education system charge you to take these classes when you could just skip them?
« Last Edit: September 09, 2016, 08:59:25 pm by DragonDePlatino »
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9991 on: September 09, 2016, 10:31:41 pm »

Remember: in Python there's always exactly one way to do something except when there's not.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9992 on: September 09, 2016, 11:19:59 pm »

Meanwhile, today I had my Python lab (the prerequisite to Java but I'm able to take both).

"Write a function to find the length of a string! No, you can't use len(string) because we haven't learned that yet. Now write a function to reverse a string! No, you can't just return string[::-1] because we haven't learned that index notation yet. No, you can't use a while loop because we haven't learned that. No, you can't use try-except blocks for your error handling. No, you can't-"

AUUUUUGH! I feel like I'm going to come unglued! Why do I have to take this class?!? Why does the American education system charge you to take these classes when you could just skip them?
*cringe intensifies*

Aie ye ye.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9993 on: September 10, 2016, 04:31:33 am »

Tail recursion is awesome. Some code just looks better as a tail recursion than it does as a loop. Also recursion is easier than loops when trying to avoid destructive updates, because you need the original structure to stay as it is.

They want you to learn specific algorithms so that you know how they work. That one actually makes sense. I still learned how an adder works and had to implement it (in a program for simulating circuitry).

In regards to "learn it when you need it": That's bunk. You mostly won't find out that you need it when you don't know it – instead you're going to work around your lack of knowledge, doing everything the hard way, only because you don't know enough to even realize that there is an easier way in the first place.
Using Python to learn Computer Science seems like a bad idea when I look at this discussion. "I don't need to learn this – somebody else already did this for me!" isn't really a healthy attitude towards programming. Yep, you don't need to implement it yourself, but knowing how it works is necessary either way. `string[::-1]` basically looks like magic and doesn't tell you anything about the algorithm. That's why you shouldn't use it when you're learning how reversing a string actually works.
Logged
Taste my Paci-Fist

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9994 on: September 10, 2016, 04:33:38 am »

In regards to "learn it when you need it": That's bunk. You mostly won't find out that you need it when you don't know it – instead you're going to work around your lack of knowledge, doing everything the hard way, only because you don't know enough to even realize that there is an easier way in the first place.

this link will explain my entire learning experience

lmao it's actually a bit embarrassing

i'm not joking this is the only thing i'm actually, like, embarrassed about

EDIT: Actually, looking at those results, I'm kind of horrified that the second one is the first to tell you "don't do that, you almost definitely want an array".

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9995 on: September 10, 2016, 05:45:49 am »

I taught myself to program before going to college.

The first code I saw horrified me, lmao. Instead of the example code using VB's "sleep" function, it used... a for loop that loops ~10,000,000 times to do nothing to simulate a wait. I looked at that, recoiled in horror, replaced it with a proper sleep, then turned it in, heh.

The teachers at my school are very fine with me actually keeping good habits up despite instructions, though... as long as the code passes all their tests, it's fine, I guess.
Not that I'm seriously considering this as valid code, but... wouldn't that be massively dependent on processing speed?
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9996 on: September 10, 2016, 06:00:39 am »

College computers are all the same anyway.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9997 on: September 10, 2016, 06:18:37 am »

I taught myself how to program mostly by learning to create games. It's not a bad idea in theory, but I feel like there's some pretty huge gaps in my overall knowledge of programming as a result. not the least of which because I hate using raw graphics libraries and just prefer to use game engines like Unity or UDK.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9998 on: September 10, 2016, 10:15:26 am »

In regards to "learn it when you need it": That's bunk. You mostly won't find out that you need it when you don't know it – instead you're going to work around your lack of knowledge, doing everything the hard way, only because you don't know enough to even realize that there is an easier way in the first place.

Then what would you recommend I do...I can't learn my entire programming language (C++, primarily SFML) before I start to make anything. That's like expecting me to learn the entire English language before I say anything. I can't seek out and learn things before I even know what I'm looking for.

As an example, take game architecture. For a while, I took an object-inheritance approach and discovered all of the problems that go with that. I then Googled a better way to structure things, and now I'm using a data-driven Entity Component System. I had a gut feeling that object inheritance was "doing everything the hard way" but I knew to seek out help online if I started having trouble with an approach. The difficulty of using object-inheritance served as motivation for learning a better way of doing things. It's not the *best* way of learning programming but I think it's sufficient as long as you end up with fast, concise code.
« Last Edit: September 10, 2016, 10:22:09 am by DragonDePlatino »
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9999 on: September 10, 2016, 11:02:04 am »

Then what would you recommend I do...I can't learn my entire programming language (C++, primarily SFML) before I start to make anything. That's like expecting me to learn the entire English language before I say anything. I can't seek out and learn things before I even know what I'm looking for.
I didn't say you should learn everything before starting programming, I said you shouldn't wait to learn things until you need them.

The intention was to teach recursion by forcing us to use it instead of iteration. It's frustrating, I feel it's teaching us Java students a very bad approach to an otherwise simple problem. In the few months of C++ experience I taught myself, I never had to use recursion. For better or worse, I'm a strong advocate of "learn it as you need it" when it comes to programming. The general consensus online seems to be "Use recursion when its faster/more intuitive than iteration" and I fully intend to hold off recursion until I hit a problem like that.
Here you were complaining about having to learn recursion. How do you intend to understand when recursion is going to be faster than iteration if you haven't learned the theory behind recursion yet? Have you even learned about complexity calculations? Do you intend to wait to learn those until one of your programs locks up your computer?

Recursion is not some kind of highly specialized, complex corner case of programming, it's one of the most important concepts to understand, no matter whether you actually use it or not. It's not about usage but understanding and habit.
If you're in the middle of some complex task you do not want to pause and seek out a tutorial about reactive programming, regular expressions or pushdown automata and you certainly don't want to fight through a whole book's worth of theory to understand the trappings and applications beyond what writers of tutorials considered.

What I recommend? Put aside half an hour a day, or maybe an hour a week, or whatever you feel doesn't infringe on your time too much and use that time to seek out and learn programming concepts you don't know yet.
Logged
Taste my Paci-Fist

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10000 on: September 10, 2016, 12:28:42 pm »

uh do you have any example of recursive code being faster than iterative? afaik pushing the call stack is slow af and every recursion unrolled with a fake stack backed by an actual array is gonna be faster
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10001 on: September 10, 2016, 12:44:43 pm »

That might as well be. Only that writing an iterative quicksort is an exercise that is mostly going to leave you exhausted and distraught, with a severe wish to write bubble sort instead, and then recursive Quicksort is faster again.
Same for Mergesort.

Programming for speed when speed isn't crucial is a bad idea either way. Program for clarity and optimize for speed only when it becomes an issue. Recursion is often much clearer than iteration, especially since it is declarative instead of instructive. Finding a fast algorithm can sometimes be easier with recursion than with iteration.
Logged
Taste my Paci-Fist

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10002 on: September 10, 2016, 09:28:46 pm »

Here you were complaining about having to learn recursion. How do you intend to understand when recursion is going to be faster than iteration if you haven't learned the theory behind recursion yet? Have you even learned about complexity calculations? Do you intend to wait to learn those until one of your programs locks up your computer?

Yes. When I start writing programs large enough to need optimization, that's when I intend to learn complexity calculations. I frequently read the documentation at cplusplus.com so I already have a vague idea of how complexity works and why its useful. Same goes for recursion. If I ever come up with some sort of a tree-based structure I need to traverse, that's when I'm going to seriously learn and use recursion. I was frustrated with my classes because they're forcing us to use recursion in cases where when iteration is more intuitive. I wish they would've held off on teaching it until we had a good reason to use it.

If you're in the middle of some complex task you do not want to pause and seek out a tutorial about reactive programming, regular expressions or pushdown automata and you certainly don't want to fight through a whole book's worth of theory to understand the trappings and applications beyond what writers of tutorials considered.

Admittedly, when I talk about "learn it as you need it" I'm talking about hobby programming as opposed to professional programming. In a job setting, I absolutely would need to have a strong foundation in the entirety of C++ before I could work with others. Right now, I'm just programming a game in my free time so I don't mind pausing to pour through a tutorial for a few hours. Like I said, it's not the *best* way of learning programming.

What I recommend? Put aside half an hour a day, or maybe an hour a week, or whatever you feel doesn't infringe on your time too much and use that time to seek out and learn programming concepts you don't know yet.

I'm absolutely open to the idea of doing this even for several hours a day. The other day I read a fun article on beginner's A* pathfinding. Heck, you could probably even use recursion to traverse the parent nodes back to the beginning. The problem is, I don't know how to seek out new programming concepts if I don't know what I'm even looking for. ^^;
« Last Edit: September 10, 2016, 11:04:08 pm by DragonDePlatino »
Logged

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10003 on: September 10, 2016, 09:50:55 pm »

I find recursion to be an invaluable tool for solving problems in general. It can often produce clear, simple to understand solutions, even if they are sometimes not very efficient for the computer to process. Turning these solutions into an iterative version is usually pretty straight forward anyway.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10004 on: September 10, 2016, 10:38:56 pm »

From what I've seen my amateur game development dabbling, recursion is sometimes a better solution but its almost never the only solution.  99.9% of the time there's nothing you could do with recursion that you couldn't do with a wrapper function, or a single function with one or more loops.  In fact I'm thinking and I can't think of anything that would straight up require recursion.

I too am a big fan of learn it as you need it.  For unpaid work obviously... although from what I've seen of stack exchange, I suspect that some professionals also are learning it as they need it.  I dunno, my first programming project that got off the ground was a huge, bloated, inefficient mess and it was one of the best learning experiences I've ever had.  I mean for fuck's sake, you're posting on a forum that once hosted discussion of the first Armok game.  If that's not an example of learning by doing I don't know what is.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule
Pages: 1 ... 665 666 [667] 668 669 ... 796