I want to learn programming -- How?

In summary, learning a programming language can be beneficial for finding a job, pursuing personal interests, and generating extra income. C is a good starting point for its wide usage and ability to understand other languages. However, it may be beneficial to also learn languages like C++ or Java, which offer more flexibility and easier ways to construct software. It is recommended to attend a course to fully grasp the language and its concepts.
  • #36
jedishrfu said:
Checkout the open source Processing.org website. Processing is designed for casual programmers and interactive graphic artists. Programs are called sketches and there is a large collection of samples and books to learn from.

The Processing IDE supports several languages: java, javascript, python and scala (earlier version of the IDE)

We've used it at work for quick prototyping. The programming model is extremely simple. You define a setup() method that is run once and a draw() method that is called by default 60 times a second.

Java:
void setup() {
    size(200,200);
}

void draw() {
    ellipse(mouseX,mouseY,10,10);
}

The sketch shown above creates a 200x200 pixel window and reacts to mouse movement drawing a circle about each mouse cursor position.

Processing also supports an ANDROID mode where your program can be sideloaded onto an Android device which can make Android development a lot of fun.

You made me dig up some of my old Processing code. Here's an old sketch I made a long time ago:

Java:
//Recursively draw a leaf.
float aa = -PI / 3; //Angle a.
float ab = (11 * PI) / 36;  //Angle b.

void setup(){
    size(1400, 900);
    background(255);
    stroke(0, 200, 0);
    strokeWeight(1.25);
    drawStem(0, height / 3, 0, 150);
}

void drawStem(float x, float y, float angle, float lineLength){
  if(lineLength > 1){
      float endX = x + (lineLength * cos(angle));
      float endY = y + (lineLength * sin(angle));
      line(x, y, endX, endY);

      drawStem(endX, endY, angle + 0.05, lineLength * 0.9); //Main stem.
      drawStem(x + (endX - x)/3, y + (endY - y)/3, angle + ab, lineLength / 3); //Bottom leafs.
      drawStem(endX, endY, angle + aa, lineLength / 3); //Top leafs.
  }
}

I remember having a lot of fun with this language.
 
Last edited:
Technology news on Phys.org
  • #37
Zondrina said:
You made me dig up some of my old Processing code. Here's an old sketch I made a long time ago:

Java:
//Recursively draw a leaf.
float aa = -PI / 3; //Angle a.
float ab = (11 * PI) / 36;  //Angle b.

void setup(){
    size(1400, 900);
    background(255);
    stroke(0, 200, 0);
    strokeWeight(1.25);
    drawStem(0, height / 3, 0, 150);
}

void drawStem(float x, float y, float angle, float lineLength){
  if(lineLength > 1){
      float endX = x + (lineLength * cos(angle));
      float endY = y + (lineLength * sin(angle));
      line(x, y, endX, endY);

      drawStem(endX, endY, angle + 0.05, lineLength * 0.9); //Main stem.
      drawStem(x + (endX - x)/3, y + (endY - y)/3, angle + ab, lineLength / 3); //Bottom leafs.
      drawStem(endX, endY, angle + aa, lineLength / 3); //Top leafs.
  }
}

I remember having a lot of fun with this language.

and it still runs under Processing 2.2.1:

Screen Shot 2015-07-04 at 8.52.29 PM.png


Nice work Zondrina!
 
  • Like
Likes Thermo
  • #38
Wooow. Is that how you make graphics? Amazing!
 
  • #39
  • Like
Likes jedishrfu
  • #40
DrZoidberg said:
Beautiful recursive image. btw. I translated it to JavaScript and put it on jsfiddle
https://jsfiddle.net/o5peosbj/

Please give @Zondrina of PhysicsForum some author credit for this program as she was the one to post it here.

Place a comment at the start of the program as to who wrote and where you discovered it. Its a real important courtesy that is too often neglected in the real world of programming. In some cases, it has caused great legal troubles to some companies who've incorporated code into a product without the proper attribution.
 
  • #41
To @Zondrina:

One cool improvement that could be done is to switch to using the draw() method and add some variation so that the fern fronds move in the wind or with respect to mouse movement somehow.
 
  • #42
On a related topic, processing variations are available on Android (see java-based APDE app) and on iPhone (see javascript-based ProcessingJS app).

In addition, iPhone has Codea (Lua programming) and Pythonista (Python programming) apps which I think can be exported as uploadable apps for the AppStore and the Textastic programmers editor for viewing and editing 80+ programming languages.

On Android, there is the AIDE app for developing Android apps on the device the perfect gift to the mobile hacker.
 
  • #43
Making art with programming is cool. It feels good to make a nice drawing, since I can't really draw with my hand too well.

I was fooling around with a cool program I was going to make into an app. I wrote it in processing some time ago, and it brought back memories of my naive programmer days:
Screen Shot 2015-07-05 at 7.11.56 PM.png

Screen Shot 2015-07-05 at 7.13.24 PM.png


Screen Shot 2015-07-05 at 7.12.18 PM.png
 
  • #44
Zondrina said:
Making art with programming is cool. It feels good to make a nice drawing, since I can't really draw with my hand too well.

I was fooling around with a cool program I was going to make into an app. I wrote it in processing some time ago, and it brought back memories of my naive programmer days:View attachment 85578
View attachment 85577

View attachment 85576
I don't understand any of this. I am self taught in C. C usually does not support graphics as it is intended as a universal language. You seem to be producing graphics with C. I am only able to get graphics with the SVGA library in command line C in Linux but it is hard to load the application and to get it to work. Also it seems to be outdated. I am also able to program graphics on a Raspberry Pi in C but this seems limited to the raspberry pi. How did you get your graphics to work? Please correct me if i am wrong. Also you are right it is fun to make computer graphics.
 

Similar threads

  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
1
Views
737
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
8
Views
902
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
12
Replies
397
Views
14K
Back
Top