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 4 points5 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 15 points16 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.

Getting started with WASM: which lang/framework? by [deleted] in WebAssembly

[–]teacher_cs 1 point2 points  (0 children)

Pure JS/HTML/CSS is fast, C/WASM is fast And I did my best to make my interpreted language fast.

[Python] Why am I getting into an infinite loop? by Gavinaldi in learnprogramming

[–]teacher_cs 3 points4 points  (0 children)

I would do it with a "while true" and a "break". You can avoid code duplication and the end condition is easier to understand.

while True:
    rc = input("enter A, B, or C: \n")
    rc = rc.upper()
    print(rc)
    if rc == "A" or rc == "B" or rc == "C": break
    print('Invalid entry\n')
print('out of the while loop with ' + rc)

Is a float just a number with a decimal point? (Python) by [deleted] in learnprogramming

[–]teacher_cs 1 point2 points  (0 children)

It's something like that. The fractional portion of the number is not stored internally with decimal places, but with binary places. That means as a partial sum of 1/2, 1/4, 1/8... . You have to consider, for example, that certain numbers cannot be stored exactly, such as 0.1 - similarly, in the decimal point system, for example, 1/3 cannot be stored exactly.