• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

poweld

Member
Yes. Calling function.apply() just takes a function (its first argument) and applies it to the rest of the argument list. So function.apply(f, i) would have the same effect as the call f(i) would have, if that were allowed.

Apply is a basic primitive in functional programming. You'll see it turning up in all sorts of different programming languages that attempt to accommodate the functional paradigm.

https://en.wikipedia.org/wiki/Apply

I think that's slightly off - apply is a method of a Function object, and its arguments are the argument for the function. So in this case, function is the object, and its apply method takes a single Integer argument.
 
I think that's slightly off - apply is a method of a Function object, and its arguments are the argument for the function. So in this case, function is the object, and its apply method takes a single Integer argument.

Yes, you're quite correct. The semantics of Apply vary considerably from language to language.
 

poweld

Member
Yes, you're quite correct. The semantics of Apply vary considerably from language to language.

Yeah, the style you mentioned sounds like Python methods where you are implicitly passing self as the first parameter.

Sidenote: I love programming so much. I've spend a good portion of my break going through some great exercises from the book Functional Programming in Scala

I certainly experience ups and downs in this industry, but as long as there's something to learn I find it difficult to fall into complacency.
It's only been 6 years since I earned my degree, but it seems like each year I understand more than the last, and realize how much more there is to learn.

Finally, it feels great to have a small community here to share knowledge with. Sites like stackoverflow are a bit too "big" for me to feel comfortable contributing.

Anyway, cheers!
 

Mr.Mike

Member
http://www.oreilly.com/pub/get/prognews?imm_mid=0c924a&cmp=em-prog-na-na-newsltr_20141227

O'reily is offering a free ebook out a a selection of:

Test-Driven Development with Python
iOS Game Development Cookbook
Java Performance: The Definitive Guide
Continuous Enterprise Development in Java
Clojure Cookbook
Mastering Perl Second Edition
Mining the Social Web, Second Edition
Java Network Programming, Fourth Edition
Understanding and Using C Pointers
Embedded Android
ZeroMQ
Programming Android, Second Edition
Geolocation in iOS
Programming Computer Vision with Python
Safe C++
Python and AWS Cookbook

Mining the Social Web seems pretty interesting to me. I have currently tasked myself with reading K&R, SICP and a tutorial on HTML and CSS, in theory before the start of my next semester. I might be putting too much on my plate. Regardless, SICP is pretty cool so far.
 
I have a Python question. I read a couple of months ago about a way you could increase the speed of a class (as in, member and method access IIRC) by 'freezing' it, which meant that you could not add new methods/members to the class at runtime. I think you can do that because per default, a class is implemented as a hash table in Python and that change makes it so this is no longer the case. I've been googling for 'python freeze class' but all I'm getting is a method to make a class immutable, which is not quite what I want.
 

maeh2k

Member
I have a Python question. I read a couple of months ago about a way you could increase the speed of a class (as in, member and method access IIRC) by 'freezing' it, which meant that you could not add new methods/members to the class at runtime. I think you can do that because per default, a class is implemented as a hash table in Python and that change makes it so this is no longer the case. I've been googling for 'python freeze class' but all I'm getting is a method to make a class immutable, which is not quite what I want.

This might be what you mean:https://wiki.python.org/moin/Freeze
 

Thanks. I registered and ended up choosing the C++ book. With the amount of high level languages I've been using for the past few years, I need a refresher on the low level stuff.

I might be putting too much on my plate. Regardless, SICP is pretty cool so far.

SICP is one book I wish I'd had access to in the mid-1980s. Although it makes heavy use of the simplest and cleanest form of Lisp, known as Scheme, it brings a clarity of approach to program structure that benefits the reader no matter what they go on to do. I think that has a lot to do with the choice of that language for teaching, really.
 

That wasn't it, (it seems to be about 'compiling' a Python program so you don't have to rely on a Python interpreter being there) but some additional googling revealed this blog post, which is the one I was looking for. However It seems I didn't remember it right and it's mostly about memory usage, not performance when you have a ton of instances of the same (small) class.
 

JesseZao

Member
Sometimes I feel dumb because I need to sketch out what a program/function does on a piece of paper to follow it completely.

Flowcharts / pseudocode are the first thing you're taught when learning program logic and structure.

People use outlines in many disciplines. Planning the logic is the hardest part!
 
