/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

learncpp.com/
forbes.com/sites/rajatbhageria/2017/09/10/is-learning-how-to-code-still-worth-it/amp/
lmgtfy.com/?iie=1&q=What is string[] args in main?
srfi.schemers.org/srfi-119/srfi-119.html
docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/reflection
stackoverflow.com/questions/13865842/does-static-constexpr-variable-make-sense
twitter.com/SFWRedditVideos

When does the fun part start? I have been learning C++ because I want to create Qt Quick apps!

>C++
>fun

user, I...

Came here to appreciate Lain.

That's right, C++ is fun.

The only part I find somewhat fun is debugging.

I'm in chapter 9.12 of this tutorial
Will I ever make it? learncpp.com/

Just wait until you meet templates, that's when the real fun begins.

What's the best Scheme flavor?

>C++ is fun
>en.wikipedia.org/wiki/Stockholm_syndrome

>incomprehensible and kludgy C++ metaprogramming is "fun"

>using templates for metaprogramming

>not using templates for metaprogramming

Template metaprogramming sucks, you said it yourself.

>not using templates for metaprogramming
That only makes your statement weirder. They are about as "fun" as Java generics if used normally.

forbes.com/sites/rajatbhageria/2017/09/10/is-learning-how-to-code-still-worth-it/amp/

>his language's type system isn't turning-complete

>best Scheme flavor
I'd say Racket is the most usable and practical option if you want to develop an entire application in it (rather than, say, use it as a scripting language for your app).

>this is somehow actually useful

at least Rust has compiletime computations now :)

How would you parse a PDF invoice for the invoice number? (can be letter & numbers).

So far i load the document as 1 big string and then look for strings like "invoice no." Then I navigate right via 1 or 2 spaces and regex for potential hits.
Works ok~ish but hardly seems the best solution. Using the Itextsharp lib in .Net

>compiletime computations
I'm waiting for the day mainstream language designers take a hint from lisps and start offering proper metaprogramming facilities instead of barely usable template and type system hacks.

Without homoiconicity I don't see how you can get much further than constexpr.

>They think type-level computation is the same as compile-time computation which is the same as macros
You really shouldn't post about things you don't understand. Besides, Rust already has compile-time computation as part of optimization and macros.

Have you loved Lain today, /dpt/?

>implying i ever said they are the same thing
You really shouldn't post at all because you're a sperg.

>Without homoiconicity I don't see how you can get much further than constexpr
It can be done if you design your syntax so that it translates into s-expressions in a predictable manner.

What is ( String [ ] args ) parameter means in main method?

lmgtfy.com/?iie=1&q=What is string[] args in main?

>java -jar Foo.jar crap -x 100 -y 200 -z 300
>String[]{"crap", "-x", "100", "-y", "200", "-z", "300"}

So guys, I am reading Kochan, and K&R at the same time. Which one is a better way to get input from the user?
int c;
while((c = getchar()) != EOF && c != \n)


||

scanf(%i, &i);

>he's a white boy who codes
psssh nothin personnel kid

getchar
scanf is pretty unsafe.

Guys. Should I learn python as my first language or not? I want to get into programming. Been told python is a good start to learn the while C syntax and stuff. But what do you Sup Forumsentoolmen think?

Yes, Python is a good choice for the first language.

Python and JavaScript are ok for beginners, but be aware that in order to get into programming you have to understand how computers work and that implies also learning C/ASM.

Thank you for your answer, but, could you elaborate on that? I was reading eskimo.com, or something, and he said the same thing. Never went into it, as far I remember, though.

Nice, thanks! Also just out of curiosity, what would be a next step from python?

>in order to get into programming you have to understand how computers work and that implies also learning C/ASM

Plenty of people don't bother with such things and are able to create and contribute to software.

getf might read more than fits to your variable.
There might be getnf or some other variation that lets you specify the byte count how much it can read max.

C is a good idea. And then your third language should be something functional such as Ocaml or Haskell.

You can't design efficient software if you don't understand what's happening inside the machine.

i fell for "python is super easy all beginners should start with python" meme, learn C or C++, for absolute beginner there is no difference, and python and C/C++ will be hard, so better start with less abstract language and if you need to learn other language in future then you can do it in a week or less without much effort.

I think you replied to the wrong person, famalam.

I did. I meant to respond to .

Software should be easy to understand and maintain, and it should work. You can write very efficient code with only a cursory understanding of performance best-practices. Additional optimization comes later as necessary when the business needs are satisfied.

