Syntax refers to the set of rules that define how to write a correctly structured program in a language. It explicitly does not deal with the program's meaning or interpretation.

learn more… | top users | synonyms

3
votes
2answers
172 views

When to (enforce) linting in a software project

I'm heading a new team of developers working on a software project that makes use of continuous integration (circleci) w/ a pretty fleshed out suite of busterjs unit/integration/acceptance tests. Our ...
68
votes
3answers
24k views

Why do programming languages, especially C, use curly braces and not square ones?

The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
4
votes
3answers
7k views

Checking “instanceof” rather than value using a switch statement

Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this: switch ...
2
votes
1answer
232 views

Are there studies about foo/bar/baz and how they inhibit or facilitate comprehension?

Preface foo,bar,baz are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to ...
26
votes
4answers
15k views

Why store a function inside a python dictionary?

I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me ...
2
votes
1answer
327 views

How are “Json.org”-like specs graphs called and how can I generate them?

In http://www.json.org Douglas Crockford shows the specs of the JSON format in two interesting ways: In the right side column he lists a text spec that looks like a YACC or LEX listing. In the main ...
8
votes
3answers
1k views

Why can't we write nested shorthand functions in Clojure?

I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me. The expression was: (#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed The output was: ...
2
votes
2answers
127 views

How to programmatically construct textual query

Here is a query language, more specifically, it's JQL, you can use it in Jira, to search for issues, it's something like SQL, but quite simpler. My case is that, I need to construct such queries ...
4
votes
5answers
1k views

Why do node packages put a comma on a newline?

I'm learning node.js and am trying out Express. My first app had this code: var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = ...
1
vote
3answers
1k views

Syntax Memorization [duplicate]

Possible Duplicate: Programmers forgetting syntax Do programmers need a good memory? I'm a new web developer. I began learning HTML/CSS around June of this year. I picked them up ...
11
votes
8answers
2k views

Why isn't functional language syntax more close to human language?

I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it... I have one curiosity though, why is the syntax so cryptic (in lack ...
1
vote
3answers
286 views

How can you learn names of methods or classes of a framework or an API?

I've been programming C++ for a year now. I've gone through the language features and I've written good programs with it, so I decided to move on to OpenGL. At first it seemed confusing. As I kept ...
8
votes
8answers
1k views

How important is it to learn makefiles? [closed]

I work in c++ mostly as a hobby (I'm still in school and therefor don't have a real job). The IDEs generate the makefile for me and so I'm wondering if it's worth learning how to make them myself. By ...
6
votes
3answers
1k views

Omit terminating semicolon in a tag - a good idea?

It's possible to omit the terminating semicolon in a tag. Example: <table> <th><td>Name</td><td>Email</td> <? foreach ($receivers as $receiver): ?> ...
16
votes
9answers
2k views

Teaching kids to program - how to teach syntax? [closed]

I've been spending this week teaching kids (11-18) to program. Teaching them the core concepts and the logic has been going fine, but I've noticed one snagging point for them all: syntax. I feel like ...
3
votes
5answers
464 views

Confusion regarding def function within Python

I've been learning Python for about 2 months now (Started with Learn Python The Hard Way, now reading Dive Into Python), and within both books, I still seem to be confused over this one bit of code. ...
5
votes
2answers
228 views

Can the Clojure set and maps syntax be added to other Lisp dialects?

In addition to create list using parentheses, Clojure allows to create vectors using [ ], maps using { } and sets using #{ }. Lisp is always said to be a very extensible language in which you can ...
3
votes
2answers
232 views

Are “backwards” terminators for if and case unique to shell scripting?

In bash at least, if and case blocks are closed like this: if some-expr then echo "hello world" fi case $some-var in [1-5]) do-a-thing ;; *) do-another-thing esac as opposed to the ...
5
votes
1answer
164 views

Pythonesque global variable assignment

