[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 | | 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: 339
Thread images: 28

File: DPT.png (389KB, 934x1000px) Image search: [iqdb] [SauceNao] [Google]
DPT.png
389KB, 934x1000px
Old thread: >>61784776

What are you working on, /g/?
>>
File: anim haskell.jpg (56KB, 480x480px) Image search: [iqdb] [SauceNao] [Google]
anim haskell.jpg
56KB, 480x480px
>>
Learning category theory/type theory with purescript
>>
>>61792980
Is there a Scheme-tan?
I will also accept a Lisp, but it's not ideal.
>>
>>61793013
You should learn how it relates to logic as well
>>
>>61793058
>You should learn how it relates to logic as well
That's redundant. All type theory textbook has to cover the relation, and you can't even have type inference without proof theory.
>>
Found a trivial challenge in a codeshare posted a little while eariler.

>Write a program that asks the user for a number n and prints the sum of the numbers 1 to n
>Modify the previous program such that only multiples of three or five are considered in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17

A little bit of background knowledge in math should suggest that the answer to the first part of the problem is to simply calculate n * (n+1) / 2, and the problem is solved in O(1) time. For the second part, however, I found an interesting approach. The sum of all multiples of k in the range 1..n inclusive is calculated as follows:

1. let p = n / k
2. let q = p * (p + 1) / 2
3. Return q * k.

Essentially, we are dividing the summation of multiples by k to get a sum of 1..n/k, re-applying the sum formula, and then multiplying by k again. From this we create a function
static inline unsigned
sum_multiples(unsigned n, unsigned k)
{
unsigned p = n / k;
unsigned q = p * (p + 1) / 2;
return q * k;
}


And then we just sum all of the multiples for 3 and 5 and subtract their union (multiples of 15).

unsigned total = sum_multiples(n, 3);
total += sum_multiples(n, 5);
total -= sum_multiples(n, 15);


I am bored. The codeshare was here:

https://codeshare.io/2j4bpK

Someone make it alive again.
>>
>>61793077
Consider a multi-valued path config, much like LD_LIBRARY_PATH? You'd need to factor in a resolver but a simple one shouldn't be too hard even in C. How many files are we talking, and are there subdirectories that might need to be enumerated and unioned?
MY_CONFIG_PATH=/home/pajeet/project/faggot/client_configs/:/home/pajeet/project/faggot/configs/:/etc/configs faggotd --port=9000 ...
>>
>>61793162
Hm, I don't quite get the point. I hate it when I use a program and want to manually change some config files, but the files are not in the directory of the program. I just want to have something that does not need an installer - a simple directory you pass around. So everything, like the .so files and the config files will be in the directry that the executable lies in.
>>
File: 1500261898309.jpg (197KB, 935x799px) Image search: [iqdb] [SauceNao] [Google]
1500261898309.jpg
197KB, 935x799px
How's your Haskell learning going, anon?
>>
>>61793517
Bit anon, I'm learning to be a wizzard, not a mathutist
Otherwise pretty good
>>
File: sicp2-07ad7dbe.jpg (144KB, 476x409px) Image search: [iqdb] [SauceNao] [Google]
sicp2-07ad7dbe.jpg
144KB, 476x409px
>>61793536
*but
Ofc I forgot the pic, I'm tired
>>
>>61793517
Bretty gud. I got kinda used to reading Core and maybe am ready to dwell into GHC's fuckhuge codebase.
On the other hand I'm still unemployed and these Haskell timesinking sessions obviously don't help but I just can't stop obsessing over it.
>>
>>61793146
what? it's just interesting
>>
>>61793554
You can't learn type theory without knowing about the Curry-Howard correspondent anyway, because every type theory book covers the topic at least at a high enough level to bullshit your friends that "hurr computer programs are constructive proofs of mathematical theorems", that's why the other post said that it's redundant.And yes you also can't even learn type theory without logic and proof theory.
tl;dr just open a fucking textbook and stop bullshitting about things you don't actually understand.
>>
>>61793591
what the fuck is your problem

i mean actually investigate these fucking things man, did you know that reversed composition is transitivity for (->) ? No? Pick up a textbook nigger
>>
>>61793617
>transitivity
You mena transitive. And compositions in general are transitive relations. What's even your point?
>>
>>61793617
You know, if you said something like ``continuation passing styles are double refutation'' or something I'd actually buy your bullshit man.
>>
File: 1502107055168.png (61KB, 724x810px) Image search: [iqdb] [SauceNao] [Google]
1502107055168.png
61KB, 724x810px
C# is the most versatile language.
>>
>>61793663
Java >>>>>> C#
shit >>>>>>> Java
ACADEMIC QUALITY CLOSED TRANSITIVE RELATION[/cpde]
>>
>>61793636
transitivity is the state of being transitive, composition is a proof of transitivity, it isn't "transitive" because transitive is an adjective and not a noun
>>
>>61793681
Because your "transitivity for (->)" doesn't even make sense. So you mean, yeah, function composition is the proof that (->) is a transitive relation? What's the big deal when this is such a direct and basic result that it's usually given as a textbook (no pun intended) example of program-as-proof-for-type concept?
>>
>>61793714
What do you mean? It's interesting to work with this stuff and mess around with types.

id is reflexivity for (->)
(this and transitivity applies to all categories)

Reflexivity for Const would be (forall a. Const a a), which is isomorphic to (forall a. a) which is Void, so you can write these things in typecheckers, it's a proof that const isn't reflexive
>>
>>61793714
>>61793739
Eh, on the second thought, I think I actually get your point now. I guess you read about this example in some blog and found it cool and started to want to know more about type theory. That's great I guess, already much better than the common uncurious, theory-dismissing """programmers""" in fact.
>>
>>61793160
This is laughably trivial in Ruby

puts 1.upto(Integer(gets)).inject(:+)
>>
How is Haskell better than Lisp or Scheme?
>>
File: typeshit.png (45KB, 545x806px) Image search: [iqdb] [SauceNao] [Google]
typeshit.png
45KB, 545x806px
>>61793755
I did this sort of stuff when messing around writing type checkers, I was doing it for Iso because that seemed obvious but then I realised it could be generalised.


>>61793779
Strongly typed, pure.
If you don't like that stuff then you won't think it's better.
>>
>>61793827
What does it mean to even be pure?

Also, does SICP teach you about making your own compiler?
>>
>>61793837
I haven't read SICP, and purity means no side effects, referential transparency, (very pure) no mutability, etc.
So your effects are encoded in your return type
>>
>>61793837
>What does it mean to even be pure?
To to precise, "referentially transparent". That means you can substitute for example (f a) with its definition without changing the program's semantics. That means (f a) doesn't have any side effect: mutating shared memories, doing IO, nuking New York etc..
>Also, does SICP teach you about making your own compiler?
The bulk of the book is about writing different evaluator (read: interpreter) for different model of computation, and it does touch code generation in the last (I think) part of the book, after implementing the register machine.
>>
>>61793837
>What does it mean to even be pure?
Fun and interestimg to wotk with, but very unporducive in most areas.

> Also, does SICP teach you about making your own compiler?
Kinda, but not really. It teaches you about a scheme interpretter. It's still worth a read tho
>>
>>61793876
>>61793884
A pure language seems very resource intensive since you have to reproduce a new object every time you perform a mutation on it.
>>
>>61793770

Now, personally I would have used gets.to_i, but here's the thing -- I'm not talking about an O(n) solution. I'm talking about an O(1) solution to both parts of the problem.
>>
>>61793952
>A pure language seems very resource intensive since you have to reproduce a new object every time you perform a mutation on it.
There's this thing called structure sharing, meaning you don't make an entirely new structure if you don't have too. For example if you insert a new element into a binary tree, any subtree that doesn't change is reused as the new tree's subtree, and that means most of it. You might also heard of lazy evaluation, which means caching and not fully evaluating value if not needed to. That's why GC is important in FP languages too, manually managing this would be a huge mess. Also as you deconstructing a lazy structure, the GC would go behind you to collect whatever value you used and left behind, so if you know what you're doing you can even process infinite data structures with constant space.
>>
>>61794015
>still 1 year until GHC gets lineartypes
>even then it will just be typechecking and won't be used by the GC (though you can still use it for, e.g. performant safe mutatation)
>>
>>61793952
>>61794015
Referential transparency (and type system's properties, depending on the particular type system of course) can make a lot of guarantee to do all kinds of crazy code transformation of optimization (even the one actually doing mutation under the carpet) to make up for it. A classic and really basic example of this is
 
map plusOne (map plusTwo (map plustThree [1,2,3,4,5..2^64]))

Now all those 2^64 elements lists don't look particularly resource friendly, but if you take into account map's property that
forall f, g: map f . map g = map (f . g)

-- This won't hold if either f or g has side effect/is affected by side effect.

You'll can transform the above code into this
map plusOne (map plusTwo (map plustThree [1,2,3,4,5..2^64])) => map (plusOne . plusTwo . plusThree) [1,2,3,4,5..2^64] 

No more needless resource allocation and garbage collection, and it's real fucking easy to achieve to boot. The 2^64 elements argument would be deconstructed and garbage collected element by element as the map goes, so you don't have to worry about two 2^64 lists in your heap after the call.
>>
>>61793160
>just
unsigned
, not even
unsigned int

For some reason hardware guys at my work all write their C code like this.
>>
Why do we have so many normies?
Talking about trivial stuff like writing a compiler as it is hardcore hacking.
>>
>>61794172
Do you also get surprised when they use short and long instead of short int and long int?
>>
>>61794137
How's the dependent type proposal going again? My body is not ready for this and by my body I actually mean my peanut brain.
Understanding dependent type is one thing, I can't seem to naturally apply it or think of cool stuffs other than >le n-sized vector to do with it.
>>
Well that is to say, graphs in pure FP is still a huge pain in the butt.
>>
>>61794253
Still being worked on, I think it's like 3 or 4 years away?
You should mess around with Idris.
>>
>>61794172
There is literally no reason to write 'int' there, so why not just make your code shorter?
>>
I'm dabbling in python to make an app with kivy.

However, I'm doing it the OOP way, since that's all I've ever programmed in (with the exception of small python/bash scripts).
Is this a good way to program a small/medium sized project in Python?
Because it feels... wrong
>>
>>61794442
Isn't class the only real way to define new type of data structure in FIOC? If you're particularly anal about it, treat class like a record and don't do inheritance at all. If you're REALLY anal about it, encode your data structures into a combination of tuples and dictionaries instead, which might be viable because Javashit does alright with everything being dictionaries.
>>
>>61794442
>OOP
>feels wrong
because it is wrong
>>
Got a task to make some kind of server monitoring software(make http requests, parse response, probably do some simple assert tests) and can use it as a chance to learn a new language, would python be alright for something like this?
>>
>>61794568
>Got a task to make some kind of server monitoring software(make http requests, parse response, probably do some simple assert tests)
Sounds like a match for Erlang
>can use it as a chance to learn a new language
Sounds like a match for Erlang
>would python be alright for something like this?
Sounds like a match for Erlang
>2017
>Erlang the concurrent functional programming language originally implemented on top of a logic programming language is still unironically one of the few actual OOP according to Alan Kay's definition
>>
>>61794523
Named tuples are pretty much structs anyway.
>>
>>61794606
Alternatively Node.js makes the tasks you require (http request/response) easy, but you would have to deal with >javashit which might or might not be a pleasant experience. Love it or hate it you have to admit javashit is shit.
>>
>>61794442
Python oop is especially bad oop because it's not statically checked.
>so how should you program in python then
No clue. I imagine a procedural style would be relatively successful.
>>
>>61793952
It's not quite that bad but even a language like C++ struggles with making themselves fast and avoiding unnecessary copying/construction of objects so yes certainly these pure functional languages are only fast in theory.
>>
>>61794750
Well it's like comparing apple and orange, because while FP can safely reuse objects because they don't ever change anyway you can do destructive update in imperative languages and do away with the whole persistent things.
That is to say in some important cases orange is better than apple, for instance implementing an efficient graph representation in pure FP while possible is still a gigantic nigger dick in the anus, and it's infinitely easier in the present of destructive updates.
>>
>>61794750
when GHC gets LinearTypes you'll be able to write pure, typesafe destructive updates (by ensuring that what you destroy isn't used elsewhere)
>>
>>61794862
I think I'll remain negatively dispositioned until I see evidence that I shouldn't be.
>>
>>61794915
Don't worry, no one cares about your opinion anway. The world is just gonna move forward regardless.
>>
>>61794924
>nobody cares about your opinion
Likewise. Why state the obvious? Anonymous posts hold no rep and nobody pretends they do.
Sounds like you just wanted to insult but that's even more silly.
>>
File: 1494137319383.jpg (18KB, 500x375px) Image search: [iqdb] [SauceNao] [Google]
1494137319383.jpg
18KB, 500x375px
>>61794979
>Sounds like you just wanted to insult
No, I just want to passively-agressively stir up that weird feelings in your chest without resorting to actual insult or other rudeness. That's the sole reason why I'm still sticking to this progressively shittier by the day image board.
>>
>>61793160
>>Modify the previous program such that only multiples of three or five are considered in the sum
that's more basic than fizzbuzz

how about
> Find a pair of elements from an array whose sum equals a given number
>>
>>61795038
>passive aggressively
Anon I don't think you know what that means. A direct attack on the person as you would have made is clearly no passive aggressive.
>I'm here to make people mad
I can't say I've noticed you dude.
>>
>>61794915
It's not going to make everything hyper performant.
The first phase won't even change the GC or anything, it'll just add the linear type checking.
(Which will allow people to write more performant code, but still not work with the GC)
The point is purely that you can write code that you know can safely be implemented mutably.
>>
File: smug.jpg (37KB, 323x265px) Image search: [iqdb] [SauceNao] [Google]
smug.jpg
37KB, 323x265px
>>61795105
Wow that wasn't even an attack at all. You seem triggered.
>I can't say I've noticed you dude
Sure, reply to me more sempai.
>>
>>61795144
i wonder if you actually believe you triggered him.

and i know you'll try to say im samefagging to lick your wounds too.
>>
>>61795144
Anon before you go wasting your time spamming 4chan I'll have to inform you that number of replies is a terrible metric for annoyance effectiveness.
>>61795107
Yeah I wasn't expecting that they'd get there quickly. I'm just kinda sick of all the marketing wank in programming languages. People overstate the usefulness of their new features all the time.
>>61795186
I wonder that too. He probably just likes posting.
>>
File: 1497807576313.jpg (77KB, 570x380px) Image search: [iqdb] [SauceNao] [Google]
1497807576313.jpg
77KB, 570x380px
>>61795144
>>
>>61795202
It's certainly a useful feature. But it won't make Haskell as fast as C. That's my point.

It can be used not only for making this kind of destructive update pure, but also for writing server APIs and stuff that have to make guarantees that old handles aren't re-used and stuff.
>>
File: not_sure.png (7KB, 400x400px) Image search: [iqdb] [SauceNao] [Google]
not_sure.png
7KB, 400x400px
Why is working with text so hard in C
>>
>>61794442
do not make GUIs with python, it's a huge pain in the ass
>>
>>61795301
Because you're not using the standard library maybe?
It covers a lot of stuff.
>>
>>61795301
It's certainly not its strong point, but you just need to git gud.
>>
>>61795301
Protip: it's hard in C++ too (unless you use a shitty third party lib that changes its syntax from time to time)

they are old languages that are basically science projects, that said fuck you to real world developers
>>
http://www.codersnotes.com/notes/a-constructive-look-at-templeos/
Funny how this guy's description of HolyC makes it sound so very similar to JAI. Even down to compile times (though JAI probably does more work optimizing).

But what did he mean by this (pic related)? I don't get what the author is saying here.
I don't know of circumstances where you couldn't call a function without grabbing the return value. I'm really curious in how I could do that now because it'd be a nice way to ensure contracts.
>>
File: tom-57b9f3c047169.jpg (18KB, 640x640px) Image search: [iqdb] [SauceNao] [Google]
tom-57b9f3c047169.jpg
18KB, 640x640px
I working with a SQLite database in Python (sqlite3 module).

Are commits supposed to take 1.1 second on average? If so, how do I avoid committing often while preserving the ability to rollback without data loss if an exception rises?

>inb4 use redis
don't tempt me
>>
#include <stdio.h>
#include <pthread.h>

void* run_thread(void*);

/* should output "hello" 5 times */
int main(void) {
int nthreads = 5;
pthread_t tids[nthreads];

for (int i = 0; i < nthreads; i++) pthread_create(&tids[i], NULL, &run_thread, NULL);
for (int i = 0; i < nthreads; i++) pthread_join(tids[i], NULL);

return 0;
}

void* run_thread(void* unused) {
printf("hello\n");
return NULL;
}

$ ./main
hello
hello
hello


What am I doing wrong?
>>
>>61795575
https://stackoverflow.com/questions/467938/stdout-thread-safe-in-c-on-linux
>>
>>61795575
why are you returning null?
>>
>>61795575
It prints 5 times for me.
Maybe you forgot to recompile a program or you're running into a race condition (stdout is a shared variable).
>>
>>61795547
1. write test
2. write just enough code to make test pass
3. refactor
4. commit
5. goto 1
>>
>>61795624
pthread functions have to return something.
If you don't care about it, you would typically just return NULL.
>>
>>61795624
Because i'm not using the value returned by thread function anywhere.

>>61795619
In real program I write to a pipe using write and still have the same problem.
>>
>>61795547
>in Python
lol you'd think disk i/o would be the bottleneck
>>
>>61795655
>I use write()
You need to do more than that.
>>
Reeeeeeeeee
Literally the only Lua RSA library I've been able to find can only do 256 bits
I want to have a choice between 256 bits and 1024+ bits
>>
>>61795663
SQLite is an in-memory database.
>>
>>61795692
Patch it. Should be trivial.
>>
>>61795692
>Reeeeeeeeee
>>>/reeeeedit/
>>
>>61795706
this
>>
>>61795628
I don't know what to make of this.

>>61795701
But the commits go to the disk.
>>
>>61795672
Isn't write() atomic?
>The adjustment of the file offset and the write operation are performed as an atomic step.
What else do I need?
>>
File: 0etgJ.gif (2MB, 230x211px) Image search: [iqdb] [SauceNao] [Google]
0etgJ.gif
2MB, 230x211px
>about to dump Code::Blocks because I'm sick of waiting 2 minutes each time it crashes because of autocomplete plugin
>be so addicted to autocomplete plugin can't turn it off
>decide to give it one last shot for old times sake
>checkout svn
>build it, no big problems besides installing a couple of libs (gtk2, wxwidgets)
>starts up blazingly fast
>now I only have to wait 1 minute when it crashes

I'm sorry I doubted you.
>>
>>61795726
>Isn't write() atomic?
Up to a certain size, yes. I want to say 4kB, but I'm not certain.
Just to clarify, what operating system are you on?
>>
>>61795703
It's some of the most bloated code I've ever seen, there's no way I could identify everything I'd have to change to make it work with larger key sizes.
>>
>>61795741
GNU/Linux.
I write just one byte to synchronize another process with all the threads.
>>
>>61795739
debug it like a big boy and contribute a patch
>>
File: code::blocks.png (67KB, 440x190px) Image search: [iqdb] [SauceNao] [Google]
code::blocks.png
67KB, 440x190px
>>61795739
shit wrong pic
>>
>>61795761
It's C++. I only know C.
>>
>>61795459
>I don't know of circumstances where you couldn't call a function without grabbing the return value.
In that context he's talking about doing that at the top-level scope, aka outside of any functions. In HolyC you can just start writing code and it'll execute.
>>
>>61795759
Honestly, I think your code should be printing 5 times. glibc's printf is "somewhat" thread safe. Your messages might not appear in order, but you shouldn't lose any.
I think something else is the problem.
>>
>>61795739
you're so lucky that you can build your shitty ide you're addicted to for no good reason

>tfw literally impossible to build kdevelop without downloading the internet and studying the process for years
>>
>>61795793
I protected shit with a mutex and now it prints... 4 times.
>>
>>61795575
>What am I doing wrong?
You're threads are joining before they're able to print.

>>61795870
Learn how output buffering works. fflush stdout before returning in your threads.
>>
>>61795793
>>61795870
And here's that something else that's the problem:
>pthread_create: Resource temporarily unavailable
kek

>>61795898
See >>61795655
>>
>>61795915
>In real program I write to a pipe using write and still have the same problem.
It's still not flushed unless you call flush or open the descriptor with proper flags.
>>
>>61795931
>>61795915
But anyway, your real problem is this:
>pthread_create: Resource temporarily unavailable

That's why it only prints four times, because you didn't create the fifth thread.
>>
File: 1421139415594.jpg (112KB, 1358x765px) Image search: [iqdb] [SauceNao] [Google]
1421139415594.jpg
112KB, 1358x765px
>>61793517
Haskell programmer here :)
Just gained employment!
>>
New poll