I see, I will look into it, thanks user.

ok I said getf but meant scanf.

yeah, Chapel really is the best language ever.

You don't even really have to learn to program properly in order to shit out software. You can just get by by copy-pasting shit from tutorials and stackoverflow. It doesn't mean it's a good idea.

No, Python is a perfectly fine language to learn if you want to write Python, but it's a terrible "stepping stone" language. C is really the baseline if you want to learn programming in general, it's a very simple language without a huge standard library to overwhelm you, or a ton of heavy abstractions that just confuse you and don't teach you anything. Don't fall for the C is hard for beginners meme, it's hard to write complex software in C as opposed to a higher level languages, but if you want to learn the basics of programming there's nothing better than C. Stuff you learn in C transfers very well over to other languages too, after spending a couple of years with C before going back to C# for my job I found that I could write far better code knowing better what was actually happening behind all of the abstractions.

Oh, I see. So to avoid overflows, it's better to use getchar(), or other variations. I wonder why books use scanf(), though. Is it because it is easier to understand?

Anime is not real, user.

Books try to teach concepts in easy way and on your small terminal application that only you will run it doesn't matter if you use scanf.

Stop propping up an easily berated caricature of what you think people are doing if they don't go through the drudgery of learning the ins and outs of C/ASM.
>shit out software
Does it upset you that people are able to quickly produce software that meets the needs of the project without having to do the same tedious tasks that the software wizards of 20 years ago had to do?

Not him , but "learning programming" is NOT "learning a language".

Software engineering is not tied to certain languages, it's a completely different best.


>Does it upset you that people are able to quickly produce software that meets the needs of the project..

Whoa, speaken like a true code monkey!

The problem is that "quick and dirty" works for short term, but will rape you anally in the long run. Just add some fundamental features to a projects you did one year ago, and you'll know what I'm talking. Either you wrote good code, with nice coupling and a decent structure, than you will get into the details pretty quick and hang in your code in the right hook. Or you created a monolithic bloated mess, where you need to refactor for days before you can even think about adding functionality.

I'm trying to create a cli application in crystal that reads log data from a json file and assembles a valid LaTeX file with it. Afterwards it compiles the file and deleted the temporary outputs of LuaLaTeX. It works fine, however the crystal compiler --release flag, which should invoke the LLVM compiler toolchain, causes the compiler to crash. I tried it on Debian, arch, gentoo and even the Win 10 Ubuntu subsystem. Any ideas why it's crashing?

While I agree with you about C being one of the most important languages to know I wouldn't say Python is a terrible stepping stone. Python will allow a beginner to learn how to build and decompose problems into a set of smaller problems without annoying them about stuff that only the machine cares about. Once you know how to build algorithm C becomes much easier to learn, you only have to deal with the syntax and memory management.

I wasn't saying that copy/pasting stackoverflow was what people who don't learn C do. I was saying that copy/pasting stackoverflow is a way to create apps without learning about what's really going on the algorithm side, much like using python/php/javascript without learning C is a way to create apps without learning about what's really going on the hardware side. Sure, it's possible but it's not something you should desire.
>Does it upset you that people are able to quickly produce software that meets the needs of the project
No. What upsets me is having so much computer power and so much ram and still having to deal with laggy software and web pages. It really makes me mad to see the size of websites explode while the same levels of functionality could already be reached ten years ago with a tenth of the resources we have now.

Thank you, user. I will use getchar(), because I think I have more control over the data that I am inputting.

Try compiling the compiler in debug mode and running it through gdb.

The syntax in other languages is unsuitable for real metaprogramming. You'd end up making your language lisp by doing so.

I wouldn't consider such a language distinct from a lisp. See srfi.schemers.org/srfi-119/srfi-119.html

You now what's even worse? I've had a colleague who did a single task for about 15 years. He left the company a few months ago. Turned out he automated his work with visual basic scripts and wrote a new one for every additional feature pm wanted. It was a horrible, horribble mess, we had 3 people work out what was going on in about 150 vbs files and 10 temporary mdb databases
Will do, but how is this going to help with my problem?

You'll see where it crashes and the input responsible for the crash. You'll probably be able to determine whether the problem is on your side or the compiler's side.

Oh, ok. Will do.

How do i check if a variable is defined in c#? And i don't mean null i mean defined
for example

defined("poop") // returns false


var poop = 1;
defined("poop") // returns true

You keep making the assumption that quick is necessarily dirty. Something need not be tedious to be right.

