Groovy will automatically convert integers into objects, as it sees fit. And one such case is when you assign null to an integer.
There's some more languages, which try to treat primitive types like objects, to make them more consistently usable. As I understand, nullability is a big part of the reason why it can't be solved with syntactic sugar, so presumably this would be possible in all those languages.
If I'm not mistaken, Ruby is another one of those languages.
Yeah, I kind of respect the stance, because it knows what it wants to be, but I also wrap number types into a separate data type to document that maybe you shouldn't multiply a port number by the wheel count and pass that into the temperature parameter, because I want more fine-grained typing, not one-size-fits-all.
I think that somewhat reflects the "parse, don't validate" advice I found somewhere. I'll look for the link and edit if I find it (edit: I did!) but the idea is something like "when a value first enters your code, parse it into a type / struct the rest of your code proceeds to use". That way, you check "does this make sense as a port number?" exactly once, throw it right back at the source if it doesn't, put a "yep, this fits" stamp on it if it does and never worry about it again, thus saving repetitive boilerplate code.
It's definitely part of the reason why I like these really narrow types. But the other big reason is that your internal APIs start to look like this:
It just makes it almost impossible to pass the wrong value into a parameter. You don't need to wonder, whether you should pass your port variable into a parameter called bind_port, if you introduced separate types BindPort and RemotePort for them.
Of course, this is a somewhat extreme example. It's up to you to decide, whether you're likely to encounter multiple values of the same type and whether it's therefore helpful to make it impossible to confuse them.
Also, Tcl (a cute little scripting language from the 90s, best known for giving the world the Tk UI toolkit; it was somewhat Lispy, only under the hood, worked like sh, where everything was a string).
Does GNU make count? It's crazy what you can do with the macro expressions, basically a Functional language using only string types. There's even a math "library" that will do arithmetic with numbers in strings.
SQL is the only bedrock in my entire career. Its the one thing that has stayed relevant.
SQL is great but when you start having issues processing what is actually going on, its fine to pull out what you need and throw another language on top (python, C#, etc...etc...). Getting it to work slow is one step in making it fast again.
I remember a good 4-5 years where developers all around me were using couchdb, mongodb, and a host of others. mostly json in <-> json out kind of systems. And VERY hard to maintain after the initial TODO. I remember so much debugging and finding out old records didnt have a way to deal with changes in the "tables" or equivalents. It was maddening.
Dont get me wrong, it did create some really awesome specialty tools but you cant really get around ACID compliance when dealing with databases.
I think SQL has some awesome properties that keep it going:
Most major distributions are rock solid stable.
Its optimized and fast for data.
Its understandable to many types of industries. Software development is only the start.
Its integrated with everything already. So ODBCs can just plug and play most of the time.
Its the devil we know. ACID, transactions, etc... are all things we know about and are proven to work very well. Definitly when you need to MAKE SURE a thing made its way into the system.
Yeah 100% with you, had this mongo database where the first entry was like a description, the nr 2 and on the actual data. I mean if there were a description... Sometes 2 descriptions...
Why oh why.
And for sure SQL is kind of the cement of DB today, don't get me wrong, I like that what I learned yesterday actually still works, I'm just pondering the fact that it is so.
Maybe SQL isn't the hip language so people doesn't try to reinvent it all the time 😁
Window functions were an addition, but more recently struct, json, and array fields with native support. Pipe syntax is getting multiple implementations.
Match recognize is a whole new standard abstraction of window functions.
Union by name is being added (fuck union by position).
sql as the language executed by the db hasn't changed notably, but I do think there's been significant developments in ORMs. for a lot of developmers sql is now just an intermediate target
I don't think it is, and I'm not saying they don't have their place, I'm just a bit of a hater of dynamic types, like in a fun way, I don't think they're the bane of existence or anything. I just really love static typing.
God, that reminds me of the debate on XML that I had with a developer about fifteen years ago.
Both our companies were working for a client who needed to publish product catalogues in several languages twice a year.
They had implemented a sort of Content Management System which they used with a plugin to feed data into Quark Xpress files as well as their website, IIRC. Cross-media publishing, essentially, and they had their own little set of format instructions to make words appear in bold, different colors, etc.
Since my company was tasked with translating the text into various languages, I suggested they come up with a way to store their data as XML. The standard tools in the translation industry can be easily customized to work with that, and XML would be a good way to future-proof their software. After a lot of delaying, grumbling, and ho-hum, they agreed to implement this plan.
Lo and behold, when the first meeting on the new XML format came around they showed it to me for the first time and... everything was in CDATA sections. Entire paragraphs of text with proprietary formatting instructions. 😐
When I tried to explain, very politely, and very patiently, that this was not going to work, the lead dev started insulting me. I swear to God, I've never been this close to punching someone in the face at a business meeting. 🤬
Thankfully, the client understood the issue and we eventually got an XML-based data exchange going. It is probably still in use today.
This is why I ask for the schema at the same time as asking for (even example) data at the start of a project. Don't tell me you have the data, give me proof there's a standardized structure, or the length of the project just tripled.
And it's just as crazy as one'd think. It's a 32bit value consisting of two 16bit little endian words jumbled together in big endian. So the byte order is B A D C.
Whenever I think "This is a really stupid idea, nobody would do that", turns out, someone actually did that.
The NHL banned the use of 00 as a number in the 95-96 season because they claimed their databases couldn't handle it. They still are fools because this continues to be a banned number to this day.
(i am old) both my brother and i were number 00 in our younger hockey years. we were goalies, so we got first pick of numbers on all new teams we played on, heheheh.
I opened a TCL script once. It’s use of uplevel scared me. I’ve never dared to return since.
For those who don’t know: uplevel is a command that goes up one level of the stack frame, and then executes code there. A function can therefore execute code in its callers stack frame.
tcl is pretty fun actually, it's like bash on steroids.
for a preview of the insanity: anything surrounded by "" is a string, with the variable expansion you'd expect. anything surrounded by {} is also a string, but with no expansion. the equivalent in bash is the backtick string. but you don't need to know that to write tcl. if you approach {} as "code blocks" like in other languages, it just works. reason being that tcl evals everything, constantly, attaching little tags to strings that tells the language how things are used, like "this string is an integer" or "this string is code and here is the result from last time it ran". it's madness and, weirdly, robust as hell. Xilinx writes all their tooling in tcl. SQLite started life as a tcl module, and it's still the only api that is not provided by a plugin.
Tk is overlooked, though. It's not pretty, and its approach is archaic, but it's one of the few GUI toolkits that Just Works on every platform I tried it on with minimum fuss.
Kinda started using that with polars, force the scan/read schema as string, and down the road cast as the necessary type when needed. I'm calling it "just in time" data cleaning.
94 Comments
kubica@fedia.io · 68 pts · 346d
Empty string used to be like my own version of null pointer.
marcos@lemmy.world · 49 pts · 346d
Oh, you worked at Oracle by any chance?
DScratch@sh.itjust.works · 31 pts · 346d
Dark times…
Like -1 for an Int nil value.
uranibaba@lemmy.world · 9 pts · 346d
Which language can nil an
int?Ephera@lemmy.ml · 10 pts · 346d
Groovy will automatically convert integers into objects, as it sees fit. And one such case is when you assign
nullto an integer.There's some more languages, which try to treat primitive types like objects, to make them more consistently usable. As I understand, nullability is a big part of the reason why it can't be solved with syntactic sugar, so presumably this would be possible in all those languages.
If I'm not mistaken, Ruby is another one of those languages.
JackbyDev@programming.dev · 3 pts · 346d
Groovy is pretty wild. It's like, honey, you need me to make this a BigInteger for you? I got you honey, don't even worry about it.
Ephera@lemmy.ml · 4 pts · 346d
Yeah, I kind of respect the stance, because it knows what it wants to be, but I also wrap number types into a separate data type to document that maybe you shouldn't multiply a port number by the wheel count and pass that into the temperature parameter, because I want more fine-grained typing, not one-size-fits-all.
JackbyDev@programming.dev · 2 pts · 346d
I love the idea of "tiny types" like that and wish they were built into more languages.
luciferofastora@feddit.org · 2 pts · 330d
I think that somewhat reflects the "parse, don't validate" advice I found somewhere. I'll look for the link and edit if I find it (edit: I did!) but the idea is something like "when a value first enters your code, parse it into a type / struct the rest of your code proceeds to use". That way, you check "does this make sense as a port number?" exactly once, throw it right back at the source if it doesn't, put a "yep, this fits" stamp on it if it does and never worry about it again, thus saving repetitive boilerplate code.
Ephera@lemmy.ml · 1 pts · 330d
Ah, yeah, very familiar with that article. 🙃
It's definitely part of the reason why I like these really narrow types. But the other big reason is that your internal APIs start to look like this:
It just makes it almost impossible to pass the wrong value into a parameter. You don't need to wonder, whether you should pass your
portvariable into a parameter calledbind_port, if you introduced separate typesBindPortandRemotePortfor them.Of course, this is a somewhat extreme example. It's up to you to decide, whether you're likely to encounter multiple values of the same type and whether it's therefore helpful to make it impossible to confuse them.
Valmond@lemmy.world · 4 pts · 346d
Just cast it. /s
Ephera@lemmy.ml · 3 pts · 346d
I believe, that would mean that any 0 is equivalent to the null pointer, since the null pointer is just memory address 0...
qqq@lemmy.world · 4 pts · 346d
Not exactly "memory address 0"; there be dragons there. https://c-faq.com/null/index.html
Valmond@lemmy.world · 1 pts · 346d
In C that would make sense yes.
Jankatarch@lemmy.world · 1 pts · 345d
Probably some monad magic idk functional programming.
baines@lemmy.cafe · 10 pts · 346d
easy there satan
Cruel@programming.dev · 67 pts · 346d
I took great pains last week to convert a big python project to make it typed. (shoutout to MonkeyType)
It's so much nicer to develop now...
jjjalljs@ttrpg.network · 19 pts · 346d
Oh that's a neat library. Type annotations in python are really nice, and you don't have to add tooling like when you switch from JS to TS.
Cruel@programming.dev · 7 pts · 346d
Yeah, I stopped developing in JS for good ~1.5 years ago. After using TS, it seems crazy to go back.
panda_abyss@lemmy.ca · 46 pts · 346d
Ah, the SQLite approach!
joyjoy@lemmy.zip · 32 pts · 346d
Me: Puts a boolean into sqlite
Me: Asks for that boolean
SQLite: "Here's that int you asked for"
asperan@programming.dev · 21 pts · 346d
It is also the bash approach, isn't it?!
AllNewTypeFace@leminal.space · 10 pts · 346d
Also, Tcl (a cute little scripting language from the 90s, best known for giving the world the Tk UI toolkit; it was somewhat Lispy, only under the hood, worked like sh, where everything was a string).
brian@programming.dev · 7 pts · 346d
more directly, sqlite was originally for tcl which is why they share the semantics.
also I'd argue that sqlite is a bigger contribution than tk, but I suppose in a more roundabout way
ChrysanthemumIndica@discuss.tchncs.de · 1 pts · 346d
Does GNU make count? It's crazy what you can do with the macro expressions, basically a Functional language using only string types. There's even a math "library" that will do arithmetic with numbers in strings.
MonkderVierte@lemmy.zip · 2 pts · 346d
You can calculate n and n?
Crashumbc@lemmy.world · 4 pts · 346d
28
That's easy
saltesc@lemmy.world · 6 pts · 346d
God, I'm so over SQL.
It's great, but it is so old and shows it. Feels like 99% of my SQL queries are just cheese.
Works though, and quick.
mesamunefire@piefed.social · 22 pts · 346d
SQL is the only bedrock in my entire career. Its the one thing that has stayed relevant.
SQL is great but when you start having issues processing what is actually going on, its fine to pull out what you need and throw another language on top (python, C#, etc...etc...). Getting it to work slow is one step in making it fast again.
Valmond@lemmy.world · 4 pts · 346d
Yeah it's curious that it hasn't really undergone some major changes or had some major challengers (except NoSQL I guess).
mesamunefire@piefed.social · 15 pts · 346d
Its been a while but yeah NoSQL was the closest.
I remember a good 4-5 years where developers all around me were using couchdb, mongodb, and a host of others. mostly json in <-> json out kind of systems. And VERY hard to maintain after the initial TODO. I remember so much debugging and finding out old records didnt have a way to deal with changes in the "tables" or equivalents. It was maddening.
Dont get me wrong, it did create some really awesome specialty tools but you cant really get around ACID compliance when dealing with databases.
I think SQL has some awesome properties that keep it going:
Valmond@lemmy.world · 5 pts · 346d
Yeah 100% with you, had this mongo database where the first entry was like a description, the nr 2 and on the actual data. I mean if there were a description... Sometes 2 descriptions...
Why oh why.
And for sure SQL is kind of the cement of DB today, don't get me wrong, I like that what I learned yesterday actually still works, I'm just pondering the fact that it is so.
Maybe SQL isn't the hip language so people doesn't try to reinvent it all the time 😁
panda_abyss@lemmy.ca · 9 pts · 346d
It has though
Window functions were an addition, but more recently struct, json, and array fields with native support. Pipe syntax is getting multiple implementations.
Match recognize is a whole new standard abstraction of window functions.
Union by name is being added (fuck union by position).
Valmond@lemmy.world · 1 pts · 346d
Isn't this more like evolution or even just optimisation? I mean it doesn't seem like a fundamental shift (can be wrong, just checked it out quickly).
panda_abyss@lemmy.ca · 2 pts · 346d
Sure, i think its just sql has not had any breaking version changes in like… ever?
Valmond@lemmy.world · 2 pts · 346d
Yeah, that's really one in a kind for such an important feature.
brian@programming.dev · 4 pts · 346d
sql as the language executed by the db hasn't changed notably, but I do think there's been significant developments in ORMs. for a lot of developmers sql is now just an intermediate target
Valmond@lemmy.world · 1 pts · 346d
Cool concept, didn't know about it will check out!
saltesc@lemmy.world · 1 pts · 346d
Yeah, this is what I end up doing. SQL does all the heavy lifting, and python or M usually doing the rest. Though M can be soooo slow.
JackbyDev@programming.dev · 5 pts · 346d
They finally added strict tables which avoids most (all?) of those shenanigans.
panda_abyss@lemmy.ca · 1 pts · 346d
I never really minded the shenanigans, after reading the docs once it all mostly made sense
JackbyDev@programming.dev · 3 pts · 346d
I don't really mind them either, it's just exciting that there is finally a way to make it actually act type safe.
JackbyDev@programming.dev · 34 pts · 346d
I am strongly strongly statically typed pilled and I will not apologize.
expr@programming.dev · 4 pts · 345d
100%. Though I can't imagine the meme is actually saying that things being stringly typed is a good thing.
JackbyDev@programming.dev · 1 pts · 345d
I don't think it is, and I'm not saying they don't have their place, I'm just a bit of a hater of dynamic types, like in a fun way, I don't think they're the bane of existence or anything. I just really love static typing.
Jankatarch@lemmy.world · 1 pts · 345d
But what about the absraction and portability and the inheritence and bunch of other buzzwords?!
JackbyDev@programming.dev · 5 pts · 345d
Every compile error I work through is a runtime error I don't have to troubleshoot by surprise. 🙏
adminofoz@lemmy.cafe · 1 pts · 341d
Portability, abstraction and inheritance are fundamental concepts, not buzzwords. Strongly typed languages can and does have all of these things.
magic_lobster_party@fedia.io · 28 pts · 346d
void*InternetPerson@lemmings.world · 7 pts · 346d
We don't touch that unless we really know what we're doing.
BenLeMan@lemmy.world · 23 pts · 346d
God, that reminds me of the debate on XML that I had with a developer about fifteen years ago.
Both our companies were working for a client who needed to publish product catalogues in several languages twice a year.
They had implemented a sort of Content Management System which they used with a plugin to feed data into Quark Xpress files as well as their website, IIRC. Cross-media publishing, essentially, and they had their own little set of format instructions to make words appear in bold, different colors, etc.
Since my company was tasked with translating the text into various languages, I suggested they come up with a way to store their data as XML. The standard tools in the translation industry can be easily customized to work with that, and XML would be a good way to future-proof their software. After a lot of delaying, grumbling, and ho-hum, they agreed to implement this plan.
Lo and behold, when the first meeting on the new XML format came around they showed it to me for the first time and... everything was in CDATA sections. Entire paragraphs of text with proprietary formatting instructions. 😐
When I tried to explain, very politely, and very patiently, that this was not going to work, the lead dev started insulting me. I swear to God, I've never been this close to punching someone in the face at a business meeting. 🤬
Thankfully, the client understood the issue and we eventually got an XML-based data exchange going. It is probably still in use today.
Whelks_chance@lemmy.world · 2 pts · 343d
This is why I ask for the schema at the same time as asking for (even example) data at the start of a project. Don't tell me you have the data, give me proof there's a standardized structure, or the length of the project just tripled.
kiri@piefed.social · 17 pts · 346d
Jerkface@lemmy.world · 12 pts · 346d
... Little Endian or Big Endian?
squaresinger@lemmy.world · 6 pts · 346d
Middle Endian ftw!
JackbyDev@programming.dev · 5 pts · 346d
I made a joke about that lately after someone suggested YYYY-DD-MM.
Whelks_chance@lemmy.world · 1 pts · 343d
Oh good god
baines@lemmy.cafe · 2 pts · 346d
how big is your word and how would this work
squaresinger@lemmy.world · 5 pts · 346d
You know, I was just joking, but turns out, Middle Endian really does exist!
https://en.wikipedia.org/wiki/Endianness#Middle-Endian
And it's just as crazy as one'd think. It's a 32bit value consisting of two 16bit little endian words jumbled together in big endian. So the byte order is B A D C.
Whenever I think "This is a really stupid idea, nobody would do that", turns out, someone actually did that.
baines@lemmy.cafe · 3 pts · 346d
oh lord why but that is about what i thought itd be
apfelwoiSchoppen@lemmy.world · 15 pts · 346d
The NHL banned the use of 00 as a number in the 95-96 season because they claimed their databases couldn't handle it. They still are fools because this continues to be a banned number to this day.
AmazingAwesomator@lemmy.world · 6 pts · 346d
(i am old) both my brother and i were number 00 in our younger hockey years. we were goalies, so we got first pick of numbers on all new teams we played on, heheheh.
lime@feddit.nu · 10 pts · 346d
some of you have never programmed in tcl and it shows
magic_lobster_party@fedia.io · 21 pts · 346d
I opened a TCL script once. It’s use of
uplevelscared me. I’ve never dared to return since.For those who don’t know:
uplevelis a command that goes up one level of the stack frame, and then executes code there. A function can therefore execute code in its callers stack frame.lime@feddit.nu · 13 pts · 346d
tcl is pretty fun actually, it's like bash on steroids.
for a preview of the insanity: anything surrounded by
""is a string, with the variable expansion you'd expect. anything surrounded by{}is also a string, but with no expansion. the equivalent in bash is the backtick string. but you don't need to know that to write tcl. if you approach{}as "code blocks" like in other languages, it just works. reason being that tclevals everything, constantly, attaching little tags to strings that tells the language how things are used, like "this string is an integer" or "this string is code and here is the result from last time it ran". it's madness and, weirdly, robust as hell. Xilinx writes all their tooling in tcl. SQLite started life as a tcl module, and it's still the only api that is not provided by a plugin.frezik@lemmy.blahaj.zone · 4 pts · 346d
I have. I quickly learned not to.
Tk is overlooked, though. It's not pretty, and its approach is archaic, but it's one of the few GUI toolkits that Just Works on every platform I tried it on with minimum fuss.
lime@feddit.nu · 3 pts · 346d
having used swing and modern js, i still prefer tk.
desmosthenes@lemmy.world · 10 pts · 346d
lol I think this when I see “any”
kruhmaster@sh.itjust.works · 9 pts · 346d
MonkderVierte@lemmy.zip · 4 pts · 346d
Cat type?
kruhmaster@sh.itjust.works · 3 pts · 346d
No, just meow.
MonkderVierte@lemmy.zip · 2 pts · 346d
No, i'm asking what type the cat is.
MigratingApe@lemmy.dbzer0.com · 2 pts · 346d
Perl!
ICastFist@programming.dev · 9 pts · 346d
Me, trying to learn flat assembler: "What is even an object?"
expr@programming.dev · 7 pts · 345d
Me, as a professional Haskeller: "What is even an object?"
trxxruraxvr@lemmy.world · 8 pts · 346d
Remember Tcl
Feyd@programming.dev · 5 pts · 346d
I fucking love tcl
MigratingApe@lemmy.dbzer0.com · 2 pts · 346d
The almighty
package require Expect. The muse of automation.ripcord@lemmy.world · 2 pts · 346d
Surprising amount of Tcl love in this thread
Valmond@lemmy.world · 1 pts · 346d
🤢
KindaABigDyl@programming.dev · 8 pts · 346d
Just use enums
communism@lemmy.ml · 8 pts · 346d
Simply make everything an array of bytes
baines@lemmy.cafe · 7 pts · 346d
where my Ada bros not committing war crimes at?
fibojoly@sh.itjust.works · 6 pts · 346d
Haha! Reminds me when I arrived in a team whose API accepted JSON and all the booleans were "True" or "False" (meaningful case, obv.) That was fun.
Whelks_chance@lemmy.world · 1 pts · 343d
I have the opposite issue with helm charts, where true and false are very, very loosely defined.
Lemminary@lemmy.world · 6 pts · 346d
[Laughs in computed TypeScript strings]
svcg@lemmy.blahaj.zone · 5 pts · 346d
This certainly Tcl'd my funny bone.
kewjo@lemmy.world · 5 pts · 346d
at the end of the day everything's a []u8 if you want it to be
driving_crooner@lemmy.eco.br · 3 pts · 346d
Kinda started using that with polars, force the scan/read schema as string, and down the road cast as the necessary type when needed. I'm calling it "just in time" data cleaning.
NigelFrobisher@aussie.zone · 2 pts · 346d
There are two genders: string and null
NateNate60@lemmy.world · 6 pts · 346d
There are eight genders: null, undefined, false, NaN, 0, "0", {}, and "".
Jankatarch@lemmy.world · 2 pts · 345d
nil
cupcakezealot@piefed.blahaj.zone · 2 pts · 346d
make everything a string then cast all data every time you want to use that data in a variable.
brashboy@lemmy.world · 1 pts · 346d
If it's not getting used in a mathematical function, I'm making it a string
Garbagio@lemmy.zip · 2 pts · 346d