Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Couldn't not display Name

Code Blocks type usage

Recommended Posts

What's the meaning of:

C Languages (C, C++, etc.)

CSS

HTML

JavaScript

Lua

Perl

PHP

Phython

Ruby

SQL

sTex/LaTex

Swift

XML

 

I know it is some kind of code or programming language.So, what is the usage of these code blocks? Can someone explain in detailed 😢😢

Share this post


Link to post

Good question. Let me try it out.

 

Spoiler

<html>
  <body>
    <h1>Does this do anything?</h1>
    <ol type="a">
      <li>Testing</li>
      <li>Testing</li>
      <li>1</li>
      <li>2</li>
      <li>3</li>
    </ol>
    <br>
    Yo! What up?
  </body>
</html>

 

EDIT: Okay... My html is a little if-y. Let me do C.

Spoiler

#include<stdio.h>
#include<conio.h>
main()
{
  int a,b;
  int sum=0;
  scanf("%d %d",&a,&b);
  sum=a+b;
  printf("%d",sum);
  getch();
}

 

EDIT: I guess they highlight relevant keywords and symbols?

Share this post


Link to post

The question seems to be "what is a programming language?" but it's not really clear what you're asking. The items in your list are programming languages.

 

Programming computers involves telling computers what to do, and it has to be done in a very logical, precise way. Because this is difficult, programmers invented a number of programming languages to make the job simpler and more friendly for humans, so we can program computers just by writing down what we want. Just like human languages there are many different programming languages and there is not just one of them that everyone uses. Different languages are used to solve different problems, just like how a screwdriver and a hammer are tools which are used for different purposes.

 

Here is an example of some C code. Here is an example of some Python code. You should be able to tell that they're different languages because they look different, even if you don't understand what any of it does.

Share this post


Link to post
27 minutes ago, fraggle said:

The question seems to be "what is a programming language?" but it's not really clear what you're asking. The items in your list are programming languages.

 

 

I think he's asking something else.

He's asking (I think) what selecting those languages in the drop-down menu in DW's code option does.

Share this post


Link to post

Different coding language (to be more generic than programming language -- stuff like HTML isn't programming) have differences in their syntax and vocabulary.

 

So let's take an example (out of laziness, I'm gonna borrow from @Zulk RS) :


#include<stdio.h>
#include<conio.h>
main()
{
  int a,b;
  int sum=0;
  scanf("%d %d",&a,&b);
  sum=a+b;
  printf("%d",sum);
  getch();
}

