Bookends and curly braces

preview_player
Показать описание

Thanks much to GaggiX for hi and bye in Italian. Also to Shritesh Bhattarai for improvements to the Elixir code.

0:00 Intro
0:21 TypeScript
2:58 Long function examples
3:42 XML, HTML, and SGML
4:57 Pascal
6:11 Ruby
7:27 Elixir
9:43 Basic
11:28 Scala 3
Рекомендации по теме
Комментарии
Автор

Thanks much to GaggiX for hi and bye in Italian!

contextfree
Автор

If { } is preferred over BEGIN END because it is seen to be less cluttered to reserve reserved words for other stuff, and it is advisable to indent logically subordinate code blocks in { } despite this being unnecessary to the compiler as it relies on the { } and because changes to code can make it so the indentation does not match the { }s then it must therefore be better to declutter the { }s completely and just rely on mandatory logically subordinate indents.

If TAB is used then the IDE can be adjusted to adjust the width of the indent, whereas SPACEs are more hassle to keep straight under code maintenance and end up requiring house style to enforce it throughout developers, and even then libraries might end up with a different number of SPACEs, when TAB is just TAB for every level of indent.

As it is a bad idea to have code S1; S2 where S1 is a long statement that means S2 is cut off from being readily viewed without scrolling sideways along the line to reveal S2, then you might not know S2 is there, where a rule that prevents this would just enforce this by having NEWLINE terminate statements rather than ; either terminate them or separate them (an intolerable ambiguity depending on the language being used).

Getting rid of all clutter from type declarations by inferring it from the literal being assigned just means writing:

c = 3.0i
r = 3.0
z = 3
b = 11₂

____uncompetative
Автор

Just a small touch: in Ruby is actually possible to do one-line if's without a then + end.

puts "hi" if true # just put the condition in the end =)

Matheus.Richard
Автор

Great video. Very well explained, and as a side note, it was a nice mini-tour through the languages. 👍

DomainObject
Автор

I am absolutely in love with your content

cilea
Автор

BASIC code is nostalgia. My first language was GW-BASIC . Amazing content as usual. Learnt a lot about how blocks works. Thanks..

AbhinavKulshreshtha
Автор

koka has some really interesting indentation and brace elision rules! indentation signifies a brace, and thats it! but i've found it really, really intuitive

Tacosnation
Автор

Java has this hidden feature that I only just discovered: labeled blocks. If you have a nested for loop, and want to break out of everything, you can write `break outer;`. Or if you wanted to use the continue keyword for the outer loop, you write `continue outer;`.

SWinxyTheCat
Автор

Very fun! I can tell you spent a good deal of time and care to make this video. I really appreciate the treatment you gave my favorite language, Ruby! <3

TimMorgan
Автор

Jason and Spencer I will use as his bookends. These will be those who surround him. I will take the musicians with me

kimmanning
Автор

Ada has it's Pascal origins, but have some more verbose/expressive ways of ending "block-like" structures.

FreeScience
Автор

As with many other things, you can have the worst of all worlds in the HDL languages (VHDL and Verilog).
You are required to use begin-end (and then/loop, etc.) everywhere, often in an unpredictable way; this is unlike Pascal or Ada where a lot of repetition is optional if that makes sense. E.g., in the case of Verilog, when you want to have multiple "instructions" in the body of an "if" statement you have to also create a begin-end pair.

japedr
Автор

Amazing video man, keep it up, please!

bobDotJS
Автор

Doesn't the latest Java version also support indentation?
Maybe it would have also been worth mentioning clang format.

akj
Автор

Syntax can be customized with langtrans.github.io

bijinregipanicker
Автор

You could also have mentioned languages with fully indent-based blocks such as python. This makes me wonder, what's the language with the less "language overhead" (keywords, braces, separators, etc...) compared to actual user code ?
Great video as always !

Sadiinso
Автор

Great video! I'm impressed with the Elixir and Scala communities for better handling missing end and/or closing curly braces. I was also surprised to see a language like BASIC do a better job than many others.

OGBhyve
Автор

When you talk about teaching programming at 1:56 and how indentation often feels arbitrary to beginners, my immediate thought was that opening braces on separate lines would be a lot clearer in this case, because you could see at a glance that there are more opening braces than closing braces. Do you have any insight whether this is true when learning to program?

SLiV
Автор

I wish I could program in c++ without braces. If you need an extra scope, let's just add a "scope" keyword that almost noone will use anyway. I'm programming a bit in python and I love how minimalistic and elegant the code looks like without braces.

ashrasmun
Автор

Get ready, yall. God is not playing with such disobedience. It's oppression of His will and His way. He aint having it.

kimmanning