Fortnightly Programming Q&A Thread
General Programming Q&A thread! Ask any questions about programming, answer the questions of other users, or post suggestions for future threads.
Don't forget to format your code using the triple backticks or tildes:
Here is my schema: ```sql CREATE TABLE article_to_warehouse ( article_id INTEGER , warehouse_id INTEGER ) ; ``` How do I add a `UNIQUE` constraint?
Got listed as A contributor on a bigger GitHub project for finding a bug. Now I’m in the mood to contribute to more things. Any projects you have contributed to?
An awkward number of my "contributor" badges on large projects are
That's useful too! I always catch little typos, think about changing them, then don't. I'm still using the exuse that someone was mean to me once. But I can get over it!
Well done, any particular language you're looking to work in?
I feel comfortable enough to contribute in js, python and java. Thinking of maybe some creative stuff too. Maybe some projects I can use to teach, too. That’s actually how I got to the last project
Contributing to Rails, way back when, was the fastest way for me to establish my credentials when abandoning Microsoft-land for open source work.
These days, most of my contributions to public projects are typo fixes. I still commit tons of code at work, and I've started up a new private side project which may or may not go somewhere...
I'm currently learning C for real (as opposed to just cobbling stuff together), and it made me think about utf8. Any languages use utf8 by default?
Swift does. You can have variable names be almost any set of unicode characters (er... code points... whatever), except for mathematical symbols. They exclude mathematical symbols because you can use those for creating your own operators. Want a dot product operator that uses the actual dot product symbol? You can do that! It's pretty cool.
That is cool! One thing I like about Haskell.
Rust's strings are UTF-8. This is actually considered a safety guarantee: it is not possible, without using
unsafe, to put bytes which do not correspond to a valid sequence of UTF-8 code points into a string.
Oh cool! I'll have to try rust again. I got lost on borrowing last time I tried it.
I have been having a lot of fun learning/using Rust the last several months. Coming from a C background, I really liked Learn Rust the dangerous way to get my feet wet with rust.
Python is very utf8 friendly.
Not sure, what you mean by “use UTF-8 by default”, but in Go, both the programme source code and strings are required to be UTF-8 by the language specification.
I mean that! Thanks for the info -- it looks like I'm going to try bouncing between Go and Rust, starting maybe in a few months.
Here is a nice riddle for yall: How do you get the exit status of a non-last command in a pipeline in POSIX shell without using temporary files, FIFOs, and alike?
The POSIX shell bit is important. In Bash you have
Is there a list of C problem.
I don't know what they called, maybe list of memory management issues. and if there is a basic issue from which these issues came, but I don't want someone to tell me it has no GC, or something like that. this is not a problem.
There is the Common Weaknesses Enumeration. For example, here are the ponter issues.
Are you in the process of debugging a memory issue? If so, there are a lot of great tools for that. What OS are you programming for? For macOS/iOS, there's Address Sanitizer, the Leaks instrument, the Allocations instrument, Zombies, guard malloc, and guard edges. For Linux and Unix there's valgrind. (I think Valgrind also works on macOS and Windows, too, but am not positive.) I'm sure Microsoft has some memory debugging tools in VSCode and Visual Studio.
There's also static analysis of your code. If you're building with llvm you can use the clang static analyzer to find memory issues, for example.