r/ProgrammerHumor • • Feb 13 '19

The user's solution for everything...

Post image
5.0k Upvotes

216 comments sorted by

View all comments

409

u/[deleted] Feb 13 '19

[removed] — view removed comment

64

u/[deleted] Feb 13 '19

Why not at least use a json file or something? Only reason I could imagine is that you're dealing with a stupid amount of data and don't wanna use up disk space wherever you're hosting it

50

u/nickleformypickle Feb 13 '19

I guess JSON isn't really the issue, but rather the fact that it's a file database.

One thing about these file based databases is that they are a lot more prone to corruption than a proper database like MySQL/PostGres, or Mongo and Redis.

Another is that file based databases get exponentially slower as more things read from it and as more data gets written. Unless you're streaming the JSON file (which adds more complexity), you're loading ALL of the data into memory before you can retrieve 1 field. As you can tell, this will probably fuck up badly if you were to scale.

JSON databases also don't support relational data (Mongo/Redis too I guess), which kinda sucks if your data/app was to have any sort of complexity.

39

u/lengau Feb 13 '19

Honestly, SQLite is a nice intermediate for a lot of things like this. It gives you a fairly simple SQL database, so while your app/data are tiny and easy to manage with just a file, sqlite gives you a simple solution. Likewise, if your database ever gets big enough that you really need to move it into a full RDBMS, your work is probably easier because the data is already structured in a way to make that easy.

2

u/ShadoWolf Feb 14 '19

honestly, the best approach is to just use an ORM framework. My preference is Sqlalchemy when working in python.

You get all the same power as SQL with any backend (SQLite, mysql, etc). But it maps everything into native objects. So you can just treat with a query like interacting with a normal Class object.

→ More replies (4)

28

u/MoroseBurrito Feb 13 '19

Proper database

Mongo

Pick one

15

u/The_White_Light Feb 13 '19

But MongoDB is web-scale.

15

u/MetalPirate Feb 14 '19

MongoDB: Snapchat for databases

7

u/[deleted] Feb 14 '19

[removed] — view removed comment

5

u/The_White_Light Feb 14 '19

Shards are the secret ingredient in the web-scale sauce.

11

u/sourcecodesurgeon Feb 13 '19

Google Sheets has a reasonably tolerable API, its free, trivial to set up, and you can easily manage the data by hand from your phone/tablet.

I've used it as a proof of concept for toy projects before and didn't think it was a terrible experience.

8

u/[deleted] Feb 13 '19

[removed] — view removed comment

2

u/BeckonedCall Feb 14 '19

That is the same way I run the discord bot I wrote to replace airhorn bot. I just leave the pi rumning 24/7 on my desk.

17

u/Superpickle18 Feb 13 '19

Google did support SQL queries for google sheets... soooooo

https://support.google.com/fusiontables/answer/2571232

5

u/blue_horse_shoe Feb 14 '19

right on, good for google.

i was using a raspberry pi to write sensor data to google sheets. i'd take extracts of the sheet and import them into a db. if this api was available then, it would've been amazing!

4

u/Superpickle18 Feb 14 '19

it's been available for years (since 2009?), my friend. It's being discontinued now.

5

u/blue_horse_shoe Feb 14 '19

daymn... well if i knew in 2012 it wouldve helped out alot

→ More replies (1)

12

u/Mehekoro Feb 14 '19

I'm new to this sub and programming and all that jazz, but I think your badges mean you know c++, c#, and Python? If you do, I was wondering which one you started with. I want to learn c++, but it's very difficult so I'm starting with Python instead. I was thinking of going to c# next and then c++. Is this a good idea?

15

u/[deleted] Feb 14 '19 edited Feb 14 '19

[removed] — view removed comment

2

u/Mehekoro Feb 14 '19

This was super helpful. Thanks for taking your time to respond to a newbie like me >:) !

2

u/g2rade Feb 14 '19

My college started us with c# when I was in first year. I find c# was a good language to start with. Once you learn the fundamentals in c# you can easily branch off and learn other languages.

We first started with making simple console applications which I found a great way to learn because you don’t need to worry about UI and stuff. You can just focus on the fundamentals and learn how to think logically.

→ More replies (1)

2

u/asdfman123 Feb 14 '19

Just learn one language for now. If your goal is to eventually get a programming job, specialize in a language that's widely used in your area.

2

u/jeffs_world Feb 14 '19

Depends what you wanna do, web? Backend? Desktop applications?

2

u/CSW806 Feb 14 '19

CS student senior year here. I think python would be a great place to start. Not much syntax to distract you so you can really learn the fundamentals of programming. Get yourself familiar with variables, if/else statements, loops, arrays, recursion and functions. Then make the switch to an object oriented programming language like Java or C++. Personally I learned Java. You will learn how similar the previous concepts are to implement in the new language with minor syntax adjustments. Now build your knowledge and learn how to create objects, use more complex data structures like linked lists for example. Once you feel comfortable at this level of programming, move to a lower level programming language like C. The biggest and hardest thing you will have to wrap your head around here are pointers. Playing around in C will make you miss a lot of the features that higher level languages have built in like memory allocation. Each language you start learning will have it's own unique quirks. Learn them, because they might allow you to do things differently, and possibly better, than other programming languages.

This is how my uni exposed me to programming. I learned python and thought I was the shit. Then I jumped over to Java and was quickly humbled. But as things stand now I'm fairly confident in my programming ability and pass my programming assignments with ease.

Lastly, never be ashamed if you find yourself googling how to do things in different languages. No one is able to write code without a few syntax errors especially if they are jumping around a lot of languages. So don't use that as a metric to grade yourself by. Also googling your problems often results in more efficient solutions and exposes you to best practices.

Hopefully this helps, this is in no way a comprehensive check list of things you should learn with each of the languages I've listed. It's just a general idea or roadmap you could try and follow. Best of luck!

→ More replies (5)