|
taqueso posted:I should be able to link verilog or vhdl with my normal code cursed
|
# ? Jul 11, 2020 07:25 |
|
|
# ? Mar 29, 2024 08:16 |
|
DELETE CASCADE posted:there is no good reason to use dynamic typing. none. i will die on this hill yeah but you've already started programming so reason has been cast to the wind
|
# ? Jul 11, 2020 07:41 |
|
brap posted:if you write a prototype for demo purposes, and then you demo the prototype to management, you will end up shipping that prototype, so i don’t think you should write things as if you will get the luxury of throwing them away. one word: load-bearing dongles
|
# ? Jul 11, 2020 08:24 |
|
FamDav posted:i want to meet the person who tried to emulate pipes in soa queues
|
# ? Jul 11, 2020 09:59 |
|
taqueso posted:I should be able to
|
# ? Jul 11, 2020 10:01 |
IMO Python is mostly fine, but boy are its warts warty. I recently ran into one of my "favorite" python quirks in the wild, while helping my new-to-programming friend debug this line:Python code:
The issue was that this code would accept any response and never prompt for a new response. Now, you might think it's a precedence issue, and find out that adding parens fixes it (or just change it to if response not in valid_reponses), and move on with your life. But you'd be missing out on the truth: this is actually parsed as Python code:
because Python expects "in" (and "is") to work like the usual comparison operators and wants to support if 2 < x < 5. This is also why Python code:
is True, but Python code:
and Python code:
are both False.
|
|
# ? Jul 11, 2020 17:56 |
|
Until recently a date time object in Python would be true except at midnight, meaning you couldn't do 'if time:' but had to do 'if time is not None:' I have a lot of experience teaching code to children and young adults, and people always choose Python for this, when Python is actually a terrible choice. Users don't understand how strict whitespace sensitivity is. Your example reminded me of this because they constantly write things like 'if n == 3 or 5:' which should be forbidden by a type checker. Instead we had to start every class with a list of gotchas. And making sure that everyone downloaded the right Python version. Most of them don't know the difference so if you don't go check each computer manually there will be at least one person who follows along in Python 2, failing everything, and not speaking up until the end. xtal fucked around with this message at 04:35 on Jul 12, 2020 |
# ? Jul 11, 2020 18:02 |
|
I had a surprising number of nonprogrammers start their numbers with leading zeroes when I was teaching python
|
# ? Jul 11, 2020 18:02 |
|
i learned about octal when i had built the lookup table for a state machine in excel and was going to copy it over to my source code as a big ole array. i thought it would look prettier in the source file if the array numbers were all lined up, so that's an east fix, before we export it we'll just have excel insert leading zeroes in front of all the state numbers that are less than three characters long!
|
# ? Jul 11, 2020 21:30 |
|
Phobeste posted:i actually unironically looked up that article and recommended it to a coworker who was stuck in design paralysis and it worked great. thanks tef every month the developer at my company who committed the most net line deletions to the main repo gets a slack shoutout and a goofy lil' toy prize i'm the guy who runs it and at the end of last year i wrote a big ol email summarizing the year's code deletion accomplishments and then basically just paraphrased that article (with citation) to justify the endeavor
|
# ? Jul 12, 2020 02:39 |
|
raminasi posted:every month the developer at my company who committed the most net line deletions to the main repo gets a slack shoutout and a goofy lil' toy prize Will you link the article?
|
# ? Jul 12, 2020 14:00 |
|
CarForumPoster posted:Will you link the article? https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to quote:If we see ‘lines of code’ as ‘lines spent’, then when we delete lines of code, we are lowering the cost of maintenance. Instead of building re-usable software, we should try to build disposable software.
|
# ? Jul 12, 2020 15:09 |
|
One thing with that Meowseum adoption website project I had a few years back is that the graphic designer who had worked for Nokia was all like "you'll get venture capital" a few years back, and I believed him because of the Juicero story and all that. I should've realized earlier that I wasn't getting venture capital for a business without so much as a business license or the ability to sell anything, just a page on some venture capital social media site with five hits. Instead, I should've geared it toward paying for listings and adoption posters, the same revenue model as https://www.tabbytracker.com or https://www.petharbor.com but better at it. I also should've concentrated on having the minimal UI to get my first sale. I let myself get sidetracked with unnecessary tasks like allowing video uploads, which opened up a huge can of worms in terms of validation and processing. Also, I wanted to practice using JavaScript settings so I tried adding a night mode, and I found out the hard way that it's a bad idea to use JavaScript for page load effects because there was some flashing I could never get rid of. Whenever I get back to the project, just for the sake of practicing, I'm probably going to start over from scratch. I'll be jettisoning the adoption side of the website to concentrate on the lost/found sections and removing the Organization type of user. I don't think I'm going to get any local shelters or animal rescue organizations to join an experimental website, and I didn't get any replies when I sent out emails last time. If charging for lost/found listings and posters is successful, I can try again later. When I first started, I thought I always had to use Bootstrap grids as long as I'm using Bootstrap. I kept having to tweak individual elements to position them closer to my mockup for optimal spacing between UI elements. By the time I was done, I realized that as long as I'm working from a mockup, using custom exact maximum column widths works a lot better. I'm going to switch from using Django templates to using React. I wrote the project before ECMAScript 2015, so I'll probably update the JavaScript code to that version for the sake of practicing it. At that point, I also hadn't learned how to do virtualization with Python's venv module, and I was coding on Windows, so a lot of the modules are in this "C:\Program Files (x86)\Python35-32\Lib\site-packages" directory with some packages I altered under "C:\Program Files (x86)\Python35-32\Lib\site-packages_editable", because I was being lazy about collaborating on GitHub when I found bugs in a dependency. Starting over from scratch and copying and pasting in code from the old project as I go will probably be easier. Aside from the practice, at least it'll be in better shape for answering the "Have a project? We'd like to see it" line in job listings. galenanorth fucked around with this message at 03:47 on Jul 13, 2020 |
# ? Jul 13, 2020 03:43 |
|
how about you stop givin one poo poo about code and start being obsessed with how nobody wants this poo poo abstract words like validation and product market fit distract from the essential problem of nobody wanting your poo poo and lure people towards assuming people want their poo poo after literally becoming the largest company in the world by market cap amazon still has regular and astounding episodes of nobody wanting their poo poo (their video game, the treasure trucks, the phone etc etc). you will never stop being paranoid that people dont want your poo poo also dont send out emails, pick up the phone or show up. bad timing for showing up
|
# ? Jul 13, 2020 03:46 |
|
at the same time as nobody wanting your poo poo everybody will lie to your face about wanting your poo poo because their actual task at hand is to try to get the dipshit out of their face right now welcome to startupland! it helps to be asking questions
|
# ? Jul 13, 2020 03:51 |
|
can someone explain like i'm five years old rust arrays, slices, references and lifetimes and why the hell i can't make this code fragment work no matter what i try putting in place of the pointed-to parenscode:
|
# ? Jul 13, 2020 04:19 |
|
bob dobbs is dead posted:how about you stop givin one poo poo about code and start being obsessed with how nobody wants this poo poo this make something people want and will tell their friends about
|
# ? Jul 13, 2020 04:26 |
|
Ciaphas posted:can someone explain like i'm five years old rust arrays, slices, references and lifetimes and why the hell i can't make this code fragment work no matter what i try putting in place of the pointed-to parens
you can always take a reference to a [u8;8] to create a &[u8;8], or a slice of part or all of it to create a &[u8], but you can't safely go backwards, at least not at compile time -- the length information is no longer part of the type since your new function just takes a slice as its argument, there is no guarantee that it will actually have 8 bytes to read. if you really want to keep the signature this way for some reason, you can do something like this: code:
for real code you could handle it in some other way -- try_into() returns a Result, so instead of calling expect() or unwrap() you can just match on the return value and do whatever you want if it's an error. the cleaner option is to make your new function accept an array reference with an explicit length: code:
also notable: in rust, the last statement of any block is always returned (as long as it has no semicolon), so you don't need the "let x = ... return x" bits. code:
a lifetime is a template parameter to a type or a function that tells it how long it's allowed to live without ending up with a potential dangling pointer code:
lifetimes are used as template parameters, just like types are, so we want to specify explicitly that we're varying on it when we write the implementation code:
here, we specify that the new function takes a data argument whose lifetime is ALSO 'a. code:
|
# ? Jul 13, 2020 07:41 |
|
Ciaphas posted:can someone explain like i'm five years old rust arrays, slices, references and lifetimes and why the hell i can't make this code fragment work no matter what i try putting in place of the pointed-to parens your types dont match up. your struct has a [u8;8] and your new function takes a &[u8]. 1. your probably either gonna want to use try_into in the new function to make it into a [u8;8] also, or have new take a [u8;8] as its input argument. 2. you also need to figure out who owns the data here. you might want to be copying the data in your constructor, or if you use references for everything your gonna need to put explicit lifetimes on your struct, in your impl block, and on the data argument in the constructor
|
# ? Jul 13, 2020 08:41 |
|
yeah what that guy said
|
# ? Jul 13, 2020 08:42 |
|
fart simpson posted:2. you also need to figure out who owns the data here. you might want to be copying the data in your constructor, or if you use references for everything your gonna need to put explicit lifetimes on your struct, in your impl block, and on the data argument in the constructor yeah this is the fundamental problem here (assuming you don't just copy the bytes as [u8; 8] as mentioned). trying to store a reference inside a struct is precisely the thing rust is paranoid about because what if you drop the original memory but still have the struct with the reference in??? what if you accidentally try to reference it? with the CANPacket<'a>(&'a [u8; 8]) construction you will also run into issues if you try to drop the original memory before you drop the struct - there's no going off and storing this struct somewhere else unless you keep the original buffer alive for the whole of the rest of your program. i.e. this part: RPATDO_LAMD posted:if we change the struct this way, it will store just a reference to the memory location of the data array somewhere else. this also means that the struct as a whole has its lifetime tied to the lifetime of that reference, so if you construct it from a function-local array or something, you won't be able to return the struct outside that function, or the compiler will complain
|
# ? Jul 13, 2020 10:31 |
|
but yeah it's just 8 bytes loving copy it and not give a gently caress. until you're doing zeRo cOpY and need every nanosecond from your code I tend to avoid using references all over the place just because it requires you to think harder. note that you have to think exactly the same about if you were doing this in C++ if you don't want memory safety bugs but the compiler won't complain at you when you don't
|
# ? Jul 13, 2020 10:34 |
|
Ciaphas posted:can someone explain like i'm five years old rust arrays, slices, references and lifetimes and why the hell i can't make this code fragment work no matter what i try putting in place of the pointed-to parens i think you probably dont really need an explanation on arrays and slices. arrays are just statically sized arrays. slices are basically arrays where the size is known at runtime rather than compile time. not really anything different here than other languages. e-z. references and lifetimes get to the core of what rust is and what problems the borrow checker is there to solve. basically what the borrow checker does is it makes sure every object or value doesn't outlive its owner. every block of code in rust is scoped, and when you reach the end of that block, the value of that expression is returned and everything that's owned by that scope is deallocated. what you need to do is make sure that there's no possibility of you trying to use anything that already got destroyed in a previously executed block. imagine this code:
code:
another way to fix it, if we don't want to be evil and waste precious bytes of memory by copying stuff is to prove that the data which is referenced will outlive our rear end. this is where lifetimes come in. code:
code:
does that make any sense to you?
|
# ? Jul 13, 2020 13:07 |
|
Thank you for going into so much detail, I just wasn't getting the right mental hints from reading the rust book that all makes a lot more sense - especially if I say to myself "would doing this potentially gently caress me over in c++? if so the compiler will complain instead of me finding out later" The core of my actual confusion, I think, is move vs copy semantics and when they're necessary - which in this case probably means I'm overthinking optimization. At the same time I want to do things as idiomatically as possible while I'm learning the language, so I'll ask more newbie questions - CANPacket::_data's contents can be 1 to 8 bytes inclusive, and it shouldn't be mutable after construction if possible. What type do i probably want to store in the struct: an array or vec or something else? (I assume not a slice, for the lifetime reasons discussed - but see below) - CANPacket is heavily used (CAN is broadcast network and there are some dozen addresses broadcasting all the time on these devices) but I don't know how heavy, if that makes sense. How hard is optimizing stuff like this later, do I have to architect this in advance to get it right or what? said devices are very weak on CPU and RAM, so unfortunately I really DO have to think about this - However I actually store the bytes (or a reference to them), I want new() to be able to take one-to-eight bytes from any dang where without particularly caring whether it's an array, vec, slice or something else. At this level I don't even care if they're memory-contiguous, optimization aside. Given all that, what's the idiomatic way to spec that function parameter? Ciaphas fucked around with this message at 13:54 on Jul 13, 2020 |
# ? Jul 13, 2020 13:45 |
|
Given that it really is just 1-8 bytes the way that is most idiomatic is to just copy the memory. If you want to own a variable length array then a Vec is an array on the heap but in this case you probably want a SmallVec which is a variable length array that's on the stack (usually) and is owned.code:
Slices are the most flexible input type, you can turn an array, vec, whatever into one just by doing &vec[..]
|
# ? Jul 13, 2020 13:57 |
|
thanks! I'll be reading/writing all of my non-unit-test data from/to sockets - specifically crate socketcan::CANSocket::read_frame() - if that changes anything
Ciaphas fucked around with this message at 14:11 on Jul 13, 2020 |
# ? Jul 13, 2020 14:08 |
|
I could create a website where people play board games against each other, only via webcam, instead of an electronic version. I don't have any money to pay people, so I'd use a site currency where people get 1000 points to spend on games, they can earn points by setting up a board game in front of a webcam and moving around pieces for two other people, and rich people can buy more of the in-game currency instead of earning them by running/refereeing board games
|
# ? Jul 13, 2020 14:18 |
|
Okay the CANFrame struct already copies the data out of the socket and stores it as a [u8; 8] which it exposes to you as a &[u8] when you want to look at it (since not all 8 bytes might be valid). So you can just pass that around maybe.
|
# ? Jul 13, 2020 14:20 |
|
galenanorth posted:I could create a website where people play board games against each other, only via webcam, instead of an electronic version. I don't have any money to pay people, so I'd use a site currency where people get 1000 points to spend on games, they can earn points by setting up a board game in front of a webcam and moving around pieces for two other people, and rich people can buy more of the in-game currency instead of earning them by running/refereeing board games What does this thing have over skype? You're hiring somebody to set up the board/move the pieces? What?
|
# ? Jul 13, 2020 14:23 |
|
Maybe if it were an online gambling site, but those are banned in the U.S. Otherwise it'd just be Omegle for board games, but I don't think that Omegle makes any money. The site currency part would only be useful for games where one side can't know what the other is doing, like Battleship, but no one's going to pay for that. I'll think of something else galenanorth fucked around with this message at 14:45 on Jul 13, 2020 |
# ? Jul 13, 2020 14:27 |
|
gonadic io posted:Okay the CANFrame struct already copies the data out of the socket and stores it as a [u8; 8] which it exposes to you as a &[u8] when you want to look at it (since not all 8 bytes might be valid). So you can just pass that around maybe. y'know what it took me a shower just now to realize? why am I copying the fields out of CANFrame instead of just... saving the CANFrame itself as a field? programming is hard and at times I am not quick on the uptake
|
# ? Jul 13, 2020 14:40 |
|
Ciaphas posted:y'know what it took me a shower just now to realize? why am I copying the fields out of CANFrame instead of just... saving the CANFrame itself as a field? It was a good learning experience nonetheless!
|
# ? Jul 13, 2020 14:43 |
|
it was! i need to ease up on the self-deprecating in jest or otherwise, not doin me any favors
|
# ? Jul 13, 2020 14:47 |
|
Ciaphas posted:it was! i need to ease up on the self-deprecating in jest or otherwise, not doin me any favors now u know rust
|
# ? Jul 13, 2020 14:47 |
|
fart simpson posted:easy way to fix this is by making rear end actually own its own data instead of a reference to data owned by something else: i think if you omit the clone() here then butts will be moved rather than copied but that's only a valid strategy in cases like that example, where farts() doesn't try to interact with butts after it's been moved for example this will fail to compile: code:
|
# ? Jul 13, 2020 15:05 |
|
oh yeah you’re right. i thought i might be forgetting something there
|
# ? Jul 13, 2020 15:08 |
|
terrible programming: FAIL: reference of butts after move to rear end
|
# ? Jul 13, 2020 15:12 |
|
some ideas already in my rejects pile - Selling customized packages of non-perishable food such as custom trial-sized packages, the whole single-color M&M's thing but with companies that don't do that yet. All else being equal, I'd prefer to start with an idea that doesn't involve physical products so that the money being risked is minimized. - TiVo for radio as an online app was in my June 2018 list, but Radio.com did it a year later. - Automatic local lottery statistics analysis. A website selling a PC program for this appears to have recently gone out of business. It seems too niche to be worth it - Quiz site - When I wrote this is in 2016, small-time quiz site Playbuzz had secured $15 million for sneaking ads into its quizzes, and I think that ship has sailed by now - Deathogram, a website for dead man's switch content and actions (e.g. email sending) - All else being equal, I wouldn't want to do this one even if it worked out - Website with a better UI than the one https://www.congress.gov and https://www.senate.gov or third-party sites provide. Include an asterisk when the member voted differently in committee than in the floor vote, because "moderates" tend to switch sides because floor votes are more visible. Sort by Yea+Not Voting or Nay+Not Voting and by political party simultaneously. Use the Congressional Record to automatically splice together C-SPAN clips while allowing the user to tweak start and end times. Those are some features I'd like to see. I guess the only revenue would be from donations, and I don't want to try to make money from donations anyway Edit: I have a web scraping project that involves scraped data and competing with https://www.aggata.com and other sites which sell CSVs. I've been using WordPress to make the site. If I can't think of another app, I think switching to Django and React will suffice to check off "has a project written in Django and React" for job searching purposes. I'll also probably need to do it in order to leave open the possibility of custom widgets like embedded Google Maps showing the data and allowing customers to file custom orders of data (e.g. competing coffee shops in Arkansas). galenanorth fucked around with this message at 16:07 on Jul 13, 2020 |
# ? Jul 13, 2020 15:30 |
|
tbh the move-by-default thing is like my fav part of rust and if you're able to structure things to take advantage of it you can quickly end up with safe code that also has almost no malloc overhead
|
# ? Jul 13, 2020 15:32 |
|
|
# ? Mar 29, 2024 08:16 |
|
galenanorth posted:some ideas already in my rejects pile all these ideas would involve selling to peeps who, to a first approximation, dont have any fuckin money to solve their problems
|
# ? Jul 13, 2020 16:21 |