
AstonJ
The syntax thread!
What is your preferred syntax style and why?
Perhaps we can add examples and use the code below as a simple reference point (how would you write it in your chosen language?) but feel free to add additional examples if you feel they show off your preferred syntax well too.
Ruby
class Ball
def initialize(colour)
@colour = colour
end
def red?
@colour == "red"
end
end
my_ball = Ball.new("green")
my_ball.red?
# false
Most Liked

davearonson
One thing I like about the syntax of typical OO languages, and “pipelined” languages like Elixir, is the concept of “take this, do this with it, then do that with it, then do the other thing with it”. That concept really helped me pick up Elixir pretty quickly after realizing that |>
was very much like .
just without the implicit matching on whatever kind of thing (Ruby object, Elixir data) you had at that time.

hauleth
Whatever people say I prefer languages with block delimiters instead of off-side rule. Off-side rule is okayish in configuration languages and other languages that describe trees (like HAML or Slime), but IMHO do not works well in programming languages (sorry Python, I never really liked you anyway).

Korbin73
Hands down my favorite syntax is ML family of languages ocaml/f#/haskell/Elm
let registerNewUser dbClient =
request ( fun inputGraph ->
Newtonsoft.Json.JsonConvert.DeserializeObject<UserRequest>(inputGraph.rawForm |> System.Text.ASCIIEncoding.UTF8.GetString)
|> hashPassword
|> registerWithBson dbClient
|> RealWorld.Convert.userRequestToUser
|> jsonToString
|> Successful.OK
)
Why? Whitespace is a natural idiom in written languages. We use indentation in table of contents, spaces between words, paragraphs, etc. So adding glyphs like brackets or begin…end in a language is completely redundant. In ML family languages all symbols have contextual meaning. Parenthesis are used to group “stuff” together. Brackets are added when the need to indicate a “block” only in certain contexts.
Simply put, if whitespace significance didn’t matter in programming languages, then remove all of the spaces in your C family languages that the compiler is happy to build and see if you like it LOL
That being said, I don’t dislike C-family languages (I program in swift and kotlin on my job) but ML syntax is definately the most pleasant for me to read due to the low visual “noise”.
Popular General Dev topics










Other popular topics










Latest in Dev Chat
Latest (all)
Categories:
Sub Categories:
- All
- In The News (10779)
- Dev Chat
- Questions (29)
- Resources (118)
- Blogs/Talks (26)
- Jobs (3)
- Events (14)
- Code Editors (58)
- Hardware (57)
- Reviews (3)
- Sales (15)
- Design & UX (4)
- Marketing & SEO (1)
- Industry & Culture (15)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (4)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /textmate
- /sublime-text
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /c
- /slackware
- /julia
- /neovim