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

0
votes
0answers
40 views

Using JavaScript to find the correct offset in bundled files

I am currently making multiple parsers using PEGjs and have implemented my own partial preprocessor which using a RegExp finds and replaces '#include' directives with the desired files, resulting in a ...
1
vote
1answer
63 views

About AST construction in LL1 non recursive parser

I have implemented a LL1 parser in a non recursive approach with a explicit stack. The following algorithm is from the Dragon Book: set zp to point to the first symbol of w; set X to the top stack ...
1
vote
4answers
545 views

Why are scientific programming languages so weird? [closed]

It seems to me that programming languages meant for use in science and engineering are consistently weird compared to general-purpose languages. Some examples off the top of my head: In Matlab, each ...
18
votes
9answers
2k views

What is the benefit of having the assignment operator return a value?

I'm developing a language which I intend to replace both Javascript and PHP. (I can't see any problem with this. It's not like either of these languages have a large install base.) One of the things ...
2
votes
3answers
359 views

Syntactic Sugar for old languages

I first learned about the existence of syntactic sugar languages, like CoffeeScript and SASS while working in Rails. This got me thinking... why do we not have well-known (if any at all) syntactic ...
11
votes
7answers
475 views

What is idiomatic use of arbitrary blocks in C?

A block is a list of statements to be executed. Examples of where blocks come up in C are after a while statement and in if statements while( boolean expression) statement OR block if (boolean ...
2
votes
6answers
811 views

Stacking keywords on top of each other - poor style?

I have always wondered about this, especially in C/Java style languages. For example, consider the first 3 lines of this C# code: lock (serviceLock) using (var client = new ServiceClient()) try { ...
3
votes
2answers
182 views

Variable declaration versus assignment syntax

Working on a statically typed language with type inference and streamlined syntax, and need to make final decision about syntax for variable declaration versus assignment. Specifically I'm trying to ...
0
votes
2answers
108 views

Languages like Tcl that have configurable syntax? [duplicate]

I'm looking for a language that will let me do what I could do with Clipper years ago, and which I can do with Tcl, namely add functionality in a way other than just adding functions. For example in ...
7
votes
3answers
211 views

Construct your solution logic in syntax or in a faster and more efficient mental model?

I am a newbie, studying programming and I came across this question today: How can I make sure that I'm actually learning how to program rather than simply learning the details of a language? A ...
7
votes
6answers
866 views

Optional semicolons

Most often, in a general-purpose imperative language - semicolons as statement-delimiters are either required, or completely disallowed (e.g. C and Python). However, some languages, like JavaScript, ...
2
votes
3answers
233 views

What language has integrated “list insertion” as part of code *syntax*?

Many programming languages permit natural manipulation of strings, and some languages permit the manipulations of lists too. More often then not (always?), these operations are done as procedure ...
1
vote
1answer
284 views

How to write a syntax checker [closed]

How is a syntax checker for a programming language written? I am guessing a grammar has to be written first. How to then proceed? Motivation I'm using a programming language (Apex for Salesforce) ...
1
vote
3answers
347 views

Any languages use the '=>' and '=<' operators? [closed]

I'm just curious if there are any programming languages that use the '=>' and '=<' operators for something. I wonder why these are not commonly used when their variant '<=' and '>=' are so ...
4
votes
1answer
2k views

Why there is no markdown for underline? [closed]

I am wondering why there is no markdown syntax for underline? I know that basic html tags can be embedded to achieve this but I am trying to understand why underline got omitted when bold and italics ...
0
votes
1answer
149 views

Truth condition testing with BOOL

BOOL myBool; myBool = YES; ... if (myBool) { doFoo(); } I have read that because there are instances where the above does not actually call the doFoo() function, it is best to instead always test ...
3
votes
5answers
594 views

Does relying on intellisense and documentation a lot while coding makes you a bad programmer? [duplicate]

Is a programmer required to learn and memorize all syntax, or is it ok to keep handy some documentation? Would it affect the way that managers look at coders? What are the downside of depending on ...
7
votes
4answers
659 views

What makes Common Lisp “big”?

I've been learning both Common Lisp and Racket, and one thing that I consistently hear is that Racket is a much "smaller" language than Common Lisp. I was wondering what this really meant. As far as I ...
14
votes
1answer
543 views

Dollar Sign Blues: Javascript and PHP

I grew up programming C++ and Java where everything was safe and beautiful. Compilers made sure to keep me in check if I ever strayed. Of course, everyone did a little Perl in college, but I didn't ...
2
votes
1answer
139 views

How do I distinguish between things belonging to the standard library, specific gems, and those that are user-generated in Ruby?

I'm a beginning programmer, that for various reasons is using an existing Ruby codebase to learn to program. My goal is to be able to understand and eventually extend this codebase. However, I find it ...
0
votes
2answers
101 views

What Does “The Program Must Process Each Character Before Reading the Next One” Mean?

From the book Think Like a Programmer (emphasis mine) The Luhn formula is a widely used system for validating identification numbers. Using the original number, double the value of every other ...
2
votes
2answers
341 views

foreach over multiple lists at once

Are there any languages that support foreach over multiple lists at once? Something like this: foreach (string a in names, string b in places, string c in colors) { // do stuff with a, b, c ...
2
votes
1answer
170 views

Objective C - nested messages … confusion about

Wonder if anyone could shed some light on this messaging construct: The documentation says that messages appear btwn brackets [] and that the msg target/object is on the left, whilst the msg itself ...
2
votes
2answers
117 views

Helper Methods Placement

Here's a question that's always bugged me. I'm going to use java as an example because I've almost never run into a problem in java where I didn't need to use helper methods in its class structure. ...
45
votes
7answers
3k views

Why are semicolons and commas interchanged in for loops?

In many languages (a wide list, from C to JavaScript): commas , separate arguments (e.g. func(a, b, c)), while semicolons ; separate sequential instructions (e.g. instruction1; instruction2; ...
35
votes
2answers
2k views

Why do bitwise operators have lower priority than comparisons?

Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
30
votes
11answers
2k views

What is the difference between “Syntax” and “Syntactic Sugar”

Background The Wikipedia page on Syntactic Sugar states: In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. ...
3
votes
2answers
153 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 ...
64
votes
3answers
21k 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 ...
2
votes
3answers
4k 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
211 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 ...
18
votes
4answers
7k 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
241 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
798 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
121 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 ...
3
votes
5answers
798 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
595 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
1k 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
255 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
965 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 ...
4
votes
3answers
724 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
1k 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
396 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
207 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
214 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 ...
2
votes
2answers
547 views

What are complete programming languages with a minimal syntax and how is that important? [closed]

With minimal syntax I mean a language that could be entirely described with the least words possible, but complete enough to make any kind of program.
5
votes
1answer
150 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
226 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
92 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 ...
4
votes
6answers
2k 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 ...