/tek/ Technology Archived Board plus4chan home [baw] [co/cog/jam/mtv/tek] [ck/coc/draw] [pco/coq] [a/mspa/op/pkmn] [Burichan/Futaba/Greygren/Plusle]
[Return] [Entire Thread] [Last 50 posts]
Posting mode: Reply
Name
Email
Subject   (reply to 2655)
Message
File
Password  (for post and file deletion)
  • Supported file types are: GIF, JPG, PNG
  • Maximum file size allowed is 7168 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 634 unique user posts.

File 129385971659.jpg - (14.82KB , 320x240 , dingwen[1].jpg )
2655 No. 2655
I saw a TED speech about essentially today you have no excuse to not be able to program- we should be teaching it to kids so that use computers as a tool, not a video game console to the interwebs, and that programming is something that all computer users should be able to do, and I agree.

So I'm trying to learn to program. The most practical I can think of is Java, for making actual programs, and having taken a little bit of programming in the past it looks the most familiar to me, plus you can get a working GUI virtually right away. Is Java a good language to start with? I know people will say "C++, faggot" but I tried reading a book about that and it looks a bit... overwhelming. I'd go with python but that looks a bit TOO easy.

what was YOUR first language? how many do you know now and do you think your first language contributed to how easy it was to learn more than one? Do you actually program for a living? What'd you recommended to do, first off?
34 posts omitted. Last 50 shown. Expand all images
>> No. 2943
>>2938
Someone correct me if I'm wrong, but technically having fewer lines is better; when code is read by the machine, each line represents a single operation by the computer. So in more complex programs, if you can execute everything through shortcuts that keep the overall line count down, you should. At least, that's how I understood it.

The thing is in the real world you'll need to be able to interpret other peoples 50 lines of code, and learning the single-line method requires knowing the 50 already, so.

OO programming has its' place but it does little to define hierarchy or organize itself. The theory I always thought was most suitable was that of Logical application; you should always go with the most efficient (I.E. fewest number of logical operations) method that is possible for you.
>> No. 2945
>>2943
The effect that the number of lines has on the efficiency of your application is negligible, at least directly. More important is the efficiency of the operations you're doing in those lines of code.

As an example (using PHP just because that's what I've coded in most recently and am therefore in the right mind for thinking in that syntax), a five line script that goes:

----------------------------
$myString = "Hello World";

function sayHello() {
echo($myString);
}

sayHello();
----------------------------

Would be a lot more efficient than a three line script that says:

----------------------------
for($i = 1; $i > 0; $i++) {
echo("Hello");
}
----------------------------

That's a ridiculously overblown example, though, since it uses an infinite loop. But the point remains the same: how many steps you make the interpreter (or computer, in a compiled language) go through is more important than how many lines your code is.
>> No. 2947
>>2943
You'd have to unroll every loop and other such nonsense for this to be a realistic way to look at it, but actually you've hit on the key insight for program optimization: You can never make individual instructions happen faster except by changing the clock speed, so the only way to get from point A to point B more quickly is to reduce the number of steps involved.

So, speeding up a program generally involves the following:
1) Figure out which parts absolutely have to happen to get the result you need
2) Establish a set of rules for the program to follow to make sure this result will be correct (if you didn't care about correctness, you could reduce every program to a single instruction that does absolutely nothing)
3) Replace the vital parts with the shortest version you can find that still follows those rules
4) Remove everything else

Programs that do this for you are called optimizing compilers. The "optimizing" part is important, because there are some compilers that don't optimize shit. However, even with those compilers, the very first thing that happens is that your source file gets translated into a format where trivial shit like formatting (comments, indentation, extra blank lines) and variable names ("numberOfWordsInDictionaryNotContainingTheLetterE" vs. "n") no longer matter to the computer. So if you go around deleting all the comments and newlines and renaming your variables to one-letter names, your program won't get any faster, but it will get harder for humans to read.
>> No. 2948
01001000011001010110110001101100011011110010000001110111011011110111001001101100
0110010000100001
>> No. 3010
>>2943
it's generaly accepted that you need to be twice as smart for debugging a code than for writing it in the first place. so by definition, if you write the smartest code (with all the fancy shortcut you know) you'll never be able to debug it and make it run (and you ALWAYS have to debug your code).