What programming languages do you know?
(Multiple selection)

(Don't include shit you knew 10 years ago and don't know now)
http://www.strawpoll.me/13656540
>>
>>61796017
Basically I want to know the numbers of people in /dpt/ who know each language
>>
>>61796017
Why did you make a bunch of JavaScript dialects (like TypeScript) separate languages, but didn't include actual languages such as Perl and PHP ?
>>
>>61796067
Sorry, I forgot some.
If I could edit I'd add those
>>
>>61796017
>Lisp
>Scheme
Are you implying that Scheme isn't a Lisp?
>>
File: 1479629111642.jpg (198KB, 566x333px) Image search: [iqdb] [SauceNao] [Google]
1479629111642.jpg
198KB, 566x333px
I am working on a hook which allows me to inspect and modify sections of data structures while being ingame via console input. So just an inbuild disassembler, but where you can see all the dataflow of the game with identified offsets and structures.
>>
>>61796080
Whoops, it should probably be Common Lisp.
>>
>>61795941
Yep. I write to the pipe if I get an error in pthread_create and now everything works fine.
Any other potential problems I should be aware of?

I don't think I need to flush. I write() almost at the start of thread function and there there's a lot of other work done before a thread exits so the chances something goes wrong because I don't flush are very low. Even in this minimal subset of my program I posted everything now seems to work for me.
>>
>>61796206
>I don't think I need to flush. I write() almost at the start of thread function and there there's a lot of other work done before a thread exits so the chances something goes wrong because I don't flush are very low.
Famous last words, but whatever. Just know that concurrent access to output buffers has always been a major pain for debugging multithreaded programs. For small things you might get by just fine, but know that it can be an issue later on if you rely on output and you're better off by protecting write calls with a mutex and explicitly flushing the output buffer.
>>
>>61796235
First I need to refactor all the mess and then I'll think of that. But I shall remember your words when I run into next big problem.
>>
I use Code::blocks. Who wants to redpill me on Visual Studio
>>
How important is it to know advanced lambda calculus if you want a well-paying job in the industry?
>>
File: costanza.jpg (7KB, 250x250px) Image search: [iqdb] [SauceNao] [Google]
costanza.jpg
7KB, 250x250px
>>61792971
Learning Java because it's easy, it's what a large chunk of the job market is looking for, and also I'm a retard that will probably only be a code monkey.
>mfw java calls floats doubles
Why. Why on God's green earth would you do this. The fuck is wrong with you Sun™.
>>
>>61796356
Not very, I suppose.
But it's easy to learn and helps you understand FP and uses for lambdas.

