Threads for ducdetronquito

  1. 1

    Regarding SQLite, I would not recommend using react-native-sqlite-storage: the package seems in maintainance mode and issues are stacking.

    react-native-quick-sqlite should probably be your goto sqlite driver, but be aware that you won’t be able to unit test your queries on your computer: you will need another driver suitable for desktop os like node-sqlite3 or better-sqlite3, and code your app so that you rely on a DB abstraction rather than the driver itself to make it testable; therefore tou will be able to switch the driver in the unit tests.

    It may lead to bugs in production not reproductible in unit tests, but I don’t know a better option.

    1. 6

      It’s a great resource ! I remember building an hex grid based game with a friend a few years ago thanks to this :)

      1. 1

        That’s nice! :)

      1. 6

        MERGE requests are gonna be a real treat at $day_job !

        1. 3

          I posted this not because it’s earth shattering, but because it offers a bunch of helpful techniques actually written out in practice so folks struggling with coming up to speed with unit testing can benefit.

          1. 2

            Good tips !

            I ended up doing the same techniques at work and it works great.

            On thing I do differently is that I tend to create a test file per class where each public method is tested in a dedicated test suite, like:

            class TestRefresh(TestCase):

            def test_success(self): pass

            def test_fail_when_some_reason(self): pass

            1. 2

              I have an irrational dislike of anything that smells like Java unittest so I always use Pytest :)

          1. 2

            Gleam looks like a very nice language: I hope to find time to give it a try this summer.

            Is there a showcase of “stuff built with Gleam” out there ? I’m curious :)

            1. 2

              There’s a list of libraries and projects here: https://github.com/gleam-lang/awesome-gleam

              Could be useful. More to come in future!

            1. 7

              This all sounds really great, except this bit:

              And on a related node, recently publish packages can be replaced with gleam publish –replace. This is useful for correcting any mistakes made during the process of releasing a package.

              Does that mean the content of a particular version of a package can change? (Also I think there’s a typo “recent published packages”?)

              1. 12

                This is a feature of Hex (a package manager for all BEAM modules (erlang, elixir, gleam, etc)). The time limits are quite short so there should be very little danger:

                There are exceptions to the immutability rule, a package can be changed or unpublished within 60 minutes of the package version release or within 24 hours of initial release of the package.

                https://hex.pm/docs/faq#can-packages-be-removed-from-the-repository

                1. 4

                  That’s neat !

                  I wish PyPI had this: these kind of small release mistakes can happen very easily.

                  1. 3

                    Ahh ok. The time limits make it a bit less concerning.

                    1. 6

                      Packages also come with checksums so the tooling will identify a change compared to what is expected in the lockfile.

                  2. 1

                    While we’re pointing out typos: s/related node/related note

                  1. 2

                    Excellent article !

                    I hope more widely known library will try compiling with mypyc, even without deploying anything, as it will provide useful feedbacks to the maintainers.

                    1. 3

                      I never used Inkscape but the UI/UX looks very polished from a newcomer perspective: it makes me want to use it even if my drawing skills are stick man grade !

                      1. 4

                        Inkscape has become a lot more polished over the years. Been using it since 0.92. 1.2 is a fabulous release.

                        1. 3

                          I’ve only used very sparingly and for simple stuff throughout the years, but i’ve always had this really nice feeling of of things being a bit better every time i used it, both in terms how UI polish but also in snappiness/performance :)

                          1. 2

                            I started using it to get away from tikz, and I gotta say it was the right choice

                          1. 5

                            Yes it matters.

                            At least with C++ developers can slowly learn the more arcane part of the language language while they use it. A bit more difficult with Rust.

                            Furthermore, it might be possible to implement some form of borrow checking for existing languages.

                            Any language should be easy to learn. That’s true for C and python. Language popularity is highly correlated with ease of learning. And this is true for all the new languages out there that try to do fancy things: most developers do not care.

                            Personally, all I would ever want, is something mostly like C/C++, with pythonic features, easier to read and use, faster to compile, without a GC, statically compiled, without sophisticated things.

                            1. 17

                              I wouldn’t call C easy to learn. It probably has less essential complexity than Rust has, but there’s still a lot of fiddly details to learn that wouldn’t come up in languages created decades later with garbage collection and better tooling and syntactic defaults.

                              1. 9

                                A couple issues I found when wanting to learn C is all of the variation because of its history. What tooling should I use? Which conventions should I follow? Which version is the current version?

                                The various C standards are not conveniently discoverable and even when you map them out, they’re written in reference to past standards. So to get the set of rules you have to mentally diff K&R C with a handful of other standards published over 40 years, etc. Starting completely from no knowledge and trying to figure out “What are the complete set of rules for the most modern version of C?” is nearly impossible. At least that has been my experience and biggest struggle when trying to get started with C multiple times over the years.

                                Then I constantly see veteran C programmers arguing with each other about correct form, there seems to be far less consensus than with modern languages.

                                1. 5

                                  I’d say C is easy to learn but hard to master. But that could be said about a lot of languages.

                                  1. 2

                                    I think there is a big difference to what is the absolute minimum you can learn.

                                    You can “learn” C with programs that compile and run the happy path mostly correctly. The probably have tons of bugs and security issues but you are using the language.

                                    Rust forces you to handle these issues up front. This does make the minimal learning longer but the total learning to be a “production ready coder” is probably actually shorter.

                                  2. 15

                                    Man, I was terrified when I was learning C++. I would stick to the parts I was “comfortable” with, but when I would call someone else’s code (or a library) I couldn’t reliably know how the features they used would intersect with mine. And the consequences very often were debugging core dumps for hours. I’m no Rust fanboy, but if you’re going to have a language as complicated as Rust or C++, I’d rather learn with one that slaps my hand when doing something I probably oughtn’t do.

                                    1. 11

                                      So, Nim once ARC lands?

                                      1. 3

                                        Is that not the case already ? I unfortunately do not use Nim often these days so I might be out of touch, but if I recall correctly arc/orc are available but not the default.

                                        EDIT: Yeah, It seems to use ref counting by default currently but the doc advise to use orc for newly written code Cf: https://nim-lang.github.io/Nim/mm.html

                                      2. 8

                                        Any language should be easy to learn. That’s true for C and python. Language popularity is highly correlated with ease of learning.

                                        All other things being equal, yes, ease of learning is good. But at some point one may have to sacrifice ease of learning to make the expert’s work easier or more reliable or faster or leaner. Sometimes that’s what has to be done to reach the level of quality we require.

                                        If it means some programmers can’t use it, so be it. It’s okay to keep the incompetents out.

                                        1. 8

                                          I was mostly with you, but “incompetents” is harsh.

                                          1. 4

                                            Can we at least agree that there is such a thing as incompetent programmers? I’m all for inclusivity, but at some point the job has to get done. Also, people can learn. It’s not always easy, but it’s rarely impossible.

                                            1. 4

                                              There are, but generally they’re not going to be successful whether they use Rust or another language. There are inexperienced developers who aren’t incompetent but just haven’t learned yet who will have an easier time learning some languages than Rust, and there are also experienced programmers who simply don’t know Rust who will also have an easier time learning other languages than Rust. Since the incompetent programmers will fail with or without Rust, it seemed like you were referring to the other groups as incompetent.

                                              1. 5

                                                Ah, the permanent connotation of “incompetent” eluded me. I was including people who are not competent yet. You only want to keep them out until they become competent.

                                                My original point was the hypothesis that sometimes, being expert friendly means being beginner hostile to some extent. While it is possible (and desirable) to lower the learning curve as much as we reasonably can, it’s rarely possible to flatten it down to zero, and in some cases, it just has to be steep.

                                                Take oscilloscopes for instance. The ones I was exposed to in high school were very simple. But the modern stuff I see now is just pouring buttons all over the place like a freaking airliner! That makes them much scarier to me, who have very little skill in electronics. But I also suspect all these buttons are actually valuable to experts, who may have lots of ways to test a wide variety of circuits. And those button give them a more direct access to all that goodness.

                                                In the end, the question is, are steep learning curve worth it? I believe that in some cases, they are.

                                                1. 3

                                                  That makes sense. Thanks for clarifying. I don’t know if I have a strong opinion, but I do believe that there are cases that require extreme performance and that often requires expertise. Moreover, having been a C++ programmer for a time, I’m grateful that where C++ would accept a broken program, Rust slaps my hand.

                                          2. 2

                                            True. Ada Programming language easy to learn but not widely accepted or used

                                          3. 4

                                            At least with C++ developers can slowly learn the more arcane part of the language language while they use it. A bit more difficult with Rust.

                                            I’m not sure what parts of Rust you consider “arcane”. The tough parts to learn, borrow checking and lifetimes, aren’t “arcane” parts of Rust; they are basically it’s raison d’être.

                                            Any language should be easy to learn.

                                            Ideally languages would be as simple/easy as they can be to meet their goals. But a language might be the easiest-to-learn expression of a particular set of goals and still be tough to learn – it depends on the goals. Some goals might have a lot of inherent complexity.

                                            1. 3

                                              If carefully aware of escape analyses as a programmer, you might realize that with Go, and, while programming Go for several years, I’m by no means a Go fanboy.

                                              In particular, I conjecture that you could write a program in Go that does not use GC, unless the standard library functions you use themselves use GC.

                                              I need to learn Rust, i realize, having written that prior sentence, and having been originally a C fan.

                                              1. 6

                                                Personally, I would strongly recommend the O’Reilly “Programming Rust, 2nd ed.” For me it was a breakthrough that finally allowed me to write Rust and not get stuck. It may not be “perfectly shiny” what I write, but before that, I often stumbled into some situations I just couldn’t get out of. Now I understand enough to be able to at least find some workaround - ugly or not, but it lets me go on writing.

                                                Also, coming from Go (with a history of C++ long ago beforehand), one thing I had to get over and understand “philosophically” was the apparent lack of simplicity in Rust. For this, my “a ha” moment was realizing, that the two languages make different choices in a priorities triangle of: simplicity vs. performance vs. security. Go does value all 3, but chooses simplicity as the highest among them (thus GC, nulls, etc; but super approachable lang spec and stdlib APIs and docs). Rust does value all 3 too, but chooses performance AND security as the highest. Thus simplicity necessarily is just forced to the back-seat, with a “sorry, man; yes, we do care about you, but now just please stay there for a sec and let us carry out the quarrel we’re having here; we’ll come back to you soon and really try to look into what you’d like us to hear.” And notably the “AND” here is IMO a rather amazing feat, where before I’d assume it just has to often be an “or”. Also this theory rather nicely explains to me the sparking and heated arguments around the use of unsafe in the community - it would appear to happen around the lines where the “AND” is, or looks like it is, kind of stretching/cracking.

                                              2. 2

                                                Personally, all I would ever want, is something mostly like C/C++, with pythonic features, easier to read and use, faster to compile, without a GC, statically compiled, without sophisticated things.

                                                I think you’re looking for Myddin (still WIP) or possibly Hare. Whether they’re “pythonic” is debatable though.

                                                1. 1

                                                  Any language should be easy to learn.

                                                  Not only easy to run. Easy. Because why would one make it difficult if it clearly can be made easy? The whole point of programming languages is providing simoler alternatives to the targets of their compilers.

                                                1. 23

                                                  I love those kinds of programs! I create aliases and small shell functions all the time in this style. One of my favorites is a puts function that basically evals in Ruby what I type. I often use it to do maths and date calculations. I know you can do this in shell, but I do so much Ruby that it is like a second language (third, after English?) for me.

                                                  function puts() {
                                                    ruby -r date -e "puts($*)"
                                                  }
                                                  
                                                  $ puts Date.today + 10 # What day is ten days from now?
                                                  2022-03-19
                                                  
                                                  $ puts "10 ** 3 / 9.0"
                                                  111.11111111111111
                                                  
                                                  1. 3

                                                    Very cool ! I always do this by opening a Python shell, but never thought about making a shortcut: thanks :D

                                                    1. 2

                                                      I just open devtools in the browser, or maybe aa node repl instead, to each their own :)

                                                      One of my first utilities that I wrote was a dice, we wanted to play GURPS but didn’t have dice so I wrote one quickly. Back in the nineties there were no cellphones. I’ve written such things before and after but this one i always remember.

                                                    2. 2

                                                      Why did you call it puts?

                                                      1. 7

                                                        To follow the name of Ruby’s method to print to output. You can even see me calling it in the code puts($*).

                                                        Also, it not only evals the code, but prints its result.

                                                      2. 1

                                                        I have a similar one:

                                                        $ datedate
                                                        Thursday 2022-03-10 13:09:58 Europe/Stockholm 2022
                                                        2022-03-10T13:09:58+01:00
                                                        1646914198
                                                        
                                                        $ datedate +22 days -1month
                                                        Friday 2022-03-04 13:10:02 Europe/Stockholm 2022
                                                        2022-03-04T13:10:02+01:00
                                                        1646395802
                                                        
                                                        $ datedate 1646395802 
                                                        Friday 2022-03-04 13:10:02 Europe/Stockholm 2022
                                                        2022-03-04T13:10:02+01:00
                                                        

                                                        but since I haven’t found anything as good as php’s strtotime(), it remains the only script that forces me to install php :( Source here: https://github.com/chelmertz/dotfiles/blob/master/bin/datedate

                                                        1. 3

                                                          A coworker of mine created something like this in Rust:

                                                          $ date-math 'dec 30, 2021 + 2 weeks + 1 day'
                                                          2022-01-14
                                                          
                                                          1. 10

                                                            Note that GNU date can do this built-in:

                                                            % date -d 'dec 30, 2021 + 2 weeks + 1 day'
                                                            Fri Jan 14 00:00:00 CET 2022
                                                            
                                                            1. 1

                                                              This has made my Friday.

                                                          2. 1

                                                            Maybe https://github.com/hroptatyr/dateutils do the same job without PHP?

                                                          3. 1

                                                            My aliases

                                                            alias rm="rm -i"
                                                            alias cdtemp="cd $(mktemp -d)"
                                                            alias pb="curl -F\"file=@-;\" https://envs.sh"
                                                            

                                                            Favorite one is cdtemp, great for quickly testing out stuff.

                                                          1. 5

                                                            A couple interesting projects I’ve come across written in Crystal:

                                                            1. 3

                                                              There is also invidious which is a very nice alternative frontend for Youtube !

                                                              1. 1

                                                                Hmm, that’s only two data points, but it seems like a trend to write these alternate frontends in Crystal. I wonder why that would be? Is it because they might have written it in Ruby on Rails back in the day, and Crystal has some similar ergonomics? Or nostalgia / familiarity among a specific demographic, in other words?

                                                            1. 4

                                                              Not much time to review your code properly, but here are some minor things found in your Zig code:

                                                              • Here, you can shorten the syntax: std.os.getenv("HOME").?

                                                              • Yes an ArrayList only manages the memory of the underlying array, not the memory of its items.

                                                              • Since you use an ArenaAllocator, and your cli lifetime is short, you probably don’t need to worry about deallocating stuff

                                                              • Channel.name looks like it can just be a byte array name: []const u8

                                                              1. 8

                                                                zig force the programmer to worry about error handling. The way I see it, things should not error, if they do, stop everything and print a stack trace, please don’t bother me with it…

                                                                run_this_erroring_function() catch @panic("nope");
                                                                

                                                                I believe this will produce a stack trace in zig

                                                                Otherwise, a good article!

                                                                1. 21

                                                                  I think that the author’s mindset is perfectly understandable for a data scientist and at the same time absolutely inadequate for software engineering (the author does point out their appreciation for that disinction right after that quote). The two fields (data science, swe) both make use of a computer but for very different goals.

                                                                  A high-quality application needs to be able to gracefully handle failures and explicitness in the language helps do the methodical work required to get there. This is obviously true for stuff like kernel modules, but it’s also true for user-facing applications. I’ve used recently a video editing software that would use a lot of ram while encoding a video and it would have been absolutely unacceptable for it to crash the instant it hits system limits. Coincidentally, encoding a video would instantly crash Discord and Firefox for me.

                                                                  And it’s not just allocation problems, but also all kinds of errors when there’s unsaved user data at hand, critical systems, etc. In data science crashing is the best strategy because at that point the program will not be computing the right answer anyway, but the same doesn’t hold as true for other applications.

                                                                  Also explicitness helps with deciding when an error can be safely ignored or not. If you’re writing the above mentioned video editing application and trying to print to a log file fails, you might want to continue running anyway as it should not be a show-stopper for a lengthy encoding process, for example. If instead you’re writing a command line tool whose main job is to print to stdout and printing fails, then that’s a different story, which is why Zig has no print statement.

                                                                  1. 3

                                                                    In data science crashing is the best strategy

                                                                    Also you know very well how your target system looks like and want to perform as fast as possible, using as many speed improvements as you can get. For example we did test openmpi stuff at a local node (64+ cores), using the “let it crash” style was easy there, while also compiling it on that target hardware. And then submitted the batch job to the supercomputer of the university, which distributed it along all nodes. Later on you got your reports back.

                                                                  2. 9

                                                                    I might be missing something, but it seems to me that using try everywhere is the most concise way to let an error bubble up without dealing with it.

                                                                    Coming from Python, I admit I was a bit annoyed to use it in places like adding an item to a list, as it can fail to allocate, but in the end you get to like it.

                                                                    1. 2

                                                                      Yeah, you’re absolutely right, I didn’t even think of that!

                                                                      1. 1

                                                                        With ArrayList specifically, you can also use initCapacity() and/or ensureTotalCapacity()/ensureUnsusedCapacity() and then appendAssumeCapacity() (without try), which can lead to nicer code in some situations.

                                                                    1. 1
                                                                      • Enjoy my last week of vacation
                                                                      • Zig: Work again on h11 to make it allocation free and upgrade requestz accordingly. I hope to release a v0.2.0.
                                                                      • Run tuesday, thursday and saturday: my body is not ready !
                                                                      1. 16
                                                                        • How to optimize PostgreSQL (@work)
                                                                        • How to repair a house I just bought in the countryside; Maybe wood work too.
                                                                        • More stuff surely, but I don’t know it yet !
                                                                        1. 8

                                                                          Woodwork is very rewarding. Even if you do crude things at the beginning, it’s still incredibly fulfilling to me.

                                                                          1. 5

                                                                            I’m curious, how did you start learning it ? A book ? Videos ? Just you trying things ?

                                                                            1. 6

                                                                              Well I started by trying first and only occasionally googling how a thing is done.

                                                                              I did have “second hand” experience from watching dad make things. He always made stuff with very low education and he instilled in me the fact that you don’t need school to make things, you need to make things to make things.

                                                                              But how I started is I wanted a really specific desk for my apartment and I just couldn’t find anything looking good enough to buy. So I drew what I wanted, figured out what kind of planks and stuff I needed and ordered them from a woodworking skip. They cut the stuff for me and all, and I mostly just glued it together. But the plans were mine and it was a start.

                                                                              Later on I did more and more things for myself. For example, the last piece was bunk beds for my kids. Where I sawed the wood, lacquered it, cut it, assembled, everything.

                                                                          2. 5

                                                                            Re: Postgres: may I suggest looking into https://www.pgmustard.com/ ? It’s a really neat query explainer explainer tool

                                                                            1. 1

                                                                              Thanks, I am going to have a look at it :)

                                                                              1. 1

                                                                                +1 on the suggestion, I had a lot of success with pgmustard. It has a nice user-friendly hints associated with the highest costing things in your query plans, so you can really dig in and learn something about what makes queries efficient.

                                                                            2. 2

                                                                              How to optimize PostgreSQL (@work)

                                                                              Are you talking about queries or the DB itself?

                                                                              In either case, I can highly recommend really digging deep into the documentation and also their Wiki. And also make sure to not trust external stuff. Next to stuff changing between versions, sadly some information even on PG consulting company pages are outright wrong.

                                                                              But much fun to be had, with query analysis, understanding how memory is used, how much a difference locales can make (collate), when most don’t even think about it. Really interesting stuff.

                                                                              1. 2

                                                                                Nice! How are you planning to tackle the Postgres optimization?

                                                                              1. 2

                                                                                Kudos ! We use Django a lot at work and it reminds me that we nees to upgrade from 2.2 to 3.2.

                                                                                I wish I had the time to benchmark Falcon for our usage: it looks well maintained, straightforward and fast. Do any of you has feedbacks on using Falcon ?

                                                                                1. 2

                                                                                  @home:

                                                                                  • Catch up on the advent of code in Nim; I hope to have the day 5 done before this weekend !
                                                                                  • Go running/climbing to prepare for all the good food of christmas
                                                                                  • Take time to read
                                                                                  1. 1

                                                                                    Trying my luck with Nim 1.6.0 this year ! 👑

                                                                                    1. 6

                                                                                      I’m going to try Zig this year, adding solutions to the same repository mk12/aoc.

                                                                                      1. 2

                                                                                        Also trying Zig, and my first time attempting the AoC. My repo

                                                                                        1. 1

                                                                                          Good luck, it is a very enjoyable language to work with :)

                                                                                          PS: Lightweight standard library documentation can be found here => https://ziglang.org/documentation/0.8.1/std/

                                                                                        1. 3

                                                                                          Very enjoyable talk ! :)

                                                                                          Could you confirm that the code for Zig tokenizer and parser are in the following files ?

                                                                                          If so, I will take time to read them to better grok what you said in the case study.

                                                                                          1. 4

                                                                                            Yes, that is correct. You may also be interested in:

                                                                                            1. 1

                                                                                              Thank you :)