go for readable, easy to maintain or change code. when the program is done, look if you need to make it quicker. if you don't, good, you're done. if you need to, profile it and work on the bottle neck and only the bottle neck.

that the real way to be lazy.

(one could argue that you have to make algorithm optimisation at the start. IMO it's depends. don't be dumber that you are and use the obvious effecient solution. but try to make your code in a way that is easy to change)

tl;dr: your code gonna be read, your code gonna be change, but you don't know if is gonna be fast enougth. make it readable and plastic. see speed problem at the end.
>> No. 3011
>>2948

01001101 01101111 01110010 01100101 00100000 01101100 01101001 01101011 01100101 00100000 01001100 01100001 01101101 01100101 01110100 01100001 01110010 01101001 01101110 00100001
>> No. 3013
>>3011

001010000101111100101001010111110010100100100000010110010110111101110101001000000110001101100001011011100010000001101011011010010111001101110011001000
0001101001011101000010110000100000011000100111010101100100011001000111100100101110
>> No. 3024
>>3013
00101000 01011111 00101001 01011111 00101001 01111110 01111110 00100000 00001101 00001010 01000101 01010111 01010111 01010111 01010111 00100001 00001101 00001010 01001110 01101111 00100000 01110100 01101000 01100001 01101110 01101011 01110011 00101110
>> No. 3027
ZmFnZ290cw==
>> No. 3028
>>3027
Tk8gVQ==
>> No. 3081
I can't remember if my first programming language was TI-BASIC or the Expression language for GMod's Wiremod. I suppose normal wiremod building is almost a coding language. The expressions got me into Lua coding for GMod, and after that I got a book about Python and PyGame. Learned some Assembly for GMod as well, and while Python is awesome and I love the Shell, it is horribly slow compared to Java or C.

At the same time I was forced to learn JavaScript in school (I actually had a use for it on my Minecraft server recently. Imagine my surprise.) and I've continued to learn Java with a book as well.

I feel like programming has more to do with learning to think and express actions in a way a machine can understand, and then the language is just flavoring. Talking has the same principle, you have to learn to express an idea, and then the spoken language is just a medium.
>> No. 3082
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/

horray for learning!

also Java
>> No. 3084
oh hey
have you guys ever
guys have you ever
like seriously
guys
have you ever tried to
seriously
tried to use
java+alice
>> No. 3148
http://www.amazon.com/Head-First-2E-Real-World-Programming/dp/1449380344/ref=sr_1_1?ie=UTF8&qid=1302801138&sr=1-1-catcorr
>> No. 3215
Hmmm.....I took CompSci in highschool, learned Python as my first language. I can still remember the Tetris game I made with Pygame...
Afterwards, I learned Turing and Flash over the summer. Took CompSci again and learned Java. Then I went on to learn Scheme, C, C++, as well as PHP and HTML. Which technically isn't programming, but oh well.

I recommend learning Python first, as it is very visual, and easy to grasp on to the concepts. It is probably one of the most straightforward and basic languages, good for beginners.
>> No. 3216
Read the following statements and tick the box next to the correct answer.

int a = 10;
int b = 20;
a = b;


The new values of a and b are:
[ ] a = 20 b = 0
[ ] a = 20 b = 20
[ ] a = 0 b = 10
[ ] a = 10 b = 10
[ ] a = 30 b = 20
[ ] a = 30 b = 0
[ ] a = 10 b = 30
[ ] a = 0 b = 30
[ ] a = 10 b = 20
[ ] a = 20 b = 10