It'll make you a better programmer.
>>
>>61796356
>>61796425
especially if you learn a typed lambda calculi, such as a System F implementation
>>
>>61796407
>>mfw java calls floats doubles
float - single precision floating point
double - double precision floating point
Java is far from the only language that calls them that.
>>
>>61796407
>>mfw java calls floats doubles
It doesn't though. Java's float is single precision.
>>
>looking for a lib in the vast sea of shitty libs that lack serious support for a certain feature
>find a lib that does exactly every thing I need
>look at the source code
>filenames have a ".C" (capital C) extension and the inside is C++
>instantly hit ctrl-w without even judging the code itself

What are some things you autistically can't bear, /dpt/?
>>
>>61796458
Well damn, I guess you learn something new every day.
Thanks for clearing that up Anon.
>>
Ok I'm tired of Python already

Is there something that features as much ease of coding (aka list comprehensions, generators, lots of libs...), has an active community (SO / tutorials) and isn't a pain in the ass to test on the fly (aka doesn't take five minutes to compile a mid size web app every time you want to test something) ?

Looked into Kotlin but every tutorial is aimed at Java devs and I hate Java
Looking into Go and Typescript but I don't know
>>
>>61796475
Reimplement it in C and call it a day.
>>
File: hvFRY.png (113KB, 1534x648px) Image search: [iqdb] [SauceNao] [Google]
hvFRY.png
113KB, 1534x648px
Why doesnt entirely visual/graphic programming exist?
Interpreting the logical schemes like this into code and compiling it must be a trivial task

