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

File: 1504217806642.jpg (2MB, 2190x3143px) Image search: [Google]
1504217806642.jpg
2MB, 2190x3143px
What are you working on, /g/?

Old thread: >>62203462
>>
This is all you will ever need if you want to learn a programming language:

https://www.youtube.com/user/thenewboston/playlists
>>
>>62212264
>youtube
>in 2017
>>
File: MVI_4658.MOV.converted.webm (1MB, 1280x720px) Image search: [Google]
MVI_4658.MOV.converted.webm
1MB, 1280x720px
>>62212233
>What are you working on, /g/?
I am working on a status display for my raspberry.
Will also include a internet radio stream control.
Display and current radio playing works, but gotta either debounce those buttons or attach a remote to it. Probably the latter.
>>
File: 1503781261192.jpg (1MB, 620x4462px) Image search: [Google]
1503781261192.jpg
1MB, 620x4462px
Current /g/ language intelligence tiers.
>>
>>62212290
>uyama hiroto
quality music taste frendo
>>
This thread was made before the bump limit thus OP should be banned.
>>
>>62212335
you forgot my memelang, faggot
>>
>>62212335
>implying js is easy
>>
>>62212335
Why do C# and Java have better brains than C and Python?
>>
>>62212335
>fortran
>literal goto language
>any high
>>
File: IMG_20170831_150313.jpg (3MB, 4096x2304px) Image search: [Google]
IMG_20170831_150313.jpg
3MB, 4096x2304px
>>62212290
I'm using the exact same display right now.
But you seem to use it in 4bit mode, I'm using 8bit.

It's the prototype of a timestamp.
Every worker has an rfid-card that he can scan. They can divide their brakes as they wish, as long as they work their hours.

So if the worker wants to take a brake, he scans his rfid, hits the brake button and a timestamp is send to a database. Same process when he starts working again.

The second button just tells him his working hours for the day.
>>
>>62212435
>I have no idea what I'm talking about and I want everyone to be aware of it
>>
File: IMG_20170831_150329.jpg (3MB, 4096x2304px) Image search: [Google]
IMG_20170831_150329.jpg
3MB, 4096x2304px
>>62212499
>>
>>62212435
It's ok mr. I already have 20 hours of programming experience and did my first tutorial on youtube where someone said that goto's are for loosers.
>>
>>62212512
are you making a bomb
>>
>>62212502
I know what's that and it's fucking trash.
It doesn't even support recursive functions by default.
>>
>>62212560
>It doesn't even support recursive functions by default.
Yes and? Next you're going to complain about how it doesn't support pointer aliasing?
>I know what's that
If anything your answer proves you don't.
>>
Do true entry level jobs actually exist or will it always be 4 year degree + 2 years experience requirement
>>
File: 1502292216790.jpg (74KB, 640x640px) Image search: [Google]
1502292216790.jpg
74KB, 640x640px
>>62212592
>Y-y-you can't call shit my favourite trashtran, i-i-it's just you who's not intelligent to appreciate the beauty of this 50 years old shit!
>>
>>62212632
Just like send your shit anyway if you think it suits you, don't get intimidated by hrs. Every company wants a superman with 100+ years of experience for $0.1/h

Saying that tho, good companies tend to like passionate capable younglings (because they can be used as slaves for a while)
>>
Haskelfags BTFO
https://steve-yegge.blogspot.hu/2010/12/haskell-researchers-announce-discovery.html
>>
>>62212736
Ain't clicking that shit, Gyorgy
>>
>>62212694
I don't mind being used as a slave as long as there's no expectation of me showing up and knowing all the technologies they use instantly. I just have yet to find a job posting that I felt comfortable with that yet

Im a cs grad and I'm making 16/hour doing SQL for a non software company, id like to make a lot more than that
>>
>>62212683
You really are a moron.
>>
>>62212766
Cry harder.
>>
>>62212786
He's right, the fact you don't understand something viable doesn't make it stupid.
>>
File: Screenshot_20170902-061110.png (153KB, 1080x1920px) Image search: [Google]
Screenshot_20170902-061110.png
153KB, 1080x1920px
>>62212759
The problem you'll have is that there are so many other applicants.

It's not unusual to see 2000+ applicants for entry level jobs. You just gotta get lucky and throw your resume out there
>>
>>62212683
What industry are you in?
>>
File: Screenshot_20170902-061509.png (112KB, 1080x1920px) Image search: [Google]
Screenshot_20170902-061509.png
112KB, 1080x1920px
>>62212857
Also these fuckers with masters degrees applying to entry level jobs can go fuck themselves
>>
>>62212857
>Applied to dream position that's been open for 1+ month with 3 applicants
>First 10 applicants
>Still only at 7
>Pretty sure most of them merely clicked and link to the company's website and didn't actually apply
>Still on "Application currently being reviewed"
Damn can't these 10000+ employees companies cut the crap
>>
>>62212870
Software engineering
>>
>>62212377
Difficult means I'm smart!

Chopping a tree with my fists must mean in fucking smart because it's hard!
>>
>>62212845
>you don't understand
I do understand and I would never again write in this trash. It's up to you if you like this language.
>>
>>62212894
>whole range of actual engineers laughing in the background
Like poetry.
>>
File: beric_0.webm (619KB, 460x258px) Image search: [Google]
beric_0.webm
619KB, 460x258px
Can CMake download dependencies automatically like Gradle or Maven does?
>>
help, do i have autism friends?
>>
>>62212988
You can natively make it download through git or http and build or just use COMMAND to add your tools so it does download it.
>>
>>62213007
Sorry I'm wrong git isn't native. That being said it's pretty easy to plug.
>>
File: 8r.png (357KB, 368x535px) Image search: [Google]
8r.png
357KB, 368x535px
when i got to college i wasn't really into computer science because i had this pre-conceived notion that you need to be a math genius
>>
>>62213025
That's how it's suppose to be, but a lot of universities just turned it into easy shit