http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html
>> No. 3217
>>3216
That paper was interesting but also frustrating because I really would have liked to see what answers they were looking for.
>> No. 3233
>>3216
As it turned out later, the whole premise of the test was completely retarded. A lot of the people who gave the wrong answer were trying to read it as a mathematical formula, since they'd never been exposed to C/Fortran assignment conventions. Obviously, if you do that, this bit of code implies that 10 is equal to 20.

A follow-up study found that this is language-dependent. For example, you get quite different results if you use code in a language where "=" is only used for the first assignment, and you have to use some other operator for mutation (like Haskell). Alternatively you can just tell everyone to read "=" as "becomes" rather than "equals" and you see more or less the same improvement.

tl,dr: This test is useless.
>> No. 3237
>>3217

It's a trick question bro.
B wasn't assigned a new value.
>> No. 3503
File 131186698384.jpg - (172.49KB , 800x675 , my-cute-dog-derp.jpg )
3503
>make "Hello World!" work in C
>feel accomplished far out of proportion to actual accomplishment.
>> No. 3504
>mfw butthurt comp sci faggots
>peddling a worhtless skill already easily fulfilled by low-cost hindus
should have learned a real science, suckers
>> No. 3517
>>3504
This. There's no hard work involved in programming. All you do is sit in a chair and type. We already teach children to do that in kindergarten. Why are there schools that teach this to adults?
>> No. 3526
>>3517
>There's no hard work involved in programming
I don't think you realize how dumb that sounds.
>> No. 3542
>>3526
I think your trollometer has an extra GOTO 10 line somewhere.
>> No. 3579
File 131366757495.jpg - (429.01KB , 629x900 , 13598050.jpg )
3579
Why does everyone have to be able to program? I study this shit, because I want to do it for a living, why do you need to do it? Just use your computer and learn what interests you or you need to get along. If that involves using the terminal or fucking around with blog layouts or modifying games read tutorials.

We started with C. Followed by C++ and Java. The latter make things a lot easier but if you don't know the basics you'll never truly understand what the fuck your are doing.

And I hate everyone who writes one line instead of 50 in a team. Write clearly and comment if someone else has to understand it (including future self).
//When I wrote this, only God and I understood what I was doing
//Now, God only knows

HTML is for babbies. I enjoy being a babby.
>> No. 3585
Disagree with the guy in TED
Programming is not something people need to know (aside from theory), simply because not all people can grasp it.... hardware on the other hand, is something essential
Knowing how a screen or a hard drive works and how an entire computer fits together should be the kind of basics that are REQUIRED simply because people need to know how to manufacture computers

After all, not everyone knows automotive engine design but everyone knows how to fix a spark plug

>>2656
Hey, at least it's something
>> No. 3686
File 131526381113.png - (111.89KB , 1437x727 , Exercise example.png )
3686
I've been working on this beginner's Java exercise for about 3 hours now and I can't seem to crack it.

>Your program asks you to enter the size (number) of a row and get the row size from the key board. Based on the size of the row, your program asks you to enter the size of each column and get each column size from the key board. Based on the row size and the column sizes a user entered, you program constructs a two dimensional array and assigns integer numbers from 1 to the total size of the array, and displays all elements in the array.

I'm pretty sure I can assign all the numbers to the individual array cells and the like with some for-loops, but how do you set it up so that you can set the individual column sizes? Picture is an example of what my book is asking for.

Sorry in advance for what seems to be an easy problem, I'm just starting programming and all of this is a little new to me.
>> No. 3688
>>3686
The problem is, since the class wants you to demonstrate your knowledge of certain concepts, doing it the way I would do it probably wouldn't work all that well. Because personally I'd just build the array as the inputs were being given.

1. Create empty array.
2. Ask for row length.
3. Push a number of empty arrays equal to the row length into the empty array.
4. Loop through each of the empty member arrays.
5. Ask for column length.
6. Push values into active member array.
7. Repeat until done.
8. Display results.

But I suppose one way you could do it like the class is demonstrating is to just set the row length as a variable and then have the column lengths as an array with a number of integers representing the length of each column equal to the row length, then generate the two-dimensional array using that.