Having to bother with syntax is pretty much the reason i chose engineering over programming.
>>
>>61796507
Because it just doesn't work.
Real work programs are far, far too complicated to have it be represented like that and even have it be remotely tractable.
People have tried, and they all failed.
>>
>>61796516
>Real work
Real world*
>>
>>61796507
It'll take over, but probably not soon.
It's just better, because at the end of the day, a text box can just embed text based programming in a visual language.
Not vice versa.
(Not conveniently)
http://scrambledeggsontoast.github.io/2014/09/28/needle-announce/
>>
>>61796507
I mean it's a cool concept, and we already have languages like that (Scratch), but I think because the language is so simple there's no real challenge to it.
I doubt people would make complex programs with such languages, sticking only to basics and copying cookie cutter builds.
There's no real thinking behind it.
>>
>>61796507
Because this is why
https://blueprintsfromhell.tumblr.com
>>
In C11, what happens to integer literals larger than INT_MAX? Do I need to postfix them with "ul" (converting to unsigned long) to get rid of undefined behaviour?
>>
File: 125-arraybp.jpg (321KB, 1478x1024px) Image search: [iqdb] [SauceNao] [Google]
125-arraybp.jpg
321KB, 1478x1024px
>>61796507
>>61796516
>>61796533
It does exist. Try the UE4 blueprints.
>>
>>61796574
Programs can be written in a disorganized fashion too.
It's called spaghetti code.
>>
>>61796575
No C lawyers here?
>>
>>61796604
Yes, there are visual languages, but not in a significant number.
Also check out Luna, which I am suspicious of and suspect is fake.
>>
>>61796575
They become a type large enough to fit them.
Consider this program:
#include <stdio.h>
#include <limits.h>

#define type(val) _Generic((val), \
int: "int", \
unsigned: "unsigned", \
long: "long", \
unsigned long: "unsigned long", \
long long: "long long", \
unsigned long long: "unsigned long long")

int main()
{
printf("%s\n", type(10));
printf("%s\n", type(10U));
printf("%s\n", type(10L));
printf("%s\n", type(10LL));
printf("%s\n", type(5000000000));
printf("%s\n", type(5000000000U));
}

int
unsigned
long
long long
long
unsigned long
>>
>>61796616
The difference is theres literally no way to avoid the spaghetti in visual programming on anything larger than tiny arcade games.

Visual programming is fundamentally flawed, its fine as a teaching tool for young kids. But it has no reason to exist otherwise. Artists need to stop being brainlets and learn a new skill.
>>
>>61796648
...
int main()
{
puts(type(10));
puts(type(10U));
puts(type(10L));
puts(type(10LL));
puts(type(5000000000));
puts(type(5000000000U));
}
>>
>>61796665
Pointless.
>>
How do you guys handle big projects?
I recently started learning programming again and I've been doing some personal projects. Once the thing gets big, I'd look at my code and it would look kinda messy. I sometimes go, "what's this part supposed to do again?". Overall, my organizational skill sucks. Any tips?
>>
>>61796675
yes. it doesn't have pointers.
>>
>>61796682
>"what's this part supposed to do again?"
people invented this extraordinary thing called "comments".

you should try it. really.
>>
>>61796616
Nothing wrong with writing in a disorganized fashion. The problems come when the programmer is unwilling or incapable of cleaning up. Many times writing crappy prototypes inform your architectural decisions that let you write a much better end result. The more freely you can iterate like this the better your end result can be.
>>
>>61796682
>How do you guys handle big projects?
Documentation, documentation, documentation.

>"what's this part supposed to do again?"
Comments, test cases that illustrate the intention of the code, documentation etc. There are many roads to Rome.
>>
>>61796682
Code organisation is a skill that takes years to hone.
>>
>>61796682
You usually don't run into that unless you break up your code into unreadable pieces (commonly oop does this or the ideom of making no functions longer than 20 lines (imperative standard).

I suggest you learn to have a good picture of what your program is doing and giving yourself opportunities to refactor code often. Excessive documentation is another option but the overhead for writing like that is quite massive.
>>
Which one is better:

    unsigned long w = s / 604800;
s %= 604800;
unsigned long d = s / 86400;
s %= 86400;
unsigned long h = s / 3600;
s %= 3600;
unsigned long m = s / 60;
s %= 60;


or

    unsigned long w = s / 604800; s %= 604800;
unsigned long d = s / 86400; s %= 86400;
unsigned long h = s / 3600; s %= 3600;
unsigned long m = s / 60; s %= 60;


I prefer second one, but some people say that there should be only one statement per line.


