[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 312
Thread images: 33

File: K&R himegoto waifux2.png (1MB, 1000x1400px) Image search: [Google]
K&R himegoto waifux2.png
1MB, 1000x1400px
old thread: >>56176367

Return of the Hime edition!
What are you working on, /g/?
>>
First for Python is not an actual programming language
>>
>>56183488
what is then?
>>
Hi /dpt/
I'm a CS student/c++ programming, looking to try my hand at web development. I want to make a personal website.
My question: Where is the best place to buy a domain? Does it matter?
>>
>>56183583
I would look into a registrar that protects your WHOIS information, because if you're not careful, they'll put your name and home address on your WHOIS registration.

Also, if you're serious about hosting a website, I would highly suggest you get a PO Box.
>>
>>56183476
>>56183522
Actually, you need more than types. If you want to prove something about anything, you need to know about value.
>>
>>56183605
Meh, technically he can put false information in the WHOIS info. They say it's "illegal" but I've never had any issues with that during all these years that I've owned domains.
>>
>>56183640
It depends on the domain country.

Some will revoke your registration if you put blatantly false information.
>>
>>56183520
Scripting language.

Real Time Interpretation vs. Compiling.

HTML (That's not a programming language, it's a markup)
Javascript (No Anon, that's scripting)
C++/Java (hotter)
C (hotter)
Assembly (damn hot)
100010101011010100 (Now we are talking)
>>
>>56183605
Thanks for that info, it seems as though google domains has privacy settings to prevent that info from being public.
>>
File: 01-2017-ford-gt-chicago.jpg (71KB, 800x450px) Image search: [Google]
01-2017-ford-gt-chicago.jpg
71KB, 800x450px
>>56183463
and this samefagging trap poster whines hard when someone posts a thread early, kill yourself fag
>>
File: n-no_homo15.png (275KB, 844x404px) Image search: [Google]
n-no_homo15.png
275KB, 844x404px
>>56183463
>still no doujin where Hime gets his boypussy ravaged
>>
>>56183736
you can use pretty much any host, just whois other domains and if the owner's name is more or less obfuscated you should be fine, or contact the host and ask them directly, some hosts offer privacy protection as a separate service so make sure you pick that option in that case
>>
>>56183463
can we honestly keep the image to be this or the orignal
I hate it when the dpt image is something retarded like a naruto character
thanks
>>
>>56184078
the original is fine, the forced trapshit is not, even umaru is fine by me because of how desensitized i've become from this trap faggotry
>>
I started learning python as my first language. Even though I don't know a lot about programming, the further I go the more retarded this language seems.
Should I just take the plunge and start learning C instead?
>>
>>56184188
imo start with java and then learn C++, and then C if you want
>>
>>56183698
>Scripting language.
>Real Time Interpretation vs. Compiling.
the javascript V8 compiler compiles to machine code, you fail at life, give up now
>>
>>56184204 (Me)
but all of these languages including C are far better than python
>>
>>56183583
And on a related note, any recommendations for a free or cheap web hosting service?
Sorry, just really new to this.
>>
>>56184204
>java
>C++
>>
>>56184248
nice meme
>>
>>56184204
>>56184217
there is no reason to learn C++ anymore, its just a meme that gets shilled by programmers who wasted their career being 'expert' in a inherently broken language. Just learn C and move on to more advanced languages like Rust or Go
>>
How does Python pass-by-reference even work?

I have a function which does something (not really important what) and I decided to try and speed it up by passing a pre-calculated lookup table (a very large dict) to it.

The thing is I haven't done anything with the dict inside the body of the function yet. I just added it to the list of arguments and pass it to the function when I call it, but the function is otherwise unchanged and doesn't touch the dict.

Yet now the function took a huge hit to performance and now takes 30% longer to complete. If I remove the dict from the arguments it goes back to the normal speed.

What gives? Shouldn't the dict by passed by reference and have barely any impact on performance?
>>
Dry erase markers make my head dizzy
>>
File: 1411869960086.jpg (48KB, 300x300px) Image search: [Google]
1411869960086.jpg
48KB, 300x300px
>>56184267
>more advanced languages like Rust or Go
>>
>>56184284
don't sniff or huff anything it's ridiculously bad for your health
>>
>>56184273
>Python
there's your problem
>>
>>56184318
im not, im just writing with it and the smell is unbearable
>>
>>56184330
try some other brand the next time you buy markers
>>
>>56184273
Nothing is passed by reference. Just make it a global variable or close it.
>>
>>56184273
>If I remove the dict from the arguments it goes back to the normal speed.
By this I meant both removing the argument entirely and passing None instead of the dict. Both have the same effect of speeding the function back up.

>>56184328
Well even if it is I'd like to understand it.
>>
What's a good SQL/database design book? I know the basics (CRUD SQL statements and stuff) but want to go a little more intermediate.
>>
>>56184273
Try turning off garbage collection, the GC sometimes shits itself when really big objects get allocated and passed around.
>>
File: cat paws.gif (494KB, 320x187px) Image search: [Google]
cat paws.gif
494KB, 320x187px
I need an ascii to string converter.
>>
>>56183583
you're getting bad advice here

you should use [your username].github.io or heroku for their free webhosting since your website is either going to be for displaying your resume (in which case being linked to your github is a good thing) or for learning (in which case heroku and github provide it for free to you since nobody is going to see it anyways)

I really like heroku btw I use it for my web crawlers all the time. Github is easier though for obvious reasons
>>
>>56184109
You seem to be awfully sensitive to trap posting.
>>
>>56184410
>Nothing is passed by reference.
Explain.

>Just make it a global variable or close it.
It's in a separate module from where I'm calling it at the moment.

How do I "close" a dict?

>>56184458
I'll try that, thanks.
>>
>>56184534
I need one of those too, but for hexadecimals and in python
>>
>>56184534
>ascii to string converter
What?
>>
>>56184534
?
>>
>>56184552
you seem to be awfully sensitive to car posting
>>
>>56184410
Everything is kind of passed by reference, though it'll only look like it's passed by reference if its mutable object.

>>56184273
I have no idea what the issue is though. The parameter should have the same address value as what you passed in. I'd assume the issue is that even if you don't use the entire dict is getting evaluated or something. Is this like 30% of a second or 30% of a microsecond?
>>
>>56184566
>>56184569
>>56184574
This:

Ā̂Ԅ

Has to be something like this:

"012345"

I can't convert to int because then the value wouldn't be correct as above.
>>
File: 0e9.jpg (27KB, 600x600px) Image search: [Google]
0e9.jpg
27KB, 600x600px
>mfw just did hello world in python 3 without calling any functions
>>
File: a.gif (2MB, 496x296px) Image search: [Google]
a.gif
2MB, 496x296px
>>56184534
k
>>
>>56184620

Nice.
>>
>>56184595
>Is this like 30% of a second or 30% of a microsecond?

It's ~15 seconds becoming ~20.

tl;dr I'm translating several gigs of data between coordinate systems.
>>
>>56184620
so you mapped each range of similar colors to a letter? And calculated the average color for each grid of pixels like how reverse image searching does

>>56184607
you want to convert chars to their decimal counterparts, is that correct? Most languages do that
>>
>>56184607
itoa?
>>
>>56184657
do it in C/C++ if you care about performance
>>
>>56184657
>several gigs of data
python has trouble with dealing with more than 40 mbs loaded into memory at a time in my experience, you're using the wrong language for this project
>>
>>56184706
I care about learning what's causing weird spooky unexpected behaviour.

The five seconds aren't particularly critical, I just want to figure out what's crapping out which might be helpful in the future.
>>
>>56184706
>C/C++
Why are you grouping two completely different languages together?
>>
>>56184620
>running conversion on each frame
>no temporal coherence

Looks like shit
>>
>>56184545
Hm. Thanks.
I'll look into this too.
I haven't really utilized git yet for some strange reason, so this gives me an excuse to do both.
>>
>>56184733
>you're using the wrong language for this project
The thing I'm doing is a rewrite of a Perl script by someone else in the first place.

I banged it out over a week and it's three orders of magnitude faster than the original even though it's in Python. The equivalent of the 15s/20s function in question literally takes 20 minutes in the Perl version.

I'm mostly a C programmer but this was way faster to implement and also because Python parsers for the data already existed.
>>
>>56184801
because some people prefer one over the other but both are much better suited for the task than python, fucking autist
>>
>>56184801
C++ is fully backwards compatible with C and everything about C++ is designed to maintain that compatibility
>>
>tfw learned basic programming principles when I was 16
>made a couple of crappy programs that were functional, but text-based
>now 19
>want to get into programming again to prep for university

In technology times are ever changing. Back when I was 16 the language I learned was C++. What should I use to re-learn/pick it up again?

Also I need something to program.
>>
File: 1458546951680.jpg (47KB, 474x479px) Image search: [Google]
1458546951680.jpg
47KB, 474x479px
>>56184861
(You)
>>
File: file.png (89KB, 1355x602px) Image search: [Google]
file.png
89KB, 1355x602px
gui programming feels REALLY painstaking

should I just be using visual basic or something? Dragging and dropping would save me hours
>>
>>56183698

Scripting languages are programming languages.
>>
>>56184846
this is one reason why C++ and java is a better stack than C and python, you don't want to the extra work of C so you go full retard with python, meanwhile C++ would be less work than C and java would be comparable in effort to python but much better in performance
>>
>>56184846
>The equivalent of the 15s/20s function in question literally takes 20 minutes in the Perl versio
how

I mean Perl is shit but not that shit
>>
>>56184918
Suppose you went back to Ada Lovelace and asked her the difference between a script and a program. She'd probably look at you funny, then say something like: Well, a script is what you give the actors, but a program is what you give the audience. That Ada was one sharp lady...
>>
>>56184890
https://www.youtube.com/watch?v=Gse-uR-VdIg
https://www.youtube.com/watch?v=TD_OsdVTi3I
>>
>>56184914

>Visual Basic
Please consider C# before you consider Visual Basic. You can do drag and drop with WinForms or WPF.
>>
>>56184935
The programmer apparently had no idea how to process the data in the format it was in so his script converts all the data to another format using an external module, processes that (and not very efficiently), then converts it back to the original format.
>>
File: download.jpg (4KB, 259x194px) Image search: [Google]
download.jpg
4KB, 259x194px
>>56184611
How?
>>
>>56184952
kill yourself isac
>>
>>56184935
>how

Incompetence is the traditional answer.
>>
I am refactoring an intern's shitty javascript code and they did every possible wrong thing that can be done wrong.

>single-line conditionals like this: if (stuff) do stuff
>missing semicolons on some lines
>inconsistent spacing between all syntax elements-- missing spaces between parentheses, brackets, declarations, even around fucking operands
>a for loop containing an if conditional with its code, all on the same fucking line
>code copied between scripts that has not even been refactored to do that it's actually meant to do
>many many strings hardcoded separately even though most of their text is similar
>concatenated strings without spaces to separate the words
>if conditionals that always return true or false

How can people who code like this sleep at night? Fucking CS degrees are really a meme.
>>
>>56185083
*laziness
>>
>>56185091

That, too. Why do something the correct way when you can do it with some poorly-designed hack?
>>
>>56185089
also their if blocks are opened like this
>if (condition){

Not only is the opening brace on the same line it doesn't even have a space before it. This really triggers my OCD.
>>
File: ccxcxc.png (593KB, 1577x797px) Image search: [Google]
ccxcxc.png
593KB, 1577x797px
http://www.fujitv.co.jp/b_hp/dragonball_super/index.html

why can';t i download the Flash video from this site?

http://www.fujitv.co.jp/b_hp/dragonball_super/index.html
>>
Got Mono-D setup on Monodevelop
Just wish the run button didn't default to running in debug mode
>>
>>56184997
in some ways this is better, it validates the formatting automatically

>>56185099
no mate the question is why waste a ton of time writing your own interpreter for some dataset when you can just convert it to another format you have ready-made tools in and then back again and be done much quicker?
>>
>>56185112
gee i wonder
also fuck off to stupid questions thread
>>
>>56184937

While Ada Lovelace is considered to be the first computer programmer, if you asked her anything about "computer programs," she might be confused. The term "program" was not applied to computers until the 1940s. And yes, even the earliest "scripting" language -- Lisp -- was referred to as a programming language when it was first created.
>>
>>56185124
>in some ways this is better, it validates the formatting automatically

The things is the formats aren't equivalent, they aren't even used for the same thing normally. After the conversion he still keeps both data structures in the memory and cross-references them in the processing because the second format doesn't contain all the needed data for the processing.

The two format conversions are probably behind the bugs which caused me to rewrite the thing in the first place.
>>
>>56184561
>How do I "close" a dict?
Like make a closure around the dict, so it isn't polluting your global namespace.

>>56184561
>>Nothing is passed by reference.
>Explain.
I was under the impression that Python data structures were copied across all function calls. I've been able to write data-driven decision tree problems in Python without having to explicitly copy the data structures, so I assumed each function got an immutable copy of the data structure. Maybe I'm wrong.
>>
>>56185184
>so I assumed each function got an immutable copy
a *mutable* copy
>>
>>56185132
hence why she'd be talking about scripts and programs in the context of a theater, but it's still a fitting analogy
>>
>>56184937
>>56185132
>>56185209
Ada Lovelace was not a programmer. Stop spreading this misinformation and propoganda.
>>
>>56185240
Was Marie Curie a physicist?
>>
https://www.youtube.com/watch?v=JEpsKnWZrJ8

GOAT
>>
>>56185263
she was just one of the first people to have the opportunity to play around with radioactive stuff
>>
>>56185209
Not really a completely fitting analogy, considering that the script is also a program.
>>
File: tyms.png (25KB, 964x527px) Image search: [Google]
tyms.png
25KB, 964x527px
Is there a way to get clean header files for the C standard library that aren't filled with awful compiler macro hell preprocessor defines and such? I just want nice autocompletion. Pic related, I can't deal with this shit
>>
>>56185184
>>56184273
Okay I still don't know what's happening, but subsequent calls to the function run at the expected speed.

As in, if I call it without the dict it always takes 15 seconds to complete.

If I call it with the dict it takes 20 seconds the first time and 15 seconds every time after that.
>>
>>56185379
(which is a bummer since I normally only run it once)
>>
File: png.jpg (306KB, 1000x667px) Image search: [Google]
png.jpg
306KB, 1000x667px
It says here that you haven't contributed to any FOSS projects... ever. Can you elaborate a bit on that?
>>
>>56185408
FOSS is for neckbeards
>>
>>56185408
I strongly believe in proprietary code.
>>
File: Fellowes73-Shredding-Gif.gif (2MB, 600x338px) Image search: [Google]
Fellowes73-Shredding-Gif.gif
2MB, 600x338px
>>56185419
Mhmm... OK, jeesh. You can expect to hear back from us in the next, uh, week.
>>
File: osversion_fail.png (50KB, 732x437px) Image search: [Google]
osversion_fail.png
50KB, 732x437px
Testing out some free-as-in-freedom (MIT licensed) Microsoft Powershell on Linux...

It's in a VERY early alpha. It doesn't even know it's on Linux. It must be a very confused and somewhat panicked program.
>>
>>56185379
Okay, now for some proper weird shit.

The function uses multiprocessing.Pool.

If I use a single process for that, every function call takes the same time.

If I use more than one process, the first function call is slower and the rest run at normal speed.

Does Pool mess with memory?
>>
>>56185379
If it faster the first time, are you sure the dict is fully evaluated when you pass it into the function? The extra time could be the evaluation of a partially evaluated structure. Python doesn't pass-by-value, it's 'pass-by-assignment'. I guess we would have to see your function to tell you exactly.
>>
i embedde wget to download a url document from my code
what do you guys use to do it?
>>
>>56185513
Plain TCP socket, HTTP download is easy as balls.
>>
>>56184267
>he shills a language with garbage collection
>>
File: 1331289772708.gif (2MB, 768x432px) Image search: [Google]
1331289772708.gif
2MB, 768x432px
>>56185089
>missing semicolons on some lines
At least they managed to put *some* semicolons rather than none at all like another place I worked at!
>>
File: 1434495982649.jpg (280KB, 700x849px) Image search: [Google]
1434495982649.jpg
280KB, 700x849px
Have you read your SICP today, /dpt/? Be honest.
>>
>>56185684
No but i've read my sipser and wrote a quine in C
>>
how do you guys understand math (actual calculus 2+ math, mind) the best? I've been thinking of trying to implement the derivations and everything in different programs, good idea or no? It's obviously possible but has anyone else had success with a technique like that?
>>
>>56185528

Or you could just use libcurl and save yourself the trouble...
>>
>>56185617
benchmarks prove you have little to nothing to gain for manually managing memory
>>
>>56185635
He also wrote some if statements that have a lot of conditions like this:
if (first condition)
if (second condition)
if (third condition)
if (fourth condition)
if (fifth condition)
do stuff
>>
So people here absolutely love Haskell, e.g because of its "strong type system" as far as i have heard?
>>
>>56185962
if there are really any elses or the order matters for those conditionals there's really not a better way to do that you know
>>
>>56185977
Nope, it's really just that all these conditions must be met. Using &&'s would have had the same results, just not indented beyond the right edge of the screen.
>>
File: ibm.jpg (376KB, 1920x1200px) Image search: [Google]
ibm.jpg
376KB, 1920x1200px
https://discord.gg/A46b9
Hey guys I made a discord really wish some coders would join very lonely here
>>
>>56185977
>order matters
>what is short-circuit evaluation
>>
>>56185307

If only there were some utility whose sole purpose was evaluating C preprocessor macros... Oh wait there is, it's called the C preprocessor. Just run the file through gcc -E.
>>
Is it okay to read multiple books about C? Or is it a "you have read one, you have read them all" kind of thing? Currently reading Kochan's C programming book. I was thinking on reading "Programming in C" afterwards. Is it worth it?
>>
>>56186053
>implying gcc can parse these awful windows headers
>>
>>56186047
Do javascript evaluators do short-circuit evaluation?

They can somehow make the difference between two separate commands not separated by a semicolon and one command spanning over several lines so I figure they're somewhat sophisticated.
>>
>>56185957
What about GC pauses in real-time applications?
>>
>>56186106
Yes.
>>
Which is exactly the difference between python and C(besides the allocating memory part). What can python do that C can't, and vice versa. Same question, but with C and C++.
>>
why do I hate to program shit so fucking much?
I feel like literally everything has been done already, that there is no need for me to do anything. also, when I'm doing shit, it bothers me that it doesn't work as it's supposed to work, it makes me rage, having to waste hours and hours in some stupid thing.
programming feels like working with blackboxes, and who the fuck wants to develop something they know nothing about? at least some stuff is open-source...
worse yet, no one ever thanks you, you don't even see the people using your shit, you can't see anything concrete.
plus, I feel insecure about my own capabilities, and, hell, even when I was good at algebra in uni, I've forgotten practically everything...
even when I DO see how computing in general is very useful, I feel like it's a big scam. I mean, everything, EVERYTHING in IT has its quirks, it sucks, it's stressing, people literally go crazy because everything fucking sucks.
also, literally memes. lots of meme languages, frameworks, people... and fucking egocentric people.
/rant
>>
>>56186107
thats an extreme edge case where you would probably build a custom scheduler in assembly and run your program on top of that
>>
>>56186086
Beginning C books? No, read one and you're good. But there are tons of books out there for more advanced uses of C, modern idioms, optimization, etc.

>>56186053
alias unfuck='gcc -E -o /dev/stdout $1 | astyle --style=allman > $2'
>>
>>56186177
Or just don't use a garbage collector? MMM doesn't have to be unsafe or inconvenient.
>>
>>56186124
You can write programs that aren't complete dogshit in C. Retards can write programs in Python. Those are the big differences I guess.
>>
>>56186124
>What can python do that C can't
Ultimately, not a whole lot. But the stuff you need for business logic is so much more convenient, and the libraries and tooling are so high quality.

C gives you a couple important tools:
- You can directly manipulate the contents of memory by fucking around with pointer arithmetic.
- The compiler can make your code run very fast. Maybe even faster than you want it to.

C is not the only language that gives you these tools. It's just ludicrously popular and available on every computing platform that has ever existed. It's actually so prolific it puts Python to shame. That's the real power of C.
>>
>>56186212
>MMM doesn't have to be unsafe or inconvenient.
the complexity of MMM grows with the complexity of the program, the amount of cruft you have to add to a program to do MMM starts to outweigh any benefits of MMM very rapidly
>>
2 strong cups of coffee and i still haven't woken up yet or started programming. i swear it doesn't pay off in the long run to drink too much coffee. gonna go for a hot pocket and another cup tho
>>
>>56186190
Oh cool, I didn't want to go through the same thing over and over again. If you don't mid, would recommend me some more advanced "C', or programming books that you consider are a "must read". Thanks in advance.
>>
>>56186237
Cruft? Like what?
>>
>>56186235
Your post wasn't helpful.
>>
>>56186251
"""smart""" pointers, bounds checking, ARC, whatever else are current bullshit you have to add to your code to check if memory is still in use
>>
>>56186235
>The compiler can make your code run very fast. Maybe even faster than you need it to.
FTFY

you almost never want your code to be slow on purpose except maybe if you're on a microcontroller and wasting cycles is your means of timing
>>
>>56186233
>>56186235
Oh, so from I get from this is that C is a bit better/complex than python. So learning python will be a cake walk after I master C? And why does python pay better? I know it's popular because its easy, but python is one of the best paids programming languages. Is python the "Pop", or "harem genre" of programming languages?
>>
>>56186246
>I swear it doesn't pay off in the long run to drink too much coffee
yes, you develop tolerance (and an addiction) to caffeine after long enough

Last semester when I finished I was shocked that I got blistering headaches while staying perfectly hydrated. Turns out I was going through caffeine withdrawl, lmao
At least I passed though

everything in moderation
>>
>>56186250
>>56186190
>>56186086
Speaking of C books, anybody have any experience with this book? It's the required textbook for my class in September.
>>
>>56186291
Nice book.
>>
>>56186275
ARC is a kind of smart pointer (it's the same as shared_ptr - atomic reference counting). Smart pointers are more than that, though. Unique pointers have no overhead, they just express the intent of unique ownership.

>bounds checking
You don't know shit.

MMM the right way is all about expressing ownership. To yourself, always, but if you can express it to the compiler, the compiler can help you by automatically doing copies and frees, raising an error if you fuck up, etc. GC is throwing up your hands and saying that you have no fucking idea what owns what, even though keeping track of ownership still really important for more than just preventing memory errors and leaks. You probably think about most of the things you need to do MMM already.
>>
>>56186124
C became popular because personal computers had very primitive operating systems that were not much more than program loaders that allowed the program to take over the entire computer and control hardware directly. This requires a programming language that is very austere so as to be easy to port and allow any kind of types to be manipulated. C has extremely weak typing almost to the point of being typeless. C++ was created to give high level OO constructs to C without breaking any of C's extreme permissiveness as far as types or memory allocation. This is why C++ has to rely on templates to add more features to C++ because the core of C++ has to maintain closeness to C's typelessness
>>
>>56186282
It's really versatile, it can be used for websites as well as scientific computing, and there are lots of bindings which are written in C/C++ for useful things like OpenCV. The thing is, it's slow when you're not using bindings and you can't do anything that requires good memory layout/usage because there's no static typing. There's like 4(?) primitives and their sizes could be anything.
>>
>>56186282
>Is python the "Pop", or "harem genre" of programming languages?
That's a funny way of putting it. I mean funny like a comedian. I laughed.

Personally I'd say C is harem and Python is slice of life. C is trashy, but it pays the bills and it can be exciting at times. Python is comfy and pleasant, and reliably high quality.

Python jobs pay well because you're getting hired by people who don't fall for buzzwords and want their programs to actually work. Google uses it. Lots of places use it. It's not a bad investment.

C is the language chosen by people who don't fucking know any better. It's also the language chosen by serious and desperate professionals working in very constrained environments. There are high-paying C jobs as well as low-paying C jobs. There's so much C happening that it's not a reliable indicator in the slightest of what the work itself will be like.
>>
>>56186314
>MMM the right way is all about expressing ownership. To yourself, always, but if you can express it to the compiler,
>expressing ownership
>express it to the compiler
>typical bullshit C++ 'experts' spout
>>
>>56186344
Feel free to point out what you disagree with and maybe even a reason why.
>>
>>56186353
there is nothing to disagree, you are using fluffy words like 'express to the compiler' to cover for all the cheap hacks you have to do to manage memory
>>
>>56186291
>>56186306
Goddamnit, I'm an idiot.
>>
>>56186344
That poster's rhetoric matches more of a Rust user, maybe you'd like to rephrase whatever argument you just gave?
>>
>>56186282
>Oh, so from I get from this is that C is a bit better/complex than python.
No, not really. Mostly, C is a good fit for a very different class of software than python. C is great for writing system software, like operating systems, or device drivers, many server software, or the software that runs your washing machine. Python is very nice for many times of application software, web applications, and many other types of software that are closer to the surface of everyday computing -- software you interact with directly.

>So learning python will be a cake walk after I master C?
Yes. C IS a harder to use and learn system than python.

>And why does python pay better?
I don't think it does. But python is easier to find work in, because there is so much more application software than device drivers.

>Is python the "Pop", or "harem genre" of programming languages?
One of them, yes. There are others that also fit this category.
>>
>>56186364
I'd take cheap hacks over an expensive hack like GC any day.
>>
>>56186371
I'm really more of a substructural type theory guy in general. Rust takes a lot from it, so yeah, I like Rust, too.
>>
>>56186328
>>56186342
>>56186372
Thanks for the explanation guys, now I have a better understanding on the subject. Who knew comparing programming languages with anime would make things a bit clearer.
>>
>>56185132
>lisp
>scripting language
It was running entire machines back in the day. Nor is it really interpreted, it is JIT compiled and that's when macros are implemented.
>>
File: logic_gates.webm (650KB, 948x519px) Image search: [Google]
logic_gates.webm
650KB, 948x519px
What would a multi-player game look like in C#?

I have done it with Web API and most of the rendering done in browser before.

>javascript canvas
>inputs detected by browser
>inputs sent to server via $http
>response updates each player on other player's positions

But how would this happen WITHOUT a browser? I don't even know where to start. What type of project? What to draw in? How to connect the players?

Gimme SOMETHING.
>>
>>56186484
Monogame & Lidgren
>>
>>56186484
disgusting
>>
why do fags ITT reply "Go has a GC", almost immediately, when Go is mentioned, but (almost?) no one says the same about C# (or, for that matter, java)?
>>
>>56186561
Because Go is often promoted as a replacement for C while C# is just a retarded Java.
And nobody here promotes Java.
>>
>>56186502

What if I want to write it from scratch?

>>56186513

Why, you want me to do it in C++ and manage memory by hand?
>>
I need to brush up my math skills. I know that you can be a programmer without "really" learning math, but I don't buy it. I feel like math will help me think more logically, and I don't wanna be pajeet tier. So besides linear algebra, and calculus(?). Which other math subjects are worth learning/mastering in order to become a better programmer?
>>
>>56186579
Type theory.
>>
>When a sizable portion of your friends who are not exactly programmer types mention that they've been "meaning to learn how to program"

Why is this a thing?
>>
>>56186574
>What if I want to write it from scratch?
use opengl

>Why, you want me to do it in C++ and manage memory by hand?
if you want to write a game from scratch you might as well
>>
>>56186579
trigonometry if you wanna learn to draw shapes programatically
>>
>>56186600
They bought into the meme
just ignore them, they'll forget about it by next month
>>
>>56186570
ah, right

>>56186600
they want you to teach them, of course
>>
>>56186603
OpenGL is high-level and abstract as fuck.
>>
>>56186561
Because the idea that "GC is bad" is a meme and if there's one thing the chucklefucks here love, it's memes.
>>
>>56186587
Aight, thanks anon. I found this pdf online called "Type Theory & Functional Programming", by Simmon Thompson. Looks interesting, I will put it on my to read list.
>>
>>56186608
AIght, then I gotta retouch my trigonometry.I haven't practiced it in ages. I will practice it along with calculus, because they "more or less" go in hand for some parts. Thanks for the response.
>>
>>56186639
it's about as close to "from scratch" you can get for making a decent game, you could use vulkan but it'd be silly to learn vulkan the first thing you do when you're coming from fucking web dev
>>
>>56186603

>use opengl

Is it going to be faster than just drawing shit every frame (with whatever the default in-built draw shit is, I forgot - the "pen" crap)?

>if you want to write a game from scratch you might as well

I guess

>>56186608

I can confirm this from making shit 2d games before.

>tfw doing shadows / shadow crossovers on circular / irregular objects

Also had to remember physics for collisions.
>>
how many lines per class again? I'm having trouble figuring out where I stopped when I switch tabs back
>>
How do you manage guys manage reading a bunch of books? Should I start one and finish it? Or should I assign days to read one book at a time? I have so many books in my backlog that I think will be hard to keep up lol.
>>
>>56186282
>So learning python will be a cake walk after I master C?
Maybe but you won't be a GOOD Python programmer straight away.
If you write Python like C, you will get mediocre programs.
>>
>>56186642
functional programming is very tied to logic, you are better off reading "The Haskell Road to Logic, Maths and Programming"
>>
Are Haskell programmers TOO smart to be employed? What a tragedy.
>>
>>56186708
If you think autism = intelligence, sure.
>>
>>56186686
Oh, I see. So they have different mindsets/approaches. Didn't think about that. So can that be said about EVERY programming language? Example: You can't write a Java program like a C, etc. It might be obvious, but I never thought about it that way. Thanks anon, I learned many interesting things tonight, including your advice.
>>
>>56184214
No, that's called JIT compilation.
It's not quite the same as normal compilation.
>>
>>56186662
>Is it going to be faster
yes, by using opengl directly you're taking advantage of the gpu about as efficiently as possible. it's faster and more versatile than using opengl indirectly through libraries and it's a fuckton faster than software rendering
>>
>>56186696
Oh cool, one question tho. I have seen some "Haskell memers" lately, REALLY pushing Haskell. Example: >>56186708
So is your advice genuine, or am I getting memed on? Legit curious. Either, I will definitely check out that book, it looks interesting.
>>
>>56186735
Yes that applies to many languages.
It's not just about the vocabulary and grammar so to speak
>>
>>>56185648
>hey man do you have a quick reference book or good video set for understanding registers? I am trying to migrate from python to C++ and would like to understand the Windows/regular OS.

I'd recommend something on assembly if you want to know how registers are used. Kip Irvine's books are good and are available for download if you're cool with piracy. Kip Irvine's book on Intel Microprocessors, I forget the exact name, was what we used in my EE degree program. Now I think he has something called assembly for x86 processors. It looks pretty similar.

The short version:
Registers are memory that a cpu has direct access to. In order to do an operatioin like an integer addition you need both variables loaded in to a register. So you do a MOV instruction to move those variables from RAM in to a register and then use ADD with those two. I think ADD overwrites one of the registers with the result. It's been a while since I've messed with it. Then you want to MOV the result to ram to save if you need that register for something else.

Luckily there's cache. Your processor looks ahead in the instructions to predict what memory you're going to need before it. All of this happens transparent but just know you're not usually going to pay the full time penalty because you have to access memory. If you're handling more data "at once" than you have registers you get register pressure. Which means you pay a small penalty for accessing cache. If you handle more data at once than you have L1 cache you pay a penalty for L2 cache and on it goes as you start requiring more memory.

You can learn C++ without understanding this. I wouldn't wait to understand assembly before learning C++. When you want to think about improving performance a general idea of what instructions are available and how long they take is valuable. Leave the nitty gritty to the compiler.
>>
>>56186741

Ok, thanks.
>>
>>56186754
whenever someone on /g/ calls a programming language a meme thats code for 'Im a dumbfuck who cant learn new things and am afraid I will lose my job using an obsolete language so Im going to call everything new a meme'
>>
>>56186823
Nice memepost.
>>
>>56186574

If you stick to RAII and the STL, you won't have to manage a ton of memory by hand in C++. You just need to keep note of when things are coming into and leaving scope.

That said, for C#, you have a few options. Easy mode is just using a pre-packaged game engine like Unity or Monogame. Otherwise... try using a .NET wrapper for SFML or SDL.
>>
For some reason my FIFO pipe is waiting for something to be written to it before fopen runs, but if nothing has been written i want runtime to continue as normal

it just pauses itself on fopen and i have no idea why
>>
>>56186836

Ty also.
>>
>>56186708
Thanks for posting this again
>>
>>56186600

It's part of the "everybody should program xD" maymay.
>>
File: josta.jpg (111KB, 620x400px) Image search: [Google]
josta.jpg
111KB, 620x400px
anyone use MIT's AppInventor2?
how complex of an app can one create using it?
comparable to a full language like Java for writing android apps?
>>
I'm making a game using Blender's Game Engine, multi-platform in itself as I can effortlessly export the game to Windows, Linux, or Mac.

I want to make a launcher for this game that allows you to change settings before the game starts up. What's the best programming language and framework that I could use for a simple GUI that can be ported to Windows, Linux, and Mac with minimal effort?
>>
>>56186246
That's why you do actual stimulants like amph and derivatives.
>>
>>56187180
>comparable to a full language like Java for writing android apps?

Obviously not, and the whole drag/drop thing for the logic side of things is probably tiresome.
>>
I have made F# and Powershell talk to each other on Linux. I am not sure why.
>>
File: haskelel.jpg (99KB, 529x598px) Image search: [Google]
haskelel.jpg
99KB, 529x598px
>>56186754
some people in /dpt/ unironically use haskell but it's shit

http://www.strawpoll.me/10985214
>>
>>56187398
>I am not sure why.

For fun.
>>
>>56187398
>F#
You fell for the meme
>>
Can someone explain to me what a delegate is I've been trying to warp my around it for an hour with no luck.
>>
>>56187286
QT seems to be the most popular choice for cross platform.
>>
>>56187499
java is universal
>>
>>56187493
What's the context?
>>
>>56187493
do you know what a closure is?
It's basically a retarded abortion masquerading as a closure.
>>
>>56187515
That would require using java. I think anon wants to have fun making his game.
>>
>>56187286
>Blender's Game Engine
not even aggy daggy uses it
>>
>>56187533
Not sure what you mean by context, but the language is C#
>>56187539
I have no idea what a closure is.
>>
>>56187449

Nah, I don't even know much of any F#. I just felt like fucking around with Powershell and testing reflection shit. I also had it talking with some C# 6 stuff. Reason for all of this experimenting (aside from fun shit) is this: getting a C# program running with the CoreCLR is kind of awkward, and Mono is a bit slower than the CoreCLR. Powershell, however, runs on the CLR already, and loading an assembly through a DLL in Powershell could be a bit easier. I could literally just do this:

#!/usr/bin/powershell

add-type -path Program.dll
[Program]::Main()
>>
>>56187579
A closure is a function that captures information, e.g.
(C++)

int x = 5;
auto function = [&x](int y) { x += y; };
// x is captured by "function"

function(3); // x += 3

If it's C# a delegate is probably just a closure
>>
>>56187556
java's not that bad. and it can be fun. yeah steep learning curve esp for beginners, but very useful when one knows what they are doing.
>>
>>56187591
>falling for the C# meme
did someone make a virus that only infects tripcodes?
>>
>>56187594
I fail to see the use of something so obtuse.
>>
>>56187610

button.onClick([&counter](){ ++counter; });
>>
>>56182022
>This is entirely a myth brought about by old self taught programmers who are too stupid to realize that the code they write in any high level language never touches registers.
This isn't even a myth the collective of CS Phd's teaches people. Not even them are this bad.

But it makes me question the insight of people knowing about registers. Like, I tend to assume a certain standard based on what terminology is used. But apparently there's some place that's so poor at teaching they can't explain a very basic CPU architecture.

Do you guys fathom how crappy that is? That standard is EXTREMELY low. Even a rudimentary explanation of a Turing machine would have you understand it operates on memory. That's all computers do.
>>
http://www.tutorialspoint.com/csharp/csharp_delegates.htm

It's a goddamn callback function. It may close over some additional state information, like your class' static members. Fucking Google shit first, Anon.
>>
>>56187180
i think every language (well, every IDE for every language) should have a drag&drop like app inventor has (i think MIT is using someone else's tech called blockly?). it should be an option imho.
>>
>>700454004 mentions a game to learn to use linux.
are there any games to learn coding (other than shitty ass 'hour of code')?
>>
>>56183583
Get the github student dev. pack. 1 free domain from Namecheap (I used them a couple times. They're good.) and $50 hosting credits for Digital Ocean (Web hosting). Though I hear that AWS free is better.
>>
>>56187693
>coding

programming isn't a game anon
>>
>>56187708
sure it is.
>>
>>56187621
that is kind of useful, thanks.
>>56187649
I stated earlier that I've been at it for an hour.
>>
>>56187649
https://www.youtube.com/watch?v=xkZPs2K8_e8
>>
>>56187728
do you think any of us do this for fun?
the world would literally collapse without us
>>
>>56187693
just read a book on programming for a language you're interested in.
>>
>>56187578
Blender has a steep learning curve, it will make you want to rip your hair out because basic things are difficult to do and you have to memorize all of the keyboard shortcuts to adequately control it. I don't blame anybody for not wanting to bother with it.

I've been working with Blender for years at this point, so it's usable for me.
>>
>>56185648
Additionally. Simply mentioning registers leads some people to believe you're an expert on things. C++ is high level. The basic idea is that you don't have to understand underlying CPU architecture (but if you wanna write good code that's simply not the case)
>Anyone have a free compiler that is not copyleft that they can recommend?
MSVC. Using Visual studio.
I've tried using tons of different suites and most have the wrong idea about convenience. Visual studio does a lot of things that make it simpler to work with. It has debugging features available to it that are easily accessible. And while I don't enjoy locking myself to a platform like that it's not that big a deal because of the general portability of C++ code. Shame MSVC doesn't put up barriers against platform specific code. But it's overall a good trade.

>>56187180
I haven't seen it. But likely it's a 'complete' means to
>>56187693
handmadehero.org
I've grown up on games to learn programming but they all really sucked. This is a resource that actually teaches you things. It does require basic C++ programming knowledge for you to be comfortable with it. But I think that the subset used is very easy to pick up. It's similar to C.
Also is that a /vg/ link perhaps? >>>/vg/700454004

If you're looking to get kids engaged with programming giving them rapid progress with good guidance is often good. So what you need is:
-Libraries that are easy to interface with.
-Some kind of framework to hold on to
-Helpful error messages
-Documentation that doesn't involve a bunch of reading. Simply because they don't know how to discern the useful information yet.

What I find fits that description almost decently is Stencyl, a game programming environment which relies on a scratch type thing.
But it's not like you can set a kid down with that and he will solve things. What you should do is guide them towards their intent, encourage questions and eventually let them go. Hope they don't run into haxe issues.
>>
>>56187745
read as:
don't fuck with my job security
>>
>>56187649
why does microsoft rename almost every fucking concept out there? were they so ashamed of directly copying java, that they had to make bullshit names for the very same concepts used everywhere else to pretend that C# is not a copy of java?
>>
>>56187752

It's funny that the shoe is now on the other foot. Java's new features are being copied from classic C# features... poorly.
>>
>>56187752
the word doesn't come from C#, a delegate is a task that is delegated to a function, like in a GUI or something. that was the motivation for it being in C# and that's the name
>>
>>56187751
pretty much, lol.
>>
>>56187742
yes, some anyway
>>56187743
read over a dozen, and watched 100+youtube vids, but i kinda need a learning environment, cuz all that is kinda abstract.

following most books/tutorials: "do this" ok i did that (now why did i do that?)
so i need a structured game of a live instructor
>>
>>56187751
or:
freetards suck at making usable software
>>
>>56187752
why do you think they use fucking retarded PascalCase and allman braces, it's only to differntiate itself from java which uses camelCase and sensible braces
>>
>>56187749
>>>56187180
>I haven't seen it. But likely it's a 'complete' means to
Forgot to type this out.
I haven't seen it. But likely it's a 'complete' means to building applications. Meaning you CAN write anything really. But it's just a lot of hassle. That tends to be the case with programming interfaces like scratch or whatever.

Really the only reason these things exist in the first place is because platforms are awful at writing API's so instead of inventing more wrappers like everyone used to people have started making GUI interfaces instead.
It doesn't make things better really. It just takes care of small things for you.
>>
File: 1469976671467.png (654KB, 2640x1836px) Image search: [Google]
1469976671467.png
654KB, 2640x1836px
>>56187767
if you've 'read over a dozen and watched 100+ youtube vids' you should be able to just program your own projects.
>>
>>56187788
>sensible braces

You're fucking stupid.

t. Me
>>
>>56187767
don't just watch shitty tutorials, just start with your own shit and go from there, if you're stuck on something then figure out or look up how to do that thing
>>
>>56187767
Again handmadehero.org seems perfect.
If you don't want to spend 300 hours getting to where they are (since it's game specific you can skip a lot of stuff if you want to).
He starts architecture the game around episode 26 and gives you a good idea of his way of writing projects around there too.

So I'd watch that, and skip liberally. But it's a shame he doesn't separate things more. You may find yourself a bit confused at times when skipping because like a real programmer he programs out of memory. He doesn't write every piece of code in isolation.
>>
>>56187802
i have ideas for my own projects, and i've started them. i've created few crude but working tiny apps. but what i want to do is a bit deeper (but not so deep as to be on the scale of a crossplatform mmo by any means).
>>
>>56187826
shart in mart
>>
>>56187764
>>56187649

>>56187826
shut the fuck up you anarcho-micro&soft-penis-lover
>>
>>56187846
You idiot, I know what a C# delegate is, I'm saying the primary use of closures in C# was delegates and that's why they called them delegates
>>
>>56187493
It's a name that extends to both members of the state senate and the assembly, basically they're just elected officials in the legislature that represent their respective districts
>>
>>56187828
this
but having some kind of awareness of how different things can be applied and operated can simplify things A LOT
>>
>>56187788
camelCase is ugly as sin. snake_case and K&R style all the way.
>>
>>56188022
>not using based kebab-case
>>
File: give me the fucking delegates.jpg (61KB, 680x735px) Image search: [Google]
give me the fucking delegates.jpg
61KB, 680x735px
>>56187493
They're mine.
>>
>>56188030
For languages that allow them, of course.
>>
File: the delegates.gif (447KB, 640x480px) Image search: [Google]
the delegates.gif
447KB, 640x480px
>>56188034
>>
>>56188022
>wasting characters
I don't want my variable names to be 20 characters long desu

>>56187828
>>56188005
I just can't recommend this route

there's so much you won't know, you'll do everything wrong and your style will be bad without clear technique

believe it or not you have to be taught how to indent, how to document your code, everything needs to be learnt properly

at least a semester in college will do it
>>
>>56188072
Then don't come up with long names.
>>
>>56188072
>believe it or not you have to be taught how to indent, how to document your code, everything needs to be learnt properly

Is this a joke?
I can almost guarantee you do none of these things correctly.
>>
>>56188072
>how to document your code, everything needs to be learnt properly
>at least a semester in college will do it
>College
That's simply because you assume colleges do it right.
I doubt you do it well at all.
And really all of it is trivial if you use doxygen.
>Indent
Oh now you're just trolling.
>>
>>56188072
A semester in college? Just some light reading can help you with that
https://www.kernel.org/doc/Documentation/CodingStyle
http://homepages.inf.ed.ac.uk/dts/pm/Papers/nasa-c-style.pdf
>>
File: bjarne blew it.jpg (353KB, 870x500px) Image search: [Google]
bjarne blew it.jpg
353KB, 870x500px
>>56188117
>loomix colonel style
>>
>>56188117
>Open https://www.kernel.org/doc/Documentation/CodingStyle
>Doesn't use a block to close the potential local variables in a scope

But that's sortof the point isn't it. Different styles for differen't people.
Anyone who has trouble reading one style can just parse the code (because whitespace is irrelevant) and do their own shit.

Suppose my blocks for switches style hampers that but it's still fine.
>>
>>56188146
>potential local variables
In the switch that is.
>>
>>56188087
unfortunately they are necessary sometimes

>>56188115
>>56188101
>>56188117
yes obviously everything learned in college can be learned in a book in much less time, I'm not disputing that
I was pointing out the need to not just wing it and hope everything works out ok

also saying that I don't know anything doesn't negate the fact that certain practices are good and should be studied
>>
>>56188166
No. Anon you're missing the point. We don't know what you learned but it's certainly not guaranteed to be correct. College is wrong about a lot of things.

Wasting time is a concept. It means you're spending time less productively than you could.
>>
>>56188166
it's babby tier knowledge, if you can't learn things like that on your own you have no business trying to become a programmer
>>
>>56188166
If they're necessary, it's better to make them more readable., and a few more characters wouldn't hurt.
>>
>>56188146
It's simply one of many style guides; in most styleguides the authors give justifications for why they choose to style their code in the different ways, which is what matters. I only listed two style guides but I myself have read quite a number of them.

>>56188166
>yes obviously everything learned in college can be learned in a book in much less time, I'm not disputing that
>I was pointing out the need to not just wing it and hope everything works out ok
No this isn't one of those arguments. You don't need an entire semester of college to learn how to write readable code. The professor's should be teaching CS not teaching how to indent. People should be learning that stuff along iwth their studies, not for their studies.
>>
>>56188060
yes, otherwise snake_case is the best you can do
>>
File: autism is le ebin.jpg (9KB, 251x201px) Image search: [Google]
autism is le ebin.jpg
9KB, 251x201px
> He uses Hasklel
Kek,enjoy being no job having NEETS.
>>
I'm starting on my journey towards C, so I ask here: did anyone here actually learn C from K&R? I've been reading the book this weekend, and they spend more time in the first chapter doing loops with chars than the rest of the book. The reference at the end is nice, but the book itself is kinda short. I also found a few errors in the first exercises, like in the line counting program.

Do you guys know of a modern book that's better than K&R?
>>
https://youtu.be/KINIAgRpkDA
(skip to 21m23s)
where are those genius haskellers when you need them?
>>
>>56188567
elton john is a programmer?
>>
>>56188567
what do you mean?
>>
anyone here have a talent with adblock scripting?

I would like to begin filtering youtube suggestions and maybe some starting help would be nice
>>
>>56188213
>You don't need an entire semester of college to learn how to write readable code.

You need a lifetime, because every fucking six months the goalposts shift.

If there's one poster-boy of the self-damaging, pointless, pseudo-objective, religious fervor based bullshit in tech, it's style.

I once had to review a coworker's technical spec for a project. The first 40 pages were him just ranting on style, and how style is responsible for avoiding most bugs (WTF). We all just politely skipped that whole bullshit session and never brought it up again.

Discussing coding style is literally discussing fashion. Don't tell other people what the "right way" to format code, because you'll sound just like a Van Dyke-sporting, cargo-pants-wearing 1990s kid telling Millennials that their tight pants look faggy.

Your pants look faggy, BTW.
>>
>>56188651
no u
>>
>>56188651
if i have employees coding for me, and esp if they are to proof read others' code then style is important and should be uniform within that environment - outside, do whatever you want - go ahead and not put a sinlge comment or indent in yo shit
>>
>>56188691
>then style is important and should be uniform within that environment

Right, which is why you should conform to your company's standard. Like how a Taco Bell employee should wear his uniform to work. That doesn't mean a Taco Bell uniform is objectively superior to an Arby's uniform, or that the Taco Bell employee should insist on wearing a different color hat when he switches to working for Arby's.
>>
File: Tower_of_Hanoi.jpg (123KB, 677x298px) Image search: [Google]
Tower_of_Hanoi.jpg
123KB, 677x298px
>>56188623

Sex toys will not make you a better programmer.
Women's clothing will not make you a better programmer.
Programming will make you a better programmer.

How about instead of spending your time thinking about pointless shit, you spend the next hour or so (could be done in less, but I'll give you ample time since you're probably a beginner) writing a solution to the Tower of Hanoi in a language of your choice? The problem description is as follows:

You are given a set of n disks of increasing size that sit on one of three pegs on a device like this (pic related). The value of n will be an integer provided through either stdin or as the first command line argument (your choice). Assuming you are trying to move all of the disks from peg 1 (leftmost) to peg 3 (rightmost), print out each of the steps taken in moving them. The following restrictions apply:

1. Only one disk can be moved at a time
2. Only the top disk can be moved each time
3. Larger disks may not be moved on top of smaller disks.

You should also print out the number of steps taken and write a sentence or two describing the algorithmic complexity of the runtime and memory consumption.

This is a first year problem. You should be able to solve it.
>>
>>56188762
label disks in order of size
largest = 8, smallest = 1

move d1 to p2
move d2 to p3
move d1 to p2
move d3 to p3
move d1 to p1
move d2 to p3
move d1 to p3
move d4 to p2
keep pattern looping

there's the logic, i just need to learn a language
>>
>>56188820

Start with C. Also, that's not the pattern. Assuming d1 is referring the the smallest disk, you moved it to peg 2 twice in the first three moves, which would be silly. If d1 was referring to the disk on peg 1, you just made an illegal move. You are correct in that there is a repeating pattern, however.
>>
>>56188888
nice get, and yes i did typo, it's 3 am here lmao
>>
File: ruby brony.png (15KB, 796x293px) Image search: [Google]
ruby brony.png
15KB, 796x293px
>>56188888
Nice digits

>>56188691
Depends on the language and what you're making
>>
>>56188918

>3 AM
I would say such an hour would be an excuse to be derping, but during this time of year, I find myself staying up until 6 AM. Mainly because I program best around 4-7 AM after staying up all night. It's going to be weird adjusting to the working world.
>>
>>56188636
while haskellers masturbate when thinking about their own programming language, some people are improving things for themselves AND solving real problems fo the profit of everyone
>>
>>56188976
Don't you have anything better to do than insult Haskell programmers?
>>
>>56188957
>humblebrag
>>
What's something simple I can do? I can currently print "Hello World" in Python, C, C++, and Go.
>>
>>56189122
Print "Hello World" backward
>>
>>56189122
Try printing "Hello World!"
>>
>>56189185
yes. repetition is the key to getting good at anything.
10,000 times creating Hello World app = master programmer
>>
>>56189198
he was being sarcastic but you were too dumb to realize it
>>
Eclipse or NetBeans?
>>
>>56189216
and i was being sardonic
>>
>>56189241
maybe stop acting like a sardine and start acting like a human being

>>56189122
Hask ell
>>
>>56188450
intellij idea is defiently best one

jetbrains really good software company soon to dominate the industry.

you have IDE's for every languag (at least , the important ones)

https://www.jetbrains.com/
>>
>>56188762
fuck this isn't even a difficult algorithm but I am having trouble doing the sorting bit so it is taking forever

I think I'll just give up mkay

here's what I got though

a=[5,4,3,2,1]
b=[]
c=[]

def mov(frm,to):
tmp=sorted(frm)[0]
to.append(tmp)
frm.remove(tmp)
print(a,b,c)

def getmoves(a,b,c):
_1,_2,_3=(0,)*3
if len(sorted(a)) != 0:
_1=sorted(a)[0]
if len(sorted(b)) != 0:
_2=sorted(b)[0]
if len(sorted(c)) != 0:
_3=sorted(c)[0]
arr=[_1,_2,_3]
out=[]
i=0
for elem in arr:
j=0
for each in arr:
if (elem < each or each == 0) and elem != 0:
out.append(('a'+str(i),'a'+str(j)))
j+=1
i+=1
for (frm,to) in out:
print(frm,to)

mov(a,c)
print(getmoves(a,b,c))


I was able to solve the puzzle though
>>
>>56189198

The three great virtues of a programmer are laziness, impatience, and hubris. If you're going to do something 10,000 times, automate it.

#!/usr/bin/env ruby

CProgram = <<-HELLOWORLD
#include <stdio.h>

int main(void)
{
printf("Hello World!\\n");
return 0;
}
HELLOWORLD

Source = "hw.c"
Output = case RUBY_PLATFORM
when /win32/, /mingw/ then "hw.exe"
else "hw"
end

10000.times do
File.open(Source, "w") do |file|
file.write CProgram
end

`gcc -o #{Output} #{Source}`
print `./#{Output}`

File.delete(Output)
File.delete(Source)
end


>>56189473

>All of this sorting
I do not think you are trying to solve the Towers of Hanoi problem. Running your program produces this output:

([5, 4, 3, 2], [], [1])
('a0', 'a1')
('a2', 'a0')
('a2', 'a1')
None

This tells me nothing about which disks are being moved where. For the record, you cannot solve a 5 disk tower of hanoi with any less than 31 moves.
>>
>>56189555
I already told you I had solved it
and I know it is unfinished

mov(a,c)
mov(a,b)
mov(c,b)
mov(a,c)
mov(b,a)
mov(b,c)
mov(a,c)
mov(a,b)
mov(c,a)
mov(c,b)
mov(a,c)
mov(b,a)
mov(c,a)
mov(c,b)
mov(a,c)
mov(a,b)
mov(c,b)
mov(a,c)
mov(b,a)
mov(b,c)
mov(a,c)
mov(b,a)
mov(c,b)
mov(c,a)
mov(b,a)
mov(b,c)
mov(a,b)
mov(a,c)
mov(c,a)
mov(b,c)
mov(a,b)
mov(c,b)
mov(a,c)
mov(b,a)
mov(b,c)
mov(a,c)

I think this is 35 moves
>>
>>56189572

That is 36, and I can't be fucked to write a program to see if there are any illegal moves and if this produces the correct output. I will say this, however -- you only need 31.
>>
File: Capture.png (10KB, 180x442px) Image search: [Google]
Capture.png
10KB, 180x442px
>>56189601
you can tell its valid because if you attempted to move a piece out of order it would disrupt the order since they are appended

so if you moved a 2 on top of a 1 the array would end up like [1,2] rather than [2,1]
>>
File: 1470220887717.jpg (17KB, 410x415px) Image search: [Google]
1470220887717.jpg
17KB, 410x415px
>tfw GNU C style
if (foo)
{
bar();
}
>>
>>56189658

But you are sorting your "from" peg every time before you make a change to it. I cannot use your program to test its own validity.
>>
>>56189693
its printed after the array has shifted so an error would be pretty obvious

the sorting happens at the beginning of the function, see
>>
>>56189728

Here is the problem: You are grabbing the first element of the sorted version of the from peg. If every move were valid, this would be completely unnecessary because the peg would already contain sorted data. Every time you add a disk to a peg, it should not lose its status as being sorted.
>>
File: 1435624490905.jpg (92KB, 430x342px) Image search: [Google]
1435624490905.jpg
92KB, 430x342px
>when you finally understand c++ templates at an intermediate level
we meta-programming now nigga im making code that makes code
>>
>>56189555
>case RUBY_PLATFORM
Why bother adding support for multiple platforms before you need it? Seems like it would be easy enough to add later.
>>
>>56189761
hmm you're right

it could instead be this to the same result:

def mov(frm,to):
tmp=frm[len(frm)-1]
to.append(tmp)
frm.pop()
print(a,b,c)
>>
>>56189779

If you are on Windows, and you do this:

gcc -o hw hw.c


You would be left with a file called hw.exe, because MinGW is going to always automatically add the appropriate file extension (remember, Windows actually cares about file extensions). If you were to then tell Ruby to delete the file hw, it would throw a fit, since no such file exists.

Polls among /g/ users suggest that both Windows and Linux see a great amount of use here, so if I were to make the script work for only one platform, I could reasonably see one person who tried the script to tell me it doesn't work and I don't fucking know Ruby. Considering that it is incredibly easy to add multi-platform support, I consider it best to make it work on all platforms before releasing.

>>56189828

Protip: If you use -1 as the subscript to your array, you can grab the last element.
>>
Crossposting from amateur game dev general. Apologies for not explaining the game/genre to those unfamiliar with it but that would take multiple posts.

I'm (still) writing the AI for a CCG. One of the snags I ran into is how pessimistic I should be when it comes to what the opponent could play. Let me explain:

Picture a Hearthstone AI that just looks at the board, at your hand, and considers all possible plays it could make, then all possible ways the opponent could attack on their turn, then the ways you could attack on your next turn, then they on theirs. It then ranks the board and picks the series of plays which lead to the best board. It is very difficult to account for what exactly the opponent could play so I mostly don't bother but I think that maybe I should because assuming that they won't play any creature is naive. Rather than trying to guess any specific creature I could just fabricate a phantom vanilla creature with on-curve stats then simulate the turn as if they played it.

If I always assume an on-curve play then I've prepared for the worst (stat-wise) and can take precautions. The problem is that if I prepare for the worst and it does not come then I've potentially just given up opportunities to push in more damage or secure my lead by being more aggressive. So maybe I should assume they play a lower-then-curve creature.. but then if I'm too optimistic I'm fucked. How do I figure out the proper level of pessimism?
>>
>>56189895
huh

learn something every day

>>56189902
there's a berkeley course that does this exact question
http://ai.berkeley.edu/project_overview.html
>>
>>56187410
Every language is shit

Also, thanks for using my pic
>>
>>56189914
Neat. Thank you.
>>
New thread: >>56190217
>>
>>56189914
>>56189828
Popping also returns the popped object, so you could just use
to.append(frm.pop())
Thread posts: 312
Thread images: 33


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.