Go look at Georgia tech or MITs program, they still push a lot of math genius shit. Most people from other schools wouldn't survive a real CS program
>>
File: 1503992702258.png (139KB, 333x418px) Image search: [Google]
1503992702258.png
139KB, 333x418px
>>62213025

but that is actually very true, because as a webdev i dont need any.
>>
>>62213025
Good thing they dumped it down so brainlets can study it, huh?
>>
>>62212876
what else are they gonna do? after masters it's either PhD or job; are they gonna apply for senior software dev position because they did an extra year in school? cmon now
>>
File: python02.png (767KB, 758x624px) Image search: [Google]
python02.png
767KB, 758x624px
Python's where it's at! You can do almost anything with it!
>>
What C# program is well written and may be worth analyzing code-wise? I've started learning C# as my first programming language and want to see some real programming stuff instead of doing FizzBuzz
>>
>>62213141
i actually auto read your wrong sentence as the right one. i also i want to know this
>>
>>62212335
Why is Lisp above C++?
>>
>>62213189
dumb sepples poster
>>
>>62213174
I was reading both of them trying to figure out why it was deleted and reposted, I had to go word by word to see it. Deleting posts over minor typos/grammatical errors is pointless.
>>
IntEnum.__str__, IntEnum.__repr__ = int.__str__, int.__repr__  # Idiots.
>>
>>62212413
Because it's made by a literal faggot.
>>
Making a POSIX makefile.
Found out POSIX make doesn't support .PHONY targets.
Found out POSIX make doesn't support line continuations (\).
Found out POSIX make doesn't support % rules.
Found out about implicit targets and internal macros.
I like POSIX make.
>>
>in the Army because of those sweet education benefits
>hit my one year mark so I can take classes for free
>in South Korea so my only option is online classes at the moment

Any recommendations for online CS programs that will actually prepare me for a Bachelors or Masters CS degree at a Duke/UT Austin level university?
>>
>>62213235
You're the brainlet here, squirt.
>>
>>62213283
You can suck my dick and i will reward you with a frappuccino enriched with my superior semen as you like it.
>>
>>62213265
Are you surer of that?
>>
>>62213343
Yeah, though they could omit implicit targets and internal macros because they're bloat, but what can you do, nothing's perfect.
Also, % rules and .PHONY targets would be nice, maybe they will make into the next standard, but for now I can do without them.
>>
>make
fuck that.
>>
Should I use stdbool.h?
>>
>>62213427
Sure, why wouldn't you?
>>
>>62213398
>maybe they will make into the next standard
I wouldn't get your hopes up for that. If they wanted to standardise that, I'm sure they would have done it by now.
>>
>>62213427
lol no.
If you want store stuff on structs you can just
int someBool:1;
Otherwise use int.
>>
>>62213431
Just wondering if it was breaking some kind of C taboo to call my bools bools.
>>
>>62213266
Does the army not let you enroll in Korean schools? South Korea has some amazing foreigner friendly schools

Also you could get a cutey Korean girlfriend
>>
>>62213447
>t. idiot who's never maintained a project over 100kloc
Bool adds semantic documentation.
>>
>>62213451
C doesn't have bools, but it's not a problem to use them.
You can convert any int to bool with !!x
>>
>>62213473
Im going to be in KR for like 6 more months, then Texas for like a year, then Germany or Kuwait for another year. Shits too messy for bricks and mortar.
>>
>>62213511
Types in C are horribly uninformative. Use Hungarian.
>>
File: lth2102.jpg (777KB, 1026x1302px) Image search: [Google]
lth2102.jpg
777KB, 1026x1302px
>>
>>62213523
No, typedef types and comment on restrictions if the language cannot provide them programmatically.

typedef float Percentage; // float in range [0.0; 100.0]
>>
>>62213511
>not using naming convention for when function returns status and when it returns bool
t. Dumbfag who has never programmed anything
>>
>>62213539
>>62213546
>Use typedefs
>Use naming conventions
So which is it?
>>
>>62213523
>
egesz szam
fo(ures) {
nyomtatasf("Hello, world!\n");
visszateres 0;
}

Welp
>>
Any Scala niggas out here? I'm looking for an HTTP client with to parse XML and write to file.
>>
>>62213588
Kek
>>
>>62212632
I just got hired as a GUI developer (Qt) for a job that required 3 years of experience. I'm still doing my masters, this was my first application ever sent.
>>
>>62213451
>>62213511
>>62213512
>>62213523
>>62213539
bool (_Bool) actually has slightly different semantics than a normal integer type in C.
Fucking use them if you want to use them.
>>
>>62213662
What's the difference?
>>
>>62213671
All non-zero values are automatically converted to 1, including things which would normally convert to 0 as an int.
int a = 0.5;
bool b = 0.5;
printf("%d\n", a); // 0
printf("%d\n", b); // 1

It's nothing earth shattering, but it's still there. Compilers are also able to emit warnings for doing things which make absolutely no sense on a boolean (e.g. incrementing).

It also is a lot more self-documenting.
You don't need to guess if some function returning an int is "0 false, 1 true", "0 success, <0 error", or whatever common return status you might come across.
>>
>>62213730
What's _Bool implemented as?
>>
>>62213741
_Bool is its own type.
>>
OOP is most definitely not a meme.
>>
>>62213839
we wuz multiparadigm
>>
>>62213741
A mistake.
>>
>>62213875
It definitely adds value to the language. The last thing that needs to happen is every library implementing their own liba_bool_t and liba_int32_t, which might not be compatible with libb_bool_t and libb_int32_t.
>>
File: p91.png (827KB, 827x672px) Image search: [Google]
p91.png
827KB, 827x672px
Python's where it's at.
>>
>>62213839
Multi paradigm is the true solution
>>
>>62213973
>>62213854
>>62213839
You can go on about your multimemes all you want, but that doesn't mean that OOP isn't hot garbage.
>>
>>62213987
OOP is the optimal paradigm for stateful and interactive systems.
>>
>>62213987
Show us the right way, master.
>>
Review my makefile: https://pastebin.com/BJtBUNyD
>>
File: 1490990725930.jpg (124KB, 1024x1024px) Image search: [Google]
1490990725930.jpg
124KB, 1024x1024px
>if(bPointInRect == Bool.True)
nani
>>
>>62214062
I hope you generated that.
>>
>>62214093
Yes I did. However after the generation there's no need for editing it and the generation is so simple I won't include a generator in the distribution.
>>
>>62212264
Based Bucky Roberts
>>
File: 1484059550584.png (62KB, 244x216px) Image search: [Google]
1484059550584.png
62KB, 244x216px
>>62212876
>CXO level applicants
>>
Now I remember with I hate Java streams.
import java.net.{HttpURLConnection, URL}
import scala.io.Source
import scala.util.{Failure, Success, Try}