Also, I think that the "magical numbers" are self-explanatory.
>>
>>61796766
>but some people say that there should be only one statement per line.
those people are mongoloids
>>
>>61796766
unsigned long w,d,h,m;
int a = 604800;
int b = 86400;
int c = 3600;
int d = 60;
w = s / a;
s %= a;
d = s / b;
s %= b;
h = s / c;
s %= c;
m = s / d;
s %= d;
>>
>>61796802
put them in an array and loop
>>
>>61796682
Read about design patterns. Use them. Plan your project ahead. Use OOP.
>>
>>61796812
Rewrite >>61796766 to use OOP and design patterns
>>
>>61796809
>int a = 604800;
>int b = 86400;
Not portable. The standard does not guarantee that int is capable of holding such ranges.
>>
File: 1497386323804.jpg (27KB, 395x395px) Image search: [iqdb] [SauceNao] [Google]
1497386323804.jpg
27KB, 395x395px
>>61796812
>design patterns
>OOP
This is literally the worst advice you could give to someone.
>>
>>61796825
Are you retarded?
>>
>>61796838
meant to reply to
>>61796802
>>
>>61796838
buy a better computer than

>>61796842
not an argument, loser
>>
>>61796842
Spoken like a true NEET, my friend. Don't worry, your fizzbuzz toy projects don't need design patterns.
>>
>>61796766
The second version. But I prefer writing magic numbers like that in more known forms if I go up to the less known. Everyone knows 60 and 3600. Not everyone knows 86400 and 604800 though.
I'd write 60, 60*60, 60*60*24 etc.
What you've written is certainly better than commenting or declaring variables for the magic values since they're on the edge.

This is all very picky though. Unless you do something intentionally misleading you're not gonna confuse a programmer.
>>
>>61796849
I didn't say it was good advice.
>>
>>61796873
>I'd write 60, 60*60, 60*60*24 etc.
>wasting cycles computing those values

Lel
>>
>>61796838
Why are you saying this? Clearly if a programmer relies on behavior for a specific platform they don't intend to be portable.

I wouldn't tell a x86_64 programmer they're not writing portable code. They know that.
>>
>>61796880
Why wouldn't those constants be precomputed?
>>
>>61796880
Anon are you still here trying to annoy people?
This isn't even good as a joke.
>>61796903
He's clearly not sincere.
>>
Just failed my first technical interview/tests.

I was tasked with writing some sql but I expected more advanced stuff (e.g. stored procedures, triggers and query analyzing/optimization) but the questions was so extreme simple that I didn't read carefully and ended up missing two "where" clauses in the questions.

Strong feels. Have you ever been here anons? In this darkness?
>>
Reminder that whitespace slows down compilation
>>
>>61796896
This is completely fine to fail on x86_64 archs. For example, MSVC is standard compliant and int is 16 bit just to fuck with you.

If you're a x86_64 programmer, use <stdint.h> and *int*_t types.

Also, use

#ifndef __STDC_IEC_559__
#error "unsupported floating point types"
#endif
>>
>>61796575
>C11
>still doesn't have templates or structs that can define functions with one parameter that points back to it (usually called this)
>>
>>61796939
Tabs>spaces because they slow down compilation less.
>>
>>61796952
Use C++ if you want OOP.
>>
File: 055.png (134KB, 720x331px) Image search: [iqdb] [SauceNao] [Google]
055.png
134KB, 720x331px
Thoughts?
>>
>>61796935
this girl failed fizz buzz

https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>61796960
You can do OOP in C too.
>>
>>61796960
did I say anything about inheritance or virtual functions?
>>
>>61796964
you posted this before
>>
>>61796964
>thta old

what did you mean by this?
>>
>>61796942
>For example, MSVC is standard compliant and int is 16 bit just to fuck with you
No, I'm pretty sure Windows' ints are 32 bits.

>>61796952
Why the hell would you want those in C? Do you even understand the whole purpose and draw of C?
>>
>>61796998
>Why the hell would you want those in C?
for user convenience and more readable/usable code you retard
>>
>>61793517
>learning and not making dosh for years now

>>61795974
good job, where?
>>
>>61797014
>good job, where?
are you new?

it's a troll.
>>
>>61796998
Well, I don't really know, this is just what I've heard.

Anyway, the point is they *could* be and the compiler would still be standard compliant.

And your program would exhibit undefined behaviour, because it's an invalid C program.
>>
>>61796942
I didn't know I had to elaborate to the point where anyone can get it.

The point was that platform specific asm is inherently non-potable. Just like using ints outside their standard defined range.
So when a person writes code like that they're writing the code knowing they're writing for a platform where an int is large enough to fit the type.
Complaining about portability only makes sense when the programmer is explicitly showing he's aiming to be portable. What he did there is clearly not one of those cases.
>>
>>61797010
Using UFCS rather than member functions would be more convenient and readable.
>>
>>61797010
C is a very explicit language by design. It's not going shit out a massive amount of object code behind your back or hide arguments to functions from you.
>>
>>61797029
>where an int is large enough to fit the type.
I meant integer literal.
>>
>>61797020
Haven't been coming here for few years, sorry boss

>>61795107
The plan is definitely to use linear types for performance, GC-less and in-place computations; it's just not the first step

FWIW you may get less GC in linear code even without any GC changes. Anyway the real fun will start once GHC starts taking advantage of it but no code was written towards that yet.
>>
>>61797031
>using UFCS rather than member functions
But they're there for entirely different purposes.
>>
>>61797064
>write Haskell code that only uses manual memory
>still compiled with GC
life is suffering
>>
>>61797075
All it changes is that your "member functions" are no longer scoped. I don't think that matters given C's fairly weak scoping mechanisms.
>>
>>61797031
>UFCS
That's a no brainer, but it's nice to have private data members too.
>>
>>61797095
>still compiled with GC
Most likely it'll be the case for the next 10 years before linear type makes it to the next standard.
>>
>>61797110
I'm surprised I have to answer 'woosh' to this.
>>
>>61793160
In Haskell, this is just
f n = sum [1..n]
g n = sum [n | n <- [1..n], mod n 3 == 0, mod n 5 == 0]
>>
>>61797119
Like I said, use C++.
>>
>>61797047
>massive amount of object code
why would it with classes? it's a fucking C struct
>>
>>61797010
>user convenience
lol no

C doesn't even assume linear memory model or 32-bit types or 2's complement. It's fucking ancient. Pointers to different types can have different alignment requirements and casting them is implementation-specific.

C is a fucking minefield. I would like if there was some C-stress compiler that segfaulted every time someone did some of these:

int x, z;
short *y = &x;

ptrdiff_t z = &x - &z;

int n = INT_MAX;
++n;


or myriads of other cases I don't even know about.

C programmers don't even know what

void foo(int array[static 5]) {}

means (which is valid C by the way).

Valid C99 code may be uncompilable with a standard-compliant C11 compiler (VLAs).

However, I'm stuck with it because there is no other ISO-standardized language that accomodates brainlets such as me.
>>
>>61797095
Just turn off idle GC and ramp up allocation area to a high number, then GC will never run (until you run out of allocation space); in production you don't run with default RTS flags anyway, it depends on your usecase

