Old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
gamemaker tutorials.
I don't actually know how to program.
How do I start with parsers, lexers etc? Does anyone have course material for that?
>
>en.wikibooks.org
is haskell even worth it?? or just for hobbyist??
union {
struct {
float foo[2];
float bar[8];
};
float foobar[10];
};
what should the static_assert look like to make sure that this will work:
bar[0] = 1.2345f;
printf("%d", foobar[2] == 1.2345f); // 1
I love that picture. It just goes to show how much more advanced and better C++ is even though it evolved from C. I applaud whoever made it.
the C++ standard didn't define RVO. the fact that it didn't, but was permissive enough to allow it in compiler implementations, could arguably be called a bug (or at the very least an oversight), considering it did lead to issues (most notably the one user referred to). however, those issues were addressed with C++17's "guaranteed copy elision" proposal
> you are either too inexperienced to have a valuable opinion on the matter or actively engaging in doublethink.
It's funny 'cause I can say the same about you if you fail tot realize the benefits of RAII. You either have never used std::vector/fstream, or malloc/free/FILE.
> i guarantee the same way you do that an algorithm specific to your implementation
What can be specific about sorting algorithm? Unless it's some extreme cases of almost-sorted data, you can't beat the state-of-art algorithm.
> an inline assembly sorting algorithm that uses your data structures directly and has been profiled and optimized by hand
So you have not actual experience, I see.
> [some bullshit damage control about C compilers not inlining stuff]
That's simply because it's impractical for them to do inter-unit inlining with external libraries since they have no access to the source code. This is exactly the problem templates solve.
> the ~3 cycles that creating the stack frame and returning add are of no consequence even in the hottest of loops
How dense should you be to ignore literally half a dozen benchmarks and analyzes out there inventing some bullshit explanations instead? Inlining is the reason qsort sucks and std::sort doesn't.
Thanks
Most (all?) POSIX functions work in Windows, so use those whenever possible for maximum portability. For other things you'll need to use macros to set up different code blocks depending on the targeted platform.
it uses parser libraries though
I think I can write myself one if I know what it exactly does. But do you know resources where there are no parser libraries being used?
>The required alignment for an array of float is the same as the required alignment for a single float object. If float is 4 bytes, then that alignment can be no greater than 4 bytes, since arrays do not have gaps between their elements.
is this true? so should be safe or at least work in practice?
I'm really into the crypto-currency meme now and there are a few projects that are aimed to be alternatives to kickstarter
ref link
coinstarter.com QUESTIONMARK ref=dndn3tntj
I have a broad background in math and physics theory - do you have an idea what a good pitch would be to just monetize the content I provide online (e.g. youtube videos). I feel there's a chance to "get financed" for good content this way, next to my 40h job.
I'd like to do (continue, really) a project on logic and dependent type theory, and walk towards coding applications in stochastics.
But those kickstarter projects usually give back some intake and features for milestones and I don't quite know what to offer in this case.
Any input welcome.
Thank you
PS I really dig the wooden table.
I have to learn C++ at work too, but I'd really like to use more Idris
Why does everybody shit on C ?
Its a perfectly good language, as far as safety is concerned the compiler can implement buffer and pointer checks.
Whats wrong with it ?
> I'm really into the crypto-currency meme now
You're at least 5 years too late, the crypto-meme has been debunked time and time again.
What would a good Java pile look like?
It's pajeets wanting to shill their brainlet languages.
>as far as safety is concerned the compiler can implement buffer and pointer checks.
then why are they not doing it with every existing codebase?
>if you fail tot realize the benefits of RAII
>You either have never used std::vector/fstream, or malloc/free/FILE
this is not an argument, so my only response is to ask that you actually explain how you think streams are better than file buffers, and how vectors are better than just reallocing manually.
>What can be specific about sorting algorithm?
everything
>you can't beat the state-of-art algorithm.
uh yes you very much can
if your data set is small you can do a time-space tradeoff that makes sorts practically free, if you only need an arbitrary amount of the array sorted it can often be beneficial to use a number of iterations of an insertion/selection sort equal to the amount of the array you need.
>So you have not actual experience, I see.
lmao nice argument
>[some bullshit damage control
ah yes just ignore my entire explanation to prevent yourself from having to actual argue any of my points, very good, that makes your point look of very high value.
>that's simply because it's impractical for them to do inter-unit inlining with external libraries
it's because it's rarely of any value AND that, as i explained.
>How dense should you be to ignore literally half a dozen benchmarks and analyzes out there inventing some bullshit explanations instead? Inlining is the reason qsort sucks and std::sort doesn't.
a dozen benchmarks done by the people who desperately wanted to spread their cancerous language to things like gcc, benchmarks that run once for some arbitrary quantity of iterations and then exit.
if you don't realize how programs that run for 10 seconds that are written in full c style for extremely large projects like the kernel are going to have little benefit compared to hacked together examples using the very large c++ stdlib (which practically fucking contains the entire benchmark), you're a fucking moron.
educate yourself on the thing you're shitposting about at least far enough that you can come up with real arguments.
> Why does everybody shit on C ?
Because it indirectly caused the recent security fiascos by allowing and even actively promoting unsafe programming practices.
> the compiler can implement buffer and pointer checks.
1. Optional safety is unsafe.
2. It's a solution from outside the language.
3. Run-time checks defeat the purpose of having a fast simple language, you might as well write in Java.
union {
struct Foobar {
float foo[2];
float bar[8];
};
float foobar[10];
};
static_assert(sizeof(Foobar) == 10 * sizeof(float), "");
how about this
dumb frogposter
It is pretty insecure because you have so much control over memory, but that's the only thing I can think of
>It's not a language bug you fucking idiot.
No you're the fucking idiot here. RVO is what he used in lieu of move semantics because of the language bug that makes move semantics not work as it should in this instance.
Listen and use your brain for one moment, or execute yourself. People who are as stupid as you are shouldn't live. You're doing a diservice to the rest of us.
God you don't get it either. See kys.
Any good and straightforward ressources about design patterns?
reading documentation on my SoC CPU.
It's like an information jungle.
Heya all, I'm an older guy here who has been out of the game for a good while, cut my teeth on LOCO BASIC, graduated to C but not done anything in years.
Recently had a yearning to get back into it and I find the programming world has changed immensely, everything I knew is so obsolete it isn't even funny and I'm a little lost.
Is Python a good place to get back into the swing of things? Rust?
Any advice would be greatly appreciated.
>optional safety is unsafe
clearly we need architectures that enforce memory cucking upon us to truly be safe.
>it's a solution from outside the language
compilers are a solution from outside the language, the language should standardize it's own compilation, clearly.
>run-time checks
nobody implied this and it's also retarded
gcc already does check pointer bounds in all common bug cases if you enable all warnings
rust is overcomplicated trash and it needs llvm, the actual compiler part of the compiler, which is written in c++ (it's main target) just to be compiled.
>in any case where the function call overhead of qsort is going to be relevant
If your compiler can't inline qsort it can't inline the comparison function. That's the problem, not the qsort call inlining.
Unless it generates multiple qsorts with the same comparison function. Which would be a very odd circumstance and I doubt it ever actually happens in good code. Maybe if you repeatedly call qsort in a loop. But that's a very odd case.
>an inline assembly sorting algorithm that uses your data structures directly and has been profiled and optimized by hand is never going to be beaten by a function in your standard library
This is true a lot of the time though.
>3
Cant you run a static C code analyzer in that case ?
Also it becomes more of a code base issue when it comes to runtime checks, i assume that the main reason for them is not actual speed and safety but a means to an end when it comes not porting your code to another language and giving safety.
Which brings me to my main point.
Safety in C is possible even if its not built in to the language, which i guess sort of add on to my first point that you don't have to worry about modifying code.
I assume that you need formal safety specifications in the language but still, i think that a solution like this is favorable rather than rewriting code in something like rust
if you were comfortable with c i don't think it's going to be too hard. i don't like python much but i think it's a good choice here, unless you can be more specific about what you want to accomplish
> my only response is to ask that you actually explain how you think streams are better than file buffers, and how vectors are better than just reallocing manually.
You can never forget to free/close them.
> uh yes you very much can
This is why most of the generic sort implementations check for the size of the data first and even try to detect partially sorted parts. In almost no case is it practical to write your own sorting algorithms for every specific case you have.
> lmao nice argument
It's a good argument since anyone who thinks writing sorting algorithms in assembly by hand is somewhat realistic and even efficient clearly have no idea what he's talking about.
> just ignore my entire explanation
The explanations go against the benchmarks.
>it's because it's rarely of any value
Except for literally every benchmark out there showing how it's actually important.
>a dozen benchmarks done by the people who desperately wanted to spread their cancerous language
Wew, lad, so now you're saying all the benchmarks that don't confirm your point of view is FAKE NEWS.
Definitely skip on Rust for now, it will feel too "advanced", and you will feel even more lost.
Python is alright but you have to keep in mind that it's an interpreted language and it might not be suited for all tasks.
Ignoring security issues why do people dislike it feature wise, i know its apples to oranges but lets compare C with python.
>Unless it generates multiple qsorts with the same comparison function.
Different, not same.
Excellent, Python it is then. Thanks fellas.
Something like python is fine. Depends on what you aim to do. I think Java/C#/other has more job opportunities and overall better jobs than python. But for hobby programming it's absolutely not a bad choice..
No things were different. I'm not gonna argue that if you can learn C you're not likely to be fit for other languages but they're different skillsets.
>Effective C++
>Moar Effective C++
>Effective Modern C++
Is this a fucking joke, Meyers?
hm... is that from the standard? i could swear it's still possible to have padding *after* an array (though not between elements, of course, unless the type the array contains is itself aligned to a boundary larger than its contents)
What stuff should I be able to program from scratch before I become hire-able? I'd like to think I know enough to get a job being a good little monkey, but having not been able to find an internship near me I don't really know that.
Just how many books do you need to learn C? It's not that hard.
They probably don't even agree with each other on what's the best way to program.
>2
I say they don't actually teach you enough. But I don't know any good learning C books.
it does sound ridiculous but cut him a little slack given what makes for effective C++ changes every time they release a new standard. kek
>you can never forget to free/close them
that doesn't make them better, especially when they go out of the scope they're supposed to by accident and you end up carrying around the memory for the life of your program.
>This is why most of the generic sort implementations check for the size of the data first and even try to detect partially sorted parts.
not talking about partially sorted arrays, explained this already, read my argument or i'm not arguing with you
>anyone who thinks writing sorting algorithms in assembly by hand is somewhat realistic and even efficient clearly have no idea what he's talking about
maybe in (((extremely high level))) world where nobody has even seen inline assembly, sure, but some of us live in the real world where computers execute instructions.
if you think inline assembly as a whole isn't "efficient" you're a fucking moron, i can't sugar coat that.
>The explanations go against the benchmarks.
>Except for literally every benchmark out there showing how it's actually important.
>Wew, lad, so now you're saying all the benchmarks that don't confirm your point of view is FAKE NEWS.
it really doesn't have anything to do with benchmarks, and seeing as your entire argument has been reduced to them, i will have to explain in full detail.
when you write a benchmark that heavily uses features in the standard library of one language and uses one specific element of another, you are automatically favoring the former.
in such a benchmark, since it runs for a very limited time, inlining the function has no downsides, but in the real world, people use qsort multiple times in a single project with multiple different comparison functions, and in hotpaths, they write their own implementation, (usually in inline assembly, if this is a **hot** hotpatch, but apparently that is a difficult concept for you) in which case, the cache usage of having multiple sorts inlined with slightly different comparisons is a much bigger deal.
Because you need to write about 8 times more lines in C than in Python to implement the same algorithm.
What's the book under K&R?
the first edition?
>Its a perfectly good language, as far as safety is concerned the compiler can implement buffer and pointer checks.
The problem is that finding these errors through static checks is not an easy task. I certainly don't think it's as unsafe as people think it is but it won't have the same guarantees other languages like Rust give you.
I think the problem is that people are terrible at cost benefit analysis. They use the wrong languages for the task and would often prefer universal solutions over solutions fit for specific situations.
But you end up hundeds of times faster. Most likely. It's not a reason to dislike the language. But if development time is much more valuable than performance you just shouldn't have picked C for that task.
This is also why end-user software is stupid slow. Because we have powerful machines where we can waste. Sometimes people go overboard and shit that you'd expect to run on an i586 runs poorly on the monster computers we have today. When that happens it's because the dev doesn't have the skillset to cope with the problems. She doesn't know C. Knowing C lets you call C code from most other languages using their FFI. So you can meet the demands without problems. People don't do that enough.
>What stuff should I be able to program from scratch before I become hire-able?
Most hired programmers only modify code.
Find ways to make yourself a more attractive hire instead. Perhaps that is making a project from scratch and putting it up on github. Perhaps it's being better at interviews.
Are header-only libraries a meme?
How do they protect themselves from multiple includes?
languages that require header and source files are a meme
(((Meyers))) doesn't have to have a real job anymore
Too late to get rich, not to late to make 200$ a week from clicking a few buttons at the right time.
#pragma once
#pragma once
or
#ifndef _HEADER_NAME_
#define _HEADER_NAME_
#endif
They are usefull because managing libraries with C is tedious.
They are usually shit because instead of just providing functions they might use some static variable for global state. Depends what it does and who wrote it.
You can call C from Python, if you create a wrapper for it. And the speed differences are not really that significant. Especially if you consider non-linearly scaling problems. Then it's all about the algorithm, and only about the language if you want to squeeze the last few extra percents.
>#pragma once
doesn't solve the redefinition problem
>Are header-only libraries a meme?
They're the only sane way to do libraries in C or C++ imo. But that's not to say they're amazing compared to other languages options. They're just very easy to integrate.
>They are usually shit because instead of just providing functions they might use some static variable for global state.
I haven't seen this.
Should be easily remedied though right?
see
Usually they tell you to define
LIBRARY_NAME_IMPLEMENTATION
in only one .c file.
>Why does everybody shit on C ?
They have envy because C has remained pure due to not being OO. Because of this blessing from heaven, pajeets in the 90s had to move to C++, Visual Basic, pascal and Java to do their boring CRUD desktop apps.
C++ has aged badly, and now that it pretends to be pythonic its even more abhorrent. C on the other hand is the patrician language. Its small yet powerful, old but capable.
-Some basic manual of your choice
-Effective Java
-Java Concurrency in practice
That would be the basic pack.
>instead of just providing functions they might use some static variable for global state
the problem of global state is by no means limited to header-only libraries
>The speed differences are not really that significant
Not true. The multiplier you take by using python is massive. All the benchmarks will show you ~10-100 times improvements going from python to C++ for instance. Depends on the task and if they're just racing to call out to pre-compiled code (as is often the case in benchmarks).
If you consider normal naively written python code that is the nice stuff you'd like to get from the language to keep development times low
(unlike benchmarksgame.alioth.debian.org
And while bigO matters when you have millions upon millions of entries that doesn't matter so much when you consider the difference between neat python and normal C/C++.
Whenever performance starts being a concern I advocate just writing it in C. The FFI for most languages are nice enough that you shouldn't be all that worried about it. Most of the time you just create a .so/.dll and ship it with the script.
Other compiled languages tend to have less of a case for writing C and using FFI but for interpreted languages it's uncommon that they perform well enough to be sensible to use for an entire application.
> that doesn't make them better
Yes, it does, this is why every modern language has a variant of RAII, even the ones with GC.
> if you think inline assembly as a whole isn't "efficient" you're a fucking moron, i can't sugar coat that.
It's not the 90s anymore, grandpa, your hand-written assembly will never be anywhere near as efficient as the one generated by a modern compiler on a modern architecture. The only exception is AVX and likes since compilers suck at autovectorizing for now.
> [benchmarking doesn't represent the real world experience]
It's close enough tho, you can't just disregard all the benchmarks just because these specific ones don't reinforce your pre-existing position. I mean, all the claims of C being fast are based on benchmarks, should we ignore them too?
Writing RAII code is an overhead productive programmers shouldn't bother with.
...
It's not bad because "hurr some blog poster said global variables are bad" but it's bad because if you load dynamic libarary and want to reload it the static variable resets. So when providing some functionality you should let the user define the variable that holds the state if it needs to be stored somewhere.
excellent oc
>0.14% cross dressing index score
Sounds very low.
it's logarithmic
Noice
homosexual post
'Real World Haskell' or 'Learn You a Haskell for Great Good'?
I remember reading the introduction to the latter and thinking that the explanations were a bit janky.
WHERE MY C-MEN AT???
Real World.
LYAH is too simplistic, and I don't like her 'humour'.
PS. The Allen and Mononuki book, can't remember its name, is better than those two.
needs haskell
i'm aware, thanks. i'm not some memeing sperg. and that's not the only reason it's bad. a well-designed API should be arbitrarily instanceable, and the instances should be allowed to have independent and differing states if that's what the user requires. this is easily achievable with context objects, so there's no real excuse for global state. also the issue you're referring to applies to dynamic libraries which are, by nature, not header-only
>I don't like her 'humour'
I think that's what I disliked about her explanations--she would try to frame them as jokes that I didn't find funny.
Also, hello, fellow Britfag. I wonder how many Britons there are in this thread at this time of day.
Why does he move his mouth like that?
apples = 5;
show(apples);
i guess he's reading off a script and trying too hard
That language has one of the worst syntaxes ever.
Really? I don't particularly trust a book that cherry picks reviews for its website and doesn't even provide sample excerpts.
>this is why every modern language has a variant of RAII, even those with GC
source pls, that reeks of bullshit
>your hand-written assembly will never be anywhere near as efficient as the one generated by a modern compiler on a modern architecture
if you actually think this then you haven't seen assembly generated by a modern compiler. they are not perfect by any means whatsoever.
also, you can totally just take the assembly a compiler generates and tweak it, but whatever
>It's close enough tho
it really isn't, and i explained why
the cache is never going to be anywhere near saturated in a
I don't think people realize just how lucrative it is to invent a problem and then "solve" with your new book every few years.
All those programmers who invented a language, and then wrote their own authoritative book are now fucking rich off the consultancy fees alone.
In my website, I'm going to send cookies to their personal address, to anyone who accepts cookies.
Is this a good idea?
how will you get their personal address though¿
people would have to fill out a form, obviously
Autism.
>he doesn't require people to sign in before they can access your website
What are you from the 90s?