I'm designing a language with Pythonesque syntax, including casual creation of variables by assignment. I'm wondering at the moment exactly how to deal with assignment to global variables (and ...
3
votes
3answers
243 views

Eliminating tab characters in a new language

I'm working on a new programming language, which determines structure with indentation instead of braces in the manner of Python and CoffeeScript. Obviously placing lines indented with spaces next to ...
0
votes
2answers
93 views

Reinforcing Syntax Elements

I am currently learning Javascript, and there is one element of the syntax that I can just not seem to nail down. That element is adding semicolons at the end of each line. I have learned Python and ...
6
votes
6answers
4k views

Is there a language that transcompiles to C with a better syntax? [closed]

CoffeeScript is a language with a very clean Ruby-like syntax that transcompiles to JavaScript. Does the same thing exists with C? Then writing more readable and as fast as original C programs would ...
4
votes
5answers
343 views

How to remember the details (Core APIs) of one computer language?

I found my self often paused to check a certain usage of one core API when writing either javascript or Ruby. I am wondering how the other guys doing? Is it necessary to remember every Core API ...
0
votes
1answer
151 views

Syntax logic suggestions

This syntax will be used inside HTML attributes. Here are a few examples of what I have so far: <input name="a" conditions="!b, c" /> <input name="b" /> <input name="c" /> This ...
109
votes
12answers
11k views

Why are statements in many programming languages terminated by semicolons?

Is there a reason that a semi-colon was chosen as a line terminator instead of a different symbol? I want to know the history behind this decision, and hope the answers will lead to insights that may ...
0
votes
6answers
1k views

Syntax for goto labels

In C, C++ and some dialects of BASIC, goto labels are declared with the syntax label:. I'm working on a language that uses name: type as the syntax for variable declarations, so I'd prefer if possible ...
21
votes
4answers
6k views

What's the difference between implementing an Interface explicitly or implicitly?

In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly. public class Test : ITest { public string Id // Generated by Implement ...
6
votes
4answers
444 views

Backquoted symbols, good or bad?

I'm designing a programming language which has three kinds of quoted entities: strings and characters as in C, and symbols (interned strings intended for use as lookup keys and such) which I consider ...
4
votes
3answers
192 views

Syntactic sugar regarding function parameters

Are there any modern programming languages where you don't have to specify types for each parameter in a function's definition? Ex: procedure P(a, b, c, d: integer) vs void P(int a, int b, int ...
25
votes
10answers
3k views

Is there any reason why most programming languages don't have '!>' (not greater than) and '!<' (not less than) operators?

I wonder if there is any reason - or if it is just an accident of history - that there are no !> and !< operators in most programming languages? a >= b (a greater OR equals b) could be ...
10
votes
11answers
721 views

Is there a personalizable programming language you can use to convert to others?

Is there a programming language in which you can set your own syntax configurations and it would convert the code to a language you choose? For instance, you would choose specific configurations like ...
53
votes
6answers
3k views

Why the Select is before the From in a SQL Query? [closed]

This is something that bothered me a lot at school. 5 years ago, when I learned SQL, I always wondered why we specify first the fields we want and then where we want them from. According to my idea, ...
6
votes
3answers
705 views

Is there a reason to prefer lambda syntax even if there is only one parameter?

List.ForEach(Console.WriteLine); List.ForEach(s => Console.WriteLine(s)); To me, the difference is purely cosmetic, but are there any subtle reasons why one might be preferred over the other?
0
votes
2answers
264 views

Does syntax matters for a (Lispy) Domain Specific Language (MELT, inside GCC)?

I am the main author and designer of MELT, a domain specific language to extend GCC (the Gnu Compiler Collection). The implementation is available free software (GPLv3 licensed). If you want a ...
12
votes
5answers
665 views

Does the syntax of programming languages depend upon their implementation?

Although, my question may be entirely irrelevant, but I have sensed a pattern between most programming languages and their official implementations. Interpreted (byte-interpreted?) languages like ...
5
votes
2answers
4k views

Why do PHP variables need to be preceded with a dollar sign?

I understand that all PHP variables need to be preceded by a dollar sign (e.g. $someValue = 1), but why is this the case? Why was this design choice made? The reason I ask is my girlfriend asked why ...
13
votes
5answers
4k views

Why pointer symbol and multiplication sign are same in C/C++?

I am writing a limited C/C++ code parser. Now, multiplication and pointer signs give me really a tough time, as both are same. For example, int main () { int foo(X * p); // forward declaration ...
0
votes
2answers
197 views

Naming Rules: Standards, Reserved, and what do they depend on? [closed]

I want to know the rules of naming (AlwaysCapitalize, _underscore, firstSmallLetter, etc...) for each of Namespaces, Classes, Interfaces, Exceptions, Data Members, Methods, Variables, etc.... also I ...
11
votes
5answers
1k views

What's the idiomatic name for a throwaway variable? [closed]

Velocity Template Language's set directive requires a variable on the left hand side. This doesn't work. #set ( $entries.add("d") ) Even though I have no use for the return value of add("d"), I ...
2
votes
1answer
1k views

What's the point of initializing a variable with the same value twice? [closed]

I was reading Ben Cherry's "JavaScript Module Pattern: In-Depth", and he had some example code that I didn't quite understand. Under the Cross-File Private State heading, there is some example code ...
3
votes
6answers
453 views

Is there a language that allows this syntax: add(elements)at(index); [duplicate]

Possible Duplicate: Is there a language out there in which parameters are placed inside method name? Does a language exist with such a syntax? If not, what are some of the ...
4
votes
5answers
2k views

Why was the C syntax for arrays, pointers, and functions designed this way?

After having seen (and asked!) so many questions similar to What does int (*f)(int (*a)[5]) mean in C? and even seeing that they'd made a program to help people understand the C syntax, I ...
7
votes
3answers
5k views

Whats the difference between syntax and grammar?

I understand the difference between syntax and semantics - syntax - how the symbols are combined to form a valid expression or statement. semantics - the meaning of those symbols that form an ...
0
votes
5answers
255 views

ternary or something similar for choosing function?

I posted this question on stackoverflow and it got a poor reception. In reality, the problems I'm facing are minor and any workaround can be considered impractical. However, I believe it might be of ...
57
votes
12answers
32k views

What's the difference between syntax and semantics?

I've always thought that referring to the syntax of a language was the same as referring to the semantics of a language. But I've been informed that apparently that's not the case. What's the ...
5
votes
7answers
677 views

Are operators just “special” methods? [closed]

Here's what is meant by operators and methods. Attempting to keep the questions as simple and open ended as possible, since the question is more about the conceptual nature of operators and methods ...
26
votes
15answers
2k views

Is there a language out there in which parameters are placed inside method name?

in JavaScript: function getTopCustomersOfTheYear(howManyCustomers, whichYear) { // Some code here. } getTopCustomersOfTheYear(50, 2010); in C#: public List<Customer> ...
8
votes
4answers
421 views

Should the syntax for disabling code differ from that of normal comments?

For several reasons during development I sometimes comment out code. As I am chaotic and sometimes in a hurry, some of these make it to source control. I also use comments to clarify blocks of code. ...
4
votes
1answer
495 views

How do I view Scala code without all the syntactic sugar?

I have been studying Scala, but what I keep running into is the optimization of syntax. I'm sure that will be great when I am an expert, but until then.. Not so much. Is there a command or a program ...
33
votes
5answers
12k views

A practical use of “yield” keyword in C#

After almost 4 years of experience, I haven't seen a code where yield keyword is used. Can somebody show me a practical usage (along explanation) of this keyword, and if so, aren't there other ways ...