Also, if the value of each cell is supposed to be a raw cell count, you would also want to set up an extra iterating variable to keep track of which cell you're on, since your x iterator is going to get reset each time you finish a y loop.
>> No. 3804
>>3686
>>3688
Finally got it back, it's terribly commented, poorly thought out, most likely terribly inefficient, and all sorts of other nasty things. I'm still proud of it for being my first bit of code. And since it's graded I can finally share it with all of you!

import java.util.Scanner;

public class HomeworkOneArray {
static Scanner scanner= new Scanner(System.in);

public static void main(String args[]){
System.out.println("Please input the number of rows and columns you want.");
int NumOfRows=scanner.nextInt();
int NumOfColumns=NumOfRows;//So that the columns will equal the number of rows, making a square.
int[][] HWArray=new int[NumOfRows][];//initializing 2-D array and setting rows.
AskLoop(HWArray, NumOfColumns);//This method asks the user for the sizes of the individual columns.
FillLoop(HWArray);//This method fills the 2-D array with the necessary numbers
OutputLoop(HWArray);//Prints out the contents of the 2-D array
}//End main method

public static int[][] AskLoop(int[][] HWArray,int NumOfRows){
for(int a=0;a<NumOfRows;a++){
System.out.println("Size of this column?");
int column=scanner.nextInt();
HWArray[a]=new int[column];
}//End of column for-loop
return HWArray;
}//End AskLoop method


public static int[][] FillLoop(int[][] HWArray){
int Numbers=0;
for(int b=0;b<HWArray.length;b++){
for(int c=0;c<HWArray[b].length;c++){
Numbers++;
HWArray[b][c]=Numbers;//Without count the array will produce nothing but zeros.
}//End of inner loop
}//End of outer loop
return HWArray;
}//End FillLoop method

public static int[][] OutputLoop(int[][] HWArray){
//These two for-loops print off the array
for(int d=0;d<HWArray.length;d++){
System.out.println(" ");
for(int e=0;e<HWArray[d].length;e++){
System.out.print(HWArray[d][e] + ",");
}//End of inner loop
}//End of outer loop
return HWArray;
}//End Output method

}//End HomeworkOneArray class
>> No. 3805
>>3804
Out of curiosity how would I make this more efficient, or at least more self-explanatory? It just feels far too clunky, I'm sure I can reduce the amount of lines in my code somehow, and obvious, you can tell that I was required to make a lot of comments and went kind of wild with it all.
>> No. 3831
Impractical.


Nobody can do everything. We're already asking kids to learn a second language in school. It will only make the work load heavier and you'll end up with more dropouts and cheats getting through by the skin of their teeth.


I think it would be great if better classes were offered in public schools, but making them a requirement would be asinine.
>> No. 3834
>>3831
In my opinion, 'no child left behind' was concocted with the explicit intention of making it harder for normal kids to graduate. It did nothing about the failing school system or shitty teachers or defunct material itself and just put the thumb screws to the kids. No piece of graduation paper, you may as well be a felon as far as colleges are concerned. The idea that a second language should be required is absurd.
>> No. 3835
>>3834
>In my opinion, 'no child left behind' was concocted with the explicit intention of making it harder for normal kids to graduate.
I really doubt that. I have a hard time believing something could be so malicious when just plain stupidity and a lack of touch with the reality of teaching is already such a good explanation.
>> No. 3868
File 132008239696.png - (34.26KB , 400x251 , AmigaBASIC.png )
3868
I began with Amiga BASIC, ARexx and BlitzBasic, then learned JavaScript and PHP after long break. Now working as Java (learned, with C/C++, during studies) developer.

I think programming education should be like that:

Kids 7-12 years old: BASIC-256, LOGO or anything from this list: http://en.wikipedia.org/wiki/List_of_educational_programming_languages#Children

kids 12-16 yrs old: more sophisticated BASIC dialects (like VisualBASIC), first steps in C, Python, PHP etc. Maybe good old Pascal (like Free Pascal).