>>61797124
Linear types don't make GC go away, they just help to write code-that-is-linear in a way that the compiler can use. Not everything is linear. Indeed most code is not.
>>
>>61797138
did I say anything about inheritance or virtual functions?
>>
>>61797139
Templates generate a new copy of all of the code for each type that gets used, which leads to a massive amount of object code.
This is just not acceptable thing for a language like C to do.
>>
>>61797157
Does it matter? It has member functions and access specification. Don't use inheritance and virtual functions if you don't want them.
>>
>>61797151
Nice reddit spacing, sepplesfag.
>>
>>61797189
>dislikes C
>Must be a sepplesfag
never change Cnile
>>
>>61797165
>that gets used
that's reasonable, and completely predictable behavior

you should not use class templates when that's a problem, which is very rare
>>
Neat emulation of copattern matching
Wonder what other case-like structures you could make

{-# LANGUAGE RankNTypes, GADTs, LambdaCase #-}

data StreamTag a b where
STHead :: StreamTag a a -- Stream a -> a
STTail :: StreamTag a (Stream a) -- Stream a -> Stream a

data Stream a = Stream {
unStream :: forall b. StreamTag a b -> b
}

sRepeat :: a -> Stream a
sRepeat x = Stream $ \case
STHead -> x -- head (sRepeat x) = x
STTail -> sRepeat x -- tail (sRepeat x) = sRepeat x
>>
>>61797194
What are your "preferred pronouns"?
>>
>>61797189
I browse both. Also, read the last sentence. I'm too much of a brainlet to comprehend C++, but if I could, I would try to.

If only Go was ISO-standardized. Maybe sometime.
>>
>>61797217
Fuck off, redditor.
>>
>>61796942
MSVC's ints are 4 bytes but MSVC's long are also 4 bytes.
>>
>>61797170
there's like a hundred other features I don't want, which make optimization fucking impossible and thus fuck everything up
>>
>>61797211
I swear I saw this code recently

https://www.reddit.com/r/haskell/comments/4aju8f/simple_example_of_emulating_copattern_matching_in/
>>
>>61797250
>Things I don't use reduce performance
The whole point of C++ was for this not to be the case.
>>
>>61797250
I agree. We need a C without explicit pointers.
>>
>>61797215
xir they/them
>>
>>61797284
what?
>>
>>61797284
use ATS like real men
>>
>>61797278
But they failed demonstrably.
Also no. Bjarne has always had that as a marketing goal.
>>
>>61797267
is Haskell a big jerk off language?
>>
>>61797267
Yes, it's from that
>>
>>61797301
Just threw up in my mouth a little
>>
>>61797306
Demonstrate it.
>>
>>61797297
Pointers (especially when passed to a function) destroys so many opportunities for compiler optimizations it's just silly. A major reason member functions in C++ can be so sneakily problematic is because of the implicit this pointer. If the semantics were different they'd be fine.
>>
>>61797343
Could you go into more detail please? What would the alternative be?
>>
>>61797337
Use any of the features in the language in a real program. Watch your program do unnecessary calls and operations compared to the equivalent SSA form code.
I'm not gonna write it for you though. A bit too lazy.
>>
>>61797319
Not really, it just makes it easy to do if you're into that

>>61797323
oh thought you wrote that or something, my bad

>>61797335
what's wrong, afraid of some proven-correct C-speed code?
>>
>>61797371
Afraid of gross syntax, otherwise I'd be memeing around with it
>>
>>61797371
It's not literally copy pasted but it could have been

>>61797383
what parts of the syntax don't you like?
>>
>>61797369
But you don't have to use those features. You wouldn't be writing C++ like that. You merely want member functions and access specification. How is the "C with member functions and access specifications" style of C++ slower than C?
>>
>>61797383
never look at the code it generates then though maybe it's better these days (doubt)
>>
>>61797211
Why even the need for default lazy evaluation if you can just define codata and do co-pattern matching on them like this?
Why are Haskalors such inconsistent fags.
>>
>>61797413
You can also just have a Lazy monad.
>>
>>61797401
It's difficult to explain to someone who doesn't know C++ but this should be easy to grasp.
http://www.drdobbs.com/c-theory-and-practice/184403384
It's not the core of the article but read through it with the understanding that he's paying where he doesn't use things.
>>
>>61797337
did you miss the point that the compiler fails to optimize because it must be prepared for 2^100000000000 possibilities?

bloat fucks performance, but it's not obvious when you're a retard
>>
>>61797365
Constructs which let you define that you don't wish to store a copy but you don't care about the way you reference at all. I don't know good names for that. That way you leave it up to the compiler to do tons of nice stuff without programmer overhead. As I see it that's our goal. Right now C++ deals with this using move semantics. They're a rather hefty price to pay for what's normally not a problem. And though they solve some of the unnecessary run-time processing you'd have in C (unless you're very careful) they mainly assist C++ features.
>>
File: B_mOsG4WYAEKRlI.jpg (26KB, 599x375px) Image search: [iqdb] [SauceNao] [Google]
B_mOsG4WYAEKRlI.jpg
26KB, 599x375px
>>61794924
>Don't worry, no one cares about your opinion anway.
In other words:
>LOL HE LOSE BECAUSE HE REPLY

>>61794979
>Why state the obvious?
In other words:
>LOL HE LOSE BECAUSE HE REPLY

>>61795038
>That's the sole reason why I'm still sticking to this progressively shittier by the day image board.
>implying the other guy is wrong to have any other reason
In other words:
>LOL HE LOSE BECAUSE HE REPLY

>>61795105
>>I'm here to make people mad
>I can't say I've noticed you dude.
In other words:
>LOL HE LOSE BECAUSE HE REPLY

>>61795144
>Sure, reply to me more sempai.

Do people these days really have no other rhetorical device at their disposal?
>>
>>61797400
From what I remember last time I was trying it, there were just a bunch of small quirks with it that seemed pointless. One example that came to mind is "andalso" vs. && (though I think it said you could just use &&)
>>
>>61797365
I'm not an
EXPERT C PROGRAMMER
but pointers for once destroy every shred of locality, so that would flush possible opportunities for parallelization and effective use of processors' caches.
>>
>>61797511
Wtf is "andalso"
>>
>>61797524
SML's and I suppose.
>>
File: ATS.png (13KB, 840x121px) Image search: [iqdb] [SauceNao] [Google]
ATS.png
13KB, 840x121px
>>61797524
>>
>>61797543
>true
>false
>andalso
>orelse
>~1
Well so it really is SML.
>>
>>61797509
I'm not sure I'm clever enough for this post.
>>
>>61797543
Ohh, ATS
>>
>>61797413
>>61797450
The keyword here is "default".
>>
>>61797512
> but pointers for once destroy every shred of locality

not if it's a pointer to an array
>>
>>61797591
aka c++ vector
>>
>>61797591
Doesn't C downcast array pointers to just pointers when they're passed to functions?
>>
>>61797586
I mean you can change that using -XStrict, but I think laziness is a nicer default than strictness.
It makes composition more efficient and gives you memoization
>>
>>61797618
doesn't matter, the compiler will deal with pointers if your actual data to be processed is reasonably compact
>>
/dpt/ are opaque data types as bad as classes?

