4 ms·
I felt some nostalgia for Fortran a while ago. Spent half an hour programming in it, cured. Maybe take a shot at parsing JSON in C++ and see if the nostalgia su
by JonChesterfield 3y ago
I felt some nostalgia for Fortran a while ago. Spent half an hour programming in it, cured. Maybe take a shot at parsing JSON in C++ and see if the nostalgia survives the process.
- ChuckMcM 3y agoIt took 30 minutes to cure you?!? One of the first things I did when I got my PiDP-11 which can run RSX-11M and the DEC fortran compiler. I spent many many hours programming in Fortran when I was in college and thought wow I could relive some of that, about 5 minutes in I was "okay, step slowly away from the console." :-)
- tialaramex 3y agoThere's a fun stream where tsoding decides to learn Fortran, and the instructions he's working from say to turn off implicit typing (ie write "implicit none"). He's familiar with modern languages with type inference and with C++ type deduction which is a similar idea to full blown inference - and so he has no reason to even guess what Fortran is going to do without that admonition and you can see he's not happy when he finds out.
- pklausler 3y agoI don't get that at all. Old FORTRAN has a mildly confusing feature that is easy to disable. He then got upset about the mildly confusing feature that everybody now disables. If one wants to bitch about Fortran, at least complain about the modern language (which is still a horror show of poorly defined and often unportable features), not the stuff that has been made obsolete.
- ChuckMcM 3y agoI was teaching one of the local highschool kids how to program in C and they asked "So why does everybody use i,j, and k for their indexes in loops?"
- pklausler 3y agoI only use 'j' and 'k', not 'i ' -- the rarely-used letters are easier to search for.
- yellowstuff 3y agoii is also good.
- magpi3 3y agoi stands for index. j and k because we can't use i anymore, and maybe because they are close together on the keyboard
- petsfed 3y agoI recently had to port an existing C++ JSON parser into a new project, and even though it was complete in terms of what we needed it to do right now, adding any kind of additional functionality to it would've been a nightmare.
- jbandela1 3y ago>Maybe take a shot at parsing JSON in C++ and see if the nostalgia survives the process. I have used this library in the past and was actually pretty easy https://github.com/nlohmann/json https://github.com/nlohmann/json
- celie56 3y agoYour recommended json solution was also my first thought but if you do not have the ability to easily introduce a new dependency then the op is correct. If I have an existing JSON file that I want to quickly parse for a demo project there is almost zero chance I would pick C++. In comparison, Python is already installed in many environments and has built-in json parsing.
- JonChesterfield 3y agoA mere 25k lines of self contained C++, bundled in a single header as the one true distribution format. I note the CI cmake script at a thousand lines of cmake. That's a very idiomatic representation of a C++ library, thank you for the example.
- SubjectToChange 3y agoA mere 25k lines of self contained C++,… Oh come on now, about 7.5k of those lines are comments and/or blank lines. Furthermore, a good chunk of the code is devoted to type checking, thorough error handling, compiler compatibility and/or workarounds, etc, all within the restrictions of C++11. … bundled in a single header as the one true distribution format. Yes, build systems are a significant pain point for C++ and C. Many users prefer to largely avoid the issue and use header-only libraries. That said, Conan and vcpkg are making genuine strides at improving the issue. I note the CI cmake script at a thousand lines of cmake. This is ridiculous. It’s a CI script running multiple test suites over dozens of compiler versions, of course it’s going to be a lot. Would it make you feel better if that CI script didn’t exist? If not, then what’s the “correct” size for CI script? That's a very idiomatic representation of a C++ library, thank you for the example. The library is genuinely good. It’s portable, well tested, user friendly, and widely supported. Your snark is unwarranted.
- pantsforbirds 3y agoIf you have any problem that isn't vector math, it's absolutely awful. Even IO is unpleasant
- JonChesterfield 3y agoVector math on raw floating point that is. If you want to wrap that float in a type to force (physical) dimensional consistency, you are going to have a bad time.
- VHRanger 3y agoLet me carefully copy paste my personal stringutils.hpp file of string handling routines and I'll be right up to it!
- rightbyte 3y agoGotta have those "readfile()", "replace_substr()", "split()" etc! I do have a copy paste string util header. .. I really wish there were more string util functions in Cpp. I mean C had strtok()!
- PaulDavisThe1st 3y agostrtok() is one of the most dangerous string handling functions in any language!
- rightbyte 3y agostrtok() is like a hot art student, smoking a cigarette. I think I've got to it once.
- PaulDavisThe1st 3y agoIn the C language, you do not get to strtok(3), strtok(3) gets to you.