it doesn't seem like people are understanding what i'm saying.

first of all it is a function from the sorted value to a value that is 'somewhat close' to its index

second of all it is an approximating polynomial generated by least squares fitting. If we were attempting to exactly determine the index of a given value via polynomial the fact that duplicates can exist would be a problem. That is not the goal, the goal is to take a very large search space and transform it into a much smaller search space that you can then binary or sequential search. As such we can use (value,index) pairs as a dataset which we can use to provide an approximating polynomial of fixed degree by least squares fitting.

What im saying is, if values can appear multiple times, say P({1,2,3,4,5}) = 6, then I don't see how you can make this constant degree polynomial approximation of the inverse apply to the general case. If you have a concrete example or construction then please share. In the above example, you would need 1 <= f(6) <= 5. Whereas if the value appeared only once you could get by with a tighter range. Your range could be the maximum multiplicity, but in the worst case you've got the full array as the range.

Also insertion cant be less than O(n), because you need to re compute the polynomial.
 
Ok, my Google skills are failing me. What is the name of the feature in Visual Studio that allows you to click on some code and go directly to its declaration in its source file? Does Qt Creator also have this feature?
 
Ok, my Google skills are failing me. What is the name of the feature in Visual Studio that allows you to click on some code and go directly to its declaration in its source file? Does Qt Creator also have this feature?

Jump to definition/declaration and yeah, it's F2 in QTCreator :)
 

cyborg009

Banned
Finally got to try android studio and wow it's pretty good! I think I need to take a look back at my Nerd Ranch books again. But since I'm going to restart my old project I wanted to ask a question about fragments.

In my old project I only had one activity but multiple fragments and I just kept replacing fragments every time I pressed a different button to go on a new page. Is this method correct? I know I was once told that every activity should have a fragment which I was use doing before.
 

Yoda

Member
So I'm looking to teach myself XML. I'm already familiar with Javascript/HTML/CSS/Python/C/C++/Java but I'm having trouble picking a solid guide. Anyone have any suggestions?
 

Husker86

Member
I have a question regarding GPLv2 licensed art.

If I use, for simplicity's sake, one piece of art in my game that is GPLv2 licensed, do I have to honor requests for my entire game's source code?
 
I have a question regarding GPLv2 licensed art.

If I use, for simplicity's sake, one piece of art in my game that is GPLv2 licensed, do I have to honor requests for my entire game's source code?

Short answer seems to be: yes.

There's this weird gray area regarding if you using the art makes your game derivative of that work, but most likely answer is still yes
 

Husker86

Member
Short answer seems to be: yes.

There's this weird gray area regarding if you using the art makes your game derivative of that work, but most likely answer is still yes

GPL for art is weird and I'm not sure that it would carry over to code. But I wouldn't trust it.

Thanks for the quick responses.