they're basically the same thing right? i mean the only real difference is the type's methods don't inhabit a lookup table and therefore no pointer to any such table is passed around inside the instances which to the contrary are just plain records. everything else about it is so similar
>>
>>61797365
>more detail
It's covering more than just this but I think you'll like it.
https://youtu.be/eR34r7HOU14
39:30 he starts touching on the destructive nature of pointers.
>>
>>61797586
>>61797625
Exactly, why the need for default lazy evaluation when you can have codata just that easily?
Default lazy evaluation essentially makes _|_ inhibit every type and compromises the type system's soundness.
>tfw no true sum type due to _|_ always being there as a hidden case to anally fuck your computation regardless of the type.
Yeah sure practically it's meaningless anyway.
>>
>>61797625
-XStrict only works on WHNF level and it doesn't make anything you import strict (or things would really break). If you have
let x = Just leak
, you'll still leak until you match on x, it will only seq the Maybe constructor
>>
>>61797667
It's not purely because of laziness though, you could do
x = x
Even with strictness, it would just hang.
If you want to demand something isn't void, just strictly evaluate it.
>>
>>61797673
Is it the same for StrictData?
>>
>>61795301
Rust is so much better with text
>>
>>61797692
Strict implies StrictData; and yes it's the same; StrictData just makes ! default for fields which is also only WHNF.

data Foo = Foo { x :: !(Maybe a) }

Foo { x = Just leak }


You only know if you have Just or Nothing (or bottom), but you can still leak trivially. Lazy structures stay lazy.
>>
>>61797726
Global rule 11
>>
>>61797739
That's a shame

We might get this though
https://ghc.haskell.org/trac/ghc/wiki/UnliftedDataTypes

We already have UnboxedTuples and just got UnboxedSumTypes
>>
>>61797655
Yes, they are, because you still have to define the methods yourself.

Seriously just use ADTs. There's no data type special enough to need to be implemented as a class, everything can be expressed as an alias to an amalgamation of various common generics.
>>
>>61797655
anon here >>61797761
means algebraic data types, not abstract data types
>>
>>61797657
>BoostCon
that's a bridge too far
>>
>>61797677
Nay, in most strict language x = x is meaningless because RHS x isn't bound before LHS x is bound to it yet.
In case x is of function type the type checker would decide its type is circular.
But of course you can always define divergent computation in any Turing complete language e.g f x = f x, it's just that with strictness _|_ wouldn't be a hidden case for sum type i.e. (x::xs) will not diverge.
>>
>>61797692
>>61797739
I should mention that even if `leak` is a strict data structure, Maybe is not so
Just leak
doesn't force leak, you should use $! instead.

>>61797756
It's not a shame, lots of stuff relies on lazy properties. If you want to have strict things, use strict data structures and don't stick them in lazy ones. If you have a tree of strict structures and the top level one is evaluated, you know all of it is.

I didn't see unlifted types proposals before, I'll have to read it in the evening
>>
>>61797824
You have types that have unlifted kind, e.g. unboxed types, and unboxed tuples/sums of them.
This just lets you newtype them.
>>
>>61797789
It's not about boost luckily. It's just a guy on the Cpp committee who's a compiler guy. It also doesn't touch C++ more than the fact that they're considering it C++ and they have move semantics as a solution. The problems exist in C too. Arguably the second example after the time code I suggested has a class. But the equivalent problem is there if you pack data into a struct and pass it to a function by pointer (not too uncommon).
Anyway. You don't have to watch obv. Just thought you might like it.
>>
>>61797752
Global rule 11b should be that everyone should use Rust
>>
>>61797906
Just stop rustfags, nobody cares about your irrelevant language.
>>
>>61797843
Eh, seems ok, not too exciting though because you can easily counter this with ! and strict fields; it shouldn't have any benefits over that except that it's ~~automatic~~. Seems like a convenience feature at best
>>
>>61797824
That's exactly what I'm talking about anon, with default strictness + codata, you can have both strict and lazy structures. With default lazy you can only have lazy structures
>>
>>61797950
…no, you can have lazy and strict structures like we already do with default lazy today. Laziness is nice for most part, it's the not-so-nice bits of it that people hate. Codata in strict languages is a pain in the ass and if you want to use it a lot, it's suddenly a big hassle and you don't get compiler support at all. IMHO it's much easier to make your stuff strict where you need it than to make sure everything is explicitly lazy
>>
>>61797942
! and strict fields are whnf, but unboxed types are unboxed
>>
>>61797657
>clang sux, the lecture
>instead of improving it I'm gonna bitch and generalize
the fact that they ignore const refs in optimization is a shocker
>>
>>61797936
try to do string shit in C and then in Rust and you'll always do string shit in Rust

that's all
>>
>>61798035
Yes but the proposal is about unlifted types, not unboxed types. Unlifted gives you your type without bottom in it. I'm saying you can have the same thing with strict structure (so we know fields aren't bottom) and strict pattern (so we know the value itself is not bottom). That is, whnf is enough if the fields are strict and you gain nothing. The proposal just makes it so you can't forgot strict pattern, strict field and enables nicer performance under the hood due to this knowledge.
>>
>>61798035
>Such data types are always boxed, but the type *does not include bottom* and is operationally represented as a pointer to the value
O-oh. I can retract >>61797950 then.
>>
>>61795739
>using an ide
you must be retarded
>>
>>61798142
You must have never worked on anything bigger than a fizzbuzz.
>>
>>61798121
hmm
also this polymorphism is just going to get worse, imagine what the type of fmap will be if it's generalized for lineartypes AND levity polymorphism
>>
>>61798142
Are you one of those persons that add 1000 features to your text editor to make it useable just like an ide for programming?
>>
>>61798098
But const ref is no better than const pointer. And that's clearly ineffectual as you see explained.
Also this is applicable to both clang and gcc. They're very similar.

But don't bother replying. I know you're biased. I just wanted to throw the facts out there.
>>
Guy a work with frequently does this:

If(condition) functionA(true) else functionA(false)

What the fuck
>>
>>61798177
Not him, but I add plugins to vim not to make it "just like an ide", but to actually turn it into an IDE.
>>
>>61798186
>But const ref is no better than const pointer
Not the guy you're responding to, but there is a difference between const references and const pointers, namely that you can't do pointer arithmetic on const references.
>>
>>61798186
>I know you're biased

compile something that YOU wrote in both and you'll be too
>>
>>61798164
AFAIU neither linear types nor unlifted types will mess it up. Actually I don't remember about linear types for sure (currently internally there's fmapL used for trying stuff out, at least that I saw, I'm not involved in that) but for unlifted types, it just takes `k` to `k` anyway...
>>
>>61798187
He must be satan
>>
>>61798203
Doesn't matter. I don't even see why you'd think that matters. It's like you haven't even watched the video.
>>61798209
I have. They're about the same. Clang had nicer tools surrounding it. Primary reason I use it.
>>
>>61798187
my boss does this. he also emits spaces just because..
>>
>>61798258
>Doesn't matter.
It does matter, const references are inherently stricter type than const pointers, which means that you have better type safety.

>It's like you haven't even watched the video.
I didn't, I just fucking said that there is a difference between the two.
>>
>>61798258
>Clang had nicer tools surrounding it.
how is that relevant to compiling?!

I use the tools, too and I use IDEs that rely on it, so what?
>>
>>61798291
>how is that relevant?!
Oh my God anon calm down. It's OBVIOUSLY not. It's just a reason to choose one over the other. They're about the same as I said.
>>61798286
I really can't be bothered anon. Learn the language first. What you're talking about is strictly programmer facing.
>>
>>61798164
>>61798221
not directly related to discussion but new linear types post just came out https://m0ar.github.io/safe-streaming/2017/08/08/take-and-zip.html
>>
>>61798326
>What you're talking about is strictly programmer facing.
Well, yeah, that's my point. Are you autistic or something?
>>
>>61798334
the bastard is taunting us
>>
>tfw you have to setup the path to gcc
>tfw you run gcc -o helloworld helloworld.c and no stdio.h file is found