object Http {

def apply(url: String): Try[String] =
new URL(url).openConnection match {
case conn: HttpURLConnection =>
try {
Success(Source.fromInputStream(conn.getInputStream).getLines().mkString("\n"))
} catch {
case e: Throwable => Failure(e)
} finally {
conn.getInputStream.close
}
}
}
>>
Given a source code in C, can I compile only one function and all functions it calls and then run it?
>>
>>62214189
with any needed definitions, structs and global variable of course
>>
>>62214189
Would a compiler avoid compiling static functions which are never called?
>>
I've been reading a lot about how Modern C++ is a great subset of C++, but it's made complicated by all the old legacy complex crap in C++. Instead of making a new language like Rust, why doesn't someone just make a C++ compiler that only supports the modern subset of C++, and disallows anything old and broken?
>>
>>62214288
Backwards compatibility.
>>
>>62214288
You don't want to alienate 99% of your userbase.
>>
>>62214288
Some deprecated things have already been removed. C++17 removes trigraphs and auto_ptr.
>>
File: 1483073157801.jpg (110KB, 1280x720px) Image search: [Google]
1483073157801.jpg
110KB, 1280x720px
Employed Haskell programmer here
>>
File: gitty-up.webm (1MB, 1042x578px) Image search: [Google]
gitty-up.webm
1MB, 1042x578px
How neat would it be to write a C/++ build system that loads projects written themselves in D. Like SCons having project files written in Python. Nothing beats having first-class language support.
>>
>>62214260
I mean something like:
void baz() {
puts("baz\n");
}

void bar() {
puts("bar\n");
}

void* foo() {
puts("foo\n");
bar();
}

int main() {
puts("main\n");
foo();
baz();
}

$[disregard main and compile only foo() and bar()]
$./foo
foo
bar
>>
Is there any way I can improve this makefile?
>>
>>62214360
tfw actually employed Haskell programmer here

get fucked memer
>>
File: scrs.png (54KB, 363x261px) Image search: [Google]
scrs.png
54KB, 363x261px
>>62214398
Forgot link
https://pastebin.com/m33prqfs
>>
>>62214288
clang-tidy -checks='modernize-*, cppcoreguidelines-*'
>>
>>62214412
you better post that image source too now
>>
>>62214360
Employed Java programmer here
>>
>>62214260
>>62214395
Difficult for the compiler to know when the language allows for pointer arithmetic. Non-portable example (AMD64 GCC Linux):
#include <stdio.h>

void f() {
puts("Hello, world!");
}

void g() {
(&g - 19)();
}

int main() {
g();
return 0;
}
>>
>>62214526
Is arithmetic on a function pointer well defined behavior?
>>
>>62214510
>pajeet and weeb
can't think of any way one could be more subhuman other than being polish
>>
>>62214526
How do you possibly get 19 and not some multiple of the word size?
>>
>>62214569
co ty kurwo masz przeciw polaków
>>
>>62214569
Being Russian?
>>
>>62214599
It all gets compiled to machine code, kid.

>>62214526
So I guess there's no way other than to generate a new source file?
>>
>>62214619
easy there sebastian
>>
>>62214599
variable instruction size
>>
>>62214510

Employed admin here.

How come every single poster on /g/ (yes, even the shitposters, the noobs on /sqt/, and frogposters) are 43543253 times better at coding than any coder I've eve had to support?

I mean holy shit. If I get one more "the CPU is faulty" complaint from some guy that left out a ; in his code I'm going to top myself.
>>
>>62214651
How does your company manage to survive if what you state is true
>>
>>62214569
>>62214624
This
>>
>>62214555
The C99 standard doesn't have any specific rules about function pointer arithmetic.
GCC just yields a warning:
-Wall -Wextra -std=c99 -ansi -pedantic

warning: pointer to a function used in arithmetic [-Wpointer-arith]


>>62214599
What >>62214637 said
Try it yourself with
gcc -g -O0 -o main main.c
gdb main
disassemble f
disassemble g
>>
>>62214679

Easy. They believe in the mythical man month and they deal with shit coders by hiring ten more shit coders and giving me ten times the work.

Last week I had to install Filezilla on a developer's desktop because it was too hard to do himself. I mean fuck me.
>>
>That guy who uses Rust because it's "safe" but makes every reference mutable and derives copy on every data structure
>>
>>62214697
So I guess it's undefined behavior by omission. Or some kind of compiler extension.
>>
>>62214651
Programmers who (also) write code as a hobby are more passionate. It's as easy as that.
>>
File: 1504237914640.jpg (31KB, 640x960px) Image search: [Google]
1504237914640.jpg
31KB, 640x960px
>>62214709
Anon, I'm sorry. Have some Clara to help you deal with it.
>>
>refactoring some Java code in IDEA
>temporarily create a circular inheritance between two classes while I change stuff
>IDE immediately freezes and CPU usage shoots up
>still frozen after a few minutes
Surely they can't be that stupid and not have added a simple infinite loop check
>>
>>62214697
>Try it yourself with

Yeah I'm not doubting that it's valid. I just thought a function would always exist on a word boundary.
>>
>>62212335
how do you think they come up with the names?

