Live data from Hacker News

Pretty.c

github.com

221–227 of 227 posts

Re: Pretty.c

#221
post #183

Earlier quoted context omitted.

'scripting' is an ill-defined term with many interpretations, certainly.

If that is the case, pick another interpretation and describe to us what "non-scripting" then might be.

the original definition is likely tossing shell commands in a file to run later. chaining commands together. since perl and python supplanted this, they get lumped in as 'scripting languages'. both certainly can be used to write long running systems or short one off tasks.

compiled languages are rarely used for one offs because the effort they require is usually greater than the task calls for.

a big part of perl/python use is in tying together libraries written in more difficult lower level compiled languages.

you'll also see scripting used to refer to languages embedded in larger projects. lua scripts to control entities in a game, for instance. do they compile these somehow? I never did in the little project I used lua for.

----

all of that together, I expect that scripting as a concept largely boils down to conceptually simpler languages with less view of the ugly underbelly of how things actually work in a computer, used to chain together abstractions created by lower level code.

scripting is duct-tape. whether you duct-tape together a one-off task or some wad of long running functionality is besides the point.

Re: Pretty.c

#222
post #221

Earlier quoted context omitted.

If that is the case, pick another interpretation and describe to us what "non-scripting" then might be.

the original definition is likely tossing shell commands in a file to run later. chaining commands together. since perl and python supplanted this, they get lumped in as 'scripting languages'. both certainly can be used to write long running systems or short one off tasks. compiled languages are rarely used for one offs because the effort they require is usually greater than the task calls for. a big part of perl/pyt…

> you'll also see scripting used to refer to languages embedded in larger projects.

Yes, but this is conceptually exactly the same as the aforementioned shell scenario. This is not something different.

Just as I suspected, there is only one definition, and one that has proven to actually be well defined to boot as you managed to reiterate the only definition I have ever known to perfection.

Re: Pretty.c

#223
post #129

> The goals for Pretty C are: > Provide so much syntactic sugar as to cause any C developer a diabetes-induced heart attack. :-D

As someone who just got diagnosed with type-1 diabetes (the auto-immune variety, not the “you eat too much sugar” variety), this was far more depressing than funny. I’m probably being overly-sensitive, but man my life has gone to shit in the last couple of years…

Uff, I’m so sorry to hear! I can see how that joke could be really not funny for someone that has gone through some crappy stuff.

I hope you stay strong as you work through such a rough life-changing diagnosis.

Re: Pretty.c

#225

Earlier quoted context omitted.

How so? it’s just char*

What if len() of a char* vs a Unicode string?

char* is just raw bytes.

At the language level C historically hasn't offered much support for working with specific character sets and their encodings. With C17 and C23 we get u"...", U"...", u8"...", type char8_t, and similar, but there's still little/no built-in tooling for text processing.

For text processing work with char* whose bytes are some encoding/s of Unicode, e.g. UTF-8, then you an use a C library such as libunistring or ICU.

However the bytes of a char* could instead be an encoding of a non-Unicode character set, e.g. GB2312 encoded as EUC-CN.

So char* is character set and encoding agnostic. And C-the-language doesn't even try to offer you tools for working with different sets and encodings. Instead, you can use a library or write your own code for that purpose.

A number of languages make the same decision, keeping the string type set/encoding agnostic, with libraries taking up the slack.

In Nim, for example, the string type is essentially raw bytes (string literals in .nim sources are UTF-8). If you're doing Unicode text processing then you'd use facilities from the std/unicode module

https://nim-lang.org/docs/unicode.html

Same story with Zig

https://ziglang.org/documentation/0.8.0/std/#std;unicode

Lua too, and you'll probably use a 3rd party library such as luaut8 for working with Unicode/UTF-8

https://github.com/starwing/luautf8

Returning to the matter of pretty.c, since it's just sugar for C, it makes sense (to me) that the string type is just an alias for the set/encoding agnostic char*. It's up to the programmer to know and decide what the bytes represent and choose a library accordingly.

Re: Pretty.c

#226
Being able to control indents for a particular case { right-aligning variable names - while keeping "=" in line can be useful for instance }... Is the perfect example of why indenting should be left for the eye of the reader not the computer.

It's exactly why I find python code difficult - nay impossible - to read at times.

So you are really doing absolutely the opposite of what you are claiming...

Obviously beauty is in the eye of the beholder - but the one thing that C got right was using "{" & "}" to specify code flow.

Post reply on HN