Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Konrad Pilch
Konrad Pilch
2,435 Points

Logic

You know, when we write HTML and CSS on good standard, i beleive, we improve in logic as well right? etc..

and programming like JavaScript is even more logic, with different rules ?

1 Answer

Benjamin Gooch
Benjamin Gooch
20,367 Points

I feel like with HTML and CSS, you aren't really implementing logic so much as just defining something to be displayed. A scripting language like JavaScript or a programming language like Java or C# requires logic to create functions, methods, and algorithms. If statements and while loops are good examples of logic, I think. I'm pretty new to Java and relatively familiar with JavaScript and I've had to really focus on improving my logical thinking. It helps to look at other people's code (which you can find all over the web) and try to understand how the program was written and why.

Konrad Pilch
Konrad Pilch
2,435 Points

Three months now heh.

I agree with you. But i think there is some sort of logic when doing HTML, and in addition CSS.

The way you build blocks, the way you keep the code DRY in the CSS, and the way you keep the code DRY in the HTML, as now i have repeated my self which is bad because i made an extra line.

I think there can be little things in HTML that can help to structure things in real life and so on.

But as you said e.g. JS, some logic from it, is soo usefull, that its amazing! When i was a teacher writing stuff like

This is 1 clip of 45
This is 2 clip of 45

and so on..

And i though, if you put that in JS incrementing loop, ud have that in one tenth second lol

And so on.

Im still new to programming lol, but seen ways it can help a little in real life. I'm sure when i become a lot better in it, stuff in real life could make things better too, a little lol.

Benjamin Gooch
Benjamin Gooch
20,367 Points

I'm working through the Java Basics course right now and the first thing they teach you is the theory behind how Objects work (it's pretty much the same concept for JS) and the teacher says that you will likely end up looking at everyday objects and thinking about them and their functionality and attributes as Java objects, and really, it's true. You can look at so many things and decide how you would write them in code. The tough part for me comes when you want that code to do something complex.

An example for the complexity I am referring to would be creating a character in a video game that deals a different amount of damage to different types of enemies who have different types of armor, and with using different kinds of weapons. This example requires that you define so many variables (ie: 4-5 types of armor and what their damage threshold is, 2-3 types of enemies and what they are weak against or strong against, types of attacks you have available to use, and so on) then you have to write code that takes all of that data and calculates an amount of damage to deal to the enemy. Then it has to apply that number to the enemy's health, and so on.

I have a strong interest in video game design and I never realized until I started learning how to program just how complex it all actually is. That example I gave doesn't even include things like making the character walk when you move a controller stick or press a button on the keyboard, or the artificial intelligence for the enemy.

I have a great respect for programmers that build video games, even games that aren't all that good. The fact that they made a system that actually functions at all is impressive to me!