the names seem perfect.
>>
>>62214402
>get fucked memer
error: missing vocative comma in line 3
>>
>>62214747
Stop using Eclipse you turd.
>>
>>62214762
No, he wanted you to get a fucked memer, all is OK
>>
>>62214761

the military, spies.... like Ada lovelace, code breakers have always been real good at naming things.

thats a good name, Ada... and it is a language!
>>
>>62214731
Thank you kind sir.
>>
File: 1401126578487.jpg (19KB, 192x220px) Image search: [Google]
1401126578487.jpg
19KB, 192x220px
>>62214776
>refactoring some Java code in IDEA
>Stop using Eclipse
>>
>>62214747
I can't decied wether this is bait or not.
Circural inheritance is easily detectable.
Infinite loopa are not
>>
>>62212435
I heard Fortran does loops really well though.
>>
>>62214651
Because companies are terrible at hiring on merit and good programmers often have problems that are external to their work that often disqualifies them from working.
Not everyone. But a good portion. People keep talking about how important the social skills are but they don't realize that what's really needed is just a conduit. Someone to bring the work from the people who needs it done to the filthy programmers who don't know human language.

I assume all of the programmers you know aren't socially inept.
>>
>>62214651
Because there's a difference between a code monkey and a software engineer that HR has yet to catch on to.
I'm of the opinion that in order to practice commercial software engineering you should have to be licensed like every other kind of engineer. The job can be just as dangerous as any other engineering field - it's all fun and games dealing with diploma mill code monkeys until their poor programming practices leak all your user's credit card details. What does /g/ think about this?
>>
>>62214916
It's more that clients, managers, etc. don't like being told when they're full of shit and need to shut up, and a lot of programmers learned their skills in environments where that was common, where ideas win and not personalities.

If they didn't have such fragile fucking egos, they wouldn't have been sweet-talked into Java and JavaScript, and we wouldn't have to put up with the mountain of shit we now find ourselves buried under.

Some customers specify that they want a solution that runs on the JVM. They're never able to articulate a good reason as to why.
>>
>>62215078
Watch out, you'll make the degree-less programmers angry.
>>
>>62215216
I don't even mind degree-less programmers as long as they can demonstrate their skills to an external body. There are a lot of awful CS graduates too - a friend of mine got a 2:1 in his degree by stringing bits of Stack Overflow code together and now he has a grad job working with medical lasers.
>>
>>62212233
rewriting linux kernel in html
>>
A text-to-speech with AHK and MS Speech API. Not the best language, but it beats installing Visual Studio just to slap some GUI in Windows.
>>
>>62215248
They tend to have an attitude of "I don't need to pass exams/get certified, look at my github profile!".

Any licensing such as you describe would probably devolve into being a glorified Python/JS class, though. After all, businesses need lots of people to maintain their buggy software.
>>
File: IMG_20170902_161801.jpg (93KB, 720x776px) Image search: [Google]
IMG_20170902_161801.jpg
93KB, 720x776px
Wew the shills really are working overtime
>>
>>62215362
D is shilled as much as Rust because it has no purpose. It's just a better <buzzword>.
>>
>>62215362
d-d-d-dead
d-d-dead d-dead
d-d-dead dead dead
>>
>>62215380
Rust is its own thing. It's not a "better" C++, it's a different language with some overlap in use cases.

D is a better C++ with a garbage collector nobody asked for.
>>
>>62215362
Yeah, I've been noticing a lot of D postings on HN and /r/programming recently, and the comments are full of shills ready to proselyte and defend their language of choice.
>>
>>62215395
In what way is Rust radically different than C++? The only thing I can think of is the way it handles memory.
>>
>>62215435
They don't spend that time actually using the language because it's dead.
>>
>>62215362
>improved integration to C
If it was not top notch in the 1.0 then I'm really skeptical that will it ever be good.
>>
>I think there's fundamentally 3 architypes of programmers, divided by which ideals we hold in highest esteem:
>You are a poet and a mathematician. Programming is your poetry
>You are a hacker. You make hardware dance to your tune
>You are a maker. You build things for people to use
Which are you anon?