>The syntax in other languages is unsuitable for real metaprogramming
It wouldn't be ideal, but it can be done by generalizing the most useful common forms and defining s-exp transformations for them.

>I wouldn't consider such a language distinct from a lisp
Why does it matter whether or not you would consider it "distinct from a lisp"?

What are you actually trying to accomplish here?

This smells of horrible design.

C# is a compiled language. If a variable does not exist it won't compile.

Doesn't matter, that is why quotes are used

"I wouldn't consider ..." is weasel words for "it is not." See that SRFI I linked. What you described is literally that SRFI. Any such language isn't meaningfully distinct from a lisp since its only differences are visual sugar.

My point is there is no such thing as a good metaprogramming language that isn't a lisp and there never will be because it isn't possible to be good for metaprogramming and not be lisp.

You could probably stitch something together using the information found on this page: docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/reflection

see
Explain what you're actually trying to do; this doesn't really make sense. Smells of an XY problem.

You cannot get local variables with reflection (at least, the implementation doesn't ensure that it is possible); only type members.

>Any such language isn't meaningfully distinct from a lisp since its only differences are visual sugar.
I don't see how your subjective opinions about whether something is "meaningfully distinct" from lisp or not are relevant to the discussion. Your objection was that mainstream languages aren't suitable for lisp-like metaprogramming because they are not homoiconic. My response is that they can be made retroactively homoiconic by generalizing common syntactical structures and defining transformations into s-exps for them, and new languages can be designed to have a smaller number of more consistent syntactical structures and still look fairly "normal". If you want to label any such language "a lisp", be my guest. It makes no difference,

Employed Haskell programmer here

>(((academic))) work is actual work

Aren't there implicit initialisations of variables in C#?

>50% surplus supply of programmers
We're boned.

what do you mean?

That machine learning cirlejerk is getting annoying, I blame that musk retard

what's the difference between a constexpr array and a static constexpr array?

why doesn't the compiler treat a constexpr array (in function scope) the same as a static constexpr array? are they not equivalent from an optimization point of view?

static (in function scope) means that the value does not change between invocations. it's essentially a global that's only visible to the function it's declared in.
I don't see how you could have a nonstatic constexpr variable. Nonstatic means it belongs to a particular invocation of the function, and you can't make that constexpr.

So you're saying you can't do partial specialization (or help the compiler with it, to be more accurate) using constexpr?
That sucks ass.

>you can't make that constexpr.
yes you can

anyway i found this explanation

stackoverflow.com/questions/13865842/does-static-constexpr-variable-make-sense

I'm just not clear about what you're asking. Partial specialization of what exactly?

I know that is possible to speed up python program with C or C++, but it's possible to do the same things with Forth instead of C?

I'd say only if you make your own hardware. Not even FPGA.

It is in my heart.

Sure, you just need a way to interface the Python ABI with the Forth ABI.

To clarify. I'm not the guy who asked first I'm just responding to your response.
Example:

void foo(int a, int b) { //b will be required to be a compile time known value for every callsite
return multiply(a, baz(b)); //Baz is a constexpr function

Would this compile assuming baz is just fine as a constexpr function? If it does constexpr can be used for partial specialization. If b is 2 or a multiple of 2 the compiler can figure out that a shift may be better than an IMUL on this platform.
If c++ doesn't have non-static constexpr using the function argument in baz would be incorrect unless the same argument is passed throughout the program or there's only one call (which has really cool uses come to think of it, but doesn't fit constexpr well).

Should add that I misspoke. Like always with constexpr it's just a way to error when the compiler doesn't manage to resolve the constant expression. I doubt compilers 'try harder'. Wouldn't make sense.

Why S-expressions? As long as you can produce an AST programmatically you've got the power.

You have no idea what you are talking about.
You have clearly not achieved SATORI.
Fuck off. Read your SICP. Then you may come back.

>SCIP
it's not scripture. It's a book.
I hate dogmatic programmers.

>Why S-expressions?
Because they're a very convenient and uniform way to represent an AST.

>I hate dogmatic programmers.
You're responding to a butthurt Java brainlet trying to be clever.

You are Java brainlet trying to be clever.

He said Haskell, not Lisp.

>inb4 joos

What Lisp do you prefer? Despite being bigger, and maybe slightly more bloated, I prefer Common Lisp to Scheme.

>write a useful ~50kb (=51200 b) python script
>...and it requires 100 additional megs of python interpreter
Did I make a bloatware?

No, you're an MIT nigger.