[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: 316
Thread images: 29

File: 1502554078961.png (111KB, 600x800px) Image search: [Google]
1502554078961.png
111KB, 600x800px
What are you working on, /g/?

Previous thread: >>61980634
>>
not this again
>>
Why dis not work?

std::set<std::string, decltype(comparator)*> TriggerValues(comparator) {values here};
>>
On C, instead of using "else if"s can i just keep using "if"s?
will it yield the same results?
>>
>>61984944
all your if statements will be queried/checked, unless you're returning in the if above it.
>>
>>61984943
I have no idea what you're trying to do
>>
>>61984944
if you have "if p { } else if q { }" then you can't blindly replace this with "if p { } if q { }". what if both p and q are true?
>>
>>61984978

Trying to supply std::set with comparator function which is something like doing strlen string 1 < strlen string2 (const char*)

actually it should be std::multiset

My C++ book said it should work properly but it doesn't, gives syntax error
>>
Is there a book that teaches C++ like it's C (precisely what happens in the memory with various complex abstract constructs)?
Also, for people who already know a lot?
>>
>>61984944
Else if will avoid checking once one comparison is true, with only ifs it will keep checking
>>
>>61984944
this
else if (condition) {
// code
}

is in fact this
else {
if (condition) {
// code
}
}
>>
File: 1496537830482.jpg (279KB, 3200x2400px) Image search: [Google]
1496537830482.jpg
279KB, 3200x2400px
>>61984897

Hey /g/ I need your help, am writing a small pet OS I have a working console I run it on qemu and the key repeat(IE arrow keys and such) is fast as one would expect and the cursor moves fast, but when I run it on real hardware or virtualbox the cursor is slow as shit.
Anyone has any experience on this? I dont really know what to search for in google desu famsenpai
>>
because I was slow, from other threaad.
>>61984723
are you saying std::string isn't dogslow and that you shouldn't favor const char * const over it? I mean, its not as retarded as QString and with SSO in C++11, it can be good but.. on interface boundaries its ideal to not expose an std::string.

internally, if you're using it for identity or as read-only, why not use the const char * const? I'm not telling him not to use a string, but in places where a const char * const will work. I use string/wstring a lot, but I know it can pretty slow for read-only strings.

or are you complaining about where my pointers are?

>>61984774
auto is nice because it doesn't do implicit conversions. so you won't have possible temporaries/copies or have the wrong type. like
std::string f = "asdf";
will do. (granted an optimizing compiler will almost always improve this).
but for non-primitives you shouldn't likely ever use = in declaration, but rather uniform initialization
std::string f{"asdf"}; // same as auto f = "asdf"s


>>61984885
oh, ofcourse not. but std::string should be passed by reference, not by value in the general case. but there are different use cases (it is c++ after all)

const std::string& // when you want to modifies caller string
std::string const& // read-only, but const char * const is probably better

std::string // a copy but...
std::string&& // this is better, or std::move(your_string)
>>
>>61985046
You're looking for pretty specific answer, I doubt you'll get anything… Add tracing to your codebase so you can see where it's slow? It's something you should be doing anyway, you can't expect to write everything with good performance on first try (as obvious here).
>>
>>61985007
oh.
Initializer list can be given as the first argument to the constructor, so
std::set<std::string, decltype(comparator)*> TriggerValues({values here}, comparator);
should work.
>>
>>61985012
Do you know C already?
>>
>>61985067

Well one would expect that it runs fast on real hardware too, am thinking if there's something like a refresh rate for the keyboard controller or something like that.
Like I said, I dont really know what to search for.
>>
>>61985090

Trying as following :

std::set<std::string, decltype(comparator)*> TriggerValues({"Nigger"}, comparator);


It says "Expression expected" near decltype operator for some reason

using Clion IDE
>>
>>61984897
Could anyone post the most updated Pro/g/ramming Challenges image?
>>
>>61985143
google "g programming challenges" and never come back
>>
>>61985098
I even know a lot of C++.
>>
File: images.jpg (6KB, 207x244px) Image search: [Google]
images.jpg
6KB, 207x244px
are you a better programmer than your peers?

Do you compare yourself to them?
>>
>>61985158
Then you should know what all of your abstractions are built out of already.
>>
>>61984897
>/dpt/ recommended
There are 0 (zero) anime girls on the picture, therefore, it's not a legit /dpt/ image.
>>
>>61985176
Where from? In many cases I can guess it after a while but it would be nice to learn this in a systematic way. Is there an in-depth book like that?
>>
>>61985174
no
yes
>>
I'm downloading NetBeans. Fucking CLion sucks coming from Visual Studio. Has no proper intellisense-like thing.

Using Linux here, i read that NetBeans gives best VS like experience
>>
>>61985250
qtcreator and kdevelop are pretty nice too. (you don't need to do Qt while using them, either).
>>
>>61985270
>Programming languages involved were C, Go, and Rust.
Youre illiterate i see.
They were compared in 2 of the 3 but i threw in Vibe because its a notable third party lib, even though i have some qualms with it.
>>
How do I redefine a method returning array of parent class objects, to make it return an array of child class objects? It does not convert on the run
>>
>>61985139
What's up with that asterisk after decltype()? Seems ambiguous and sorta funky...
>>
>>61985404

decltype defines what "comparator" function is and asterisk asks it to define pointer to comparator
>>
>>61985139
how is your comparer defined?

with a lambda:
 auto comp = [](const int& lhs, const int& rhs) -> bool { return lhs < rhs; };
std::set<int, decltype(comp)> values{{5,7,3,6}, comp};
for (auto& i : values) { std::cout << i << std::endl; }

with a function:
bool comp (const int& lhs, const int& rhs) { return lhs < rhs; }
// meanwhile
std::set<int, decltype(comp)*> values{{5,7,3,6}, &comp};
for (auto& i : values) { std::cout << i << std::endl; }


>>61985404
it treats it as a function pointer, notice the & on the other end
>>
>>61985443

bool comparator (const const char* cstr1, const const char* cstr2){
return strlen(cstr1) < strlen(cstr2);
}
>>
>>61985462

const char* const

//fix
>>
>>61985462
double const don't make sense, btw
and char* doesn't define an < operator.
use a string for that. or write your own that handles char[] (or use something like strcmp from c)
>>
>>61985517

I know, fixed double const. But it looks like error is not because of my comparator function, changing it to

bool comparator(std::string &str1, std::string &str2) {
return str1.size() < str2.size()
}

doesn't work. Still says expression expected (near decltype())
>>
>>61985536

Passing std::string instead of &std::string doesn't work either
>>
>>61985176
>>61985158

C is not the same as C++ under the hood. Certain C like expressions don't work the same in C++, I also would imagine their are gonna be weird finnicky differences between asm code generated from a C compiler and code from a C++ compiler and I thought generally with member functions C++ compilers made some sort of weird table to map out calls for specific objects which isn't really comparable to C afaik because C doesn't support oop unless you try to implement it yourself. Also templates and junk aren't really a C thing. (Not counting simple macros)

The poster of the question might enjoy some assembly books and reverse engineering books because a lot of those tend to enjoy picking at C for the sake of learning seeing as jumping between C and asm is a lot better than say Java -> JVM bytecode -> asm. I know AoA talks about its own weird class system but I stopped reading it before that point, Reversing secrets of reverse engineering had some cool parts on C# and I think it had bits on C++ too but I don't really remember it super well. That whole book picks at things from an assembly perspective. (Which makes sense because it's an RE book.)

For templates and stuff I can't be too helpful but it's worth remembering that templates are mean't to be executed before compilation so it's more relevant to like a book on code generators and compilers rather than the lowlevel stuff.
>>
>>61985462
>>61985517
I don't know your types or anything, but I presume:
bool comp (const std::string& lhs, const std::string& rhs) { return lhs < rhs; }

int main() {
std::set<std::string, decltype(comp)*> values{{"asdf","fdsa","zsdf"}, comp};
for (auto& i : values) { std::cout << i << std::endl; }
}

also, what version of C++ are you using? decltype was added in C++. and make sure your values are being passed by const reference. see std::less in the functional header for an example.
bool operator()( const T& lhs, const T& rhs ) const; // (until C++14)
constexpr bool operator()( const T& lhs, const T& rhs ) const; // (since C++14)
>>
>>61985582
I meant to say C++11. but if you're just doing < then you don't need a comparer because std::less<T> is the default.
template<
class Key,
class Compare = std::less<Key>, // <--
class Allocator = std::allocator<Key>
> class set;


if you wanted to be explicit you could do:
 std::set<std::string, std::less<>> values{{"asdf","fdsa","zsdf"}, std::less<>()};  // you don't need to put std::string in the less brackets in C++14, its implied.)
// and to sort backwards:
std::set<std::string, std::greater<>> values{{"asdf","fdsa","zsdf"}, std::greater<>()};
>>
>>61985582

It says argument type std::basic_string is not compatible to bool or something like that when i use it this way
>>
https://www.youtube.com/watch?v=YnWhqhNdYyk
>>
>>61985662
i wish this was the popular attitude. Or is the title deceptive?
>>
>>61985662
I'm gonna have to watch this for the keks.
>>
>>61985662
I fucking hate that talk so much. If you learn C++ you should know more than the average Python programmer.
>>
>>61985697

This video is retarded. It literally says

>C++ students are too dumb for learning C
>its so advanced, muh pointers
>only teach C++ Pajeet library
>>
>>61985711
c++ != c. That's the point.
>>
>>61985660
thats odd, can you show the comparer and the set (where you're making it..)?

here's an example of the 3 methods I've mentioned:
http://coliru.stacked-crooked.com/a/0d0928dee44b0e2c
>>
>>61982868
It's actually quite simple.
A module foo can either be a simple source file or a directory with a mod.rs file.
  project/
|
+- main.rs
+- foo.rs

or
  project/
|
+- main.rs
+- foo/
|
+- mod.rs
>>
>>61985751

I just copied your code and CLion is still bitching. Pretty odd.
>>
>>61985793
well.. can you show the code? I'm leaving soon but I can probably help you fix it. "no expression" sounds like a simple syntax error, in this case.

but if you're just gonna do < then don't bother with the comparers.. set is sorted by default in natural order.
// comp just does lhs < rhs
std::set<std::string, decltype(comp)*> my_set{{"rsad","asdf","fdsa","zsdf"}, &comp};
// is equivalent to
std::set<std::string> my_set{{"rsad","asdf","fdsa","zsdf"}};
// because it defaults to doing:
std::set<std::string, std::less<std::string>> my_set{{"rsad","asdf","fdsa","zsdf"}, std::less<std::string>()};

but I'd question why you need to use a set instead of std::unordered_set. you can always do std::sort on it later. its faster because each addition/removal doesn't need to be sorted at that point in time.
>>
>>61985740
Yeah, if you lie to people.
>>
>>61985697
There are good points in the talk.
>>
>>61985898

No, if you've actually studied the programming languages and know what you're talking about.
>>
>>61985662
>teaching with an IDE
>>
Holy shit i just installed NetBeans and default font is a fucking cancer. MY EYES, GOD DAMN IT.

How to fix this
>>
File: 044fa7f21cf5b975.jpg (53KB, 600x450px) Image search: [Google]
044fa7f21cf5b975.jpg
53KB, 600x450px
>use Go with a postgres database
>trawl the internet for good sql/db libraries
>every retarded """Gopher""" screams to NOT use ORM's, to only use the base sql/db package
>ok, many decent libraries like sqlx
>except they can't handle any fucking mapping involving joins or one to many relationships at all
>hur dr dont use orms ;)

how the actual FUCK are these faggots designing their projects? Don't they use joins at all? Are they running ONE QUERY PER TABLE?

what the fuck /g/
>>
>>61985898
if you're using C99 or later, you're writing illegal C++.
// are these valid C++?
void foo(char bar[10]);
void foo(char bar[static 10]);

// are these the same? (same result)
sizeof('a'); // C
sizeof('a'); // C++

// is this valid in C++?
#include <math.h> // <cmath> if you wanna be a pedant
void foo() { clog(0.3); }

// is this valid in C?
int i, j;
(i,j) = 1;

// or the easiest example of valid C, but invalid C++:
struct foo* p;
p = malloc(sizeof(struct foo));

plus a ton of other changes
>>
>>61985041
Then explain this, dimwit:
if (condition) {
// code
} else if (condition) {
// code
} else if (condition) {
// code
}
>>
File: 1432370571623.png (549KB, 838x1102px) Image search: [Google]
1432370571623.png
549KB, 838x1102px
>>61986017
>trusting faggots in language design
I feel pity for him to be honest.
>>
>>61986032
#ifdef __cplusplus
struct nu_voidptr
{
void *data;

template <typename T>
operator T*() { return (T*) data; };
};
#define malloc(x) nu_voidptr{malloc(x)}
#endif

where is your god now
>>
>>61986036
if (condition) {
// fuck
} else {
if (condition) {
// my
} else {
if (condition) {
// ass
}
}
}
>>
>>61986122
gladly
>>
>>61986122
>implying that complies
>>
File: 1502894681008.gif (66KB, 350x350px) Image search: [Google]
1502894681008.gif
66KB, 350x350px
>no windows xp support
What makes people drop old Windows support?
New Visual Studios don't support them?
>>
>>61986114
>macros
>>
Holy crap NetBeans font, what the actual fuck. How can people code using this, what....

my fucking eyes are almost bleeding

What the FUCK is wrong with Java-pajeets?
>>
>>61985174
You literally can't consider yourself better than your peers unless they use the tools you've built.
Until then, you're at best equal to them.
>>
>>61986122
if (condition) {
// fuck
} else {
if (condition) {
// my
} else {
if (condition) {
// ass
}
}
}
>>
>>61986114
yeah :^) but then you still haven't solved that assignment from void* to a type is legal (and commonly used) in C.

>>61986172
VS2013? dropped support for XP. They didn't want to continue to update the crt/msvcrt/libcmt/etc runtimes for it. So you can build it without a standard lib, get the SDK with the _xp tools in it. Or use mingw :)

(its the reason you need to all all those redists with games and shit, c and c++ target a specific runtime because of microsoft's view on ABI..)
>>
>>61986203
please attach the pic
>>
>>61986224
Better cast it just to be safe.
>>
>>61986224
> get the SDK with the _xp tools in it
Do they exist?
>>
>>61985951
You can't talk about C++ in a way that shows that you know what you're talking about without talking in C.
>>
File: Screenshot_20170819_225638.png (15KB, 698x596px) Image search: [Google]
Screenshot_20170819_225638.png
15KB, 698x596px
>>61986225
>>
>>61986064
I've been starting relating more and more with post Google Pike 2bh
>>
Trying to get fuking octave-mod to work on emacs.
>>
File: maybe.png (116KB, 1290x715px) Image search: [Google]
maybe.png
116KB, 1290x715px
>>61986263
sure. this is the latest version of VS released this week.
but you can search for, eg, vs2015 xp toolset (or v120_xp if you know the version..)
>>
>>61986280

Writing C++ like it's C is how you get some of the worst, most harmful C++ code.

So just the fact you've said this indicates that you are one of those shitty C++ programmers.
>>
>>61986383
isocpp and the core guidelines said to prefer never using new/delete. so I use malloc and free :^)
>>
help not make this shitty?
void parse_obj() {
FILE* obj_file;
obj_file = fopen("bull.obj", "r");
char c;
float v1, v2, v3;
vertArray* ptr_vert;
vertArray* temp_vert_ptr = NULL;
ptr_vert = (vertArray*) malloc(sizeof(vertArray));
int f1, f2, f3;
elemArray* ptr_elem;
elemArray* temp_elem_ptr = NULL;
ptr_elem = (elemArray*) malloc(sizeof(elemArray));
while (fscanf(obj_file, "%c", &c)!= EOF) {
if (c == 'v') {
fscanf(obj_file, "%f %f %f\n", &v1, &v2, &v3);
ptr_vert->v1 = v1;
ptr_vert->v2 = v2;
ptr_vert->v3 = v3;
ptr_vert->p_right = (vertArray*) malloc(sizeof(vertArray));
temp_vert_ptr = ptr_vert;
ptr_vert = ptr_vert->p_right;
ptr_vert->p_left = temp_vert_ptr;
}
else if (c == 'f') {
fscanf(obj_file, "%d %d %d\n", &f1, &f2, &f3);
ptr_elem->f1 = f1;
ptr_elem->f2 = f2;
ptr_elem->f3 = f3;
ptr_elem->p_right = (elemArray*) malloc(sizeof(elemArray));
temp_elem_ptr = ptr_elem;
ptr_elem = ptr_elem->p_right;
ptr_elem->p_left = temp_elem_ptr;
}
}
ptr_vert = ptr_vert->p_left;
free(ptr_vert->p_right);
ptr_vert->p_right = NULL;
unsigned int vcount = 0;
while (1) {
++vcount;//printf("%f\n",ptr_vert->v1);
if (ptr_vert->p_left == NULL) {
break;
}
ptr_vert = ptr_vert->p_left;
}
unsigned int fcount = 0;
ptr_elem = ptr_elem->p_left;
free(ptr_elem->p_right);
ptr_elem->p_right = NULL;
while (1) {
++fcount;//printf("%d\n",ptr_elem->f1);
if (ptr_elem->p_left == NULL) {
break;
}
ptr_elem = ptr_elem->p_left;
}
unsigned int i = 0 ;
float vertices[vcount*3];
while(1) {
vertices[i] = ptr_vert->v1;
vertices[i+1] = ptr_vert->v2;
vertices[i+2] = ptr_vert->v3;
if (ptr_vert->p_right == NULL) {
break;
}
ptr_vert = ptr_vert->p_right;
i += 3;
}

i = 0 ;
int faces[fcount*3];
while(1) {
faces[i] = ptr_elem->f1;
faces[i+1] = ptr_elem->f2;
faces[i+2] = ptr_elem->f3;
if (ptr_elem->p_right == NULL) {
break;
}
ptr_elem = ptr_elem->p_right;
i += 3;
}
}
>>
>>61986383
At least I know what the fuck I'm writing, bloatware fag.
>>
Can someone explain why C <math.h> functions ceil(x) and floor(x) have double argument and double result and not double argument and int result?
>>
>>61986477
ceil and floor do not convert arguments to integers.
ceil and floor round doubles to their respective whole value
>>
Is that image a meme or should I learn Scheme as my first language?
>>
>>61986524
it's a meme
>>
>>61985250
you could also just install VS on linux
>>
>>61986407 (You)
no shit, I cringe everytime I do something like this..

auto size = image->GetPropertyItemSize(PropertyTagFrameDelay);
auto item = std::unique_ptr<Gdiplus::PropertyItem>(
reinterpret_cast<Gdiplus::PropertyItem*>(
malloc(size)),
free);
image->GetPropertyItem(PropertyTagFrameDelay, size, *item);


..needed to reformat that so the ugliness can be seen..

>>61986477
beause the range of double is larger than an int? (what if your inputs are bigger than int?)
>>
>>61985250
Vim.
>>
>>61985250
What language? I'm using vscode on linux for C++ and it's pretty comfy.
>>
Lurking /g/ has killed my programming soul. Now I want to be a lawyer.
>>
>>61986877
Why?
/g/ helps me learn, desu.
>>
Anyone here that has used Rust that can tell me what the deal is with modules? I am having a hard time understanding what the language specifies as a module. It's not a namespace like in c#/java/php etc etc because it doesn't seem possible to have a module split over multiple files. Both the new and the old books are trash.
>>
>>61986172

There isn't really a legitimate reason to continue supporting a 16 year old OS. That's old enough to have sex with in my state.
>>
>>61986997
Someone already answered, or are you just shitposting?
>>
r8 my shitty memory allocator
https://pastebin.com/pzGKFTUF
>>
>>61987041
I asked that question in the previous thread and had 0 replies to it.
Just only now saw someone replied to it in this thread.

>>61985785
But If I want to split up stuff in that module into multiple files those files will be different modules.
>>
>>61986934
because I learned Java and /dpt/ constantly tells me that Java is a meme
>>
>>61987121
Wow, shame you used your one and only programming language brain slot. If only you could expand it and add a second one.
>>
>>61987121
The general rule is don't listen to any subjective opinion from /dpt/ (or in general 4chan) like that. Anonymity means any kid can come here and troll or give his shitty opinion.
>>
>>61987104
mymodule/
- mod.rs
- dicks.rs
- imafaggot.rs

was that hard?
>>
>>61986293
that's font hinting not being enabled in java: https://wiki.archlinux.org/index.php/Java_Runtime_Environment_fonts
cut your losses, learn emacs or use spacemacs
>>
Why does it say "fptr is not defined in this scope"?

I'm trying to take function pointer as argument

void func_ptr (const int &first, const int &second, bool (const int &val1, const int &val2) * fptr) {
std::cout << "Is First less than Second? " << std::endl;
std::cout << fptr(first, second) << std::endl;
}
>>
>>61987345
http://fuckingfunctionpointers.com/
>>
>>61987276
That still doesn't tell me what the language specifies what a module is.
mod.rs is module mymodule.
dick.rs is module mymodule::dick and
imafaggot is module mymodule::imafaggot.
>>
>>61985174
no
yes

everyone here is PhD or at least Masters and with ~10+ years of experience (Haskell shop)

I have like 2.5 professional exp and only Bsc

This is OK with me though, much rather work with smarter people than people I can't learn from.
>>
>>61987363

Oh shiet i forgot syntax
>>
>>61984897
>scheme
no production use
>idris
no production use
>shen
no production use

you know what production language does all three of things in that memefographic? javascript
>>
>>61987400
>Haskell shop
Lol
>>
>>61987104
For now yes, but they are thinking about reworking the module system so that each directory is one module with all files in the dir belonging to the module.
In the meantime you can do this to avoid long module::submodule::Type paths:
// In foo/mod.rs
pub mod bar;

pub use bar::Baz;

You can then use foo::Baz.
>>
>>61987390
Shit dude if you're that retarded and also completely illiterate as you're pretending to be, perhaps you should stick to qbasic.
>>
>>61987511
Excuse me?
>>
Why can't i just

auto val = delctype(function)* ?
>>
>>61987104
>>61987430
Made a mistake, last line needs to be:

pub use self::bar::Baz;
>>
>>61987570
... why would you can?
>>
How do you find motivation for coding? I had plenty of ot but I lost it when no one would want to employ me because they would want some college faggots who barely know how to hello word. I love to program and I'm good at it but when I don't get rewarded for it I lose all motivation. Currently I returned to being depressed NEET playing gayms all the day. I didn't touch my gentoo programing laptop for like 3 weeks right now. Help.
>>
>>61987589
You can start by KYSing.
>>
>>61987578

Why wouldn't i? It returns rvalue, doesn't it?
>>
>>61987570
Because a type can't be used as a value.
>>
>>61987616
Do you mean declval? When I print the AST decltype returns a type.
>>
>>61987651
>>61987648

Oh...fug
>>
>>61987427
shrug

funnily this came up in a meeting on Friday, people outside community basically don't see what's actually happening and how many places are actually using Haskell, whether exclusively or under the hood
>>
>>61987669
>how many places are actually using Haskell
Now imagine how many places are actually using other languages people talk about outside of /g/...
>>
>>61987669
so how exactly is haskell used in production?

are you clients /g/ users?
>>
>>61987589
Just go fix some issues on some open source projects on github
>>
>>61987701
Some websites have their backends in Haskell.
>>
>>61984897
What is even the point of shen? To bring completely unreadable function names to lisp? It's not even an independent language after all.
And clearly those aren't the only languages someone will need. Where are the soft-realtime and hard-realtime embedded systems languages? Scheme is a dialect of lisp but each implementation is radically different, you can't really say that scheme is a language nor that it integrates with guile emacs. Where are the scripting languages? None of them satisfy here: good file io, file processing (with various encodings over multiple filetypes such as json, csv, tsv, excel, conf, hdf5, etc.), string processing (cl21-style regex is a good example for that), native cross-platform os interaction (pipes, multiprocessing, command calls, abstractions), good amount of related libraries, etc.
>>
>>61987430
I read all of the reworking module system thread on the internals form and the rfc the now closed but none of the ideas they posted seemed to fixed the problem with modules which I find pretty funny.
>>
File: 1448039488470.png (152KB, 1194x810px) Image search: [Google]
1448039488470.png
152KB, 1194x810px
>>61987718
>do it for free
>>
What would be the ideal thread count for many small file I/O operations? Give each operation its own thread? Make the thread count equal to the number of logical cores?
>>
Thoughts on swift?
>>
>>61987888
i don't have a mac :(
>>
>>61987345
why not use an std::function?
>>
 
if (condition 1 && condition 2 || condition 3 && condition 4)
{
// code
}


this will only work if condition 1 and 2 are true or if 3 and 4 are true, right?
>>
>>61987798
b8/8
>>
>>61985003
>can't time with time
>gives up
Why are people like this? Just use rdtsc.
I never use time. It's a pointless inaccurate tool that serves no purpose for developers. It's an end user tool.
It's way less effort to use it than reading the time outputs he put there.
>>
>>61987877
1 per op seems like overkill, unless you're getting them out of a thread pool and reusing them. depends on how much "many" is and how small "small" is, you may be better off with something like select/poll or IOCP.
(and you should default to the OS async operations for IO anyway.)
>>
>>61987905
((condition 1 && condition 2) || (condition 3 && condition 4))

more readable and explicit in what you want it to do
>>
>>61987935
thanks
>>
>>61987935
((condition 1 && condition 2) || 
(condition 3 && condition 4))
>>
>>61987905
http://en.cppreference.com/w/c/language/operator_precedence
Yes. Since OR has lower precedence.
>>61987935
If you're gonna use parenthesis like this use whitespace to group the expressions as well.
>>
>>61987684
Okay. I didn't say that's not the case. It's certainly nowhere near as popular as those other languages. I was just replying to a silly remark.

>>61987701
Clients are various. Currently have project for pharma company (won't say which one but let's say in top 5 of the biggest pharma companies by revenue on wiki), data analysis company (cool project with differential privacy here actually), involved in SAGE (EU contract), helping a startup out (just looked up, they got 5.5 mil USD investment so I guess they can afford contractors; actually doing second project for them too), recently-ish finished contract with certain big storage manufacturer; I know some Chinese HFT company potentially wanted services too but I think that fell through (and they wanted some crazy things I don't think we could give them) and a few others around. Plus whatever the boss has lined up which I don't have view into anyway.

>>61987719
Actually I don't know any Haskell place that has their user-facing site running on Haskell (I guess FPCO might but I'd have to ask). I don't know why really. I mean we use warp in a product but that's not the same. By under the hood I meant that often you'll see some well known company (or not so well known) put a package up on Hackage. Recently I learned soundcloud is using Haskell though I've been told they are firing people like crazy (in general, not Haskell yet but who knows) so I wouldn't exactly advise applying there ;^). Tons of Russian companies use Haskell in-house but you basically have to know someone to find that out.
>>
>>61987953
((condition 1 &&
condition 2)
||
(condition 3 &&
condition4))
>>
>>61987896
I have an old 2012 mac mini and I was planning on using it to do stuff in swift.
>>
>>61987877
Depends on what you're doing. And what the pressure is on the IO ops.
Since you're asking so vaguely it likely doesn't matter.
>>
I'm learning C# on my own and starting a course next month. I obviously have no professional experience coding.

What does work of a team of programmers look like? Do you ask each other how to do stuff (what code to use to make the program do what you want) or is it more like 'you do this, you do this, and I'll do this and this. See you tomorrow.' and then everybody is off to their computers with no cooperation?
>>
>>61987991
>I was just replying to a silly remark
I understand you end up getting pissed.
>>
File: kek.png (154KB, 1919x1023px) Image search: [Google]
kek.png
154KB, 1919x1023px
I should be asleep already but i'm just sitting here and writing some autistic useless code for practice.
>>
>>61987921
Because when I was measuring one program running 6 seconds and another running 45, I don't need a more precise tool. I don't care for small n so I won't spend time into properly timing it.

time is an end-user tool, you are correct. In this case that's exactly what I needed.
>>
>>61988017
SIUE? About to start the same sort of course, software engineering with C#. Anyone tell what this class is like at all?
>>
>>61988025
Hm? What am I pissed about?
>>
so how does CMake work?
If I give a CMakeLists.txt with the source files, all I need to do is type cmake && make and the code can compile anywhere?
>>
>>61988017

Nah, just a regular programming course outside college system. I live in Europe.
>>
>>61988033
so you fixed your comparer for the set?
>std::set<std::string> {}
oh, I see. but since you're using C++, why not use std::function instead of the hideous C function pointers?
the syntax is pretty straight forward:
std::function<bool(std::string, std::string)> fn;
>>
>>61988113
because std::function performs like garbage
>>
>>61988083
>and the code can compile anywhere?
Sort of, cmake has generators for different build systems, by default it generates gnu make files, but it can also generate visual studio solutions and shit.
But yes, as long as your cmakelists is properly made, and your code is system agnostic, it can generate build solutions for most popular systems
>>
>>61988097

This was an answer to this

>>61988050
>>
>>61988117
..as a function parameter. it'll compile down to the same thing as that functor. if you're creating a std::function, then yes. its pretty bad (always use a lambda over it). but using it as a type doesn't denote any different performance characteristics.
>>
>>61988035
But you found the 2 seconds it takes to get the rdtsc at two points and subtracting them too much?
Sounds more like you're biased. Or maybe getting a time stamp counter in haskell is stupid difficult. But surely it's not.
>>
>>61988113
>std::function<bool(std::string,std::string)>

(String, String) -> Bool
>>
>>61988017
Depends on team. Mostly latter but you definitely ask stuff too. You don't ask how to write a for loop obviously but ask why existing code was written in such and such way, if anyone knows good libs for this or that, ideas if you get stuck &c. Just don't pester people with incompetence and you'll be fine.
>>
>>61988156
>it'll compile down
I'll never comprehend people who trust C++ compilers abilities. Sounds like dogma to me.
>>
>>61988158
I know you're baiting but all that stuff was in /tmp and I can't be bothered to go back and get it. If you care so much just do it yourself? All code was posted.
>>
>>61988158
>>61988204
and before you run your mouth, rdtsc is available (https://hackage.haskell.org/package/rdtsc-1.3.0.1/docs/System-CPUTime-Rdtsc.html) and used in multiple benchmarking/timing libs so knock yourself out.
>>
>>61988204
>if you care so much
I don't care at all about this particular example. But the situation I see here leads to poor understanding of facts. That bothers me. And time encourages this behavior I suppose. I should be more vocally opposed when people use it.
>>
>>61988123
thanks, I was in doubt about that
>>
>>61988233
>before you run your mouth
Wow dude. I was just fucking asking. Taking it for granted would be silly. What's with the aggression?
>>
How come sepples templates don't fuck up the linkage?
Suppose in a header I define a function template like
template <typename T>
T add(T x, T y) { return T + T; } ;

Then suppose I instantiate add<int> in two different compilation units. Shouldn't that cause a duplicate definition error?
>>
>>61988360
return x + y;

obviously
>>
>>61988261
My bad I guess.

>>61988235
Fact was that for any non-trivial n, the difference was huge enough to be easily demonstrated with time. Also that the C program was incorrect to begin…
>>
>>61988360
template functions are implicitly inline
>>
File: JUST.jpg (27KB, 600x424px) Image search: [Google]
JUST.jpg
27KB, 600x424px
>tfw several months into studying for the OCP

Kill me.
>>
>>61988413
will a good compiler remove all the duplicate emitted add<int> functions?
>>
>>61988196
if you can't trust the compiler abilities, then how do you know that a functor is faster than an std function? since you're bringing up dogma, and distrust. can you explain how the standard handles function pointers? and pointer to member functions?
lets walk our way through some of this logic.
>>
why is C so restrictive?
all i want to do is build a variable length array and return a reference to it.
>>
File: images(11).jpg (6KB, 255x198px) Image search: [Google]
images(11).jpg
6KB, 255x198px
Is there any advantage to using R over Python/Matlab/Excel? The graphics look nice (much better than Matlab and Excel equivalents), but I can't think of any other reason.
>>
>>61988508

What's the problem
>>
>>61988508
you can though
return malloc(n * sizeof type);
>>
>>61988413
also this
>If a template, a member template or a member of a class template is explicitly specialized then that specialization shall be declared before the first use of that specialization that would cause an implicit instantiation to take place, in every translation unit in which such a use occurs; [...]

>>61988495
and nevermind about this. I didn't see the time. but tl;dr its how the standard defines things like std::is_bind_expression and what is and what isn't a callable object. and how you'll use std::decay along with std::forward.
>>
>>61988508
it's a feature ;^)

really though, it is but if you want convenience, either use a library if you have to stay in C or pick a more programmer-friendly language

>>61988512
R has loads of very optimised data analysis/num libraries

Great reason to use Haskell with HaskellR/inline-r!
>>
>>61988520
i want to parse an .obj file and build an array of vertices and an array of faces without explicitly knowing how many verts and faces are in the .obj file ahead of time.
then i want to return references to those arrays so i can fuck around with it in opengl.
>>
not sure if this is the right thread to post, but I want to take up coding/programming as a hobby, where to start? (and preferably not to pay for any courses/books)
>>
>>61987589
Go outside, take a walk, and recharge your focus.
>>
>>61988512
I prefer R to Python + Pandas because the entire language of R is designed around dataframes, whereas it is slightly more awkward with Python. When you start doing bigger data mining Python gets irritating. Also knitr is god-tier.

Matlab and Excel (kek) are for entirely different things.
>>
>Function subprograms allow us to remove from the main function the code that provides the detailed solution to a subproblem.
I read this statement 10 time and still don't understand what it's trying ti say.
>>
>>61988591
>Excel (kek) are for entirely different things.

Sadly some people don't seem to think so. A certain massive credit scoring company recently said (privately, in requirements gathering) that they would like to be able to load 100k rows into excel if they could. They later came back saying they would like a million.

AFAIK excel limits the rows to 80k and they regularly load that much data in to process it.

Some people just can't be helped.
>>
Kernel style or GNU style?
>>
>>61988636
he just means breaking the code up and not having it all in one place
>>
>>61988679
neither, but kernel style is better
>>
>>61988679
What sort of question even is this?
>>
>>61987589
>I love to program
>but when I don't get rewarded for it I lose all motivation
Then you don't love to program.
>>
>>61988695
What do you use? Your own style?

>>61988697
Your preferred C code formatting.
>>
>>61988467
most likely, yes
>>
>>61988508
but you can do that
>>
>>61988679
>GNU style
Anything but
>>
>>61988752
Yep.
>>
>>61988752
>Your preferred C code formatting.
Yes, obviously, but who the hell would even consider the GNU style?
>>
>>61985250

>Using Linux here, i read that NetBeans gives best VS like experience

maybe switch to windows then you fucking genius
>>
Anyone here using .NET Core on Linux?
>>
>>61988836
No, dumb microshill poster
>>
>>61987918
One of the problems they have is all the facades they use because every file is their own module. the other one is both mod and use keyword having 2 usages.
>>
>>61988836
I wanted to use it on Windows but I made the ~ folder read only so it can't create any of the shitty .{ebola} folders.
>>
>>61988943
when was this picture taken?
>>
>>61984944
>>61986036
>>61986122

>C brainlets will never know the simplicity of
 
condition ? fuck : my : ass
>>
>>61988960
probably after he nearly had a heart attack screaming at BRs
>>
>>61988960
The day freedom died
>>
Does there exist a language which embeds code among lines of text?
Let's say:
{for i = 99 downto 0}
{ i } bottle{if (i >1) then [s]} of beer on the wall, { i } bottle{if (i >1) then [s]} of beer.
Take one down and pass it around, {if (i > 2) then [{i-1}] else [no]} bottles of beer on the wall.
{next}

Code is written in curly brackets, and if something needs to be printed within code, it is put in square braces.
I think there must exist something similar?
>>
Is their an Ada compiler that isn't some tacked on GNU piece of shit?
>>
>>61988982
and youll never know how to write a ternary apparently.
>>
>>61988982
There is ternary operator in, dumbfag.
>>
>>61988999
mixins?
Yeah they exist.
>>
File: 1497064248690.jpg (335KB, 700x910px) Image search: [Google]
1497064248690.jpg
335KB, 700x910px
>>61989024
>mixins
>>
>>61989041
good mixins exist.
>>
>>61989024
Those aren't mixins.
I think of some report language.
In my example, this text could become 99 bottles of beer (except of last two lines).
>>
>if you dynamically load shared library into C the functions go in global space
Is that really necessary though? You just get the function pointer to the function with dlsym so the function name doesn't matter.
>>
>>61989059
yeah, i reread it and realized, seems unnecessary and would only serve to muddy up code in my opinion. Would also be a nightmare to refactor.
Keeping your prints separate became the norm for a reason.
>>
>>61988999
The closest thing to this is probably templating languages, like what's used for web development. They can look something like this (Jinja):

<!DOCTYPE html>
<html>
<head>
<title>{{ variable|escape }}</title>
</head>
<body>
{%- for item in item_list %}
{{ item }}{% if not loop.last %},{% endif %}
{%- endfor %}
</body>
</html>
>>
Working on my bare metal RTOS for an ARM Cortex-M0 uC

No libraries, no CMSIS, no FreeRTOS
Just hundreds of pages of documentation
>>
File: Brady-TDDI-HI.png.jpg (133KB, 720x903px) Image search: [Google]
Brady-TDDI-HI.png.jpg
133KB, 720x903px
Anyone got a PDF of picrelated they can share?
>>
>>61989185
dont bother, its a dead lang
>>
>>61989185
just buy it desu
>>
File: 1502639055616-fit-1-1.jpg (17KB, 158x163px) Image search: [Google]
1502639055616-fit-1-1.jpg
17KB, 158x163px
>scheme
>clojure
>haskell
Oh you mean bargain brand lisp?
>>
>>61989184
I'm interested in doing something like this.. what's the time investment look like?
>>
>>61989418
>He uses C++ommon Lisp
>>
>accidentally discovered that you can hold Alt and use up and down arrows to move lines

That's fucking neat. Is there a list of keyboard commands like this somewhere?
>>
>>61989478
The common lisp standard hasn't changed since 1994 unlike sepples.
>>
>>61989525
What editor are you even talking about?
>>
>>61989536
Just because something hasn't been updated it doesn't mean that it isn't shit.
>>
>>61989538
I did that in CodeBlocks but wouldn't it work in any text editing program?
>>
>>61989478
>C++
Calm down Bjarne Strous-cuck we're talking about real high level languages not some ugly hacked together assembly vomit.
>>
>>61989583
not necessarily
>>
>>61989596
Sounds like C++ommon Lisp to me. Unless you were talking about some other Lisp?
>>
File: xpr_lpc1114_banner.png (215KB, 501x322px) Image search: [Google]
xpr_lpc1114_banner.png
215KB, 501x322px
>>61989444
I'm pretty much a beginner to OS development, so I'm going pretty slow.
It took something like 3 evenings to get to this point, a makefile, a few basic functions such as memcpy and some bootstrapping for this particular CPU.
Tomorrow I'm going to try to get the UART to work and get the kernel to print something, but a memory allocator is also important.

You have to know about CPU architecture and a little bit of electronics.
The Cortex-M0 is very simple, once everything works I want to move to a better CPU with a hardware MMU.
I don't even want to think about multi-core yet.

The OSDev Wiki, ARM and NXP docs, Linux, NetBSD and glibc code are very useful and a little bit of Google-fu doesn't hurt either

Pic related, it's the dev board I use
>>
File: lexer.png (122KB, 1368x794px) Image search: [Google]
lexer.png
122KB, 1368x794px
Writing an interpreter for PIC16XX ASM.
>>
>>61988769
but you can't.
>>
Question: I know function pointers can be slow, but if there's a const function pointer can't it be optimized down to the level of any other function call?

I was just thinking about it in the context of C-style polymorphism.

inb4 just use C++. I already do.
>>
>>61989525
Hold ctrl and use arrows to skip around in words and lines. Hold ctrl+shift and do the same to mark words/lines.

That's pretty much universal.
>>
File: unnamed.png (233KB, 583x360px) Image search: [Google]
unnamed.png
233KB, 583x360px
Hi /dpt/,

What's your way of getting /comfy/ and learning? I'm having major trouble keeping at it, not that I have ADD, just that I'm in a bad situation and have problems caring about anything.

I'm starting with very very beginning python using a stone river package I bought a long time ago, but I've looked at google and microsoft's free courses too. At the moment I have no objective other than finding a job without having to move (95% sure I'd have to for my current career)
>>
>>61989525
If you think that's neat, try vim (or vim bindings)
>>
>>61990079
Don't use C++.
>>
File: Capture.png (89KB, 1366x768px) Image search: [Google]
Capture.png
89KB, 1366x768px
>What are you working on, /g/?
Trying Windows development for the first time
>>
What is the obsession with "Hello World!"? that shit is starting to get on my nerves
>>
>>61990139
sorry, but I enjoy getting actual work done

>>61990108
try being more gritty. The most enjoyment I've had comes from hard work.

>>61990154
Hello, World!
>>
>>61990190
How is initialising a variable 10 different ways "getting actual work done"?
>>
>>61990079
>const
Const doesn't matter for optimization at all pretty much. It's a syntactic convenience. The reason it doesn't matter for compiler optimization (and optimization in general) is because the compiler can always const cast away.

There's like one or two exceptions which I don't remember. Something to do with global scope I believe.

I imagine it's possible that the compiler will inline your call if you set the pointer to a known (internal linkage) function just before you call it or on a path where it can see you haven't changed it from the static assignment you're doing. But that's guessing. I'm confident they could do it within the constraints of the language but you never know if they're efficient at that stuff.

You'll probably have to accept that you're gonna take the call and the late instruction fetching in most cases.
>>
>>61990207
There's infinite ways to make a sandwich
>>
>>61990154
It's just a trope. It's a pretty good starting point for most languages. As IO is vital for any computations.
I find "Hello [name]!" is better though.
>>
>>61990108
Just start with the java courses at mooc.fi
>>
>>61984897
How do I write useful code rather than simpleton command line programs that plan trips ?
>>
>>61990326
Define "useful".
>>
>>61990108
>not that I have ADD
I do. It's very painful. I have so many interesting ideas and a massive inability to follow through. I write so many starts and usually get up to something I could consider a minimum viable product and then a just quit. I've struggled hard with continuing and it's stupid hard despite there being no difficult problems usually.

Gonna go get amphetamines soon. Hope they help.

From my pov you should just acquire the knowledge you need to get by for making the first thing you desire to make and then go do it as fast as possible. If you don't struggle the way I do then you should be able to learn a lot from getting there and completing the project. Don't be afraid to look up strategies for dealing with things. /dpt/ is very happy to answer questions where the problem is well explained.
>>
>>61989004
plz help
>>
>>61989788
why pic? seems everyone nowadays are moving to atmel. pic, from what I've experienced are only popular with older people.

also, thats pretty awesome. are you going to have a visual for the i/o pins?
>>
>>61990505
>everyone nowadays are moving to atmel
as far as i can tell, everyone is moving to ARM
>>
>>61990292
That's probably one of the most retarded justifications for C++'s ungodly amount of bloat I have ever seen.
>>
>>61988508
figured it out
passed the address of the first value of the array back (along with the size) and just incremented the pointer
>>
>>61990528
ARMs are waaay above the level tjat PICs and Atmels are used for.

ARMs are full blow CPUs, while PICs are just (14-bit in his case) microcontrollers.
(think: something to control the LED COB in one of those new lightbulbs.)
>>
>>61990591
ARM cortex-m is for microcontrollers
>>
>>61990458
Thanks, good luck with the meds.

Sometimes I do wonder if I have some form of ADD, but mostly I think it's just that nothing has worked out professionally for me even after a master's degree, so I never trust investing my time into anything.

>>61990307
what are the advantages of this particular site, and why start with java? Thanks for the suggestion.
>>
>>61990505
My university insists on using it. So I'm doing this as a display or superiority to the rest of the class.
>>
>>61990505
>>61990505
>also, thats pretty awesome. are you going to have a visual for the i/o pins?
Yeah. That was the idea. Also it should be able to generate diagrams of the code - that'll save me dozens of hours in report writing over the next years.
>>
>>61990564
Sounds like a good way to corrupt memory, there, anon.
>>
>>61990732
you got a better solution?
>>
>>61990732
indeed. why is that function creating memory and returning it? is it malloc? why isn't he passing it in? (like every other C programmer would. buf, size is a very common argument list)
>>
>>61990745
Considering i don't know your problem, I can't help. Perhaps actually learning the ins and outs of the language would be beneficial.
>>
>>61990779
i've been working on this problem for about a day now.
there really is no other way of doing this in C.
besides the memory should be fine.
>>
I'm in the process of running my own Linux server off my router (rather than paying for a server in the cloud). Thinking of moving all my more important side-projects into a mono-repo. They're mostly made in OCaml, Go, and Node.

I have a beefy laptop with Ubuntu installed I am considering running the apps on but honestly I'm more leaning towards moving everything to a more capable language and running the apps on my Rasberry Pi. Elxir? Go? I'm looking for max requests served per second.

What language should I go with? Not willing to consider C/C++.
>>
File: output.webm (715KB, 1920x1080px) Image search: [Google]
output.webm
715KB, 1920x1080px
Aaaaand we have a blinking LED on day 4
>>
>>61990818
doesn't the tutorial have a blinking led example?
>>
>>61990818
oh my god that's awesome. why reinvent the wheel though? just to get a better understanding of ARM?
>>
File: 1493934512902.gif (1MB, 328x198px) Image search: [Google]
1493934512902.gif
1MB, 328x198px
>>61990818
>on day 4
>>
>>61990827
Yes, but it uses CMSIS

>>61990844
Pretty much. I've been wanting to get into OS development for a long time and I want to understand every part of the hardware and the software
>>
>>61990439
> useful

As in something people would use.
Like what is there to do, what projects to work on, what is needed, what is wanted.
>>
>C++17 literally added a whole filesystem library from BOOST
And there are people who think boost isn't std::beta
>>
>>61988679
Mozilla style with clang-format
int&
card_value(const card* this_card)
{
return this_card->rank + 2;
}
>>
>>61990910
its pretty obvious. especially when a lot of the standard lib designers and implementers are also part of boost.
and thats what boost is. its a playground to test new features for the upcoming standards. and its literally in their mission statement

where do you think the smart pointers came from?
or <thread> or half of the stuff added to <functional> in C++11. TR1 was basically porting very useful (and much needed) boost libs to the standard.
(not to mention: tuples, regex, type traits, the modern PRNG, or things no one uses like std::map / unordered_map / set / unordered_set..)

what about std::variant, std::any and std::optional for c++17?
what about the upcoming network TS? (asio and beast)

but.. generally there are differences from the boost version and the standard version.
>>
How much should you realistically be expected to know how to do in any one language to be hired for an entry level job programming in that language?
>>
>>61991059
atleast 10 years experience in rust
>>
>>61991059
I mean anything above a hello world in visual basic will atleast set you ahead of the pajeets
>>
is there any equivalent of format in C++?
use std::fs::File;
fn main() {
for i in 1 .. 200 {
File::create(format!("CH{:003}", i));
}
}
>>
>(defvar z 4)
>z
4
>(defvar ls '(x y z))
>(caddr ls)
z

How do I make this do what I want?
>>
File: sicp.jpg (108KB, 600x600px) Image search: [Google]
sicp.jpg
108KB, 600x600px
professional Lisp programmer AMA
>>
>>61991121
What is it you make commercially?
>>
>>61991106
sprintf?
>>
>>61991106
iostreams (hilariously overengineered)
or using a library like fmt: http://fmtlib.net/latest/index.html
or use the c *printf functions
>>
>>61991145
Thanks, but it feels like it's taken from the stone age. But I guess it does the job.
>>
>>61991121
1 or 2
? or p
[ or (
... or gensym

>>61991115
> (defvar list-of-vars (list x y z))
> (caddr list-of-vars)
4
> (devar list-of-syms '(x y z))
> (eval (caddr list-of-vars))
4

>>61991106
In order of high-level-but-bloated to low-level-clike
> boost format library
> std::stringstream
> mutable std::string
> sprintf
> mutate a char array manually
>>
>>61990798
what the hell are you doing
>>
>>61991188
yeah but try returning them.
>>
File: lambda_cube.png (6KB, 321x294px) Image search: [Google]
lambda_cube.png
6KB, 321x294px
>>61991142

did contract work on systems automation for large government and private data systems, right now my business is in publications drafting automation and human-computer interaction hardware

>>61991191

>1 or 2
2 but most of my code is in 1

>? or p
I like p, I use ? for functions that make database reads

>[ or (

Clojure's collection facilities are nice but the language environment and community are pretty terrible, the custom Lisp I use has other non-standard sexp delimiters like [
>>
>>61991059
Judging from my colleagues:

>US coworkers
You need to have internships + several large relevant projects in your github coming out of university or an advanced degree.
>Pajeet
You need to know what git is and how to deeply nest conditionals and loops unnecessarily.
>>
>>61991264
You prefer lisp-2?
Also does your lisps' [ have semantic meaning?
>>
>>61991121
How many of you are there? I've met one person in 20+ years who used Lisp in a professional setting (non-academic). Extremely jealous to be honest.

t. C++slave
>>
why doesn't C++ provide a log(n, b) overload? it only provides a log2, log10, log e and log e+1. surely they could provide an overload that does log10(n) / log10(b)
template <typename T>
T log(T n, T b) { return std::log(n) / std::log(b); }

I just spent more time than required reading through the docs for both <complex> and <cmath> to see that they didn't have an overload for this.
>>
>>61991311
They don't need to include it so they didn't. Besides if you have a constant base, its in your best interest to compute 1/log(b) beforehand, an optimization that your code probably isn't able to do
>>
File: lisplogo.png (29KB, 811x805px) Image search: [Google]
lisplogo.png
29KB, 811x805px
>>61991288

>Also does your lisps' [ have semantic meaning?

yes custom delimiters for different reader or macro contexts

>>61991306

most of the openings I see are in California or Boston for old Lisp systems, or Clojure gigs, many AI companies look for Lisp programmers too

the best way to introduce Lisp into your professional life is by automating your non-lisp work with Lisp, then getting freelance or consulting work with a Lisp product portfolio you build from that, in my case it was distributed data systems and 3d animation

to be honest I have never met another professional Lisp programmer, in person, that wasn't using Clojure
>>
File: C++ : redundant include?.png (43KB, 1600x1200px) Image search: [Google]
C++ : redundant include?.png
43KB, 1600x1200px
How does #include work? Does it blindly paste the entire source into a file? Or does it paste only the part of source that which is required if necessary?
>>
>classes starting up again

who else /ready/ for influx of retards asking "How do I make a variable in java"
>>
>>61991311
>why doesn't C++ provide ...
because fuck you that's why
>>
>>61991424
The first. It's called a translation unit if you wanna google more btw
>>
>>61991459
>tfw you your masters last week
>tfw done with school forever
>>
>>61991459
Are you implying the current state of dpt is any better?
>>
>>61991424
it literally just inserts the file. but you can tell the cpp (C Preprocessor) to ignore files with macros.
#ifndef WOW__NO_MODULES // any name will work.
#define WOW__NO_MODULES
// code goes here
#endif /* WOW__NO_MODULES */

if it hasn't seen WOW__NO_MODULES yet, it'll define it and include the code. but the next time it'll skip over it

(things to look up: include guards and whether you can use #pragma once and the modules TS. unless of course you're using C (picture strongly implies C++), then get used to typing that out, or making a macro in your editor.)

but yes, as states >>61991543 look up translation units. (it'll make understanding the whole compiling procedure actually possible).
>>
>>61991578
also to add some (ab)uses for it. I use it outside of c and c++ for doing things that I should really be using m4 or t4 or some other macro language for.

like I use it for writing notes, I have a header.inl that provides some boilerplate, and does some stuff with macros inside of it. so..
>cpp -P -H $HEADER $OUTPUT
or you could do it with gcc..
>gcc -C -E -H -P -nostdinc -undef -x c $HEADER -o $OUTPUT
>>
File: Iamconfuse.png (39KB, 808x662px) Image search: [Google]
Iamconfuse.png
39KB, 808x662px
Any regex/ASM guys here who can tell me how to distinguish functions and labels? My current regex registers all text as a label (so, PORTB, PORTC, etc.) how is this normally dealt with?

I can't seem to find a rigid definition of ASM labels.

This is for a PIC16F87XA controller btw
>>
>>61991945
if you are keeping whitespace, just check for ^([A-Z]*)\s* which'll get anything YELLING at you starting at the beginning until the first whitespace.
>>
Almost time for another new thread guys

Better make it a good one
>>
>>61992070
No thanks
>>
New thead

>>61980634
>>61980634
>>61980634
>>
>>61989418
Scheme is the only good lisp dialect desu senpai. Cuckmon lisp doesn't have proper functional programming support because of the lisp2 meme after all, on top of being bloated as fuck.
>>
>>61992121
Hilarious.

Actual new thread here:
>>61992323
>>61992323
>>61992323
>>
$ cat branchless.c
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int max1(int x, int y) {
return (x > y) ? x : y;
}
int max2(int x, int y) {
return (-(x>y) & (x^y)) ^ y;
}
int main() {
srand(time(NULL));
for (int i = 0; i < 1000000; i++) {
printf("%d", max1(rand(), rand()));
printf("%d", max2(rand(), rand()));
}
}
$ gcc branchless.c -std=c11 -O2
$ objdump -d a.out
[...]
0000000000400660 <max1>:
400660: 39 fe cmp %edi,%esi
400662: 89 f8 mov %edi,%eax
400664: 0f 4d c6 cmovge %esi,%eax
400667: c3 retq
400668: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
40066f: 00

0000000000400670 <max2>:
400670: 31 c0 xor %eax,%eax
400672: 39 f7 cmp %esi,%edi
400674: 0f 9f c0 setg %al
400677: 31 f7 xor %esi,%edi
400679: f7 d8 neg %eax
40067b: 21 c7 and %eax,%edi
40067d: 89 f8 mov %edi,%eax
40067f: 31 f0 xor %esi,%eax
400681: c3 retq
400682: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
400689: 00 00 00
40068c: 0f 1f 40 00 nopl 0x0(%rax)
[...]

>muh optimizing compiler
>>
I'm looking for a small fun project to do in C++, C# or more Perl. Ideas?
>>
File: g projects 2.png (378KB, 1450x1080px) Image search: [Google]
g projects 2.png
378KB, 1450x1080px
>>61994144
Go crazy.
>>
>>61994191
Thanks!
Thread posts: 316
Thread images: 29


[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.