Honestly, I'm probably going to have to just go for it. I am learning Blender to make a Unity game that doesn't just consist of sprites created by me (lets just say that it's apparent I concentrate more on programming than art), and am going to have to rely on textures from Open Game Art website.

Maybe I'll take a day or so and see what kind of tiles I can create by myself, but I'm not too optimistic about the results.
 

Husker86

Member
Are you worried about open sourcing your code?

Basically.

Though I obviously wish for success, in reality the game will probably not be so widespread that anyone would want to reskin it (or just not bother reskinning) and rerelease it, but if it ever got to that point I'd prefer for that to not be possible.

For that reason I will most likely go with more basic textures that I can come up with, or look for some CC BY licensed art which just require attribution to the creator.
 
Basically.

Though I obviously wish for success, in reality the game will probably not be so widespread that anyone would want to reskin it (or just not bother reskinning) and rerelease it, but if it ever got to that point I'd prefer for that to not be possible.

For that reason I will most likely go with more basic textures that I can come up with, or look for some CC BY licensed art which just require attribution to the creator.

Don't go GPL over 1 little piece of art. GPL needs to die, quite frankly.
 

Bleepey

Member
Is there anyone here who uses R? I have read the dummies book on r programming and I wanna get better at it. Any resources online that can allow me to test what I know. I wanna use it for epidemiology-related tasks such as modelling, logistic regression, decision tree modelling that sort of thing. I wanna ask here before I make a thread.
 

survivor

Banned
I am having a hard time opening Android Studio on Mac.

I get this Error:



I downloaded the Java Platform (JDK) 8u25.

Please help me. :(

I had the same issue when I updated to Yosemite. I believe Android Studio needs java 6 in order to run. Basically I just downloaded this java version from Apple website and it allowed me to run Android Studio while keeping whatever JDK I installed beforehand.
 
Any assembly folks here? Can somebody break down for me what these are:
Code:
.little
.text
.data
.stack
.code
The beginning of my compiled programs are littered with stuff like this. I'm trying to learn through examples and university PDFs, but I'm not finding a good description on what they are.
 

Kansoku

Member
Any assembly folks here? Can somebody break down for me what these are:
Code:
.little
.text
.data
.stack
.code
The beginning of my compiled programs are littered with stuff like this. I'm trying to learn through examples and university PDFs, but I'm not finding a good description on what they are.

I've only seen .text and .data, and it's been a while, so this might be incorrect, but I remember that ".text" was to indicate where the code was, and ".data" for variable declarations for the run time or something like that.

Code:
.text
.globl main

addi s0, x, 3

.data
 x: .word 5

s0 holds 8 at the end.
 
I've only seen .text and .data, and it's been a while, so this might be incorrect, but I remember that ".text" was to indicate where the code was, and ".data" for variable declarations for the run time or something like that.

Thanks for the help. Do you have or know of any resources I could look at?
 

mooooose

Member
I've only seen .text and .data, and it's been a while, so this might be incorrect, but I remember that ".text" was to indicate where the code was, and ".data" for variable declarations for the run time or something like that.

Code:
.text
.globl main

addi s0, x, 3

.data
 x: .word 5

s0 holds 8 at the end.

s0 wouldn't hold 8, you can't even do that. anything in the data section is initialized when the program starts and is considered static data. all memory is assigned space and possibly a value, and defined by a label. that label refers to the address

so you would have to do

lw $s0, x (load word from address x)
addi $s0, $s0, 3 (add 3 to x)
sw $s0, x (store x back into memory from the register that we manipulated)

you can't just manipulate memory like that

Thanks for the help. Do you have or know of any resources I could look at?

what kind of assembly is it?
 
Got Android Studio running

Just run this in Terminal

launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk

I need to figure out how to open Sublime text in Terminal using subl. Help? Mac here
 
Don't go GPL over 1 little piece of art. GPL needs to die, quite frankly.
Completely false. It's a hammer, but an absolutely necessary hammer in some situations. It's impossible to imagine Linux being as successful and transformative without the GPL. Everyone who wants to use it in their product is obligated to contribute back. That's tremendously useful in certain contexts.

But people should not license their stuff under the GPL unless they really, really understand all the ramifications first. It's often used as the de facto OSS license, and it absolutely shouldn't be. Even if you want something copyleft, Mozilla's license or the LGPL (I prefer Mozilla's license because it's more intuitive) is probably what you actually want, not the GPL proper.
 
Any assembly folks here? Can somebody break down for me what these are:
Code:
.little
.text
.data
.stack
.code
The beginning of my compiled programs are littered with stuff like this. I'm trying to learn through examples and university PDFs, but I'm not finding a good description on what they are.

They're section names. What a section name means depends on the executable file format and the OS loader. Since you're doing dreamcast assembly, you would need to check the Dreamcast spec to know what the nonstandard sections like .little are used for.
 

Nesotenso

Member
any good online tutorials about how to write makefiles? I was following Learning C the hard way online and am looking for additional resources on composing makefiles.
 

MarkusRJR

Member
So I'm planning to go to University this September to learn computer science, and I was thinking of getting a head start so I'm not completely flustered at the beginning of the school year.

Which programming language should I start with (most relevant or easiest), and are there any good online resources to learn how to program?

Also, I'm planning to get a cheap desktop since my laptop is hard to type on for longer periods of time. What are the lowest specs that I should get, that will last me my 4 years of uni programming? I don't have much money since I'm saving.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
What language does your school use? No sense learning C if your school is using Python or Java.

2nd. Send an email to your future professor or the department chair and ask them what language is used.

Then get yourself a good book on that language and start making some programs.

Most likely it will be Python, Java, or C++.
 

maeh2k

Member
So I'm planning to go to University this September to learn computer science, and I was thinking of getting a head start so I'm not completely flustered at the beginning of the school year.

Which programming language should I start with (most relevant or easiest), and are there any good online resources to learn how to program?

Also, I'm planning to get a cheap desktop since my laptop is hard to type on for longer periods of time. What are the lowest specs that I should get, that will last me my 4 years of uni programming? I don't have much money since I'm saving.

You don't necessarily need to get a head start. There'll be enough time to learn that stuff at college. The stuff that gets CS students flustered is usually math :)

As for programming language, any will do. The concepts are mostly the same. You don't need to pick the one you'll use at university.
Java/C# is always a safe bet. They are relatively easy to get into and are used a lot at as well as outside of university.
Starting with C++ wouldn't be a bad idea, either. It's not the easiest language and probably won't be used in Programming 101, but it gives you a different perspective when you start Java at university. I think knowing how pointers work in C/C++ really helps to understand Java.
Or you could start with a functional language like Haskell. I think it's a great language for starting programming and you'd quickly get familiar with recursion.

You could take some classes on coursera: https://www.coursera.org/courses?languages=en&categories=cs-programming,cs-theory
This one starts in February: https://www.coursera.org/course/pythonlearn and this one in March: https://www.coursera.org/course/codeyourself
This one would also be an option: https://www.coursera.org/course/gameprogramming


Programming at university rarely demands for a powerful device (especially not at the beginning). Virtually any desktop will do. You could also get by plugging an external keyboard/mouse/monitor into your laptop. Doing stuff on the laptop has the advantage that you always have it with you on campus/in class. You could try to hold off from purchasing a desktop and wait till the need actually arises. Then you'd already be settled in and you'd have a way better idea of what you need.

If you do buy a desktop, consider that you probably won't need Windows (which you get for free at most universities; or you could just use Linux). Don't know what your budget is, but if you don't just want the cheapest one possible (which would still be fast enough), you should look into this one: http://amzn.com/B00ILH15DA or the Dell Poweredge T20. The two are relatively cheap, but really nice servers. The Xeon 1225 is pretty great. They don't come with an OS (free from university). They aren't big gaming rigs (can't put in really fast GPUs since that would need a bigger power supply) -- it's not what those servers are meant for -- but for programming and light gaming they're perfectly fine.
I bought the Dell not too long ago for myself. I put in a cheap SSD and used a Windows 8.1 license I already had. I think it's a great machine for a really great price.
 