Letting people install Code::Blocks was a mistake.
>>
>>61798357
Enable the compiler plugin.
>>
>>61798356
not really, I may or may not work for place developing it ;^)
>>
>>61798341
It's not sensible to bring it up in this discussion. And you're wrong because you think compilers could use it to make more informed decisions. They can't.
>>
File: karen gun.png (30KB, 128x108px) Image search: [iqdb] [SauceNao] [Google]
karen gun.png
30KB, 128x108px
>>61798404
give us the language extension and nobody gets hurt
>>
>>61796766
Generalized the fuck out of this.

typedef struct {
unsigned long long baseUnitCount;
const char *singularForm, *pluralForm;
} Unit;

#define WEEK_UNIT ((Unit){604800, "week, "weeks"})
#define DAY_UNIT ((Unit){86400, "day", "days"})
#define HOUR_UNIT ((Unit){3600, "hour", "hours"})
#define MINUTE_UNIT ((Unit){60, "minute", "minutes"})
#define SECOND_UNIT ((Unit){1, "second", "seconds"})
#define UNITS ((Unit[]){WEEK_UNIT,DAY_UNIT,HOUR_UNIT,MINUTE_UNIT,SECOND_UNIT})

static void unitStr(long long n, const Unit *units,
const char *glue, const char *lastGlue,
const char *positiveSignSuffix, const char *negativeSignSuffix, const char *zeroString)
{
// TODO
}


I think I'm ready to do Java guys
>>
>>61798455
there's a docker image with pre-compiled GHC with linear types but last time I saw the discussion, let and case still weren't implemented so don't know how fun that would be to use
>>
>>61798407
>It's not sensible to bring it up in this discussion.
I responded to your statement. Maybe you should have worded your post differently.

>And you're wrong because you think
Are you telling me what I supposedly think, now?

>you think compilers could use it to make more informed decisions
I don't see talking about compilers at all, but technically they could use them to make more informed decisions if they want to.
>>
>>61798460
Welcome to the fold :D
>>
Am I just a retard or is there really no uint64_max in c++? Why not?
>>
>>61798547
Include climits or use std::numeric_limits
>>
>>61798479
God what a useless programmer you must be. So insincere. It's difficult to believe you're not still in school even.
>technically they could
No. They absolutely could not. They'd be breaking standards. They might as well do the same with const pointers at that point.
Unless what you mean by 'technically' is 'arbitrarily'. Yes. They could absolutely arbitrarily choose to go against the language spec and make const ref be very different from const pointer at the optimizer level.
>>
>>61798558
>God what a useless programmer you must be.
Ad hominem attacks, classy.

>No. They absolutely could not. They'd be breaking standards.
What exactly in the standard would it break? The standard makes very few assumptions on the implementation for a reason.

>They could absolutely arbitrarily choose to go against the language spec and make const ref be very different from const pointer at the optimizer level.
Again, how does it go against the standard?

Please, try to stay on topic rather than just spouting bullshit about the quality of my work.
>>
Can we all agree that
constexpr
is a good feature and we would like to see it in C?
>>
>>61798677
sure
>>
>>61798677
REEE
>>
>>61798677
No, absolutely not.
Constexpr should be the default, not a keyword.
>>
new thread when? :3
>>
>>61798699
Look at this poor anon:
>>61798460
He must do
#define WEEK_UNIT ((Unit){604800, "week", "weeks"})

instead of
const Unit WEEK_UNIT = {604800, "week", "weeks"};

because otherwise his code won't compile.
>>61798724
But that will break backwards compatibility, won't it?
>>
>>61798765
>But that will break backwards compatibility, won't it?
With what?
C doesn't have constexpr
>>
>>61798724
It is the default, constexpr simple raises an error if you try to do a compile time evaluation outside of a context where it's possible.
>>
>>61798775
I'm talking about introducing it. With something like _Constexpr. Because I want const arrays without invoking preprocessor.
>>
>>61798788
>It is the default, constexpr simple raises an error if you try to do a compile time evaluation outside of a context where it's possible.
no

>>61798724
no
>>
>>61798836
>>61798869
Constexpr should be entirely compiler inferred.
>>
>>61798886
Compilers largely already do compile time evaluation if they can. The purpose of constexpr is to force evaluation at compile time.
>>
>>61798937
Yes, but this would allow you to do

int x[func(3)];

and maybe constexpr variables
>>
new thread fucking where
>>
>>61798974
When this one dies.
>>
>>61798974
>>61798993
I think it could grow to something like 500 replies if faggots didn't create a new thread just after it goes after bump limit.
>>
Can /dpt/ wait till page 10?
>>
Before I waste my time, does anyone know of a remote control thing to have only transmit a window? Sort of like that window feature on VM but for remote control
>>
File: 1485055575601.png (40KB, 291x187px) Image search: [iqdb] [SauceNao] [Google]
1485055575601.png
40KB, 291x187px
>>61793050
>>
File: 1477780845278.png (96KB, 400x467px) Image search: [iqdb] [SauceNao] [Google]
1477780845278.png
96KB, 400x467px
>>61793050
my only two
>>
>>61798555
Ah thanks, turns out I was looking for ULONG_MAX
>>
>>61799021
To what end? Why would we want that?
>>
>>61799200
Maybe we would impress Hiromoot and /prog/ would happen again
>>
Shit, C is bad for this function.

typedef struct {
unsigned long long baseUnitCount;
const char *singularForm, *pluralForm;
} Unit;

static char * // pointer to string end (buffer + strlen(buffer)) or NULL on err
unitStr(long long n, // base unit count
const Unit *units, // array of Unit (ends when baseUnitCount == 1)
const char *glue, // ", " recommended
const char *lastGlue, // " and " recommended
const char *positiveSignSuffix, // appended when n is positive
const char *negativeSignSuffix, // appended when n is negative
const char *zeroString, // returned when n is 0
size_t bufferSize, // muh safety
char *buffer)
{
// TODO
}


Maybe this should be my first C++ program using std::string?
>>
>>61798937
No its absolutely no that. It's to get errors when it can't. And it's woefully restrictive in that. Instead of having you write whatever and evaluate it presuming it's doable at compile time there's tons of silly restrictions that absolutely don't need to be there.

And even less obvious things like IO can be done at compile time. Why not let your constexpr open a file read from it and close? Probably because they don't wanna be bothered with implementing it. Honestly. The rest of the excuses are secondary. There's no reason to fear clutter anymore since it's already a mess. There's no stylistic measures to restrict based on. Constexpr is just as poorly done as other features in C++.
>>
>>61799265
I can't even tell what you're trying to do.
>>
File: consider.jpg (29KB, 600x600px) Image search: [iqdb] [SauceNao] [Google]
consider.jpg
29KB, 600x600px
new thread
>>61799317
>>
>>61799306
>I can't even tell what you're
I want to make strings like
321 weeks, 1 day, 6 hours and 12 seconds ago
4 miles, 32 yards and 2 inches ahead
10 liters, 10 milliliters
>>
>>61799350
Not him but learn to use asprintf before you try that or you'll be in for an hour of byte twiddling that could be replaced with a simple call to asprintf
>>
>>61793160
fnct sum_mult(k:int, n:int) -> int $ (p=k/n)(q=p*(++p)/2) ; return (q*n) ?
total:int as 0 += sum_mult(N, _2) with _2 in range (_2=3,5,15);
Thread posts: 339
Thread images: 28


[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]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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 4Archive shows an archive of their content. If you need information for a Poster - contact them.