(Full article https://josephg.com/blog/3-tribes/ )
>>
>>62215438
Rust doesn't even have OOP. It's not like C++ at all.
>>
Implementing a logging system because Windows doesn't support the console in proper Windows applications (using WinMain).
>>
>>62215482
There's four types, actually. The fourth type, most common to /dpt/, is:
>You are a nodev. You shitpost about things you don't understand instead of making anything.
>>
>>62215482
>>You are a maker. You build things for people to use

I'm a maker but I appreciate code written by poets and mathematicians
>>
>>62215486
>using Windows
imagine being this much of a windows user
>>
>>62215482
http://esr.ibiblio.org/?p=7478
>>
>>62215494
True
>>
>>62215438
> In what way is Rust radically different than C++? The only things I can think of the crucial issue of memory handling, plus type system, pattern matching, macros, error handling, program organization, integrated build system and package manager.
>>
>>62215505
It's best described as
[pain]
>>
>>62215555
Why not just switch to Linux?
>>
>>62215580
I use both. This program needs to run on Windows specifically.
Plus, debugging is infintely better.
>>
>>62215494
please dont bring /agdg/ shit in /dpt/.
>>
>>62215705
Only if you stop bringing /dpt/ shit to /agdg/.
>>
>>62215438
Rust is closer to Haskell than it is to C++. The only similarity with C++ is the C machine model.
>>
>>62215769
>Rust is closer to Haskell...
Where did this meme come from?
>>
>>62215830
dude adts lmao
>>
>>62215769
Where are true HKTs? Where is TCO?
>>
>>62215833
https://stackoverflow.com/a/30672566
    let mallard: Rc<RefCell<QuackWrap>> = Rc::new(RefCell::new(QuackWrap::new(Duck)));

So this is the power of Rust?
>>
>>62215769
>laziness isnt default
>you have to manage your memory in a way
>you have structs and classes and everything else
>type annotations are completely different
>decl names
nani?
Rust is hardly like haskell
>>
>>62215881
What's so difficult about that code?
>>
>>62215830
ADT, traits (which are basically type classes), pattern matching, monadic error handling, type inference, immutability by default, iterators (which is basically Haskell's lists and have little to do with C++ iterators), the standard library full of functional stuff.
>>
>>62215908
:<l<>>=::(::(::()));
>>
>>62212560

>It doesn't even support recursive functions by default
This only holds true if you are compiling Fortran 77 or below.

>>62213529

>void main
Invalid C program.

>>62215482

Hacker with a splash of the poet/mathematician added in. Just because I care about performance doesn't mean I don't give a shit about correctness. My OS professor is an example of the pure hacker type, and I am nonetheless confused as to why he reimplemented gets() in his kernel.
>>
>>62215925
still not seeing the problem
>>
>>62215942
Because you have never programmed anything.
>>
>>62215921
Haskell is a lazy pure functional programming language. None of that applies to Rust.
>>
>>62215936
Hey Rubester

Call it a contradiction if you will, but Ruby gives you neither performance nor correctness, yet you claim to care about both?
>>
>>62215906
No one said Rust is Haskell, but the former has been influenced by the latter a lot.
>>
>>62215830
Rust is basically a functional language that disguises itself as an imperative language because diploma mill graduates run away screaming "I DON'T GET MATH" when they hear the phrase "functional language"
>>
>>62215950
Yes I have.
>>
>>62215874
Both are on the roadmap.
>>
>>62215962
Rust inheriting aspects of != Rust is alike to
Rust to me just looks like an experimental C++ branch where someone forgot to get rid of all the shit and just added more functional stuff on top
>>
>>62215952
Well, there would be no point in Rust if it was exactly like Haskell, something no one claimed btw. The point here is that it has borrowed at least as much from Haskell as from C++, and probably more from the former if you don't count things like syntax.
>>
>>62215969
You wish. Rust is an imperative language with functional constructs to act hip and modern. It's the polar opposite of Haskell.
>>
>>62215362
>needs to add new syntax for compile-time computations
top zozzle
>>
>>62215987
on the roadmap != in the language
>>
>>62215987
By that logic Haskell can be counted as having dependent types, so Rust is still far behind it.
>>
>>62216003
Rust is nothing like C++. It's more like C with magic pointers.
>>
>>62216003
> Rust to me just looks like an experimental C++ branch where someone forgot to get rid of all the shit and just added more functional stuff on top
To me, Rust looks like Haskell 98 made practical, that's the problem of classifying a language with several different sources of inspiration.
>>
Reminder that if anyone claims you need OOP, they're either lying or misinformed
>>
>>62215961

1. Different tools for different jobs. I don't use Ruby when I want to make fast programs, I use it when I want to hack together a tool quickly, and performance doesn't really matter, either because the program is I/O bound or because I'm only going to run it once or twice.
2. You can have correctness in any language. I generally don't like most functional languages. I can agree with the first camp in that correctness is important, but I disagree in them thinking everything needs to be immutable and purely functional.
>>
>>62216048
Funny, to me it looks like Haskell 98 made impractical.
>>
>>62216045
>Cons operator everywhere
>extremely verbose
>the BC is just another version of RAII
vhatever you say lad
>>62216048
>Haskell 98
how
>>
>>62216041
> Rust is still far behind it.
Only if you think Rust is trying to out-Haskell Haskell, which it isn't.
>>62216066
> how
See >>62215921, by Haskell 98 I mean barebone Haskell without fancy GHC extensions.
>>
I think we can all agree that Rust is a new language unlike anything that has ever been seen before.
>>
>>62216062
>Haskell is practical
1 G b / S
G
b
/
S
>>
>>62216101
Its an amalgamation we've never seen before, yes.
>>
>>62216055
>2. You can have correctness in any language. I generally don't like most functional languages. I can agree with the first camp in that correctness is important, but I disagree in them thinking everything needs to be immutable and purely functional.
For me at least, referential transparency is much more important than worrying about line-by-line immutability. I don't care if a function uses a mutable data structure internally if it doesn't leak out.
>>
>>62216049
why?
>>
The best thing about Rust is Cargo. I wish C++ had something similar, but we're probably going to be stuck using cmake moonrunes for the next 30 years.
>>
>>62216133
Hows Conan?
I never see it talked about so i assume its either shit or no one can escape the *make cult.
>>
>>62216131
Because you don't need OOP.

>>62216133
One thing I don't think cargo could do when I last checked was build some targets for build and others for host, so you might still need to use other build systems for some projects.
>>
Two factor authentication combines a thing that you'll forget with a thing that you'll lose.
Discuss.
>>
>>62216101
>shit standard library
>borrow checker tries to outsmart you
>snake_case
>more verbose than C++
agreed
>>
>>62216156
For those of us who don't lose and/or forget things all the time, it's great and increases security.
>>
>>62216175
>snake_case is bad
>>
>>62216184
CamelCase is vastly superior.
>>
>>62216200
snake_case for variables, camelCase for functions and PascalCase for types.
>>
>>62216200
Fuck that, classic C style all the way with everything lower case except for stuff that's fully capitalized.
>>
>>62216200
Consistent use of all three > only using one like an autist
>>
>>62216156
>forget
>not having your own password creating scheme that makes them guessable, but only for you
>>
>>62216145
>Hows Conan?
It's alright, but you can still tell that it's just a wrapper around cmake.
>>
>>62216256
>it's just a wrapper around cmake.
sad, I wonder if the ISO have ever talked about a proper package manager.
>>
>>62216256
The C++ build pipeline is getting ridiculous now.
>use conan to generate CMakeLists.txt
>use cmake to generate makefile
>use make to generate actual program

Literally four different layers just to make unreadable moonroons readable. Why not just have a build system/package manager that is readable in the first place?
>>
Stop with this C, C++, Java shit
Holy Ocaml is the only worth learning programming language
>>
>>62216331
that's not haskell
>>
>>62216331
There's nothing wrong with Java. The only ones who complain are MineCraft kids.
>>
>>62216334
that's not idris
>>
>>62216331
>double ;'s
>>
>>62216126

>I don't care if a function uses a mutable data structure internally if it doesn't leak out.
Then don't write functions that mutate the external environment.
>>
>>62216348
>still no value types
>>
>>62216361
I don't, but I have to work with other people, it'd be nice if the compiler could enforce it through the type system or something else.
>>
>>62216376
You mean const?
>>
>>62216348
Java is not Ocaml, so is shit
>>
>>62216376

>I have to work with other people
You see, these are your problems. I avoid working with other people as often as humanly possible.
>>
Learning the basics of C#.

I've learnt: loops, arrays, basics of OOP. What next?
>>
https://pastebin.com/eaqH6WsX
>>
>>62216466
functions,structs, & generics
>>
>>62216480

thanks
>>
File: drinking.jpg (23KB, 425x283px) Image search: [Google]
drinking.jpg
23KB, 425x283px
realizing how much i fucked up not saving my class assignments to put on github
>>
>>62216498
You think youd really stand out among the millions of other CS grads in having probably the same examples/projects?

Do something different lad.
>>
>>62216498
What kind of assignments?
>>
>>62216514
i'm applying to grad school at carnegie mellon and they want proof when you say you've done an assigment over X lines of code
>>
>>62216526
That wasnt my point.
My point was you'd probably hurt yourself more putting up shit theyve seen a trillion times.

Come up with a relativity unique project you'd have an actual interest in.
>>
>>62216566
yeah let me just whip up a real unique 1k line project in my free time between classes in a couple months before the application period closes. they'll surely like to see a halfassed game of life implementation more than whatever grueling coursework i had to do in operating systems
>>
for x in ["abc", "abcde, "abc"]:
sys.stdout.write("\r"+x)
sys.stdout.flush()
time.sleep(2)


This code first prints out abc. Then it jumps back to the beginning of the line and overwrites the line with abcde. Then it jumps back to the beginning and overwrites the line with abc, BUT it doesn't erase the "de" part at the end, so the line will still say "abcde".
How do i clear the line after each print? Using Python 2 if that matters.
>>
>>62216526
Out of curiosity, how many LOC did they need/want?
>>
>don't smoke for 3 days
>head hurts
>can't focus
>can't write proper code
>always angry and frustrated
fucking hell, I fell for that ""healthy lifestyle"" meme
>>
>>62216498
put them on github now?
>>
>>62216602
>don't inject heroin for a day
>veins itching
>everything hurts
>can't focus
>angry and frustrated
>what the hell is this healthy lifestyle meme?
literally you
>>
So why isnt the function "collatz" running here? It just prints to say a number and when i do the program ends instead of doing collatz(number)
def collatz(number):
if int(number)%2==0:
return number/2
elif int(number)%2==1:
return number*3+1
#DO LATER while True:
print("Input a number.")
collatz(int(input("")))
>>
>>62216689
>python
>>
>>62216689
You're forgetting to recurse. Look at your return statements.
>>
What do you think of some of my ideas for a language?
1. multiple values (and they're not the same as tuples):
>write (1, 2, 3)
(1, 2, 3)
>write 1, 2, 3
1
>write each 1, 2, 3
123

2. functions and calls like this:
>write fun(x) return x end "Hello", "world"
Hello
>write each fun(x, y) return x, y end "Hello", "world"
Helloworld
>write fun() return "Hello world" end $ #$ calls the function with no parameters
Hello world

3. with
writeln with open pop args each readln $    #if the function takes arguments, $ provides to it with's arguments
#this is the same as:
writeln with file = open pop args each readln file

with used inside a loop evaluates only once, so this code is the same as above:
writeln each readln with open pop args

4. generators:
fun fibonacci(n)
with a, b = 1, 1 for each i in seq 1, n generate a, b = b, a + b
end

generate provides output but does not return from the function as long as there's more output to provide and there's a demand for the output
so the function above returns a sequence of first n Fibonacci numbers

5. for loops:
for each i in seq 1, pop args with (if (i % 3) == 0 then "fizz") .. if (i % 5) == 0 then "buzz") writeln if $ == null then i else $
with [each fibonacci pop args] for each i, v in pairs($) writeln i .. " " .. v
>>
constructors are shit
>>
>>62216738
>multiple values
What's the advantage to using this over tuples and lists? In other words, what problem does this solve that tuples/lists cannot?
>>
>>62216768
See generators.
>>
>>62216738
most of those are pretty awful, desu.
especially your functions.
>>
>>62216600
a 'select all that apply' for an OOP language and C, for <200, 200-1000, and 1000+ lines of code
>>
>>62216768
Also, a tuple is a single value that contains multiple values rather than a sequence of multiple values.
each called on a tuple will only execute once since the sequence of values passed to it only contains one value that happens to be a tuple.
>write each 1, 2, 3
123
>write each (1, 2, 3)
(1, 2, 3)
>>
>>62216618
if i still had them do you think i wouldn't do that?
>>
>>62216689
How about you print the output of the function? Not to mention the function isn't correct.
>>
>Sepples
Suppose I have a pod struct like this.
struct Foo
{
int x, y, z;
};

I can initialize it memberwise just like C.
Foo foo = {10, 11, 12};

So why can't I do the same in a class?
class Bar
{
public:
static void whoCares(int x, int y, int z)
{
Bar bar = {x, y, z};
}
private:
int x, y, z;
}
>>
>>62216840
Yeah, the parenthesis in argument list are stupid. There's no need to use them and parenthesis means a tuple. Also, end is redundant since return does its job.

fun fibonacci n
with a, b = 1, 1 for each i in seq 1, n generate a, b = b, a + b
return


Better now.
>>
>>62217013
Why would I use !Python over Python?
>>
>>62216526
>X lines
how many
>>
>>62217053
i already answered this
>>62216850
>>
>>62217013
Also, with is not needed in this particular example since scope for a and b is limited to the function which doesn't do much more anyways
fun fibonacci n
a, b = 1, 1
for each i in seq 1, n generate a, b = b, a + b
return


The code in >>62217013 is still valid but this is more readable.

>>62217044
?
>>
>>62217058
shit my bad
thanks for linking the answer
>>
>>62217060
replace fun with def (which are both shit) and a lot of your syntax is just tweaked python.
>>
>>62214748
>I just thought a function would always exist on a word boundary.
It's a reasonable assumption and functions are aligned to word boundaries with optimization enabled.

gcc -g -O2 -o main main.c
gdb main
info addr f
Symbol "f" is a function at address 0x660.
info addr g
Symbol "g" is a function at address 0x670.
>>
>>62217085
desu it's mostly Lua mixed with Icon. Now that I got rid of end keyword it may resemble Python more but it's not because of indentation but because fun is an expression that expects function body finished by return keyword.
Some fun with functions:
>writeln fun x write "Hello " return x "world"
Hello world
>writeln fun x write "Hello " return "world"
fun <0x[function address]>
>writeln (fun x write "Hello " return) "world"
("Hello")


Hm, now I think end is needed after all but only when function returns no value.
>writeln fun x write "Hello " end "world"
Hello


So this >>62217060 code should be:
fun fibonacci n
a, b = 1, 1
for each i in seq 1, n generate a, b = b, a + b
end

otherwise return expects an argument and it will take next expression as such.

So, 'end' would be the same as 'return null'.
>>
>>62217247
get rid of fun and any other declaration keyword like it.
Instant turn-offs in a language.
>>
>>62217265
I also thought of using assignment operator like in some functional languages but I'm not sure about it.
>>
>>62217265
>looks like Python
>"remove fun and declaration keywords"
>now looks like CLU
What's the difference?
>>
>>62216977
Why would you want that.
>>
>>62217419
would make named constructors much more convenient
>>
Another idea: some OOP language treat literally everything as an object so why not make a language that treats everything as a function?
For example, a literal would be a function that returns self, a literal with an argument passed to it would be a function that returns self only if it equals to the argument and a literal with 2 arguments passed would return self if it equals to the first argument and otherwise return the second argument:
write 0 x #writes 0 if x == 0
write 0 x, 1 #writes 0 if x == 0, otherwise 1
>>
>>62217435
Go do functional programming
>>
Another idea: some OOP language treat literally everything as an object so why not make a language that treats everything as a function?
For example, a literal would be a function that returns self, a literal with an argument passed to it would be a function that returns self only if it equals to the argument and a literal with 2 arguments passed would return self if it equals to the first argument and otherwise return the second argument:
write 0 x        #writes 0 if x == 0
write 0 x, 1 #writes 0 if x == 0, otherwise 1
>>
>>62217435
Oh boy, just wait until you find out about functional programming.
>>
>>62217449
>cannot delete posts this often
fuck 4chan
>>
I'm an experienced programmer and I want to learn several new languages. Can someone give me a suggestion for a project I could write in each language as a learning experience?

Something big enough to actually let me learn and try out the language, but small enough to be practical and to let rewrite it in each language. Probably something that doesn't need random obscure third-party libraries, but standard library stuff is fine.
>>
>>62217477
an HTTP server
>>
>>62217473
Why the fuck do you keep deleting posts anyway?
Theres literally no need to.
>>
File: lambda1.png (62KB, 1374x726px) Image search: [Google]
lambda1.png
62KB, 1374x726px
>>62217462
Congratulations, you've just invented a shitty version of lambda calculus. Which, btw, has been shown to be Turning-complete, even in the bare-bone form, without numbers and conditionals.
>>
>>62217504
I just missed one comma.
>copy the post, paste in the field, correct my mistake and post again
>delete old post
>forgot about the fucking
 tags
>post again, this time all correct
>cannot delete old post

Why can't we edit our shit?
>>
Can I conditionally initialize a union member in C++?
struct ContainsUnion
{
union
{
int i;
char c;
};
bool i_not_c;

ContainsUnion(ContainsUnion const &other): /* if other.i_not_c is set then initialize i with other.i, else initialize c with other.c */ {};
};


Doing it in the constructor body is not acceptable.
>>
>>62217541
just quote your post and make an asterisk correction you dumb reddit poster.
>>
>>62217541
Dafuq just happened?
I didn't close the code tag so I expected it to be ignored.

What a fucking garbage.
>>
>>62217548
This is good for shitposting boards.
>>
>>62217541
Noone cares about or even notices small errors like that, the brain fills it in for you as you read it. Unless the post is a complete grammatical trainwreck or you've made a major mistake then just forget about it.
>>
>>62217542
No, I think you have to do explicitly in the body. Or name the union and copy it as a single value.
>>
>Noticed that I have no Pajeets in my classes this semester
>This is weird, because a year ago, it had tons
>Remember Trump's Great Eviction
The absolute MADMAN
>>
>>62217581
It was in the code, not in a sentence. Everything is a major mistake.
>f x, y
>call f with x and y as arguments
>f x y
>call x with y as an argument, then call f with the result as an argument
>>
>>62217583
>Or name the union and copy it as a single value.
Fuck I'm stupid, of course. So what will a union to union copy do, just memcpy the bytes occupied by the union?
>>
>>62212233
Been writing down ideas for a business specific customer management system for years.. I've drawn out the database multiple times and have gotten as far as creating the login/authorization using jwt and passport. Can't seem to make progress beyond this, keep getting hung up on UI. Any advice?
>>
>>62217629
I guess, unions get default copy constructors. It's still a UB to read from a field that wasn't been written to last tho.
>>
>>62217715
>t's still a UB to read from a field that wasn't been written to last tho.
Some anon told be that was valid only in C89 but later standards fixed it
>>
>>62217699
>keep getting hung up on UI. Any advice?
Ask your parents or tech illiterate friends to use it.
If they don't bitch or get confused then its probably okay
>>
In one of my class projects for C I need to generate and store 100 random integers.
The storing part, is that what arrays for?
>>
>>62217748
Yes.
>>
>>62217748
Yes.
>>
>>62217728
C99 and C11 allow it (as implementation-dependent, I guess), but C++ doesn't.
>>
>>62217748
Your professor obviously wants you to declare 100 integers
>>
Hi I'm still new to programming, I want to make a VN/adventure game with android/java.
I have a good grasp on java and have the basic on android.

It's pretty simple, just change the text depending on choices, display pictures and play music.

However, for the text.
I could put thousands of strings or put them in an array, or I could read them from a txt file and read that.
I feel the last option is the best, however how would I tell where the user is up to in the text file to change the pictures and music accordingly?
Would I need multiple text files for the branching choices? It would be easy with just a thousand strings and I could tell which is which, but that doesn't seem to effective.

I'm not sure what's the best direction I should take, can you guys help me?
>>
>>62217715
I can't see how it would work if I started putting copy-constructable or even move-constructable types in the union.
>>
>>62217748
#include <stdlib.h>
#include <time.h>
#define RND_INT_COUNT (100)
int main(void) {
int rndInts[RND_INT_COUNT];
srand(time(NULL));
for (int i = 0; i < RND_INT_COUNT; ++i) rndInts[i] = rand();
}
>>
What do you think about using double period for method calls? I'm thinking about simple syntax sugar where
object..method(arg)
is expanded to
method(object, arg)
.
I don't want to use a single dot because struct member selection already uses that and i want to have all symbols resolved before typechecking.
I can't use colon (like in lua), because these are reserved for declaring types.
Any ideas?
>>
>>62217787
put them in a text file and read that into an array

?
>>
>>62212543
haha h-hating gotos are just a meme r-right?
>>
File: C++14 9.5.2.png (24KB, 833x152px) Image search: [Google]
C++14 9.5.2.png
24KB, 833x152px
>>62217801
Then you would have to provide these members for the union by yourself.
>>
>What are you working on, /g/?

Tryng to improve my application's multithreading API. I wanted something that would work a little like "fibers" from a user's perspective, so I thought you could add two types of object's to a threadpool's queue: groups (I don't know why I named them execution contexes for now) and single jobs:

struct th_job_t
{
void (*func)(void*);
void *args;
}

struct th_exec_ctx_t
{
th_job_t *jobs;
int32 num, max;
int32 num_started;
int32 num_completed;
};

/* Work entries are added to the thread pool's queue */
struct th_work_entry_t
{
int type;

union
{
th_job_t job;
th_exec_ctx_t *ctx;
} data;
};


Then in the thread pool's worker functions I could check if we're dealing with a work group or a single job:

    void (*func)(void*);
void *args;

th_work_entry_t *w = tp->work[tp->work_first];

switch (w->type)
{
case TH_WORK_ENTRY_JOB:
{
func = w->data.job.func;
args = w->data.job.args;
INCREMENT_TP_FIRST();
}
break;
case TH_WORK_ENTRY_CTX:
{
th_exec_ctx_t *ctx = w->data.ctx;
int32 i = interlocked_increment_int32(&ctx->num_started) - 1;

func = ctx->jobs[i].func;
args = ctx->jobs[i].args;

if (i == ctx->num)
{
INCREMENT_TP_FIRST();
}
}
break;
}


I don't know if it'll work well or not yet though. I just want to be able to do two types of job entries: async one-shot stuff in the case of which you don't care when the function finishes, and work groups which you want to synchronize at the end of a stack frame while doing work for the group on the waiting thread. Suggestions welcome.
>>
New thread:

>>62217857
>>62217857
>>62217857
>>
>>62217830
Seems comfy.
>>
>>62217858
Never realized I could put member functions in a union, looks awkard but I think I can do it with this.
I must have to pass that tagging bool into the constructor because it won't know which member it contains otherwise.
>>
>>62217830
Double period is for concatenation.
Use $ desu.
>>
>>62217929
>Double period is for concatenation.
what languages do this?
>>
>>62217951
Lua for example.
>>
>>62217929
>>62217830
Actually, I think @ would make more sense.
>
object@method(arg)
>>
>>62217923
No, I just end up with the same problem. Fuck.
>>
>>62217835
I get that but how would I tell where the user is up to when reading it?
Like let's say I have 1000 lines in my game and at line 45 the user is presented with a choice and the background changes the following line.
How would I know that? Would I have to count all 45 lines and then show the choice dialogue? Couldn't that string have an extra value that I can check to see if I need to show the dialogue box?
Is it possible? Like if the line was an object instead, with a string and boolean value for displayChoiceBox.
>>
>>62217929
>>62217987
Both $ and @ seem kind of hard to notice, they blend in with normal characters a bit too much, i think. i think my only free single char operators would be ~ and !, maybe \ ?
object\method(args)
>>
>>62218039
Does your language have pointers? ~> might be neat by an analogy to ->.
>>
>>62218052
This.
>>
>>62218052
or =>

>>62218039
>>
>>62218052
It does, but i guess methods on pointers will just be defined to take a pointer as first arg. I also never liked the arrows in c/c++.
Also if i go with two-char operator then i think i like .. the most.
>>62218074
=> is for lambdas and function types
>>
import java.net.{HttpURLConnection, URL}
import scala.io.Source
import scala.util.{Failure, Success, Try}

object Http {

def apply(url: String): Try[String] =
new URL(url).openConnection match {
case conn: HttpURLConnection =>
try {
Success(Source.fromInputStream(conn.getInputStream).getLines().mkString("\n"))
} catch {
case e: Throwable => Failure(e)
} finally {
conn.getInputStream.close
}
}
}
>>
>>62212990
use something like ANTLR or a specialized library to parse XML and friends.
Thread posts: 329
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]

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.