MarkusRJR

Member
2nd. Send an email to your future professor or the department chair and ask them what language is used.

Then get yourself a good book on that language and start making some programs.

Most likely it will be Python, Java, or C++.
Looking at the course material for the current year it appears to be Java.

You don't necessarily need to get a head start. There'll be enough time to learn that stuff at college. The stuff that gets CS students flustered is usually math :)

As for programming language, any will do. The concepts are mostly the same. You don't need to pick the one you'll use at university.
Java/C# is always a safe bet. They are relatively easy to get into and are used a lot at as well as outside of university.
Starting with C++ wouldn't be a bad idea, either. It's not the easiest language and probably won't be used in Programming 101, but it gives you a different perspective when you start Java at university. I think knowing how pointers work in C/C++ really helps to understand Java.
Or you could start with a functional language like Haskell. I think it's a great language for starting programming and you'd quickly get familiar with recursion.

You could take some classes on coursera: https://www.coursera.org/courses?languages=en&categories=cs-programming,cs-theory
This one starts in February: https://www.coursera.org/course/pythonlearn and this one in March: https://www.coursera.org/course/codeyourself
This one would also be an option: https://www.coursera.org/course/gameprogramming


Programming at university rarely demands for a powerful device (especially not at the beginning). Virtually any desktop will do. You could also get by plugging an external keyboard/mouse/monitor into your laptop. Doing stuff on the laptop has the advantage that you always have it with you on campus/in class. You could try to hold off from purchasing a desktop and wait till the need actually arises. Then you'd already be settled in and you'd have a way better idea of what you need.

