The Big Programming Thread - Page 580
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
artynko
Slovakia86 Posts
| ||
Manit0u
Poland17203 Posts
On February 08 2015 00:35 sabas123 wrote: For next semester I like a 90% chance I pick my own project. So far I only decided that I want to do something in C. any suggestions? You can do anything you want with it. If you add some Lua on top of it the world is the limit. On February 08 2015 01:05 Incognoto wrote: so i'm kind of bored and decided to dick around with some c++. careful, i'm like the noobiest person to ever enter the url to this thread i downloaded visual c++ 2010 express and started dicking around in that program. just adding integers and showing the result in a window we did a little programming in VBA at university (that's what we'll mostly due) and i decided to mess around with c++ since i have very, very basic understanding of how to write very, very basic programs my question is, what good is c++ for? could i write a program, which i would execute, and have it ask me for 3 numbers, which would then be assigned to a ax² + bx + c = 0 style equation, which the program would then solve? i'm guessing that yes, i would. i would call it "polynomialesforidiots.exe" for example what else could i do? tl;dr, what real world applications does c++ have? Are you serious now? Almost all of the games and many, many applications are written in C/C++. Most likely around 90% (if not more) of the software you're using on your computer was written in it. | ||
Incognoto
France10239 Posts
More seriously, if C++ is as powerful and widespread as you say it is, then what are the other languages for? The difference between C++ and VBA would be that VBA is run from Excel (I guess?), making it very accessible. It's also easy to work with because the language is "clear" (less sure of this). Stuff like HTML and HTML5 are for web pages, I'm guessing. What about Java? What applications does that language have? The same as C++? From what I understand, all programs work around the same principle, what really changes is the way the principles are executed (e.g. language, I can say "that dog is nice" in English and say "ce chien est gentil" in French; two languages yet the same thing is said). I digress, I suppose the real question I'm asking is what separates different languages other than the fact they're different? Applications? I guess that's one thing. Ease of use? Why would one (I read first post) be advised to learn to code in C before anything else? Consider me the curious layman, with little to no experience in this kind of stuff. | ||
Deleted User 101379
4849 Posts
On February 07 2015 11:04 Manit0u wrote: There are some basic guidelines when it comes to this stuff (assuming you're using some form of ORM). If you need a method (no matter how complex) that only needs to do stuff with a single entity (table), you can put this method in the entity class. In case of methods that need to do stuff on multiple tables/rows you can create repositories in your model (you would have say 'User' entity and you could create 'UserRepository') and put your code in there as public methods. If you need more than 5 methods per repository you should think about creating a service though. Here's a nice article on repositories: http://www.whitewashing.de/2013/03/04/doctrine_repositories.html I've moved away from repositories towards a database centric method and I can only recommend others to try out the same. Basically, every database access in my application is just a "SELECT * FROM x WHERE y=z". If I need to join multiple tables, it's always done through views, reducing it again to a single SELECT without a join. Updating is done through SQL functions/procedures, so every data update is as simple as "CALL x(y, z)" or "SELECT x(y, z)". It helped make the data models a lot simpler since I'm always working on single entities. As it turned out, it also removed the need for complex ORM, which to me was always just a lot of useless overhead anyways. Models and DTOs are created automatically from a simple database description and have practically zero overhead apart from turning the results into DTOs. These days people don't use even a tenth of the capabilities of SQL databases. No views, no triggers, no cursors, no procedures nor functions, always just queries after queries in the code, sometimes hidden behind ORM, sometimes not. It's no surprise no-sql databases are so popular these days when noone actually uses SQL databases properly anyways. As to the question of BlueRoyaL, all business logic belongs into the model. The controller takes input and passes it to the model, the model works with the data and the view displays it. The controller and the view are pretty simple, paging, sorting and filtering are all done by the model. It's possible to make an argument towards putting it into a ViewModel as the ViewModel decides which data to provide to the view, depending on whether your application uses them at all, but since only the model knows whether the results are all there is, sorting there would mean that the ViewModel would need access to all results to sort them properly. Since the model should be the only layer knowing everything about the data, it would bring the ViewModel and Model too close together. In your case if you don't get the data from a database, I would probably put it right into the model as a "SetSortOder(SomeSortOrderEnum sortOrder)" method in the respective model. The model then uses a different sorting function depending on the parameter. You can use a class implementing the IComparer interface to sort differently. The controller just passes the parameter to the model and when the view accesses the data from the model, the model returns it in the correct sort order. On February 08 2015 01:24 Incognoto wrote: I am serious, I have absolutely no knowledge whatsoever in these things. The stuff I'm studying at university has nothing to do whatsoever with programming, I'm not sure why they even gave us a couple hours on VBA. More seriously, if C++ is as powerful and widespread as you say it is, then what are the other languages for? The difference between C++ and VBA would be that VBA is run from Excel (I guess?), making it very accessible. It's also easy to work with because the language is "clear" (less sure of this). Stuff like HTML and HTML5 are for web pages, I'm guessing. What about Java? What applications does that language have? The same as C++? From what I understand, all programs work around the same principle, what really changes is the way the principles are executed (e.g. language, I can say "that dog is nice" in English and say "ce chien est gentil" in French; two languages yet the same thing is said). I digress, I suppose the real question I'm asking is what separates different languages other than the fact they're different? Applications? I guess that's one thing. Ease of use? Why would one (I read first post) be advised to learn to code in C before anything else? Consider me the curious layman, with little to no experience in this kind of stuff. What C and C++ lack is what the industry calls "Rapid Application Development". They are powerful languages that provide a great performance (if used properly), but one line in other languages can do as much as 500 lines C/C++. That is why other languages are used more. Performance and efficiency is less important than getting things done yesterday if your business depends on it. Different languages have different levels of getting things done fast in different areas. PHP can get web applications developed fast, C# gets stuff done on Windows, Java gets stuff done (slightly less rapid) cross-platform and on mobile devices, etc. It's not that other languages couldn't do it, they just don't make it as easy. You can develop GUIs in PHP, you can write web applications in C, but languages specialized for a task have an advantage when you want to get stuff done and don't care about efficiency. | ||
sabas123
Netherlands3122 Posts
On February 08 2015 01:14 Manit0u wrote: You can do anything you want with it. If you add some Lua on top of it the world is the limit. thats the problem, No idea what I should writeT_T @Morfildur isn't C++ in the same range of development speed as JAVA? good post btw. | ||
Cynry
810 Posts
On February 08 2015 02:18 sabas123 wrote: thats the problem, No idea what I should writeT_T @Morfildur isn't C++ in the same range of development speed as JAVA? good post btw. My current assignment is rendering a "wire" 3D version of a file given. Files are like this : 0 0 0 5 5 5 (there's actually a \n here) 0 0 0 5 5 5 (here too) where each value is the height of the coordinate located where the number is in the file. Now all you need is a lib that opens windows and puts pixels in them, and gl hf ! I don't know how proficient you are at programing, so I'll just say it's not as hard as it first looked to me. Think I'm at 300+ lines for the main feature, so it's nothing huge. | ||
sabas123
Netherlands3122 Posts
On February 08 2015 03:19 Cynry wrote: My current assignment is rendering a "wire" 3D version of a file given. Files are like this : 0 0 0 5 5 5 (there's actually a \n here) 0 0 0 5 5 5 (here too) where each value is the height of the coordinate located where the number is in the file. Now all you need is a lib that opens windows and puts pixels in them, and gl hf ! I don't know how proficient you are at programing, so I'll just say it's not as hard as it first looked to me. Think I'm at 300+ lines for the main feature, so it's nothing huge. so take all the values of the file, convert them into a int and use those ints as coordinates for where to display the orignal values? | ||
Cynry
810 Posts
To put it simply (I hope :D) 1 number in the original file is a point, which you have to connect in your output window to its neighbours to have the wire 3D thing. So each point have a x,y,z, x being its place on a row in the file, y its row number, and z the actual number stored. From my previous exemple, the first 5 would have x = 3 (4th on its row), y = 0 (first row), and z = 5. What you do then to get from this file to the end result is up to you, and I have seen all sorts of ways at school. Including two ways linked list with x,y,z of every single point... What I did is simply store the z value in an **int where the index to get to a point matches its x and y values. Then there's some math (easily available on the net, thank god) to draw the line connecting the points, pixel per pixel. I'm not sure about your formulation because each points still needs more than A int, but you probably had it right. | ||
sabas123
Netherlands3122 Posts
On February 08 2015 04:00 Cynry wrote: Uh maybe something like that, not sure. To put it simply (I hope :D) 1 number in the original file is a point, which you have to connect in your output window to its neighbours to have the wire 3D thing. So each point have a x,y,z, x being its place on a row in the file, y its row number, and z the actual number stored. From my previous exemple, the first 5 would have x = 3 (4th on its row), y = 0 (first row), and z = 5. What you do then to get from this file to the end result is up to you, and I have seen all sorts of ways at school. Including two ways linked list with x,y,z of every single point... What I did is simply store the z value in an **int where the index to get to a point matches its x and y values. Then there's some math (easily available on the net, thank god) to draw the line connecting the points, pixel per pixel. I'm not sure about your formulation because each points still needs more than A int, but you probably had it right. I don't understand how the first 5 can all have x 3. but the of making a graphic map based on the content of the file sounds really cool! | ||
solidbebe
Netherlands4921 Posts
![]() | ||
Cynry
810 Posts
And yeah it's cool, you get to touch different areas of programming, and your end result is not some lines on your terminal ! | ||
sabas123
Netherlands3122 Posts
but how will you be able make this 3d? | ||
Cynry
810 Posts
Big ass picture to depict end result, every junction being a number on the original file + Show Spoiler + ![]() It's basic projection math, this one being a form of isometric. It's the simpler one I believe, you get the coordinates of your points with 1 line of code, and <30 more will draw you line to join them. | ||
solidbebe
Netherlands4921 Posts
| ||
Cynry
810 Posts
| ||
Ropid
Germany3557 Posts
On February 08 2015 01:24 Incognoto wrote: I am serious, I have absolutely no knowledge whatsoever in these things. The stuff I'm studying at university has nothing to do whatsoever with programming, I'm not sure why they even gave us a couple hours on VBA. More seriously, if C++ is as powerful and widespread as you say it is, then what are the other languages for? The difference between C++ and VBA would be that VBA is run from Excel (I guess?), making it very accessible. It's also easy to work with because the language is "clear" (less sure of this). Stuff like HTML and HTML5 are for web pages, I'm guessing. What about Java? What applications does that language have? The same as C++? From what I understand, all programs work around the same principle, what really changes is the way the principles are executed (e.g. language, I can say "that dog is nice" in English and say "ce chien est gentil" in French; two languages yet the same thing is said). I digress, I suppose the real question I'm asking is what separates different languages other than the fact they're different? Applications? I guess that's one thing. Ease of use? Why would one (I read first post) be advised to learn to code in C before anything else? Consider me the curious layman, with little to no experience in this kind of stuff. What do you study? Do you do something with math? There might be some languages that might be more interesting to you, where you are thinking very differently when using them compared to what you've seen in VBA. It's absolutely not true that all languages work around the same principle. If you say what weird, theoretical stuff you see in what you study, someone might know a weird language that's related. C is interesting because every feature it has translates into at most a handful of instructions for the CPU. What will happen on the machine is very predictable. The book written by the C authors that described and defined all of the original C and its standard library is also very thin, so that's nice. Today's C++ is a massive, scary beast of a language. The code you write in it can be very high-level and very far away from what actually executes on the machine, where what it does exactly is completely hidden. At the same time, you can also write pure C in it whenever you want. There was a craze about "object-oriented programming" and hope that it will help a lot in solving problems with software-engineering. That's where Java came from (and where the original C++ came from). There's massive amounts of lines of code out there written in that style. Java is very entrenched for business software because developers can find libraries for any possible need. The language itself seems to be pretty passionately hated by a lot of people. Android uses Java. You might want to look at Python if you want to do stuff for fun. Its community has certain ideas about how things should work that might be interesting. They for example seem to think that for any problem or style question there should be a perfect way to solve or answer it, and that might help a lot to not confuse new people. | ||
nunez
Norway4003 Posts
can you give examples of c++ code that is far from what actually executes? @morfildur plenty of libs for web development in c++ afaik. can you substantiate your post with some specific examples and demonstrate with concrete code? | ||
Ropid
Germany3557 Posts
Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level. | ||
Cyx.
Canada806 Posts
On February 08 2015 06:26 Ropid wrote: I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want. Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level. @nunez: example: std::string a = "hello"; char a[] = "hello"; One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all ![]() Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time. Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev? | ||
Manit0u
Poland17203 Posts
On February 08 2015 05:30 nunez wrote: @morfildur plenty of libs for web development in c++ afaik. can you substantiate your post with some specific Plenty of libs for web development in C++, it's high performance, even entire frameworks etc. somehow don't translate into plenty of websites/web apps being written in it. As far as the web goes, the most commonly used languages are: 1. PHP - all kinds of uses, the largest number of different tools and frameworks available 2. Java EE - mostly business stuff, mainly utilised in intranets and mostly done in corporate environment 3. C# via the ASP .NET - primarily targeting the Windows market This are the biggest players with the most job offers and projects being done in them. Other major players, but not so widely used would be: 1. Python 2. Ruby 3. Scala And then, at the bottom of the pile you have the niche with the C, C++, Clojure and Haskell. The bottom line is: You can write web apps in anything you like. If you'll find a job requiring your language of choice is a different matter entirely. You see, I went with PHP for very pragmatic reasons. I'm not getting paid as much as in any of the other languages (Python and Ruby are on the same level really, others pay more) but I find comfort in the fact that if for some reason I won't like my job (bad atmosphere, bad practices, no real opportunity to improve and/or advance etc.) I can just quit and find a new one within a week. In the meanwhile I'm learning C# and other languages in my free time, so that I can have more options in the future (and because I like programming and learning it is fun for me). Who knows? Maybe one day I'll tire of PHP entirely and apply for a very well paid job in Scala? I'll probably even have advantage because of all the experience I get thanks to the ability of switching and testing out new environments and work paradigms, which I wouldn't have if I went with any of the other languages. | ||
| ||