16-18 year old: C, Python, PHP moving to intermediate (like random file access, database connection etc.)

>18: Java, C++, C#, OOP in Python and PHP, just anything advanced and/or related to vocational training.

But still everything depends on the teacher.
>> No. 3873
Huh, I just failed a Java course this year and that article about the sheep and the goats pretty much describes me, particularly the bit about meaningless symbols - that really made me impatient with the whole thing.

My tutor was rather unhelpful too, I'm guessing he was aware of this statistic and just lumped me in the non starters as soon as I failed the first assignment.

>:(
>> No. 3874
File 132035062922.jpg - (16.25KB , 254x277 , Araki.jpg )
3874
>>3873
I was in your exact position once. About a year ago I started Java 101 for my Computer Science degree. I was lost in regards to every aspect of programming, and subsequently failed the midterm exam. However by the end of the semester I had an A- in the course.

Here's some advice if you decide to continue trying to code.

>Always write the code
It's nice to look at the teacher's power points, but at the end of the day you're never going to understand code just looking at it, you've got to get down and dirty with it to really understand it.

>Don't get overwhelmed by the entire program, take it method by method, piece by piece.
You have to assume a certain mindset while programming. You don't take a problem as a whole, you break it down into manageable pieces and solve it. When trying to understand a problem, don't let your eyes glaze over the method, start from the arguments and work your way bit by bit to the end. Look for patterns, when you find one you can duplicate it and have a significant part of the program or method written in no time at all.

>Learn from your fellow students as well as your teachers
I've learned just as much from my fellow students, if not more, about code than my teachers. Having to explain a program to a struggling friend or having a program explained to you in simple, easy to understand terms helps immensely. Don't be afraid to make friends with some of the CS majors in your class, they'll make life a lot easier for you.

>While coding look for shortcuts.
As previously stated in this thread, a good programmer is a lazy programmer. Don't write
>int a;
>a=3;
>return a;
write
>return int a=3;
Find ways to make your life easier, that's the secret to good efficient programming.


All that aside I'd be happy to help you out with whatever you're on! A few questions first:
>What topics are you studying in class/previously covered?
>What IDE (Netbeans, BlueJ, Eclipse, etc.) are you using to program?

Just post your code to pastebin.com and post it here and I, and maybe a few people who've previously posted ITT, will help you out. If you have any general questions (Data types, arrays, sorts, methods, syntax, etc.) then ask away. Don't give up just yet, it's hard at first but after the initial plunge it's all easy.
>> No. 3875
Thanks, it was a distance education course (Open university) so no fellow students, but I do know and share apartment with programmers so I could have asked, too proud maybe, or I just thought it was too basic to bother them (One of my flatmates is a working programmer, the other one is a E. engineer university lecturer doing a doctorate)

You're right about doing the code, I twigged onto that a little too late to save the course but it all became a lot clearer when I actually wrote everything myself, no matter how obvious and "duh" it seemed when just reading it.

It's been a frustrating and expensive waste of time, so I'm thinking I'll keep trying (That pride thing again, I don't want to be a goat) but I'll go solo. Maybe set myself some kind of project to motivate me.

I'm thinking switching to python and learning what it can do in conjunction with blender, which I'm also learning.
>> No. 3946
>>3875

no such thing as a doctorate for engineers
>> No. 3954
>>3946

maybe they are an Engineer doing a doctorate in a different field
>> No. 3960
I don't know what to tell you. His thesis is in software engineering, cloud computing applied to mobile phone platforms.
>> No. 3961
I don't know what to tell you. His thesis is in software engineering, cloud computing applied to mobile phone platforms.
>> No. 3973
Hah. I suppose technically it would be Pascal in school.

But really, first proper language learned was VB. I think it's an awful language now.

Now I know C++ (and by proxy a bit of C), C#, Java, bit of Python, bash scripting and ofc HTML (the easiest one of all and not *really* a programming language per se - it's a markup language). Oh yeah and xml.