If you do buy a desktop, consider that you probably won't need Windows (which you get for free at most universities; or you could just use Linux). Don't know what your budget is, but if you don't just want the cheapest one possible (which would still be fast enough), you should look into this one: http://amzn.com/B00ILH15DA or the Dell Poweredge T20. The two are relatively cheap, but really nice servers. The Xeon 1225 is pretty great. They don't come with an OS (free from university). They aren't big gaming rigs (can't put in really fast GPUs since that would need a bigger power supply) -- it's not what those servers are meant for -- but for programming and light gaming they're perfectly fine.
I bought the Dell not too long ago for myself. I put in a cheap SSD and used a Windows 8.1 license I already had. I think it's a great machine for a really great price.
I'll definitely check out the coursera classes. My one major concern so far has been math tbh. I've been working for 3 years and forgot all my high school math. I've been trying Khan Academy but it seems to just give you questions until you can't answer anymore, then loosely explain it (when I'd really prefer it to go in reverse). Is there any way to catch up on math (something with videos) so that'd be prepared by the fall semester? Also, which segments of math should I focusing on?

In regards to desktops, I was told that 8gb RAM should be minimum when using a virtual machine, but if I don't need that then that's awesome. I like your idea about getting a monitor and an external mouse/keyboard, which for some reason I completely forgot I could do. I'll probably end up doing that.
 

Water

Member
So I'm planning to go to University this September to learn computer science, and I was thinking of getting a head start so I'm not completely flustered at the beginning of the school year.

Which programming language should I start with (most relevant or easiest), and are there any good online resources to learn how to program?
There are a handful of starting languages that have a particularly good combination of features and ecosystem for beginners. I recommend Python. See these, plus the Coursera course maeh2k linked:

http://learnpythonthehardway.org/
https://www.udacity.com/course/ud036
https://www.udacity.com/course/cs101

Java is far from a good beginner language, unfortunately. Doesn't matter the university is using it as their intro language - the challenge is to learn programming concepts, program structure and get practice at building programs, and those things happen easier and more efficiently in other languages. Adapting to the specific quirks of Java isn't a big deal after you have programming basics down.
Also, I'm planning to get a cheap desktop since my laptop is hard to type on for longer periods of time. What are the lowest specs that I should get, that will last me my 4 years of uni programming? I don't have much money since I'm saving.
If your current laptop doesn't work properly, prepare to buy a decent one. If only prolonged typing ergonomics are the problem, get a good external display with a USB hub, a good keyboard and a mouse. For most CS students 100% of what they do throughout the degree is perfectly doable on a low spec Macbook. If you end up doing a bit of something where you legitimately need more hardware, like low-level computer graphics work, the university has computer labs for that. Having a primary machine so easy to carry that you can have it on you at all times is a very big deal in practice, at least it is with my work habits.
 

maeh2k

Member
I'll definitely check out the coursera classes. My one major concern so far has been math tbh. I've been working for 3 years and forgot all my high school math. I've been trying Khan Academy but it seems to just give you questions until you can't answer anymore, then loosely explain it (when I'd really prefer it to go in reverse). Is there any way to catch up on math (something with videos) so that'd be prepared by the fall semester? Also, which segments of math should I focusing on?

Don't worry too much about it now. Usually you'll have time to re-learn the stuff you need for a class and everyone forgets the high school stuff. University math is a bit different, anyway.

Maybe you could also check out a coursera class like: https://www.coursera.org/course/logic1. It's not a refresher, but logic is never a bad idea. You don't necessarily have to power through the class (there's still university), but it might be nice for getting a feel for college math.

Alternatively, you could look for a not-too-big entry-level book on discrete math. But focus more on getting an idea of what you're getting into than on actually learning everything now. Really, that's what university is for.

In regards to desktops, I was told that 8gb RAM should be minimum when using a virtual machine, but if I don't need that then that's awesome. I like your idea about getting a monitor and an external mouse/keyboard, which for some reason I completely forgot I could do. I'll probably end up doing that.

8GB is a good amount and certainly helpful for VMs, but I'm sure you could make do with less. A virtual machine with 2GB of RAM can already handle quite a bit of Java :)
 

Chaos

Member
So I'm planning to go to University this September to learn computer science, and I was thinking of getting a head start so I'm not completely flustered at the beginning of the school year.

Which programming language should I start with (most relevant or easiest), and are there any good online resources to learn how to program?

The free Computer Science course from harvard just started recently for 2015

https://www.edx.org/course/introduction-computer-science-harvardx-cs50x#.VKlcunveiHc
 
any good online tutorials about how to write makefiles? I was following Learning C the hard way online and am looking for additional resources on composing makefiles.

Learning Make is definitely the hard way. Honestly im going to do you a favor and just not answer your question. Learn a useful cross platform build system like cmake or gyp.
 
Top Bottom