So this is C/C++. Notice what gets colored: the preprocessor directive (#include and other words beginning with #), the filenames (<stdio.h> and <conio.h>, identified by being between angled brackets), the variable type (int, in this case), and strings (between quote marks). In addition, the numeric constant (0 in sum=0) is also highlighted.

 

I had a whole text about what happens when you get the wrong type selected, but it turns out that it's irrelevant. The WYSIWYG editor lies to you.

 

Basically just choose "no syntax highlighting" if what you're posting in a monospace block isn't (recognized) code.

Share this post


Link to post
54 minutes ago, Zulk RS said:

He's asking (I think) what selecting those languages in the drop-down menu in DW's code option does.

Oh, I see now.

 

Then the answer is: the code block feature is there so that people can share source code in their posts, which often happens on Doomworld. To make the code easier to read, the forum will color different words according to what they mean in that language. But since not all programming languages are the same, you need to tell the forum what language your code is written in so that it will be colored properly.

Share this post


Link to post

It is a bit of a shame that these forums don't have code highlighting options for DEHACKED, DECORATE, ACS, ZScript, MAPINFO, GLDEFS, and other Doom-related codes that I could keep listing for a while. I understand that it would probably be either impossible or more trouble than it is worth.

Share this post


Link to post
59 minutes ago, Empyre said:

It is a bit of a shame that these forums don't have code highlighting options for DEHACKED, DECORATE, ACS, ZScript, MAPINFO, GLDEFS, and other Doom-related codes that I could keep listing for a while. I understand that it would probably be either impossible or more trouble than it is worth.

SLADE does have syntax highlighting capabilities for each of those I think, but I don't know much about how syntax highlighting works, or how easy it is to port syntax highlighting from one system (like SLADE) to another (whatever highlighter is used for the code snippets on here)

Share this post


Link to post
3 hours ago, Gez said:

Different coding language (to be more generic than programming language -- stuff like HTML isn't programming)

I generally agree about HTML, but I have seen it described and argued as a declarative programming language, which isn't dissimilar to TeX or SQL: you write to tell the computer what you want done rather than how, the software stack figures out the how from the what.

 

There are no hard lines for this stuff, so I'm fine with calling it whatever you want. Markup, coding, programming.

Share this post


Link to post

There are several programming languages each one with it's own characteristics and purposes. For an exemple Java sacrifices performance for productivity and some fancy features while C is lightweight and fast though it does not care much about helping the programmer. If you wanna know more about programming languages in general there's some good stuff in this channel. And Wikipedia too.

 

 

Share this post


Link to post
12 hours ago, Gez said:

 

Basically just choose "no syntax highlighting" if what you're posting in a monospace block isn't (recognized) code.

Hey i think i have heard the word monospace.I couldnt remember what it is but it is a requirement for a special text word.What it is?

Share this post


Link to post
10 minutes ago, m8f said:

Thank you! It was ASCII art!

             
        ,--, 
      ,--.'| 
   ,--,  | : 
,---.'|  : ' 
|   | : _' | 
:   : |.'  | 
|   ' '  ; : 
'   |  .'. | 
|   | :  | ' 
'   : |  : ; 
|   | '  ,/  
;   : ;--'   
|   ,/       
'---'        
             

               
               
               
         ,--,  
       ,'_ /|  
  .--. |  | :  
,'_ /| :  . |  
|  ' | |  . .  
|  | ' |  | |  
:  | | :  ' ;  
|  ; ' |  | '  
:  | : ;  ; |  
'  :  `--'   \ 
:  ,      .-./ 
 `--`----'     
               

            
            
,-.----.    
\    /  \   
;   :    \  
|   | .\ :  
.   : |: |  
|   |  \ :  
|   : .  /  
;   | |  \  
|   | ;\  \ 
:   ' | \.' 
:   : :-'   
|   |.'     
`---'       
            

            
            
,-.----.    
\    /  \   
;   :    \  
|   | .\ :  
.   : |: |  
|   |  \ :  
|   : .  /  
;   | |  \  
|   | ;\  \ 
:   ' | \.' 
:   : :-'   
|   |.'     
`---'       
            

                
                
   ,---,        
  '  .' \       
 /  ;    '.     
:  :       \    
:  |   /\   \   
|  :  ' ;.   :  
|  |  ;/  \   \ 
'  :  | \  \ ,' 
|  |  '  '--'   
|  :  :         
|  | ,'         
`--''           
                
                

              
              
              
        ,---, 
       /_ ./| 
 ,---, |  ' : 
/___/ \.  : | 
 .  \  \ ,' ' 
  \  ;  `  ,' 
   \  \    '  
    '  \   |  
     \  ;  ;  
      :  \  \ 
       \  ' ; 
        `--`  
              

   ,---,  
,`--.' |  
|   :  :  
'   '  ;  
|   |  |  
'   :  ;  
|   |  '  
'   :  |  
;   |  ;  
`---'. |  
 `--..`;  
.--,_     
|    |`.  
`-- -`, ; 
  '---`"  

 

Share this post


Link to post
3 hours ago, Couldn't not display Name said:

#include <stdio.h>

int main(void)
{
   int a = 0;
   while (a < 10) {
      printf("%d\n", a);
      if (a = 5)
         printf("a equals 5!\n");
      a++;
   }
   return 0;
}

Infinite LOOP!

So what is suitable code blocks for DooM sourcecode? 

At first, I was wondering why you said it was an infinite loop, but then I saw it. In the if statement, instead of comparing a to 5 (a == 5), the code assigns 5 to a (a = 5), which will return 1 for true to the if statement because of the successful assignment action. As a result, the output will look like this:

0
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
.
.
.

 

Share this post


Link to post
47 minutes ago, Empyre said:

At first, I was wondering why you said it was an infinite loop, but then I saw it. In the if statement, instead of comparing a to 5 (a == 5), the code assigns 5 to a (a = 5), which will return 1 for true to the if statement because of the successful assignment action.

Actually a = 5 will return 5, not 1. Like a = b = 5 will put 5 in both a and b, and not 5 in b and 1 in a. But that's still good enough for C. Modern compilers can also warn you about assignments like that. Other languages, for example C#, will not allow that at all, because the statement must result in an actual boolean value.

Share this post


Link to post
21 hours ago, Empyre said:

At first, I was wondering why you said it was an infinite loop, but then I saw it. In the if statement, instead of comparing a to 5 (a == 5), the code assigns 5 to a (a = 5), which will return 1 for true to the if statement because of the successful assignment action. As a result, the output will look like this:


0
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
6
a equals 5!
.
.
.

 

Dude i copy-paste from Wikipedia

It was intentional inifinte loop.

The explaination to the code is:

The form for (;;) for an infinite loop is traditional, appearing in the standard reference The C Programming Language, and is often punningly pronounced "forever".

 

For the unintentional loop:

#include <stdio.h>

int main(void)
{
   int a = 0;
   while (a < 10) {
      printf("%d\n", a);
      if (a = 5)
         printf("a equals 5!\n");
      a++;
   }
   return 0;
}

The expected output is the numbers 0 through 9, with an interjected "a equals 5!" between 5 and 6. However, in the line "if (a = 5)" above, the programmer has confused the = (assignment) operator with the == (equality test) operator. Instead, this will assign the value of 5 to a at this point in the program. Thus, a will never be able to advance to 10, and this loop cannot terminate.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×