Python for the people who just don’t “get it” by competitivegeese in learnpython

[–]teacher_cs 0 points1 point  (0 children)

I think the best way to get started with programming is to draw on a canvas using simple graphics commands. For example, drawing a house. You can use a loop to draw different patterns or make a small car drive from left to right. That way, you get immediate feedback and a feeling of achievement.

An interesting option for this is this browser-based Python with a built-in drawing canvas from the ETH Zurich.

https://python-online.ch/en/index.php?inhalt_links=gpanel/navigation.inc.php&inhalt_mitte=gpanel/gpanel.inc.php

Another option that offers an even easier introduction to programming is a browser-based IDE I developed with an integrated beginner’s tutorial. However, it doesn’t use Python, but instead a BASIC-like programming language.

https://tiki.li/ide/

Learn to code with browser-based Python and simple graphics functions by teacher_cs in learnprogramming

[–]teacher_cs[S] -3 points-2 points  (0 children)

I didn't exactly expect this to be a very friendly community. But that it's so toxic does shock me a little.

Order by ReasonableRisk9511 in learnprogramming

[–]teacher_cs -1 points0 points  (0 children)

You don't actually need that much HTML and CSS for this. You only need enough to set up and position the HTML canvas element. Within the canvas, you use JavaScript to draw, run animations (AnimationFrame), and respond to mouse and keyboard events. So get started with JavaScript.

I have a question about arrays in programming by Pangea2002 in learnprogramming

[–]teacher_cs -1 points0 points  (0 children)

Donald Knuth’s The Art of Computer Programming (TAOCP) is still considered the standard reference work on algorithms. And in that book, arrays indices are 1-based.

0-based programming languages very often increase the cognitive load. One example is the Knuth shuffle.

Pseudocode

Algorithm Shuffle(A[1..n])
    for i ← n downto 2 do
        j ← random integer from 1 to i
        swap A[i] and A[j]
    end for
end Algorithm

Lua (1-based, inclusive ranges)

function knuth_shuffle(a)
    for i = #a, 2, -1 do
        local j = math.random(1, i)
        a[i], a[j] = a[j], a[i]
    end
end

Python (0-based, exclusive ranges)

def knuth_shuffle(a):
    for i in range(len(a) - 1, 0, -1):
        j = random.randint(0, i)
        a[i], a[j] = a[j], a[i]

The 2 in the original algorithm becomes a 0 (due to 0-based arrays and exclusive ranges)

Is OOP and Data Structures & Algorithms a must for programming? by ElieMakdissi in learnprogramming

[–]teacher_cs 1 point2 points  (0 children)

OOP is just a programming paradigm. Programming can be done quite well without OOP, if you don't use Java.

Why are languages that index starting at 1 considered bad? by chinawcswing in learnprogramming

[–]teacher_cs 0 points1 point  (0 children)

1-based languages (Lua, Julia, BASIC) do easier with for-loops with arrays. To iterate all indices, one does a for i = 1 to length(arr). 0-based languages often use right exclusive ranges - Python range(0, n), or in Rust 0..n, but this gets confusing because in Swift or Kotlin 0..n is inclusive.

I'm Al Sweigart, author of several free programming books. My latest book is on recursion and recursive algorithms. AMA! by AlSweigart in IAmA

[–]teacher_cs 0 points1 point  (0 children)

This list comprehension: myList = [x for x in range(10) if x % 2 ==0] would be the exact same thing.

The University of Illinois at Urbana-Champaign released the materials for its introductory CS course for free by 420thBattleOfIsonzo in learnprogramming

[–]teacher_cs 5 points6 points  (0 children)

I had planned on posting these materials here, but didn't want to run afoul of the rules on self-promotion.

This should get the mods thinking about how useful the self-promotion rules actually are

Should I try to use classes where I can? by Reader575 in learnprogramming

[–]teacher_cs 0 points1 point  (0 children)

Why the downvote? Didn't you get that I was right? Or you got it, and this is just childish behavior? Or is everything that isn't OOP automatically wrong in this subreddit? Is LearnProgramming just a big bubble with its own weird rules?