I think once you got the basics down and can get your head around variables, value vs reference types, functions and classes, then everything else is easy.
>> No. 4036
Does a Window Manager for Linux, coded in C, seem like a project to take on in order to learn the language?
I have never learned anything more than the cursory Python tutorial, but I have also never had a reason to program.
>> No. 4053
File 132794276574.jpg - (604.48KB , 1024x600 , 129333489452.jpg )
4053
I fucked around with QBasic in high school, barely passed, tried VisualBasic and ragequit due to the sheer childish nature of the language. (Also, I was stupid.)

Like OP, I'd love to learn me some programming language, only I'm not sure where I'd even apply such a hobby. Would Javascript or Python be a more useful language to learn?

>>3585

This makes a lot of sense to me. But learning about computer hardware seems like it would be more difficult than learning a programming language. . . Which is more complex, the way it all fits together or understanding the software?
>> No. 4055
>>4053
Understanding the hardware is more difficult, and less useful day to day. A working understanding of soldering, electricity and general circuitry is more than sufficient for your average enthusiast. They have programs complicated enough to design Computer chips now, and non-civilian tech is beyond even that.

Code, however, is free with the purchase of a computer. IDE's are free. The problem is self-directed coursework. Understanding the theory of it can be different then the practical work. Since programing languages have their own libraries, it's fully possible to follow enough directions to create market ready programs without a full knowledge of how they actually work. Not a good idea, but possible.

I'm reading a how-to java book by Robert Lafore right now. It's good stuff, simple explanations. There's a logic to all this but too many people like to keep their damn jobs.
>> No. 4056
>>4053
>But learning about computer hardware seems like it would be more difficult than learning a programming language
In my experience learning a practical amount about hardware is far easier than learning enough of a language that you can do useful stuff with it.
>> No. 4063
From grade school to high school I learned:
Logo
BASIC
Turbo C++

And I think one other language, but I can't recall clearly.

I remember barely anything about how to program on those anymore. :p
>> No. 4069
I'm taking a course that goes over bioinformatics analysis tools, learning really basic stuff like baby steps in mysql and perl.

And good god. R. I cannot stand R. The documentation is no help for even basic things and the error messages are cryptic with no useful explanation available.
>> No. 4070
I should come to /tek/ more often. I had no idea this thread was here.

4th year in the computer science major, still feels like I'm making shit up as I go along while waving my hands. I'm not sure if that's how I'm supposed to feel though.
>>4053
>This makes a lot of sense to me. But learning about computer hardware seems like it would be more difficult than learning a programming language

Speaking from my limited experience, which just amounts to a couple of classes, it's not particularly too difficult. I mean, unless you're talking about the engineering perspective. But when you get into stuff like caching, pipe-lining and all that jazz it's not too bad. I mean I had a much easier time understanding that than grasping things like dynamic programming.

But really programming languages are kind of in a similar situation considering you can solve a lot of problems without actually going too in-depth of an understanding of the language. But then again there are people who could go to graduate school and spend years trying to learn the ins-and-outs of a language and still not completely understand it all.
>> No. 4078
It think it was the BASIC variant that was used in "Learn to Program Basic", though I might have tried out batch files a bit first.
Not sure I know any that well, I know some BASIC, ANSI C, the fact that I do not want to use Java ever, Flash, and now some Lua.
No I do not.
I think a QBasic variant might be good, but so far Lua is nice. Very C-like, but to me it seems a bit easier. Though now that I think of it, I might be able to go back and do better at C, I'm not sure. I ran into a brick wall trying to work with the filesystem the last time I tried C, but it went pretty smoothly in Lua despite the complete I/O model being so similarly to that of C. I think a part of it is that I'm not searching though a pile of libraries for the most simple of tasks. The Programming in Lua Guide has been very useful, at any rate.
[Return] [Entire Thread] [Last 50 posts]


Delete post []
Password  
Report post
Reason