This is an action for a declaratory judgment brought pursuant to the provisions of Chapter 32-23 RCND 1943. The controversy that is the basis of the suit involves the construction of Section 49-1313 RCND 1943 and its application to the operation of a machine known as a power ballaster. The plaintiff contends that the section of the statute under consideration does not apply to a power ballaster of the model and type used by the plaintiff and that if it, by its terms, does so apply, 'the statute is arbitrary and unreasonable and is not a constitutional exercise of the police power of the state and has no reasonable relation to public safety.
The Attorney General of the State of North Dakota, who is a defendant in this action, has rendered an opinion to the effect that the statute is applicable to the power ballaster operated by the plaintiff. Section 49-1313 BOND 1943 reads as follows: “Self-Propelled Vehicle on Rail; Full Crew Required. No railroad corporation doing business in this state shall, operate or permit to be operated on or over any of its main track any self-propelled crane, pile driver, weed-burner, or other self-propelled engine or machine not used for the transportation of passengers and freight or property for hire which has sufficient power to draw or propel itself and one or more standard railroad cars, unless such.engine or machine shall be manned by a full crew of *727competent employees consisting of not less than one conductor or pilot and one person qualified to do flagging duties as provided hy law.”
Section 49-1314 provides: “Self-Propelled Vehicle; Violations in Manner of Operation; Penalty. Any railroad corporation doing business in this state which shall operate or permit to he operated any self-propelled engine or machine in violation of section 49-1313 shall be liable in treble damages for any sickness, injury, loss, disability, or accident resulting from or caused by any such violation. In case of the disability of any member of the crew1- while the vehicle is being operated upon the main track of any such railroad, it shall not he construed as a violation of said section to operate said vehicle to the nearest available sidetrack with less than a full crew.”
Section 49-1315 provides that a railroad corporation violating any of the provisions of Section 49-1313 “shall he punished hy a fine of not less than one hundred dollars nor more than five hundred dollars for each such violation. Each day that any locomotive engine or car is operated or used, or structure or obstruction is maintained, in violation of the provisions of this chapter, shall constitute a separate offense. The commission shall lodge with the state’s attorney of the proper county information of any such violation as may come to its knowledge.”
The plaintiff, in its complaint, alleges that it has no plain, speedy, or adequate remedy at law and that the penalties provided are so great that it cannot await action to enforce the penalties, and cannot operate the machine in compliance with the statute without incurring additional and wholly unnecessary expense of $31.84 per day for each machine, and that an actual justiciable controversy exists between the parties to this action which should in justice and equity be determined at this time.
The Public Service Commission of this state was not made a party to the action and has not intervened, but it has filed a brief amicus curiae and its Commerce Counsel appeared before this court and argued that the district court, and this court upon appeal, could not entertain this action for a declaratory judgment and that the remedy here sought is improper because no *728administrative hearing has been had before the Public Service Commission under Section 49-0204 BOND 1943, which vests in the Commission power to make rules and regulations relating to practices, equipment, appliances, facilities, and service of public utilities. It is argued that the plaintiff should have sought a hearing before the Public Utilities Commission to determine what rules, if any, should be made by the Commission concerning the operation of a power ballaster, and that an appeal from a determination of the Commission under the Administrative Agencies, Uniform Practice Act (Chapter 28-32 BOND 1943) furnishes the plaintiff an adequate remedy which should have been followed to the exclusion of an action for a declaratory judgment.
We do not hold that the Public Service Commission, by an appearance amicus curiae, has the right to question the jurisdiction of the district court or this court at this stage of the proceedings. However, this court may upon its own initiative inquire whether or not the plaintiff may maintain an action for a declaratory judgment. Langer v. State, 69 ND 129, 284 NW 238. Our examination of the record in this case leads us to the conclusion that a justiciable controversy exists between parties whose interests are adverse; that the issue growing .out of the applicability of the statute to the plaintiff’s power ballaster is ripe for judicial determination and that the plaintiff has a legally protectible interest, in the controversy. If the plaintiff by operating the power ballaster, as it maintains it has a right to do, thereby violates the statute in question it is subject to severe criminal penalties and becomes liable to treble damages in certain instances. The Attorney General and the State’s Attorney of Cass County, as parties defendant, are interested in the enforcement of the law and the application of these penalties. The defendant, J. P. Norberg, as Chairman of the Brotherhood of Bailroad Trainmen, is representative of a large body of employees of the plaintiff corporation who are interested in the general enforcement of .the statute and the safety of workers for which it is designed to provide. The statute is specific in its requirements. The Public Utilities Commission has no authority, by rule or otherwise, to relieve a railroad corporation from penalties that *729it would otherwise incur under the statute. Nor, on. the other hand, may it make applicable those penalties to situations which would not fall within the statute. The statute speaks for itself and not through the Commission. It is therefore proper for a railroad corporation to appeal directly to the courts to have the meaning of the law determined.
The defendant Norberg, in his separate answer, which was adopted at the trial by the other defendants, alleges that all persons who have an interest in the subject matter of the action, or would be affected' by the declaration sought, have not been made parties as required by the provisions of. Section 32-2311 RCND 1943. This section provides that: “. . . all persons who have or claim any interest which would be affected by the declaration, shall be made parties, and no declaration shall prejudice the rights of persons not parties to the proceeding.”
Section 49-1313 RCND 1943 came into our law as Chapter 221 Session Laws ND 1933, and was then entitled: “An act to promote the safety of employees and travelers on railroads by compelling common carriers by railroad to properly man self-propelled vehicles operated on rails, and providing penalties and measuring damages for violation thereof.”
By declaration and import the statute was enacted as a safety measure. In a broad sense all persons whose safety is promoted are affected by or interested in the construction and application of the statute. Likewise all law enforcement personnel who may have occasion to enforce the statute are interested. But to require them all to be made parties to an action of this kind is so obviously absurd that we have no hesitation in saying that the legislature intended mo such result. The statutory provision just quoted clearly anticipates that there may be parties whose rights will be affected by the proceedings and who will not be made parties to the action. Thus it provided that the determination of the court should not prejudice the rights of persons who were not parties to'the proceedings. In this case we have as party defendant, the Attorney General, who is the chief law officer of the State. He is by statute made the ex officio attorney for the Public Service Commission (Section 49-0109 RCND *7301943). The State’s Attorney of Cass County is also made a party defendant. The main line of plaintiff’s railroad passes through that county. The State’s Attorney is the prosecutor and enforcer of criminal laws within that county. He is also under obligation to represent the Public Service Commission, at its request (Section 49-0109 supra). The Commission and other parties might have been properly joined as defendants. But they are nqt necessary to the jurisdiction of the court and the failure to join them is not fatal to plaintiff’s right to maintain this action.
The merits present two issues. First, does the power ballaster described in the pleadings and the evidence come within the provisions of Section 49-1313 BOND 1943? And second, if so, is the statute constitutional as applied to the ballaster ? The machine under consideration is designed for tamping ballast under railroad ties. It weighs 31,000 pounds and is powered by a 100 horsepower engine. It is propelled by its own power and operates on and over the railroad track. Its maximum speed is 25 miles per hour. It is operated in connection with maintenance of way crews. Men raise the track in front of the ballaster and throw in the ballast and the machine tamps the ballast material. It is not equipped with draw bars, couplings, or air brakes. And it is not used for the purpose of moving or propelling railroad cars. It has sufficient power to push or pull a railroad freight car. In its usual operation the machine tamps the ballast under about half a mile of track per day.
. In order to obviate the necessity of running the ballaster to a side track or passing track in order to permit trains to pass on the main track, it is equipped with a set-off device by which it can be moved under its own power off the main track onto a crib or rest adjacent to the track. Cribs are built at intervals of about one half mile along the stretch of track being ballasted. The ballaster is removed from the main track by means of transverse wheels which are operated by an airlift. In order to clear the main track the machine is run opposite to a previously prepared set-off crib. Bails are slipped under the transverse wheels and the machine is lifted sufficiently to clear the main track by *731means of air cylinders, and is run off the main track and onto the crib under its own power. The transverse rails are then removed from the main track and it is thus cleared. The removal operation takes from three to five minutes. The ballaster is operated under maintenance of way rules, and when in operation is protected by maintenance crew flagmen operating in a manner prescribed by those rules. If the machine is to be transported for a considerable distance it is loaded onto a flat car.
The trial court determined that when Section 49-1313 RCND 1943 was enacted, the power ballaster did not exist and was therefore not within the contemplation of the legislature when the statute was enacted, and that the statute does not include the power ballaster among those devises to which it applies. We are unable to agree with the trial court in these conclusions. It is true that at the time the statute was enacted and incorporated into our Revised Code in 1943, a self-propelled power ballaster that could remove itself from the track by means of a power set-off was unknown. But a similar model without a power set-off was in use prior to 1943. It cannot be said that the statute has no application to machines not then invented which are operated on railroad tracks in a manner dangerous to the safety of employees and travelers. The statute enumerates certain specific machines to which it is applicable and sets up a standard for other machines to which it is to be applied in these words: “or other self-propelled engine or machine not used for the transportation of passengers and freight or property for hire which has sufficient power to draw or propel itself and one or more standard railroad cars.”
This provision clearly applies to engines or machines to be invented as well as to those in existence at the time the statute was enacted. 50 Am Jur, Statutes, Sec 237. The legislature laid down a safety standard in which it did not undertake to enumerate every apparatus which it covered. The question, then is whether plaintiff’s power ballaster falls within that standard. It is argued that the standard does not apply because the ballaster is not equipped to push or pull a railroad car. The statute, however, does not require bumpers or draw bars in order to *732make the machine susceptible to its provisions. The sufficiency of power is made the criterion- and when we take into consideration the purpose of the statute as a safety measure we cannot say that this standard is an unreasonable one. It was intended to provide traffic over the track with proper protection against major obstructions. The legislature no doubt determined that the size and weight of a machine naturally bore a reasonable relation to the power that it was able to produce, and that if it was of sufficient power to propel itself and a standard railroad car, it would constitute a hazard that should be guarded against in the manner provided by statute.
It is not argued that a machine weighing 31,000 pounds would not cause a dangerous obstruction. But it is argued strenuously that the manner in which it is operated obviates that danger. This brings us to plaintiff’s second contention, which is that if the ballaster does fall within the purview of the statute, that it is unconstitutional when applied to the ballaster constructed and operated in the manner disclosed by this record.
Presumptively the statute is a valid act of the legislature and the burden is on the railroad to show that it is not. The wisdom, necessity, and expediency of the law are primarily matters for legislative rather than judicial consideration. State v. Cromwell, 72 ND 565, 9 NW(2d) 914; State ex rel Linde v. Taylor, 33 ND 76, 156 NW 561, LRA1918B 156, Ann Cases 1918A 583; Federal Farm Mortgage Corporation v. Falk, 67 ND 154, 270 NW 885, 113 ALR 724; 11 Am Jur, Constitutional Law, Section 138; 16 CJS, Constitutional Law, Section 198; City of Bismarck v. Hughes, 53 ND 838, 208 NW 711; Minot Special School District v. Olsness, 53 ND 683, 208 NW 968, 45 ALR 1337; State v. First State Bank, 52 ND 231, 202 NW 391; State ex rel Sathre v. Board of University and School Lands, 65 ND 687, 262 NW 60. On the other hand “. . . a regulatory statute enacted in the exercise of the police power must be reasonable. Its real purpose must be to protect the public health, morals or general welfare, and it must be reasonably required and suited to attain that purpose. It cannot masquerade as an exercise of the police power and arbitrarily invade personal rights or private prop*733erty. It cannot disregard the constitutional guaranties. And, whether it does so, is a.- question for the courts to determine.” State v. Cromwell, supra.
The statute in question falls' within the category of legislation commonly known as “full crew acts.” Such acts have generally been held to be a lawful exertion of the police power of the state. Missouri Pacific Railroad Co. v. Norwood, 283 US 249, 75 L Ed 1010; Pennsylvania Railroad Co. v. Ewing, 241 Penn 581, 88 Atl 775, 49 LRA (NS) 977, Ann Cases 1915B 157. But see Pennsylvania Railroad Co. v. Driscoll, 330 Penn 97, 198 Atl 130.
In this case the constitutional challenge is a somewhat narrow one. The railroad does not contend that full crew laws in general are unconstitutional or that the specific statute under consideration is unconstitutional as applied to all types of machines therein described. It is not argued that Section 49-1313 RCND 1943 is invalid as a whole, but that it is invalid when applied to the power ballaster in question when used in' the manner described in the complaint and in the testimony of the plaintiff’s witnesses. It is asserted that the operation of the power ballaster so differs from the operation of other machines falling within the purview of Section 49-1313 that this constitutional challenge is properly directed to this specific machine and its method of operation. ■
“. . . the constitutionality of a statute, valid on its face, may be assailed by proof of facts tending to show that the statute as applied to a particular article is without support in reason because the article, although within the prohibited class, is so different from others of the class as to be without the reason for the prohibition.” United States v. Carolene Products Co., 304 US 144, 82 L Ed 1234.
The singular attributes of the ballaster as contended for by the plaintiff are set out in its statement of ultimate facts as follows :
“The ballaster machine, as used by the plaintiff, is a static piece of equipment, does not operate on or over the rails except in a limited way and removes itself from the track on its own power without clearing thru a switch. It is not equipped to *734either pull or push a standard car and is not used to do so. It was put on the market and first used in 1946. It is not in the same ‘genus’ as the other machines mentioned'in the statute as they all operate on and over the tracks for long distances, are not self-removable, and all except the weed burner are. equipped with draw bars and couplings. The machine, as used by plaintiff, is not therefore included in and covered by the statute.”
The attributes of size, weight, power, and self-propulsion over the railroad tracks place the ballaster within the class of hazardous obstacles which, in the interest of safety, the legislature has determined must be manned by the crew prescribed by the statute. There remains the question of whether the manner of operation is such that the use of a full crew is a requirement that is unreasonable and arbitrary and results in the violation of the plaintiff’s constitutional rights. The argument of the plaintiff in this respect rests on two points. First, that the machine moves’itself off the track by its own power and clears the way in a relatively short period of time. And second, that when performing its function as a ballaster it is used with a crew or gang of maintenance of way employees whose operations are required to be protected, under a rule promulgated by the railroad known as 99 (M) which sets forth in detail the methods to be used in protecting traffic against hazards created by maintenance of way operations including the use of a flagman in each direction from the obstruction.
"With respect to the removal of the ballaster under its own power, the position of the plaintiff appears to be wholly without merit. The set-off device enables the machine to be moved onto a crib which eliminates the necessity of running it onto a siding-in order to clear the track. The cribs are erected at intervals of about a half mile. To clear the track the ballaster must be run to the nearest crib and then removed by an operation that takes from three to five minutes. The set-off device enables the track to be cleared more quickly, but in no manner reduces the hazard of collision while the ballaster remains on the track. It is obvious that as long as it remains in a position dangerous to traffic it is reasonable to require that traffic and the operator of *735the machine be protected. If no other protection was provided it conlcl scarcely be argued that the statute placed an arbitrary and unreasonable burden on the plaintiff.
But, says the railroad in effect, we have a' rule of our own which requires maintenance of way crews to protect their operations by flagmen and other safety measures, and compliance with the statute creates a duplication of flagmen which adds about $36.00 per day to the cost of operation of each ballaster and compliance with both our maintenance rule 99 (M) and the rule provided by the statute renders the application of the statutory rule burdensome, arbitrary, and unconstitutional.
The plaintiff has cited a number of cases dealing with the limitation of the police power of states. "When the attempted exercise of that power comes in collision with the constitutional guaranties in state constitutions and in the federal constitution under due process of law and equal protection of the law clauses, the constitution prevails. In no case does it appear that a statutory rule of safety becomes unconstitutional because a private rule of safety adequately protects against the same hazard sought to be eliminated by the statute.
In Pennsylvania Railroad Co. v. Driscoll, 330 Penn 97, 198 Atl 130, certain provisions of a full crew law, passed in 1937, were held unconstitutional and void. It is there held that:
“Where a law depends upon the existence of a certain set of facts to uphold it, if the facts change, then, though valid when passed, it may be invalid under the altered facts and circumstances.”
The court reviewed significant advances that had been made in the mechanical construction and operation of railroad equipment and reached the conclusion that in the light of all the facts of a long record, certain provisions of the law were unnecessary and arbitrary. In Shreveport v. Shreveport Railways Co., 38 Fed2d 945, 69 ALR 340, the court held that an ordinance that was reasonable as applied to conditions at the time of its adoption may become unreasonable because of changing conditions and it was decided that an ordinance requiring two-men street cars was no longer valid in view of the changes in mechanical *736safety devices and traffic conditions. These cases would be in-point if the ballaster, although technically within the provisions of Section 49-1313 RCND 1943, was "as a practical matter not a hazard to traffic. But the question here, as we have already pointed out, is which method shall be pursued in protecting traffic against an obstacle that the legislature has determined requires that measures be taken for the protection of the traveling public and the employees of the railroad, and which the plaintiff concedes requires flagging protection.
Assuming that compliance with both, the statute and rule 99(M) will cause a duplication of flagmen (a point that is controverted by the defendant Norberg) and that the duplication will result in an unreasonable financial burden on the plaintiff, we are not warranted in striking down the statute because of the rule. If we were to do so, we would be holding, in effect, that the rule making power of the railroad is superior to the law making power of the legislature.
Counsel for the plaintiff also challenges as an arbitrary and unconstitutional exercise of police power the provision of Section 49-1313 which requires that the flagman shall be a “person qualified to do flagging duties as provided by law.” This is conceded to mean that the flagman must have at least one year’s experience in train service. See Sections 49-1309, -1310, and -1311. Thus, all other employees of the railroad are prohibited from acting as flagmen on vehicles falling within the provisions of Section "49-1313 RCND 1943, including the power ballaster in question. The "question, therefore, is: May the state constitutionally restrict the employment of flagmen on the power ballaster to those persons having one year’s experience in train service? The record clearly shows that members of the maintenance of way gangs customarily perform flagging duties and presumably they are competent to do so, for they regularly per-, form these functions. "We find persuasive in this case, the reasoning of the United States Supreme Court in Smith v. Texas, 233 US 630, 58 L Ed 1129, LRA1915D 677, Ann Cases 1915D 420. That case involved a Texas statute which made it a misdemeanor for a person to act as conductor on a freight train without hav-' *737ing two years’ experience as a brakeman on a freight train. The court said:
“So that the case distinctly raises the question as to whether a statute, in permitting certain competent men to serve, can lay. down a test which absolutely prohibits other competent men from entering the same employment. It would seem that to ask the question is to answer it — and the answer in no way denies the. right of the State tó require examinations to test the fitness and capacity of brakemen, firemen, engineers and conductors to enter upon a service fraught with so much of risk to themselves and to the public. But all men are entitled to the equal protection of the law in their right to work for the support of themselves and families. A- statute which permits the brakeman to act — because he is presumptively competent — and prohibits the employment of engineers and all others who can affirmatively prove that they are likewise competent, is not confined to securing the public safety but denies to many the liberty of contract granted to brakemen and operates to establish rules of promotion in a private employment.
“If brakemen only are allowed the right of appointment to the position of conductors, then a privilege is given to them which is denied all other citizens of the United States.”
In Atchison, Topeka & Santa Fe Railway Co. v. State, 33 Ariz 440, 265 Pac 602, 58 ALR 563, it was held that a statute ‘providing that no person who had less than one year’s experience as a telegraph operator should be employed by, a railway company or permitted by it, after employment, to receive or transmit by telephone an order or message affecting the movement of a train, was unreasonable and arbitrary and not a valid exercise of the police power.
"We believe that the reasoning of the two cases just cited is sound and when applied to the provision of the statute under consideration leads us to the conclusion that the restriction by Section 49-1313 of the employment of flagmen on power ballasters to those who have at least one year’s experience in train service is arbitrary and unreasonable. Article 1 Section 20 of *738the North Dakota Constitution forbids the granting of privileges or immunities to any citizen or class of citizens “which upon the same terms shall not be granted to all citizens.” Under this provision proper classification is permitted. But arbitrary and unreasonable discrimination is forbidden.. Beleal v. Northern Pacific Railway Co., 15 ND 318, 108 NW 33, 11 Ann Cases 921; Figenskau v. McCoy, 66 ND 290, 265 NW 259.
The ballaster under consideration is not a train, nor is it any part of a train. It is- basically a piece of equipment that is used in connection with the maintenance of the roadbed of the railroad. While it is such an obstruction -when in use on the main track that the legislature may, in the interest of safety, reasonably require that it be manned by -a crew consisting of a pilot and flagman, it is unreasonable and arbitrary to require that the flagman have one- year’s experience in train service. This record clearly demonstrates that many persons other than those in train service perform flagging duties. The legislature has never by general law undertaken to establish standards for determining the qualifications of those who may perform flagging duties. The standards set up by Sections 49-1309, -1310, and -1311 apply only to the operation of passenger, freight, and mixed trains outside of the yard limits. The attempt made in Section 49-1313 to transfer and apply those standards to the employment of flagmen on power ballasters and thereby exclude the employment of other flagmen who may be equally competent to perform the duties under consideration appears to be without reasonable justification, and is violative of Article 1 Section 20 of the North Dakota Constitution.
We have determined that.the record in this-case, presents a proper case for the rendition of a.declaratory judgment; that the machine known as a power ballaster, which is the subject of this action, falls within and is subject to the provisions of Section 49-1313 ROND 1943; that the provision in Section 49-1313 restricting crew members doing flagging duties to those who have at least one year’s experience in train service is as applied to the power ballaster in question, unreasonable, arbitrary, unconstitutional, and void.
*739The trial court restrained and enjoined the defendants, the Attorney General of the State of North Dakota and the States Attorney of Cass County, from enforcing or attempting to enforce the penalties provided by Section 49-1315 because of the use and operation by the plaintiff of a power ballaster without its being maimed as required by Section 49-1313. This action was taken upon the assumption that' the latter section was not applicable to the operation of a power ballaster of the plaintiff. Since we have determined that the section is applicable, the restraining order must be dissolved.
The case is remanded to the district court with instructions to modify and enter the declaratory judgment in this case in accordance with this opinion.
Nuessle, C. J., and Burke, Christianson and Grimson, JJ., concur.