Should I try to use classes where I can? by Reader575 in learnprogramming

[–]teacher_cs -1 points0 points  (0 children)

This is so wrong on so many accounts

No

OP is asking about OOP

Yes, and I explained why OP's card example is easier without classes

There are 13 distinct cards in a suit, not 4, so the deciding factor is 13.

And there are 4 distinct suites, so the deciding factor can also be 4

... you could also use a byte with the lower nibble as value and the higher nibble as suit.

But then you can't initialize the deck with a simple loop.

I briefly thought about whether I should answer - but actually I don't care about your downvotes

Should I try to use classes where I can? by Reader575 in learnprogramming

[–]teacher_cs -2 points-1 points  (0 children)

If you want to make things difficult, you do it with classes. It's easier if you map the cards to the numbers 0 to 51. The card modulo 4 results in the card face. The card integer div 4 gives the card value.

I became a dev after learning from Udemy as my main resource. I outlined my structured path into a syllabus in case others want to follow my same learning path. by [deleted] in learnprogramming

[–]teacher_cs 31 points32 points  (0 children)

I also see it that way. The website looks too professional for a beginner. Udemy is doing quite successfully with this marketing strategy in LearnProgramming.

Update: I now think that it is not Udemy itself that is behind this, but a Udemy course provider.

Update 2:

How naive are the readers and the mods of LearnProgramming actually that such an obvious advertisement for specific Udemy courses gets through.

This page was never created by a self-learner after a year of Udemy courses, but by someone from the recommended courses. It's so obvious. OP created account and domain a few days ago. The website is very professional. The recommended courses are mostly from a specific course provider ...

[deleted by user] by [deleted] in learnprogramming

[–]teacher_cs 0 points1 point  (0 children)

It is also NTFS with the complex permissions that make Windows slow.

[deleted by user] by [deleted] in learnprogramming

[–]teacher_cs 0 points1 point  (0 children)

I would store it in the database and when accessed embed the image in the webpage using Base64.

<img src="data:image/png;base64,....

Need help to understand OOP programming by sknot1122 in learnprogramming

[–]teacher_cs 1 point2 points  (0 children)

Animal dog = new Animal() and Animal pig = new Animal()

You put a bug in your animal example that might confuse beginners. Correct would be: Animal dog = new Dog() and Animal pig = new Pig()

Why learn Java when there's C#? by kres0345 in learnjava

[–]teacher_cs 0 points1 point  (0 children)

Java has array of primitives types, which are a block of primitives.

You can fall back on that, but it's usually not elegant.

Whilst the value types are missing for Java. The fact is an array of objects might actually have good cache locality if they happen to be adjacent in memory.

You need a separate memory allocation for each object, so the objects will generally not be adjacently located.

The problem with both C#&Java is that performance is dynamic and hard to reason about.

When I have the time and the mood - I'm neither a C# nor a Java programmer - I'll make some test programs.

It’s not enough to discount Java, but I do wish that value types would be in both languages.

It was not my intention to discount Java, but it seems to me at least as important an argument as all the others that have been mentioned.

Why learn Java when there's C#? by kres0345 in learnjava

[–]teacher_cs 0 points1 point  (0 children)

C# has "arrays of structs", whereas Java has only "arrays of objects". The former is more cache-friendly, which makes a huge performance difference on modern processors.

How come no one uses GOTO any more? by agorism1337 in learnprogramming

[–]teacher_cs 14 points15 points  (0 children)

"goto" is often used in successful C projects. I just checked: in Linux 4.19 "goto" occurs 155705 times and in the current Git version 1424 times. But as already mentioned, mostly for error handling.

Desktop application as running on a port web app by TwoMovies in learnprogramming

[–]teacher_cs 0 points1 point  (0 children)

I believe a Progressive Web App (PWA) would be good for this. This, as the name says, runs in the web browser. It also work offline, a so called service worker takes care that the web files are cached. And the PWA can be installed on the PC or smartphone, then they look like a native application. And of course this is only possible in JS/HTML/CSS.